ar71xx: fix gpio count for ar7241/ar7242
[openwrt.git] / target / linux / ar71xx / files / arch / mips / include / asm / mach-ar71xx / ar71xx.h
1 /*
2 * Atheros AR71xx SoC specific definitions
3 *
4 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
5 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 *
8 * Parts of this file are based on Atheros 2.6.15 BSP
9 * Parts of this file are based on Atheros 2.6.31 BSP
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
14 */
15
16 #ifndef __ASM_MACH_AR71XX_H
17 #define __ASM_MACH_AR71XX_H
18
19 #include <linux/types.h>
20 #include <linux/init.h>
21 #include <linux/io.h>
22 #include <linux/bitops.h>
23
24 #ifndef __ASSEMBLER__
25
26 #define AR71XX_PCI_MEM_BASE 0x10000000
27 #define AR71XX_PCI_MEM_SIZE 0x08000000
28 #define AR71XX_APB_BASE 0x18000000
29 #define AR71XX_GE0_BASE 0x19000000
30 #define AR71XX_GE0_SIZE 0x01000000
31 #define AR71XX_GE1_BASE 0x1a000000
32 #define AR71XX_GE1_SIZE 0x01000000
33 #define AR71XX_EHCI_BASE 0x1b000000
34 #define AR71XX_EHCI_SIZE 0x01000000
35 #define AR71XX_OHCI_BASE 0x1c000000
36 #define AR71XX_OHCI_SIZE 0x01000000
37 #define AR7240_OHCI_BASE 0x1b000000
38 #define AR7240_OHCI_SIZE 0x01000000
39 #define AR71XX_SPI_BASE 0x1f000000
40 #define AR71XX_SPI_SIZE 0x01000000
41
42 #define AR71XX_DDR_CTRL_BASE (AR71XX_APB_BASE + 0x00000000)
43 #define AR71XX_DDR_CTRL_SIZE 0x10000
44 #define AR71XX_CPU_BASE (AR71XX_APB_BASE + 0x00010000)
45 #define AR71XX_UART_BASE (AR71XX_APB_BASE + 0x00020000)
46 #define AR71XX_UART_SIZE 0x10000
47 #define AR71XX_USB_CTRL_BASE (AR71XX_APB_BASE + 0x00030000)
48 #define AR71XX_USB_CTRL_SIZE 0x10000
49 #define AR71XX_GPIO_BASE (AR71XX_APB_BASE + 0x00040000)
50 #define AR71XX_GPIO_SIZE 0x10000
51 #define AR71XX_PLL_BASE (AR71XX_APB_BASE + 0x00050000)
52 #define AR71XX_PLL_SIZE 0x10000
53 #define AR71XX_RESET_BASE (AR71XX_APB_BASE + 0x00060000)
54 #define AR71XX_RESET_SIZE 0x10000
55 #define AR71XX_MII_BASE (AR71XX_APB_BASE + 0x00070000)
56 #define AR71XX_MII_SIZE 0x10000
57 #define AR71XX_SLIC_BASE (AR71XX_APB_BASE + 0x00090000)
58 #define AR71XX_SLIC_SIZE 0x10000
59 #define AR71XX_DMA_BASE (AR71XX_APB_BASE + 0x000A0000)
60 #define AR71XX_DMA_SIZE 0x10000
61 #define AR71XX_STEREO_BASE (AR71XX_APB_BASE + 0x000B0000)
62 #define AR71XX_STEREO_SIZE 0x10000
63
64 #define AR724X_PCI_CRP_BASE (AR71XX_APB_BASE + 0x000C0000)
65 #define AR724X_PCI_CRP_SIZE 0x100
66
67 #define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000F0000)
68 #define AR724X_PCI_CTRL_SIZE 0x100
69
70 #define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
71 #define AR91XX_WMAC_SIZE 0x30000
72
73 #define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
74 #define AR933X_UART_SIZE 0x14
75 #define AR933X_GMAC_BASE (AR71XX_APB_BASE + 0x00070000)
76 #define AR933X_GMAC_SIZE 0x04
77 #define AR933X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
78 #define AR933X_WMAC_SIZE 0x20000
79
80 #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
81 #define AR934X_WMAC_SIZE 0x20000
82
83 #define AR71XX_MEM_SIZE_MIN 0x0200000
84 #define AR71XX_MEM_SIZE_MAX 0x10000000
85
86 #define AR71XX_CPU_IRQ_BASE 0
87 #define AR71XX_MISC_IRQ_BASE 8
88 #define AR71XX_MISC_IRQ_COUNT 32
89 #define AR71XX_GPIO_IRQ_BASE 40
90 #define AR71XX_GPIO_IRQ_COUNT 32
91 #define AR71XX_PCI_IRQ_BASE 72
92 #define AR71XX_PCI_IRQ_COUNT 6
93 #define AR934X_IP2_IRQ_BASE 78
94 #define AR934X_IP2_IRQ_COUNT 2
95
96 #define AR71XX_CPU_IRQ_IP2 (AR71XX_CPU_IRQ_BASE + 2)
97 #define AR71XX_CPU_IRQ_USB (AR71XX_CPU_IRQ_BASE + 3)
98 #define AR71XX_CPU_IRQ_GE0 (AR71XX_CPU_IRQ_BASE + 4)
99 #define AR71XX_CPU_IRQ_GE1 (AR71XX_CPU_IRQ_BASE + 5)
100 #define AR71XX_CPU_IRQ_MISC (AR71XX_CPU_IRQ_BASE + 6)
101 #define AR71XX_CPU_IRQ_TIMER (AR71XX_CPU_IRQ_BASE + 7)
102
103 #define AR71XX_MISC_IRQ_TIMER (AR71XX_MISC_IRQ_BASE + 0)
104 #define AR71XX_MISC_IRQ_ERROR (AR71XX_MISC_IRQ_BASE + 1)
105 #define AR71XX_MISC_IRQ_GPIO (AR71XX_MISC_IRQ_BASE + 2)
106 #define AR71XX_MISC_IRQ_UART (AR71XX_MISC_IRQ_BASE + 3)
107 #define AR71XX_MISC_IRQ_WDOG (AR71XX_MISC_IRQ_BASE + 4)
108 #define AR71XX_MISC_IRQ_PERFC (AR71XX_MISC_IRQ_BASE + 5)
109 #define AR71XX_MISC_IRQ_OHCI (AR71XX_MISC_IRQ_BASE + 6)
110 #define AR71XX_MISC_IRQ_DMA (AR71XX_MISC_IRQ_BASE + 7)
111 #define AR71XX_MISC_IRQ_TIMER2 (AR71XX_MISC_IRQ_BASE + 8)
112 #define AR71XX_MISC_IRQ_TIMER3 (AR71XX_MISC_IRQ_BASE + 9)
113 #define AR71XX_MISC_IRQ_TIMER4 (AR71XX_MISC_IRQ_BASE + 10)
114 #define AR71XX_MISC_IRQ_DDR_PERF (AR71XX_MISC_IRQ_BASE + 11)
115 #define AR71XX_MISC_IRQ_ENET_LINK (AR71XX_MISC_IRQ_BASE + 12)
116
117 #define AR71XX_GPIO_IRQ(_x) (AR71XX_GPIO_IRQ_BASE + (_x))
118
119 #define AR71XX_PCI_IRQ_DEV0 (AR71XX_PCI_IRQ_BASE + 0)
120 #define AR71XX_PCI_IRQ_DEV1 (AR71XX_PCI_IRQ_BASE + 1)
121 #define AR71XX_PCI_IRQ_DEV2 (AR71XX_PCI_IRQ_BASE + 2)
122 #define AR71XX_PCI_IRQ_CORE (AR71XX_PCI_IRQ_BASE + 4)
123
124 #define AR934X_IP2_IRQ_WMAC (AR934X_IP2_IRQ_BASE + 0)
125 #define AR934X_IP2_IRQ_PCIE (AR934X_IP2_IRQ_BASE + 1)
126
127 extern u32 ar71xx_ahb_freq;
128 extern u32 ar71xx_cpu_freq;
129 extern u32 ar71xx_ddr_freq;
130 extern u32 ar71xx_ref_freq;
131
132 enum ar71xx_soc_type {
133 AR71XX_SOC_UNKNOWN,
134 AR71XX_SOC_AR7130,
135 AR71XX_SOC_AR7141,
136 AR71XX_SOC_AR7161,
137 AR71XX_SOC_AR7240,
138 AR71XX_SOC_AR7241,
139 AR71XX_SOC_AR7242,
140 AR71XX_SOC_AR9130,
141 AR71XX_SOC_AR9132,
142 AR71XX_SOC_AR9330,
143 AR71XX_SOC_AR9331,
144 AR71XX_SOC_AR9341,
145 AR71XX_SOC_AR9342,
146 AR71XX_SOC_AR9344,
147 };
148 extern u32 ar71xx_soc_rev;
149
150 extern enum ar71xx_soc_type ar71xx_soc;
151
152 /*
153 * PLL block
154 */
155 #define AR71XX_PLL_REG_CPU_CONFIG 0x00
156 #define AR71XX_PLL_REG_SEC_CONFIG 0x04
157 #define AR71XX_PLL_REG_ETH0_INT_CLOCK 0x10
158 #define AR71XX_PLL_REG_ETH1_INT_CLOCK 0x14
159
160 #define AR71XX_PLL_DIV_SHIFT 3
161 #define AR71XX_PLL_DIV_MASK 0x1f
162 #define AR71XX_CPU_DIV_SHIFT 16
163 #define AR71XX_CPU_DIV_MASK 0x3
164 #define AR71XX_DDR_DIV_SHIFT 18
165 #define AR71XX_DDR_DIV_MASK 0x3
166 #define AR71XX_AHB_DIV_SHIFT 20
167 #define AR71XX_AHB_DIV_MASK 0x7
168
169 #define AR71XX_ETH0_PLL_SHIFT 17
170 #define AR71XX_ETH1_PLL_SHIFT 19
171
172 #define AR724X_PLL_REG_CPU_CONFIG 0x00
173 #define AR724X_PLL_REG_PCIE_CONFIG 0x18
174
175 #define AR724X_PLL_DIV_SHIFT 0
176 #define AR724X_PLL_DIV_MASK 0x3ff
177 #define AR724X_PLL_REF_DIV_SHIFT 10
178 #define AR724X_PLL_REF_DIV_MASK 0xf
179 #define AR724X_AHB_DIV_SHIFT 19
180 #define AR724X_AHB_DIV_MASK 0x1
181 #define AR724X_DDR_DIV_SHIFT 22
182 #define AR724X_DDR_DIV_MASK 0x3
183
184 #define AR7242_PLL_REG_ETH0_INT_CLOCK 0x2c
185
186 #define AR91XX_PLL_REG_CPU_CONFIG 0x00
187 #define AR91XX_PLL_REG_ETH_CONFIG 0x04
188 #define AR91XX_PLL_REG_ETH0_INT_CLOCK 0x14
189 #define AR91XX_PLL_REG_ETH1_INT_CLOCK 0x18
190
191 #define AR91XX_PLL_DIV_SHIFT 0
192 #define AR91XX_PLL_DIV_MASK 0x3ff
193 #define AR91XX_DDR_DIV_SHIFT 22
194 #define AR91XX_DDR_DIV_MASK 0x3
195 #define AR91XX_AHB_DIV_SHIFT 19
196 #define AR91XX_AHB_DIV_MASK 0x1
197
198 #define AR91XX_ETH0_PLL_SHIFT 20
199 #define AR91XX_ETH1_PLL_SHIFT 22
200
201 #define AR933X_PLL_CPU_CONFIG_REG 0x00
202 #define AR933X_PLL_CLOCK_CTRL_REG 0x08
203
204 #define AR933X_PLL_CPU_CONFIG_NINT_SHIFT 10
205 #define AR933X_PLL_CPU_CONFIG_NINT_MASK 0x3f
206 #define AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT 16
207 #define AR933X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
208 #define AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT 23
209 #define AR933X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
210
211 #define AR933X_PLL_CLOCK_CTRL_BYPASS BIT(2)
212 #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT 5
213 #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK 0x3
214 #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT 10
215 #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK 0x3
216 #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT 15
217 #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK 0x7
218
219 #define AR934X_PLL_REG_CPU_CONFIG 0x00
220 #define AR934X_PLL_REG_DDR_CONFIG 0x04
221 #define AR934X_PLL_REG_DDR_CTRL_CLOCK 0x8
222
223 #define AR934X_CPU_PLL_CFG_OUTDIV_MSB 21
224 #define AR934X_CPU_PLL_CFG_OUTDIV_LSB 19
225 #define AR934X_CPU_PLL_CFG_OUTDIV_MASK 0x00380000
226
227 #define AR934X_CPU_PLL_CFG_OUTDIV_GET(x) \
228 (((x) & AR934X_CPU_PLL_CFG_OUTDIV_MASK) >> \
229 AR934X_CPU_PLL_CFG_OUTDIV_LSB)
230
231 #define AR934X_DDR_PLL_CFG_OUTDIV_MSB 25
232 #define AR934X_DDR_PLL_CFG_OUTDIV_LSB 23
233 #define AR934X_DDR_PLL_CFG_OUTDIV_MASK 0x03800000
234
235 #define AR934X_DDR_PLL_CFG_OUTDIV_GET(x) \
236 (((x) & AR934X_DDR_PLL_CFG_OUTDIV_MASK) >> \
237 AR934X_DDR_PLL_CFG_OUTDIV_LSB)
238
239 #define AR934X_DDR_PLL_CFG_OUTDIV_SET(x) \
240 (((x) << AR934X_DDR_PLL_CFG_OUTDIV_LSB) & \
241 AR934X_DDR_PLL_CFG_OUTDIV_MASK)
242
243 #define AR934X_CPU_PLL_CFG_REFDIV_MSB 16
244 #define AR934X_CPU_PLL_CFG_REFDIV_LSB 12
245 #define AR934X_CPU_PLL_CFG_REFDIV_MASK 0x0001f000
246
247 #define AR934X_CPU_PLL_CFG_REFDIV_GET(x) \
248 (((x) & AR934X_CPU_PLL_CFG_REFDIV_MASK) >> \
249 AR934X_CPU_PLL_CFG_REFDIV_LSB)
250
251 #define AR934X_CPU_PLL_CFG_REFDIV_SET(x) \
252 (((x) << AR934X_CPU_PLL_CFG_REFDIV_LSB) & \
253 AR934X_CPU_PLL_CFG_REFDIV_MASK)
254
255 #define AR934X_CPU_PLL_CFG_REFDIV_RESET 2
256
257 #define AR934X_CPU_PLL_CFG_NINT_MSB 11
258 #define AR934X_CPU_PLL_CFG_NINT_LSB 6
259 #define AR934X_CPU_PLL_CFG_NINT_MASK 0x00000fc0
260
261 #define AR934X_CPU_PLL_CFG_NINT_GET(x) \
262 (((x) & AR934X_CPU_PLL_CFG_NINT_MASK) >> \
263 AR934X_CPU_PLL_CFG_NINT_LSB)
264
265 #define AR934X_CPU_PLL_CFG_NINT_SET(x) \
266 (((x) << AR934X_CPU_PLL_CFG_NINT_LSB) & \
267 AR934X_CPU_PLL_CFG_NINT_MASK)
268
269 #define AR934X_CPU_PLL_CFG_NINT_RESET 20
270
271 #define AR934X_CPU_PLL_CFG_NFRAC_MSB 5
272 #define AR934X_CPU_PLL_CFG_NFRAC_LSB 0
273 #define AR934X_CPU_PLL_CFG_NFRAC_MASK 0x0000003f
274
275 #define AR934X_CPU_PLL_CFG_NFRAC_GET(x) \
276 (((x) & AR934X_CPU_PLL_CFG_NFRAC_MASK) >> \
277 AR934X_CPU_PLL_CFG_NFRAC_LSB)
278
279 #define AR934X_CPU_PLL_CFG_NFRAC_SET(x) \
280 (((x) << AR934X_CPU_PLL_CFG_NFRAC_LSB) & \
281 AR934X_CPU_PLL_CFG_NFRAC_MASK)
282
283 #define AR934X_DDR_PLL_CFG_REFDIV_MSB 20
284 #define AR934X_DDR_PLL_CFG_REFDIV_LSB 16
285 #define AR934X_DDR_PLL_CFG_REFDIV_MASK 0x001f0000
286
287 #define AR934X_DDR_PLL_CFG_REFDIV_GET(x) \
288 (((x) & AR934X_DDR_PLL_CFG_REFDIV_MASK) >> \
289 AR934X_DDR_PLL_CFG_REFDIV_LSB)
290
291 #define AR934X_DDR_PLL_CFG_REFDIV_SET(x) \
292 (((x) << AR934X_DDR_PLL_CFG_REFDIV_LSB) & \
293 AR934X_DDR_PLL_CFG_REFDIV_MASK)
294
295 #define AR934X_DDR_PLL_CFG_REFDIV_RESET 2
296
297 #define AR934X_DDR_PLL_CFG_NINT_MSB 15
298 #define AR934X_DDR_PLL_CFG_NINT_LSB 10
299 #define AR934X_DDR_PLL_CFG_NINT_MASK 0x0000fc00
300
301 #define AR934X_DDR_PLL_CFG_NINT_GET(x) \
302 (((x) & AR934X_DDR_PLL_CFG_NINT_MASK) >> \
303 AR934X_DDR_PLL_CFG_NINT_LSB)
304
305 #define AR934X_DDR_PLL_CFG_NINT_SET(x) \
306 (((x) << AR934X_DDR_PLL_CFG_NINT_LSB) & \
307 AR934X_DDR_PLL_CFG_NINT_MASK)
308
309 #define AR934X_DDR_PLL_CFG_NINT_RESET 20
310
311 #define AR934X_DDR_PLL_CFG_NFRAC_MSB 9
312 #define AR934X_DDR_PLL_CFG_NFRAC_LSB 0
313 #define AR934X_DDR_PLL_CFG_NFRAC_MASK 0x000003ff
314
315 #define AR934X_DDR_PLL_CFG_NFRAC_GET(x) \
316 (((x) & AR934X_DDR_PLL_CFG_NFRAC_MASK) >> \
317 AR934X_DDR_PLL_CFG_NFRAC_LSB)
318
319 #define AR934X_DDR_PLL_CFG_NFRAC_SET(x) \
320 (((x) << AR934X_DDR_PLL_CFG_NFRAC_LSB) & \
321 AR934X_DDR_PLL_CFG_NFRAC_MASK)
322
323 #define AR934X_DDR_PLL_CFG_NFRAC_RESET 512
324
325 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MSB 19
326 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB 15
327 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK 0x000f8000
328
329 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_GET(x) \
330 (((x) & AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK) >> \
331 AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB)
332
333 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_SET(x) \
334 (((x) << AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB) & \
335 AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK)
336
337 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_RESET 0
338
339 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MSB 14
340 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB 10
341 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK 0x00007c00
342
343 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_GET(x) \
344 (((x) & AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK) >> \
345 AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB)
346
347 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_SET(x) \
348 (((x) << AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB) & \
349 AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK)
350
351 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_RESET 0
352
353 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MSB 9
354 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB 5
355 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK 0x000003e0
356
357 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_GET(x) \
358 (((x) & AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK) >> \
359 AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB)
360
361 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_SET(x) \
362 (((x) << AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB) & \
363 AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK)
364
365 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_RESET 0
366
367 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MSB 24
368 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB 24
369 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK 0x01000000
370
371 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_GET(x) \
372 (((x) & AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK) >> \
373 AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB)
374
375 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_SET(x) \
376 (((x) << AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB) & \
377 AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK)
378
379 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_RESET 1
380
381 #define AR934X_CPU_DDR_CLK_CTRL_CPU_PLL_BYPASS BIT(2)
382 #define AR934X_CPU_DDR_CLK_CTRL_DDR_PLL_BYPASS BIT(3)
383 #define AR934X_CPU_DDR_CLK_CTRL_AHB_PLL_BYPASS BIT(4)
384 #define AR934X_CPU_DDR_CLK_CTRL_CPUCLK_FROM_CPUPLL BIT(20)
385 #define AR934X_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL BIT(21)
386 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
387
388 extern void __iomem *ar71xx_pll_base;
389
390 static inline void ar71xx_pll_wr(unsigned reg, u32 val)
391 {
392 __raw_writel(val, ar71xx_pll_base + reg);
393 }
394
395 static inline u32 ar71xx_pll_rr(unsigned reg)
396 {
397 return __raw_readl(ar71xx_pll_base + reg);
398 }
399
400 /*
401 * USB_CONFIG block
402 */
403 #define USB_CTRL_REG_FLADJ 0x00
404 #define USB_CTRL_REG_CONFIG 0x04
405
406 extern void __iomem *ar71xx_usb_ctrl_base;
407
408 static inline void ar71xx_usb_ctrl_wr(unsigned reg, u32 val)
409 {
410 __raw_writel(val, ar71xx_usb_ctrl_base + reg);
411 }
412
413 static inline u32 ar71xx_usb_ctrl_rr(unsigned reg)
414 {
415 return __raw_readl(ar71xx_usb_ctrl_base + reg);
416 }
417
418 /*
419 * GPIO block
420 */
421 #define AR71XX_GPIO_REG_OE 0x00
422 #define AR71XX_GPIO_REG_IN 0x04
423 #define AR71XX_GPIO_REG_OUT 0x08
424 #define AR71XX_GPIO_REG_SET 0x0c
425 #define AR71XX_GPIO_REG_CLEAR 0x10
426 #define AR71XX_GPIO_REG_INT_MODE 0x14
427 #define AR71XX_GPIO_REG_INT_TYPE 0x18
428 #define AR71XX_GPIO_REG_INT_POLARITY 0x1c
429 #define AR71XX_GPIO_REG_INT_PENDING 0x20
430 #define AR71XX_GPIO_REG_INT_ENABLE 0x24
431 #define AR71XX_GPIO_REG_FUNC 0x28
432
433 #define AR934X_GPIO_REG_OUT_FUNC0 0x2c
434 #define AR934X_GPIO_REG_OUT_FUNC1 0x30
435 #define AR934X_GPIO_REG_OUT_FUNC2 0x34
436 #define AR934X_GPIO_REG_OUT_FUNC3 0x38
437 #define AR934X_GPIO_REG_OUT_FUNC4 0x3c
438 #define AR934X_GPIO_REG_OUT_FUNC5 0x40
439 #define AR934X_GPIO_REG_FUNC 0x6c
440
441 #define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
442 #define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
443 #define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
444 #define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
445 #define AR71XX_GPIO_FUNC_UART_EN BIT(8)
446 #define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
447 #define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
448
449 #define AR71XX_GPIO_COUNT 16
450
451 #define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
452 #define AR724X_GPIO_FUNC_SPI_EN BIT(18)
453 #define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
454 #define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
455 #define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
456 #define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
457 #define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
458 #define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
459 #define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
460 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
461 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
462 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
463 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
464 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
465 #define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
466 #define AR724X_GPIO_FUNC_UART_EN BIT(1)
467 #define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
468
469 #define AR7240_GPIO_COUNT 18
470 #define AR7241_GPIO_COUNT 20
471
472 #define AR91XX_GPIO_FUNC_WMAC_LED_EN BIT(22)
473 #define AR91XX_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
474 #define AR91XX_GPIO_FUNC_I2S_REFCLKEN BIT(20)
475 #define AR91XX_GPIO_FUNC_I2S_MCKEN BIT(19)
476 #define AR91XX_GPIO_FUNC_I2S1_EN BIT(18)
477 #define AR91XX_GPIO_FUNC_I2S0_EN BIT(17)
478 #define AR91XX_GPIO_FUNC_SLIC_EN BIT(16)
479 #define AR91XX_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
480 #define AR91XX_GPIO_FUNC_UART_EN BIT(8)
481 #define AR91XX_GPIO_FUNC_USB_CLK_EN BIT(4)
482
483 #define AR91XX_GPIO_COUNT 22
484
485 #define AR933X_GPIO_COUNT 30
486
487 #define AR934X_GPIO_FUNC_SPI_CS_1_EN BIT(14)
488 #define AR934X_GPIO_FUNC_SPI_CS_0_EN BIT(13)
489
490 #define AR934X_GPIO_COUNT 23
491 #define AR934X_GPIO_FUNC_DDR_DQOE_EN BIT(17)
492
493 #define AR934X_GPIO_OUT_GPIO 0x00
494
495 extern void __iomem *ar71xx_gpio_base;
496
497 static inline void ar71xx_gpio_wr(unsigned reg, u32 value)
498 {
499 __raw_writel(value, ar71xx_gpio_base + reg);
500 }
501
502 static inline u32 ar71xx_gpio_rr(unsigned reg)
503 {
504 return __raw_readl(ar71xx_gpio_base + reg);
505 }
506
507 void ar71xx_gpio_init(void) __init;
508 void ar71xx_gpio_function_enable(u32 mask);
509 void ar71xx_gpio_function_disable(u32 mask);
510 void ar71xx_gpio_function_setup(u32 set, u32 clear);
511 void ar71xx_gpio_output_select(unsigned gpio, u8 val);
512
513 /*
514 * DDR_CTRL block
515 */
516 #define AR71XX_DDR_REG_PCI_WIN0 0x7c
517 #define AR71XX_DDR_REG_PCI_WIN1 0x80
518 #define AR71XX_DDR_REG_PCI_WIN2 0x84
519 #define AR71XX_DDR_REG_PCI_WIN3 0x88
520 #define AR71XX_DDR_REG_PCI_WIN4 0x8c
521 #define AR71XX_DDR_REG_PCI_WIN5 0x90
522 #define AR71XX_DDR_REG_PCI_WIN6 0x94
523 #define AR71XX_DDR_REG_PCI_WIN7 0x98
524 #define AR71XX_DDR_REG_FLUSH_GE0 0x9c
525 #define AR71XX_DDR_REG_FLUSH_GE1 0xa0
526 #define AR71XX_DDR_REG_FLUSH_USB 0xa4
527 #define AR71XX_DDR_REG_FLUSH_PCI 0xa8
528
529 #define AR724X_DDR_REG_FLUSH_GE0 0x7c
530 #define AR724X_DDR_REG_FLUSH_GE1 0x80
531 #define AR724X_DDR_REG_FLUSH_USB 0x84
532 #define AR724X_DDR_REG_FLUSH_PCIE 0x88
533
534 #define AR91XX_DDR_REG_FLUSH_GE0 0x7c
535 #define AR91XX_DDR_REG_FLUSH_GE1 0x80
536 #define AR91XX_DDR_REG_FLUSH_USB 0x84
537 #define AR91XX_DDR_REG_FLUSH_WMAC 0x88
538
539 #define AR933X_DDR_REG_FLUSH_GE0 0x7c
540 #define AR933X_DDR_REG_FLUSH_GE1 0x80
541 #define AR933X_DDR_REG_FLUSH_USB 0x84
542 #define AR933X_DDR_REG_FLUSH_WMAC 0x88
543
544 #define AR934X_DDR_REG_FLUSH_GE0 0x9c
545 #define AR934X_DDR_REG_FLUSH_GE1 0xa0
546 #define AR934X_DDR_REG_FLUSH_USB 0xa4
547 #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
548 #define AR934X_DDR_REG_FLUSH_WMAC 0xac
549
550
551 #define PCI_WIN0_OFFS 0x10000000
552 #define PCI_WIN1_OFFS 0x11000000
553 #define PCI_WIN2_OFFS 0x12000000
554 #define PCI_WIN3_OFFS 0x13000000
555 #define PCI_WIN4_OFFS 0x14000000
556 #define PCI_WIN5_OFFS 0x15000000
557 #define PCI_WIN6_OFFS 0x16000000
558 #define PCI_WIN7_OFFS 0x07000000
559
560 extern void __iomem *ar71xx_ddr_base;
561
562 static inline void ar71xx_ddr_wr(unsigned reg, u32 val)
563 {
564 __raw_writel(val, ar71xx_ddr_base + reg);
565 }
566
567 static inline u32 ar71xx_ddr_rr(unsigned reg)
568 {
569 return __raw_readl(ar71xx_ddr_base + reg);
570 }
571
572 void ar71xx_ddr_flush(u32 reg);
573
574 /*
575 * PCI block
576 */
577 #define AR71XX_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + PCI_WIN7_OFFS + 0x10000)
578 #define AR71XX_PCI_CFG_SIZE 0x100
579
580 #define PCI_REG_CRP_AD_CBE 0x00
581 #define PCI_REG_CRP_WRDATA 0x04
582 #define PCI_REG_CRP_RDDATA 0x08
583 #define PCI_REG_CFG_AD 0x0c
584 #define PCI_REG_CFG_CBE 0x10
585 #define PCI_REG_CFG_WRDATA 0x14
586 #define PCI_REG_CFG_RDDATA 0x18
587 #define PCI_REG_PCI_ERR 0x1c
588 #define PCI_REG_PCI_ERR_ADDR 0x20
589 #define PCI_REG_AHB_ERR 0x24
590 #define PCI_REG_AHB_ERR_ADDR 0x28
591
592 #define PCI_CRP_CMD_WRITE 0x00010000
593 #define PCI_CRP_CMD_READ 0x00000000
594 #define PCI_CFG_CMD_READ 0x0000000a
595 #define PCI_CFG_CMD_WRITE 0x0000000b
596
597 #define PCI_IDSEL_ADL_START 17
598
599 #define AR724X_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + 0x4000000)
600 #define AR724X_PCI_CFG_SIZE 0x1000
601
602 #define AR724X_PCI_REG_APP 0x00
603 #define AR724X_PCI_REG_RESET 0x18
604 #define AR724X_PCI_REG_INT_STATUS 0x4c
605 #define AR724X_PCI_REG_INT_MASK 0x50
606
607 #define AR724X_PCI_APP_LTSSM_ENABLE BIT(0)
608 #define AR724X_PCI_RESET_LINK_UP BIT(0)
609
610 #define AR724X_PCI_INT_DEV0 BIT(14)
611
612 /*
613 * RESET block
614 */
615 #define AR71XX_RESET_REG_TIMER 0x00
616 #define AR71XX_RESET_REG_TIMER_RELOAD 0x04
617 #define AR71XX_RESET_REG_WDOG_CTRL 0x08
618 #define AR71XX_RESET_REG_WDOG 0x0c
619 #define AR71XX_RESET_REG_MISC_INT_STATUS 0x10
620 #define AR71XX_RESET_REG_MISC_INT_ENABLE 0x14
621 #define AR71XX_RESET_REG_PCI_INT_STATUS 0x18
622 #define AR71XX_RESET_REG_PCI_INT_ENABLE 0x1c
623 #define AR71XX_RESET_REG_GLOBAL_INT_STATUS 0x20
624 #define AR71XX_RESET_REG_RESET_MODULE 0x24
625 #define AR71XX_RESET_REG_PERFC_CTRL 0x2c
626 #define AR71XX_RESET_REG_PERFC0 0x30
627 #define AR71XX_RESET_REG_PERFC1 0x34
628 #define AR71XX_RESET_REG_REV_ID 0x90
629
630 #define AR91XX_RESET_REG_GLOBAL_INT_STATUS 0x18
631 #define AR91XX_RESET_REG_RESET_MODULE 0x1c
632 #define AR91XX_RESET_REG_PERF_CTRL 0x20
633 #define AR91XX_RESET_REG_PERFC0 0x24
634 #define AR91XX_RESET_REG_PERFC1 0x28
635
636 #define AR724X_RESET_REG_RESET_MODULE 0x1c
637
638 #define AR933X_RESET_REG_RESET_MODULE 0x1c
639 #define AR933X_RESET_REG_BOOTSTRAP 0xac
640 #define AR933X_BOOTSTRAP_EEPBUSY BIT(4)
641 #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
642
643 #define AR934X_RESET_REG_RESET_MODULE 0x1c
644
645 #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
646 #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
647 #define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
648 #define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
649 #define AR934X_PCIE_WMAC_INT_WMAC_RXHP BIT(3)
650 #define AR934X_PCIE_WMAC_INT_PCIE_RC BIT(4)
651 #define AR934X_PCIE_WMAC_INT_PCIE_RC0 BIT(5)
652 #define AR934X_PCIE_WMAC_INT_PCIE_RC1 BIT(6)
653 #define AR934X_PCIE_WMAC_INT_PCIE_RC2 BIT(7)
654 #define AR934X_PCIE_WMAC_INT_PCIE_RC3 BIT(8)
655 #define AR934X_PCIE_WMAC_INT_WMAC_ALL \
656 (AR934X_PCIE_WMAC_INT_WMAC_MISC | AR934X_PCIE_WMAC_INT_WMAC_TX | \
657 AR934X_PCIE_WMAC_INT_WMAC_RXLP | AR934X_PCIE_WMAC_INT_WMAC_RXHP)
658
659 #define AR934X_PCIE_WMAC_INT_PCIE_ALL \
660 (AR934X_PCIE_WMAC_INT_PCIE_RC | AR934X_PCIE_WMAC_INT_PCIE_RC0 | \
661 AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
662 AR934X_PCIE_WMAC_INT_PCIE_RC3)
663
664 #define AR934X_RESET_REG_BOOTSTRAP 0xb0
665 #define AR934X_BOOTSTRAP_SW_OPTION8 BIT(23)
666 #define AR934X_BOOTSTRAP_SW_OPTION7 BIT(22)
667 #define AR934X_BOOTSTRAP_SW_OPTION6 BIT(21)
668 #define AR934X_BOOTSTRAP_SW_OPTION5 BIT(20)
669 #define AR934X_BOOTSTRAP_SW_OPTION4 BIT(19)
670 #define AR934X_BOOTSTRAP_SW_OPTION3 BIT(18)
671 #define AR934X_BOOTSTRAP_SW_OPTION2 BIT(17)
672 #define AR934X_BOOTSTRAP_SW_OPTION1 BIT(16)
673 #define AR934X_BOOTSTRAP_USB_MODE_DEVICE BIT(7)
674 #define AR934X_BOOTSTRAP_PCIE_RC BIT(6)
675 #define AR934X_BOOTSTRAP_EJTAG_MODE BIT(5)
676 #define AR934X_BOOTSTRAP_REF_CLK_40 BIT(4)
677 #define AR934X_BOOTSTRAP_BOOT_FROM_SPI BIT(2)
678 #define AR934X_BOOTSTRAP_SDRAM_DISABLED BIT(1)
679 #define AR934X_BOOTSTRAP_DDR1 BIT(0)
680
681 #define WDOG_CTRL_LAST_RESET BIT(31)
682 #define WDOG_CTRL_ACTION_MASK 3
683 #define WDOG_CTRL_ACTION_NONE 0 /* no action */
684 #define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */
685 #define WDOG_CTRL_ACTION_NMI 2 /* NMI */
686 #define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
687
688 #define MISC_INT_ENET_LINK BIT(12)
689 #define MISC_INT_DDR_PERF BIT(11)
690 #define MISC_INT_TIMER4 BIT(10)
691 #define MISC_INT_TIMER3 BIT(9)
692 #define MISC_INT_TIMER2 BIT(8)
693 #define MISC_INT_DMA BIT(7)
694 #define MISC_INT_OHCI BIT(6)
695 #define MISC_INT_PERFC BIT(5)
696 #define MISC_INT_WDOG BIT(4)
697 #define MISC_INT_UART BIT(3)
698 #define MISC_INT_GPIO BIT(2)
699 #define MISC_INT_ERROR BIT(1)
700 #define MISC_INT_TIMER BIT(0)
701
702 #define PCI_INT_CORE BIT(4)
703 #define PCI_INT_DEV2 BIT(2)
704 #define PCI_INT_DEV1 BIT(1)
705 #define PCI_INT_DEV0 BIT(0)
706
707 #define RESET_MODULE_EXTERNAL BIT(28)
708 #define RESET_MODULE_FULL_CHIP BIT(24)
709 #define RESET_MODULE_AMBA2WMAC BIT(22)
710 #define RESET_MODULE_CPU_NMI BIT(21)
711 #define RESET_MODULE_CPU_COLD BIT(20)
712 #define RESET_MODULE_DMA BIT(19)
713 #define RESET_MODULE_SLIC BIT(18)
714 #define RESET_MODULE_STEREO BIT(17)
715 #define RESET_MODULE_DDR BIT(16)
716 #define RESET_MODULE_GE1_MAC BIT(13)
717 #define RESET_MODULE_GE1_PHY BIT(12)
718 #define RESET_MODULE_USBSUS_OVERRIDE BIT(10)
719 #define RESET_MODULE_GE0_MAC BIT(9)
720 #define RESET_MODULE_GE0_PHY BIT(8)
721 #define RESET_MODULE_USB_OHCI_DLL BIT(6)
722 #define RESET_MODULE_USB_HOST BIT(5)
723 #define RESET_MODULE_USB_PHY BIT(4)
724 #define RESET_MODULE_USB_OHCI_DLL_7240 BIT(3)
725 #define RESET_MODULE_PCI_BUS BIT(1)
726 #define RESET_MODULE_PCI_CORE BIT(0)
727
728 #define AR724X_RESET_GE1_MDIO BIT(23)
729 #define AR724X_RESET_GE0_MDIO BIT(22)
730 #define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
731 #define AR724X_RESET_PCIE_PHY BIT(7)
732 #define AR724X_RESET_PCIE BIT(6)
733 #define AR724X_RESET_USB_HOST BIT(5)
734 #define AR724X_RESET_USB_PHY BIT(4)
735 #define AR724X_RESET_USBSUS_OVERRIDE BIT(3)
736
737 #define AR933X_RESET_WMAC BIT(11)
738 #define AR933X_RESET_GE1_MDIO BIT(23)
739 #define AR933X_RESET_GE0_MDIO BIT(22)
740 #define AR933X_RESET_GE1_MAC BIT(13)
741 #define AR933X_RESET_GE0_MAC BIT(9)
742 #define AR933X_RESET_USB_HOST BIT(5)
743 #define AR933X_RESET_USB_PHY BIT(4)
744 #define AR933X_RESET_USBSUS_OVERRIDE BIT(3)
745
746 #define AR934X_RESET_HOST BIT(31)
747 #define AR934X_RESET_SLIC BIT(30)
748 #define AR934X_RESET_HDMA BIT(29)
749 #define AR934X_RESET_EXTERNAL BIT(28)
750 #define AR934X_RESET_RTC BIT(27)
751 #define AR934X_RESET_PCIE_EP_INT BIT(26)
752 #define AR934X_RESET_CHKSUM_ACC BIT(25)
753 #define AR934X_RESET_FULL_CHIP BIT(24)
754 #define AR934X_RESET_GE1_MDIO BIT(23)
755 #define AR934X_RESET_GE0_MDIO BIT(22)
756 #define AR934X_RESET_CPU_NMI BIT(21)
757 #define AR934X_RESET_CPU_COLD BIT(20)
758 #define AR934X_RESET_HOST_RESET_INT BIT(19)
759 #define AR934X_RESET_PCIE_EP BIT(18)
760 #define AR934X_RESET_UART1 BIT(17)
761 #define AR934X_RESET_DDR BIT(16)
762 #define AR934X_RESET_USB_PHY_PLL_PWD_EXT BIT(15)
763 #define AR934X_RESET_NANDF BIT(14)
764 #define AR934X_RESET_GE1_MAC BIT(13)
765 #define AR934X_RESET_ETH_SWITCH_ANALOG BIT(12)
766 #define AR934X_RESET_USB_PHY_ANALOG BIT(11)
767 #define AR934X_RESET_HOST_DMA_INT BIT(10)
768 #define AR934X_RESET_GE0_MAC BIT(9)
769 #define AR934X_RESET_ETH_SIWTCH BIT(8)
770 #define AR934X_RESET_PCIE_PHY BIT(7)
771 #define AR934X_RESET_PCIE BIT(6)
772 #define AR934X_RESET_USB_HOST BIT(5)
773 #define AR934X_RESET_USB_PHY BIT(4)
774 #define AR934X_RESET_USBSUS_OVERRIDE BIT(3)
775 #define AR934X_RESET_LUT BIT(2)
776 #define AR934X_RESET_MBOX BIT(1)
777 #define AR934X_RESET_I2S BIT(0)
778
779 #define REV_ID_MAJOR_MASK 0xfff0
780 #define REV_ID_MAJOR_AR71XX 0x00a0
781 #define REV_ID_MAJOR_AR913X 0x00b0
782 #define REV_ID_MAJOR_AR7240 0x00c0
783 #define REV_ID_MAJOR_AR7241 0x0100
784 #define REV_ID_MAJOR_AR7242 0x1100
785 #define REV_ID_MAJOR_AR9330 0x0110
786 #define REV_ID_MAJOR_AR9331 0x1110
787 #define REV_ID_MAJOR_AR9341 0x0120
788 #define REV_ID_MAJOR_AR9342 0x1120
789 #define REV_ID_MAJOR_AR9344 0x2120
790
791 #define AR71XX_REV_ID_MINOR_MASK 0x3
792 #define AR71XX_REV_ID_MINOR_AR7130 0x0
793 #define AR71XX_REV_ID_MINOR_AR7141 0x1
794 #define AR71XX_REV_ID_MINOR_AR7161 0x2
795 #define AR71XX_REV_ID_REVISION_MASK 0x3
796 #define AR71XX_REV_ID_REVISION_SHIFT 2
797
798 #define AR91XX_REV_ID_MINOR_MASK 0x3
799 #define AR91XX_REV_ID_MINOR_AR9130 0x0
800 #define AR91XX_REV_ID_MINOR_AR9132 0x1
801 #define AR91XX_REV_ID_REVISION_MASK 0x3
802 #define AR91XX_REV_ID_REVISION_SHIFT 2
803
804 #define AR724X_REV_ID_REVISION_MASK 0x3
805
806 #define AR933X_REV_ID_REVISION_MASK 0xf
807
808 #define AR934X_REV_ID_REVISION_MASK 0xf
809
810 extern void __iomem *ar71xx_reset_base;
811
812 static inline void ar71xx_reset_wr(unsigned reg, u32 val)
813 {
814 __raw_writel(val, ar71xx_reset_base + reg);
815 }
816
817 static inline u32 ar71xx_reset_rr(unsigned reg)
818 {
819 return __raw_readl(ar71xx_reset_base + reg);
820 }
821
822 void ar71xx_device_stop(u32 mask);
823 void ar71xx_device_start(u32 mask);
824 void ar71xx_device_reset_rmw(u32 clear, u32 set);
825 int ar71xx_device_stopped(u32 mask);
826
827 /*
828 * SPI block
829 */
830 #define SPI_REG_FS 0x00 /* Function Select */
831 #define SPI_REG_CTRL 0x04 /* SPI Control */
832 #define SPI_REG_IOC 0x08 /* SPI I/O Control */
833 #define SPI_REG_RDS 0x0c /* Read Data Shift */
834
835 #define SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
836
837 #define SPI_CTRL_RD BIT(6) /* Remap Disable */
838 #define SPI_CTRL_DIV_MASK 0x3f
839
840 #define SPI_IOC_DO BIT(0) /* Data Out pin */
841 #define SPI_IOC_CLK BIT(8) /* CLK pin */
842 #define SPI_IOC_CS(n) BIT(16 + (n))
843 #define SPI_IOC_CS0 SPI_IOC_CS(0)
844 #define SPI_IOC_CS1 SPI_IOC_CS(1)
845 #define SPI_IOC_CS2 SPI_IOC_CS(2)
846 #define SPI_IOC_CS_ALL (SPI_IOC_CS0 | SPI_IOC_CS1 | SPI_IOC_CS2)
847
848 void ar71xx_flash_acquire(void);
849 void ar71xx_flash_release(void);
850
851 /*
852 * MII_CTRL block
853 */
854 #define MII_REG_MII0_CTRL 0x00
855 #define MII_REG_MII1_CTRL 0x04
856
857 #define MII_CTRL_IF_MASK 3
858 #define MII_CTRL_SPEED_SHIFT 4
859 #define MII_CTRL_SPEED_MASK 3
860 #define MII_CTRL_SPEED_10 0
861 #define MII_CTRL_SPEED_100 1
862 #define MII_CTRL_SPEED_1000 2
863
864 #define MII0_CTRL_IF_GMII 0
865 #define MII0_CTRL_IF_MII 1
866 #define MII0_CTRL_IF_RGMII 2
867 #define MII0_CTRL_IF_RMII 3
868
869 #define MII1_CTRL_IF_RGMII 0
870 #define MII1_CTRL_IF_RMII 1
871
872 /*
873 * AR933X GMAC
874 */
875 #define AR933X_GMAC_REG_ETH_CFG 0x00
876
877 #define AR933X_ETH_CFG_RGMII_GE0 BIT(0)
878 #define AR933X_ETH_CFG_MII_GE0 BIT(1)
879 #define AR933X_ETH_CFG_GMII_GE0 BIT(2)
880 #define AR933X_ETH_CFG_MII_GE0_MASTER BIT(3)
881 #define AR933X_ETH_CFG_MII_GE0_SLAVE BIT(4)
882 #define AR933X_ETH_CFG_MII_GE0_ERR_EN BIT(5)
883 #define AR933X_ETH_CFG_SW_PHY_SWAP BIT(7)
884 #define AR933X_ETH_CFG_SW_PHY_ADDR_SWAP BIT(8)
885 #define AR933X_ETH_CFG_RMII_GE0 BIT(9)
886 #define AR933X_ETH_CFG_RMII_GE0_SPD_10 0
887 #define AR933X_ETH_CFG_RMII_GE0_SPD_100 BIT(10)
888
889 #endif /* __ASSEMBLER__ */
890
891 #endif /* __ASM_MACH_AR71XX_H */
This page took 0.083678 seconds and 5 git commands to generate.