lua: Fixed some cross-platform issues for PPC (and probably other architectures)
[openwrt.git] / target / linux / adm5120 / files / include / asm-mips / mach-adm5120 / adm5120_switch.h
1 /*
2 * $Id$
3 *
4 * ADM5120 ethernet switch definitions
5 *
6 * This header file defines the hardware registers of the ADM5120 SoC
7 * built-in Ethernet switch.
8 *
9 * Copyright (C) 2007 OpenWrt.org
10 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published
14 * by the Free Software Foundation.
15 *
16 */
17
18 #ifndef _ADM5120_SWITCH_H_
19 #define _ADM5120_SWITCH_H_
20
21 #ifndef BIT
22 # define BIT(at) (1 << (at))
23 #endif
24 #define BITMASK(len) (BIT(len)-1)
25
26 #define SW_READ_REG(r) __raw_readl( \
27 (void __iomem *)KSEG1ADDR(ADM5120_SWITCH_BASE) + r)
28 #define SW_WRITE_REG(r, v) __raw_writel((v), \
29 (void __iomem *)KSEG1ADDR(ADM5120_SWITCH_BASE) + r)
30
31 /* Switch register offsets */
32 #define SWITCH_REG_CODE 0x0000
33 #define SWITCH_REG_SOFT_RESET 0x0004 /* Soft Reset */
34 #define SWITCH_REG_BOOT_DONE 0x0008 /* Boot Done */
35 #define SWITCH_REG_SW_RESET 0x000C /* Switch Reset */
36 #define SWITCH_REG_PHY_STATUS 0x0014 /* PHY Status */
37 #define SWITCH_REG_MEMCTRL 0x001C /* Memory Control */
38 #define SWITCH_REG_CPUP_CONF 0x0024 /* CPU Port Configuration */
39 #define SWITCH_REG_PORT_CONF0 0x0028 /* Port Configuration 0 */
40 #define SWITCH_REG_PORT_CONF1 0x002C /* Port Configuration 1 */
41 #define SWITCH_REG_PORT_CONF2 0x0030 /* Port Configuration 2 */
42 #define SWITCH_REG_VLAN_G1 0x0040 /* VLAN group 1 */
43 #define SWITCH_REG_VLAN_G2 0x0044 /* VLAN group 2 */
44 #define SWITCH_REG_SEND_TRIG 0x0048 /* Send Trigger */
45 #define SWITCH_REG_MAC_WT0 0x0058 /* MAC Write Address 0 */
46 #define SWITCH_REG_MAC_WT1 0x005C /* MAC Write Address 1 */
47 #define SWITCH_REG_BW_CNTL0 0x0060 /* Bandwidth Control 0 */
48 #define SWITCH_REG_BW_CNTL1 0x0064 /* Bandwidth Control 1 */
49 #define SWITCH_REG_PHY_CNTL0 0x0068 /* PHY Control 0 */
50 #define SWITCH_REG_PHY_CNTL1 0x006C /* PHY Control 1 */
51 #define SWITCH_REG_PORT_TH 0x0078 /* Port Threshold */
52 #define SWITCH_REG_PHY_CNTL2 0x007C /* PHY Control 2 */
53 #define SWITCH_REG_PHY_CNTL3 0x0080 /* PHY Control 3 */
54 #define SWITCH_REG_PRI_CNTL 0x0084 /* Priority Control */
55 #define SWITCH_REG_PHY_CNTL4 0x00A0 /* PHY Control 4 */
56 #define SWITCH_REG_EMPTY_CNT 0x00A4 /* Empty Count */
57 #define SWITCH_REG_PORT_CNTLS 0x00A8 /* Port Control Select */
58 #define SWITCH_REG_PORT_CNTL 0x00AC /* Port Control */
59 #define SWITCH_REG_INT_STATUS 0x00B0 /* Interrupt Status */
60 #define SWITCH_REG_INT_MASK 0x00B4 /* Interrupt Mask */
61 #define SWITCH_REG_GPIO_CONF0 0x00B8 /* GPIO Configuration 0 */
62 #define SWITCH_REG_GPIO_CONF2 0x00BC /* GPIO Configuration 1 */
63 #define SWITCH_REG_WDOG0 0x00C0 /* Watchdog 0 */
64 #define SWITCH_REG_WDOG1 0x00C4 /* Watchdog 1 */
65
66 #define SWITCH_REG_SHDA 0x00D0 /* Send High Descriptors Address */
67 #define SWITCH_REG_SLDA 0x00D4 /* Send Low Descriptors Address */
68 #define SWITCH_REG_RHDA 0x00D8 /* Receive High Descriptor Address */
69 #define SWITCH_REG_RLDA 0x00DC /* Receive Low Descriptor Address */
70 #define SWITCH_REG_SHWA 0x00E0 /* Send High Working Address */
71 #define SWITCH_REG_SLWA 0x00E4 /* Send Low Working Address */
72 #define SWITCH_REG_RHWA 0x00E8 /* Receive High Working Address */
73 #define SWITCH_REG_RLWA 0x00EC /* Receive Low Working Address */
74
75 #define SWITCH_REG_TIMER_INT 0x00F0 /* Timer */
76 #define SWITCH_REG_TIMER 0x00F4 /* Timer Interrupt */
77
78 #define SWITCH_REG_PORT0_LED 0x0100
79 #define SWITCH_REG_PORT1_LED 0x0104
80 #define SWITCH_REG_PORT2_LED 0x0108
81 #define SWITCH_REG_PORT3_LED 0x010C
82 #define SWITCH_REG_PORT4_LED 0x0110
83
84 /* CODE register bits */
85 #define CODE_PC_MASK BITMASK(16) /* Product Code */
86 #define CODE_REV_SHIFT 16
87 #define CODE_REV_MASK BITMASK(4) /* Product Revision */
88 #define CODE_CLKS_SHIFT 20
89 #define CODE_CLKS_MASK BITMASK(2) /* Clock Speed */
90 #define CODE_CLKS_175 0 /* 175 MHz */
91 #define CODE_CLKS_200 1 /* 200 MHz */
92 #define CODE_CLKS_225 2 /* 225 MHz */
93 #define CODE_CLKS_250 3 /* 250 MHz */
94 #define CODE_NAB BIT(24) /* NAND boot */
95 #define CODE_PK_MASK BITMASK(1) /* Package type */
96 #define CODE_PK_SHIFT 29
97 #define CODE_PK_BGA 0 /* BGA package */
98 #define CODE_PK_PQFP 1 /* PQFP package */
99
100 /* MEMCTRL register bits */
101 #define MEMCTRL_SDRS_MASK BITMASK(3) /* SDRAM bank size */
102 #define MEMCTRL_SDRS_4M 0x01
103 #define MEMCTRL_SDRS_8M 0x02
104 #define MEMCTRL_SDRS_16M 0x03
105 #define MEMCTRL_SDRS_64M 0x04
106 #define MEMCTRL_SDRS_128M 0x05
107 #define MEMCTRL_SDR1_ENABLE BIT(5) /* enable SDRAM bank 1 */
108
109 #define MEMCTRL_SRS0_SHIFT 8 /* shift for SRAM0 size */
110 #define MEMCTRL_SRS1_SHIFT 16 /* shift for SRAM1 size */
111 #define MEMCTRL_SRS_MASK BITMASK(3) /* SRAM size mask */
112 #define MEMCTRL_SRS_DISABLED 0x00 /* Disabled */
113 #define MEMCTRL_SRS_512K 0x01 /* 512KB*/
114 #define MEMCTRL_SRS_1M 0x02 /* 1MB */
115 #define MEMCTRL_SRS_2M 0x03 /* 2MB */
116 #define MEMCTRL_SRS_4M 0x04 /* 4MB */
117
118 /* Port bits used in various registers */
119 #define SWITCH_PORT_PHY0 BIT(0)
120 #define SWITCH_PORT_PHY1 BIT(1)
121 #define SWITCH_PORT_PHY2 BIT(2)
122 #define SWITCH_PORT_PHY3 BIT(3)
123 #define SWITCH_PORT_PHY4 BIT(4)
124 #define SWITCH_PORT_MII BIT(5)
125 #define SWITCH_PORT_CPU BIT(6)
126
127 /* Port bit shorthands */
128 #define SWITCH_PORTS_PHY 0x1F /* phy ports */
129 #define SWITCH_PORTS_NOCPU 0x3F /* physical ports */
130 #define SWITCH_PORTS_ALL 0x7F /* all ports */
131
132 /* CPUP_CONF register bits */
133 #define CPUP_CONF_DCPUP BIT(0) /* Disable CPU port */
134 #define CPUP_CONF_CRCP BIT(1) /* CRC padding from CPU */
135 #define CPUP_CONF_BTM BIT(2) /* Bridge Testing Mode */
136 #define CPUP_CONF_DUNP_SHIFT 9 /* Disable Unknown Packets for portX */
137 #define CPUP_CONF_DMCP_SHIFT 16 /* Disable Mcast Packets form portX */
138 #define CPUP_CONF_DBCP_SHIFT 24 /* Disable Bcast Packets form portX */
139
140 /* PORT_CONF0 register bits */
141 #define PORT_CONF0_DP_SHIFT 0 /* Disable Port */
142 #define PORT_CONF0_EMCP_SHIFT 8 /* Enable All MC Packets */
143 #define PORT_CONF0_BP_SHIFT 16 /* Enable Back Pressure */
144
145 /* PORT_CONF1 register bits */
146 #define PORT_CONF1_DISL_SHIFT 0 /* Disable Learning */
147 #define PORT_CONF1_BS_SHIFT 6 /* Blocking State */
148 #define PORT_CONF1_BM_SHIFT 12 /* Blocking Mode */
149
150 /* SEND_TRIG register bits */
151 #define SEND_TRIG_STL BIT(0) /* Send Trigger Low */
152 #define SEND_TRIG_STH BIT(1) /* Send Trigger High */
153
154 /* MAC_WT0 register bits */
155 #define MAC_WT0_MAWC BIT(0) /* MAC address write command */
156 #define MAC_WT0_MWD_SHIFT 1
157 #define MAC_WT0_MWD BIT(1) /* MAC write done */
158 #define MAC_WT0_WFB BIT(2) /* Write Filter Bit */
159 #define MAC_WT0_WVN_SHIFT 3 /* Write Vlan Number shift */
160 #define MAC_WT0_WVE BIT(6) /* Write VLAN enable */
161 #define MAC_WT0_WPMN_SHIFT 7
162 #define MAC_WT0_WAF_SHIFT 13 /* Write Age Field shift */
163 #define MAC_WT0_WAF_EMPTY 0
164 #define MAC_WT0_WAF_STATIC 7 /* age: static */
165 #define MAC_WT0_MAC0_SHIFT 16
166 #define MAC_WT0_MAC1_SHIFT 24
167
168 /* MAC_WT1 register bits */
169 #define MAC_WT1_MAC2_SHIFT 0
170 #define MAC_WT1_MAC3_SHIFT 8
171 #define MAC_WT1_MAC4_SHIFT 16
172 #define MAC_WT1_MAC5_SHIFT 24
173
174 /* BW_CNTL0/BW_CNTL1 register bits */
175 #define BW_CNTL_DISABLE 0x00
176 #define BW_CNTL_64K 0x01
177 #define BW_CNTL_128K 0x02
178 #define BW_CNTL_256K 0x03
179 #define BW_CNTL_512K 0x04
180 #define BW_CNTL_1M 0x05
181 #define BW_CNTL_4M 0x06
182 #define BW_CNTL_10M 0x07
183
184 #define P4TBC_SHIFT 0
185 #define P4RBC_SHIFT 4
186 #define P5TBC_SHIFT 8
187 #define P5RBC_SHIFT 12
188
189 #define BW_CNTL1_NAND_ENABLE 0x100
190
191 /* PHY_CNTL0 register bits */
192 #define PHY_CNTL0_PHYA_MASK BITMASK(5)
193 #define PHY_CNTL0_PHYR_MASK BITMASK(5)
194 #define PHY_CNTL0_PHYR_SHIFT 8
195 #define PHY_CNTL0_WC BIT(13) /* Write Command */
196 #define PHY_CNTL0_RC BIT(14) /* Read Command */
197 #define PHY_CNTL0_WTD_MASK BIT(16) /* Read Command */
198 #define PHY_CNTL0_WTD_SHIFT 16
199
200 /* PHY_CNTL1 register bits */
201 #define PHY_CNTL1_WOD BIT(0) /* Write Operation Done */
202 #define PHY_CNTL1_ROD BIT(1) /* Read Operation Done */
203 #define PHY_CNTL1_RD_MASK BITMASK(16)
204 #define PHY_CNTL1_RD_SHIFT 16
205
206 /* PHY_CNTL2 register bits */
207 #define PHY_CNTL2_ANE_SHIFT 0 /* Auto Negotiation Enable */
208 #define PHY_CNTL2_SC_SHIFT 5 /* Speed Control */
209 #define PHY_CNTL2_DC_SHIFT 10 /* Duplex Control */
210 #define PHY_CNTL2_FNCV_SHIFT 15 /* Recommended FC Value */
211 #define PHY_CNTL2_PHYR_SHIFT 20 /* PHY reset */
212 #define PHY_CNTL2_AMDIX_SHIFT 25 /* Auto MDIX enable */
213 /* PHY_CNTL2_RMAE is bad in datasheet */
214 #define PHY_CNTL2_RMAE BIT(31) /* Recommended MCC Average enable */
215
216 /* PHY_CNTL3 register bits */
217 #define PHY_CNTL3_RNT BIT(10) /* Recommend Normal Threshold */
218
219 /* PORT_TH register bits */
220 #define PORT_TH_PPT_MASK BITMASK(8) /* Per Port Threshold */
221 #define PORT_TH_CPUT_SHIFT 8 /* CPU Port Buffer Threshold */
222 #define PORT_TH_CPUT_MASK BITMASK(8)
223 #define PORT_TH_CPUHT_SHIFT 16 /* CPU Hold Threshold */
224 #define PORT_TH_CPUHT_MASK BITMASK(8)
225 #define PORT_TH_CPURT_SHIFT 24 /* CPU Release Threshold */
226 #define PORT_TH_CPURT_MASK BITMASK(8)
227
228 /* EMPTY_CNT register bits */
229 #define EMPTY_CNT_EBGB_MASK BITMASK(9) /* Empty Blocks in the Global Buffer */
230
231 /* GPIO_CONF0 register bits */
232 #define GPIO_CONF0_MASK BITMASK(8)
233 #define GPIO_CONF0_IM_SHIFT 0
234 #define GPIO_CONF0_IV_SHIFT 8
235 #define GPIO_CONF0_OE_SHIFT 16
236 #define GPIO_CONF0_OV_SHIFT 24
237 #define GPIO_CONF0_IM_MASK (0xFF << GPIO_CONF0_IM_SHIFT)
238 #define GPIO_CONF0_IV_MASK (0xFF << GPIO_CONF0_IV_SHIFT)
239 #define GPIO_CONF0_OE_MASK (0xFF << GPIO_CONF0_OE_SHIFT)
240 #define GPIO_CONF0_OV_MASK (0xFF << GPIO_CONF0_OV_SHIFT)
241
242 /* GPIO_CONF2 register bits */
243 #define GPIO_CONF2_CSX0 BIT(4) /* enable CSX0:INTX0 on GPIO 1:2 */
244 #define GPIO_CONF2_CSX1 BIT(5) /* enable CSX1:INTX1 on GPIO 3:4 */
245 #define GPIO_CONF2_EW BIT(6) /* enable wait state pin for CSX0/1 */
246
247 /* INT_STATUS/INT_MASK register bits */
248 #define SWITCH_INT_SHD BIT(0) /* Send High Done */
249 #define SWITCH_INT_SLD BIT(1) /* Send Low Done */
250 #define SWITCH_INT_RHD BIT(2) /* Receive High Done */
251 #define SWITCH_INT_RLD BIT(3) /* Receive Low Done */
252 #define SWITCH_INT_HDF BIT(4) /* High Descriptor Full */
253 #define SWITCH_INT_LDF BIT(5) /* Low Descriptor Full */
254 #define SWITCH_INT_P0QF BIT(6) /* Port0 Queue Full */
255 #define SWITCH_INT_P1QF BIT(7) /* Port1 Queue Full */
256 #define SWITCH_INT_P2QF BIT(8) /* Port2 Queue Full */
257 #define SWITCH_INT_P3QF BIT(9) /* Port3 Queue Full */
258 #define SWITCH_INT_P4QF BIT(10) /* Port4 Queue Full */
259 #define SWITCH_INT_P5QF BIT(11) /* Port5 Queue Full */
260 #define SWITCH_INT_CPQF BIT(13) /* CPU Queue Full */
261 #define SWITCH_INT_GQF BIT(14) /* Global Queue Full */
262 #define SWITCH_INT_MD BIT(15) /* Must Drop */
263 #define SWITCH_INT_BCS BIT(16) /* BC Storm */
264 #define SWITCH_INT_PSC BIT(18) /* Port Status Change */
265 #define SWITCH_INT_ID BIT(19) /* Intruder Detected */
266 #define SWITCH_INT_W0TE BIT(20) /* Watchdog 0 Timer Expired */
267 #define SWITCH_INT_W1TE BIT(21) /* Watchdog 1 Timer Expired */
268 #define SWITCH_INT_RDE BIT(22) /* Receive Descriptor Error */
269 #define SWITCH_INT_SDE BIT(23) /* Send Descriptor Error */
270 #define SWITCH_INT_CPUH BIT(24) /* CPU Hold */
271
272 /* TIMER_INT register bits */
273 #define TIMER_INT_TOS BIT(0) /* time-out status */
274 #define TIMER_INT_TOM BIT(16) /* mask time-out interrupt */
275
276 /* TIMER register bits */
277 #define TIMER_PERIOD_MASK BITMASK(16) /* mask for timer period */
278 #define TIMER_PERIOD_DEFAULT 0xFFFF /* default timer period */
279 #define TIMER_TE BIT(16) /* timer enable bit */
280
281 /* PORTx_LED register bits */
282 #define LED_MODE_MASK BITMASK(4)
283 #define LED_MODE_INPUT 0
284 #define LED_MODE_FLASH 1
285 #define LED_MODE_OUT_HIGH 2
286 #define LED_MODE_OUT_LOW 3
287 #define LED_MODE_LINK 4
288 #define LED_MODE_SPEED 5
289 #define LED_MODE_DUPLEX 6
290 #define LED_MODE_ACT 7
291 #define LED_MODE_COLL 8
292 #define LED_MODE_LINK_ACT 9
293 #define LED_MODE_DUPLEX_COLL 10
294 #define LED_MODE_10M_ACT 11
295 #define LED_MODE_100M_ACT 12
296 #define LED0_MODE_SHIFT 0 /* LED0 mode shift */
297 #define LED1_MODE_SHIFT 4 /* LED1 mode shift */
298 #define LED2_MODE_SHIFT 8 /* LED2 mode shift */
299 #define LED0_IV_SHIFT 12 /* LED0 input value shift */
300 #define LED1_IV_SHIFT 13 /* LED1 input value shift */
301 #define LED2_IV_SHIFT 14 /* LED2 input value shift */
302
303 #endif /* _ADM5120_SWITCH_H_ */
This page took 0.058627 seconds and 5 git commands to generate.