1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 /* Register Base Addresses */ 4 #define XRS_DEVICE_ID_BASE 0x0 5 #define XRS_GPIO_BASE 0x10000 6 #define XRS_PORT_OFFSET 0x10000 7 #define XRS_PORT_BASE(x) (0x200000 + XRS_PORT_OFFSET * (x)) 8 #define XRS_RTC_BASE 0x280000 9 #define XRS_TS_OFFSET 0x8000 10 #define XRS_TS_BASE(x) (0x290000 + XRS_TS_OFFSET * (x)) 11 #define XRS_SWITCH_CONF_BASE 0x300000 12 13 /* Device Identification Registers */ 14 #define XRS_DEV_ID0 (XRS_DEVICE_ID_BASE + 0) 15 #define XRS_DEV_ID1 (XRS_DEVICE_ID_BASE + 2) 16 #define XRS_INT_ID0 (XRS_DEVICE_ID_BASE + 4) 17 #define XRS_INT_ID1 (XRS_DEVICE_ID_BASE + 6) 18 #define XRS_REV_ID (XRS_DEVICE_ID_BASE + 8) 19 20 /* GPIO Registers */ 21 #define XRS_CONFIG0 (XRS_GPIO_BASE + 0x1000) 22 #define XRS_INPUT_STATUS0 (XRS_GPIO_BASE + 0x1002) 23 #define XRS_CONFIG1 (XRS_GPIO_BASE + 0x1004) 24 #define XRS_INPUT_STATUS1 (XRS_GPIO_BASE + 0x1006) 25 #define XRS_CONFIG2 (XRS_GPIO_BASE + 0x1008) 26 #define XRS_INPUT_STATUS2 (XRS_GPIO_BASE + 0x100a) 27 28 /* Port Configuration Registers */ 29 #define XRS_PORT_GEN_BASE(x) (XRS_PORT_BASE(x) + 0x0) 30 #define XRS_PORT_HSR_BASE(x) (XRS_PORT_BASE(x) + 0x2000) 31 #define XRS_PORT_PTP_BASE(x) (XRS_PORT_BASE(x) + 0x4000) 32 #define XRS_PORT_CNT_BASE(x) (XRS_PORT_BASE(x) + 0x6000) 33 #define XRS_PORT_IPO_BASE(x) (XRS_PORT_BASE(x) + 0x8000) 34 35 /* Port Configuration Registers - General and State */ 36 #define XRS_PORT_STATE(x) (XRS_PORT_GEN_BASE(x) + 0x0) 37 #define XRS_PORT_FORWARDING 0 38 #define XRS_PORT_LEARNING 1 39 #define XRS_PORT_DISABLED 2 40 #define XRS_PORT_MODE_NORMAL 0 41 #define XRS_PORT_MODE_MANAGEMENT 1 42 #define XRS_PORT_SPEED_1000 0x12 43 #define XRS_PORT_SPEED_100 0x20 44 #define XRS_PORT_SPEED_10 0x30 45 #define XRS_PORT_VLAN(x) (XRS_PORT_GEN_BASE(x) + 0x10) 46 #define XRS_PORT_VLAN0_MAPPING(x) (XRS_PORT_GEN_BASE(x) + 0x12) 47 #define XRS_PORT_FWD_MASK(x) (XRS_PORT_GEN_BASE(x) + 0x14) 48 #define XRS_PORT_VLAN_PRIO(x) (XRS_PORT_GEN_BASE(x) + 0x16) 49 50 /* Port Configuration Registers - HSR/PRP */ 51 #define XRS_HSR_CFG(x) (XRS_PORT_HSR_BASE(x) + 0x0) 52 53 /* Port Configuration Registers - PTP */ 54 #define XRS_PTP_RX_SYNC_DELAY_NS_LO(x) (XRS_PORT_PTP_BASE(x) + 0x2) 55 #define XRS_PTP_RX_SYNC_DELAY_NS_HI(x) (XRS_PORT_PTP_BASE(x) + 0x4) 56 #define XRS_PTP_RX_EVENT_DELAY_NS(x) (XRS_PORT_PTP_BASE(x) + 0xa) 57 #define XRS_PTP_TX_EVENT_DELAY_NS(x) (XRS_PORT_PTP_BASE(x) + 0x12) 58 59 /* Port Configuration Registers - Counter */ 60 #define XRS_CNT_CTRL(x) (XRS_PORT_CNT_BASE(x) + 0x0) 61 #define XRS_RX_GOOD_OCTETS_L (XRS_PORT_CNT_BASE(0) + 0x200) 62 #define XRS_RX_GOOD_OCTETS_H (XRS_PORT_CNT_BASE(0) + 0x202) 63 #define XRS_RX_BAD_OCTETS_L (XRS_PORT_CNT_BASE(0) + 0x204) 64 #define XRS_RX_BAD_OCTETS_H (XRS_PORT_CNT_BASE(0) + 0x206) 65 #define XRS_RX_UNICAST_L (XRS_PORT_CNT_BASE(0) + 0x208) 66 #define XRS_RX_UNICAST_H (XRS_PORT_CNT_BASE(0) + 0x20a) 67 #define XRS_RX_BROADCAST_L (XRS_PORT_CNT_BASE(0) + 0x20c) 68 #define XRS_RX_BROADCAST_H (XRS_PORT_CNT_BASE(0) + 0x20e) 69 #define XRS_RX_MULTICAST_L (XRS_PORT_CNT_BASE(0) + 0x210) 70 #define XRS_RX_MULTICAST_H (XRS_PORT_CNT_BASE(0) + 0x212) 71 #define XRS_RX_UNDERSIZE_L (XRS_PORT_CNT_BASE(0) + 0x214) 72 #define XRS_RX_UNDERSIZE_H (XRS_PORT_CNT_BASE(0) + 0x216) 73 #define XRS_RX_FRAGMENTS_L (XRS_PORT_CNT_BASE(0) + 0x218) 74 #define XRS_RX_FRAGMENTS_H (XRS_PORT_CNT_BASE(0) + 0x21a) 75 #define XRS_RX_OVERSIZE_L (XRS_PORT_CNT_BASE(0) + 0x21c) 76 #define XRS_RX_OVERSIZE_H (XRS_PORT_CNT_BASE(0) + 0x21e) 77 #define XRS_RX_JABBER_L (XRS_PORT_CNT_BASE(0) + 0x220) 78 #define XRS_RX_JABBER_H (XRS_PORT_CNT_BASE(0) + 0x222) 79 #define XRS_RX_ERR_L (XRS_PORT_CNT_BASE(0) + 0x224) 80 #define XRS_RX_ERR_H (XRS_PORT_CNT_BASE(0) + 0x226) 81 #define XRS_RX_CRC_L (XRS_PORT_CNT_BASE(0) + 0x228) 82 #define XRS_RX_CRC_H (XRS_PORT_CNT_BASE(0) + 0x22a) 83 #define XRS_RX_64_L (XRS_PORT_CNT_BASE(0) + 0x22c) 84 #define XRS_RX_64_H (XRS_PORT_CNT_BASE(0) + 0x22e) 85 #define XRS_RX_65_127_L (XRS_PORT_CNT_BASE(0) + 0x230) 86 #define XRS_RX_65_127_H (XRS_PORT_CNT_BASE(0) + 0x232) 87 #define XRS_RX_128_255_L (XRS_PORT_CNT_BASE(0) + 0x234) 88 #define XRS_RX_128_255_H (XRS_PORT_CNT_BASE(0) + 0x236) 89 #define XRS_RX_256_511_L (XRS_PORT_CNT_BASE(0) + 0x238) 90 #define XRS_RX_256_511_H (XRS_PORT_CNT_BASE(0) + 0x23a) 91 #define XRS_RX_512_1023_L (XRS_PORT_CNT_BASE(0) + 0x23c) 92 #define XRS_RX_512_1023_H (XRS_PORT_CNT_BASE(0) + 0x23e) 93 #define XRS_RX_1024_1536_L (XRS_PORT_CNT_BASE(0) + 0x240) 94 #define XRS_RX_1024_1536_H (XRS_PORT_CNT_BASE(0) + 0x242) 95 #define XRS_RX_HSR_PRP_L (XRS_PORT_CNT_BASE(0) + 0x244) 96 #define XRS_RX_HSR_PRP_H (XRS_PORT_CNT_BASE(0) + 0x246) 97 #define XRS_RX_WRONGLAN_L (XRS_PORT_CNT_BASE(0) + 0x248) 98 #define XRS_RX_WRONGLAN_H (XRS_PORT_CNT_BASE(0) + 0x24a) 99 #define XRS_RX_DUPLICATE_L (XRS_PORT_CNT_BASE(0) + 0x24c) 100 #define XRS_RX_DUPLICATE_H (XRS_PORT_CNT_BASE(0) + 0x24e) 101 #define XRS_TX_OCTETS_L (XRS_PORT_CNT_BASE(0) + 0x280) 102 #define XRS_TX_OCTETS_H (XRS_PORT_CNT_BASE(0) + 0x282) 103 #define XRS_TX_UNICAST_L (XRS_PORT_CNT_BASE(0) + 0x284) 104 #define XRS_TX_UNICAST_H (XRS_PORT_CNT_BASE(0) + 0x286) 105 #define XRS_TX_BROADCAST_L (XRS_PORT_CNT_BASE(0) + 0x288) 106 #define XRS_TX_BROADCAST_H (XRS_PORT_CNT_BASE(0) + 0x28a) 107 #define XRS_TX_MULTICAST_L (XRS_PORT_CNT_BASE(0) + 0x28c) 108 #define XRS_TX_MULTICAST_H (XRS_PORT_CNT_BASE(0) + 0x28e) 109 #define XRS_TX_HSR_PRP_L (XRS_PORT_CNT_BASE(0) + 0x290) 110 #define XRS_TX_HSR_PRP_H (XRS_PORT_CNT_BASE(0) + 0x292) 111 #define XRS_PRIQ_DROP_L (XRS_PORT_CNT_BASE(0) + 0x2c0) 112 #define XRS_PRIQ_DROP_H (XRS_PORT_CNT_BASE(0) + 0x2c2) 113 #define XRS_EARLY_DROP_L (XRS_PORT_CNT_BASE(0) + 0x2c4) 114 #define XRS_EARLY_DROP_H (XRS_PORT_CNT_BASE(0) + 0x2c6) 115 116 /* Port Configuration Registers - Inbound Policy 0 - 15 */ 117 #define XRS_ETH_ADDR_CFG(x, p) (XRS_PORT_IPO_BASE(x) + \ 118 (p) * 0x20 + 0x0) 119 #define XRS_ETH_ADDR_FWD_ALLOW(x, p) (XRS_PORT_IPO_BASE(x) + \ 120 (p) * 0x20 + 0x2) 121 #define XRS_ETH_ADDR_FWD_MIRROR(x, p) (XRS_PORT_IPO_BASE(x) + \ 122 (p) * 0x20 + 0x4) 123 #define XRS_ETH_ADDR_0(x, p) (XRS_PORT_IPO_BASE(x) + \ 124 (p) * 0x20 + 0x8) 125 #define XRS_ETH_ADDR_1(x, p) (XRS_PORT_IPO_BASE(x) + \ 126 (p) * 0x20 + 0xa) 127 #define XRS_ETH_ADDR_2(x, p) (XRS_PORT_IPO_BASE(x) + \ 128 (p) * 0x20 + 0xc) 129 130 /* RTC Registers */ 131 #define XRS_CUR_NSEC0 (XRS_RTC_BASE + 0x1004) 132 #define XRS_CUR_NSEC1 (XRS_RTC_BASE + 0x1006) 133 #define XRS_CUR_SEC0 (XRS_RTC_BASE + 0x1008) 134 #define XRS_CUR_SEC1 (XRS_RTC_BASE + 0x100a) 135 #define XRS_CUR_SEC2 (XRS_RTC_BASE + 0x100c) 136 #define XRS_TIME_CC0 (XRS_RTC_BASE + 0x1010) 137 #define XRS_TIME_CC1 (XRS_RTC_BASE + 0x1012) 138 #define XRS_TIME_CC2 (XRS_RTC_BASE + 0x1014) 139 #define XRS_STEP_SIZE0 (XRS_RTC_BASE + 0x1020) 140 #define XRS_STEP_SIZE1 (XRS_RTC_BASE + 0x1022) 141 #define XRS_STEP_SIZE2 (XRS_RTC_BASE + 0x1024) 142 #define XRS_ADJUST_NSEC0 (XRS_RTC_BASE + 0x1034) 143 #define XRS_ADJUST_NSEC1 (XRS_RTC_BASE + 0x1036) 144 #define XRS_ADJUST_SEC0 (XRS_RTC_BASE + 0x1038) 145 #define XRS_ADJUST_SEC1 (XRS_RTC_BASE + 0x103a) 146 #define XRS_ADJUST_SEC2 (XRS_RTC_BASE + 0x103c) 147 #define XRS_TIME_CMD (XRS_RTC_BASE + 0x1040) 148 149 /* Time Stamper Registers */ 150 #define XRS_TS_CTRL(x) (XRS_TS_BASE(x) + 0x1000) 151 #define XRS_TS_INT_MASK(x) (XRS_TS_BASE(x) + 0x1008) 152 #define XRS_TS_INT_STATUS(x) (XRS_TS_BASE(x) + 0x1010) 153 #define XRS_TS_NSEC0(x) (XRS_TS_BASE(x) + 0x1104) 154 #define XRS_TS_NSEC1(x) (XRS_TS_BASE(x) + 0x1106) 155 #define XRS_TS_SEC0(x) (XRS_TS_BASE(x) + 0x1108) 156 #define XRS_TS_SEC1(x) (XRS_TS_BASE(x) + 0x110a) 157 #define XRS_TS_SEC2(x) (XRS_TS_BASE(x) + 0x110c) 158 #define XRS_PNCT0(x) (XRS_TS_BASE(x) + 0x1110) 159 #define XRS_PNCT1(x) (XRS_TS_BASE(x) + 0x1112) 160 161 /* Switch Configuration Registers */ 162 #define XRS_SWITCH_GEN_BASE (XRS_SWITCH_CONF_BASE + 0x0) 163 #define XRS_SWITCH_TS_BASE (XRS_SWITCH_CONF_BASE + 0x2000) 164 #define XRS_SWITCH_VLAN_BASE (XRS_SWITCH_CONF_BASE + 0x4000) 165 166 /* Switch Configuration Registers - General */ 167 #define XRS_GENERAL (XRS_SWITCH_GEN_BASE + 0x10) 168 #define XRS_GENERAL_TIME_TRAILER BIT(9) 169 #define XRS_GENERAL_MOD_SYNC BIT(10) 170 #define XRS_GENERAL_CUT_THRU BIT(13) 171 #define XRS_GENERAL_CLR_MAC_TBL BIT(14) 172 #define XRS_GENERAL_RESET BIT(15) 173 #define XRS_MT_CLEAR_MASK (XRS_SWITCH_GEN_BASE + 0x12) 174 #define XRS_ADDRESS_AGING (XRS_SWITCH_GEN_BASE + 0x20) 175 #define XRS_TS_CTRL_TX (XRS_SWITCH_GEN_BASE + 0x28) 176 #define XRS_TS_CTRL_RX (XRS_SWITCH_GEN_BASE + 0x2a) 177 #define XRS_INT_MASK (XRS_SWITCH_GEN_BASE + 0x2c) 178 #define XRS_INT_STATUS (XRS_SWITCH_GEN_BASE + 0x2e) 179 #define XRS_MAC_TABLE0 (XRS_SWITCH_GEN_BASE + 0x200) 180 #define XRS_MAC_TABLE1 (XRS_SWITCH_GEN_BASE + 0x202) 181 #define XRS_MAC_TABLE2 (XRS_SWITCH_GEN_BASE + 0x204) 182 #define XRS_MAC_TABLE3 (XRS_SWITCH_GEN_BASE + 0x206) 183 184 /* Switch Configuration Registers - Frame Timestamp */ 185 #define XRS_TX_TS_NS_LO(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + 0x0) 186 #define XRS_TX_TS_NS_HI(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + 0x2) 187 #define XRS_TX_TS_S_LO(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + 0x4) 188 #define XRS_TX_TS_S_HI(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + 0x6) 189 #define XRS_TX_TS_HDR(t, h) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 190 0x2 * (h) + 0xe) 191 #define XRS_RX_TS_NS_LO(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 192 0x200) 193 #define XRS_RX_TS_NS_HI(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 194 0x202) 195 #define XRS_RX_TS_S_LO(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 196 0x204) 197 #define XRS_RX_TS_S_HI(t) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 198 0x206) 199 #define XRS_RX_TS_HDR(t, h) (XRS_SWITCH_TS_BASE + 0x80 * (t) + \ 200 0x2 * (h) + 0xe) 201 202 /* Switch Configuration Registers - VLAN */ 203 #define XRS_VLAN(v) (XRS_SWITCH_VLAN_BASE + 0x2 * (v)) 204