2 * Atheros AR71xx SoC specific definitions
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>
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
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.
16 #ifndef __ASM_MACH_AR71XX_H
17 #define __ASM_MACH_AR71XX_H
19 #include <linux/types.h>
20 #include <linux/init.h>
22 #include <linux/bitops.h>
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
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
64 #define AR724X_PCI_CRP_BASE (AR71XX_APB_BASE + 0x000C0000)
65 #define AR724X_PCI_CRP_SIZE 0x100
67 #define AR724X_PCI_CTRL_BASE (AR71XX_APB_BASE + 0x000F0000)
68 #define AR724X_PCI_CTRL_SIZE 0x100
70 #define AR91XX_WMAC_BASE (AR71XX_APB_BASE + 0x000C0000)
71 #define AR91XX_WMAC_SIZE 0x30000
73 #define AR933X_UART_BASE (AR71XX_APB_BASE + 0x00020000)
74 #define AR933X_UART_SIZE 0x14
76 #define AR934X_WMAC_BASE (AR71XX_APB_BASE + 0x00100000)
77 #define AR934X_WMAC_SIZE 0x20000
79 #define AR71XX_MEM_SIZE_MIN 0x0200000
80 #define AR71XX_MEM_SIZE_MAX 0x10000000
82 #define AR71XX_CPU_IRQ_BASE 0
83 #define AR71XX_MISC_IRQ_BASE 8
84 #define AR71XX_MISC_IRQ_COUNT 32
85 #define AR71XX_GPIO_IRQ_BASE 40
86 #define AR71XX_GPIO_IRQ_COUNT 32
87 #define AR71XX_PCI_IRQ_BASE 72
88 #define AR71XX_PCI_IRQ_COUNT 8
90 #define AR71XX_CPU_IRQ_IP2 (AR71XX_CPU_IRQ_BASE + 2)
91 #define AR71XX_CPU_IRQ_USB (AR71XX_CPU_IRQ_BASE + 3)
92 #define AR71XX_CPU_IRQ_GE0 (AR71XX_CPU_IRQ_BASE + 4)
93 #define AR71XX_CPU_IRQ_GE1 (AR71XX_CPU_IRQ_BASE + 5)
94 #define AR71XX_CPU_IRQ_MISC (AR71XX_CPU_IRQ_BASE + 6)
95 #define AR71XX_CPU_IRQ_TIMER (AR71XX_CPU_IRQ_BASE + 7)
97 #define AR71XX_MISC_IRQ_TIMER (AR71XX_MISC_IRQ_BASE + 0)
98 #define AR71XX_MISC_IRQ_ERROR (AR71XX_MISC_IRQ_BASE + 1)
99 #define AR71XX_MISC_IRQ_GPIO (AR71XX_MISC_IRQ_BASE + 2)
100 #define AR71XX_MISC_IRQ_UART (AR71XX_MISC_IRQ_BASE + 3)
101 #define AR71XX_MISC_IRQ_WDOG (AR71XX_MISC_IRQ_BASE + 4)
102 #define AR71XX_MISC_IRQ_PERFC (AR71XX_MISC_IRQ_BASE + 5)
103 #define AR71XX_MISC_IRQ_OHCI (AR71XX_MISC_IRQ_BASE + 6)
104 #define AR71XX_MISC_IRQ_DMA (AR71XX_MISC_IRQ_BASE + 7)
105 #define AR71XX_MISC_IRQ_TIMER2 (AR71XX_MISC_IRQ_BASE + 8)
106 #define AR71XX_MISC_IRQ_TIMER3 (AR71XX_MISC_IRQ_BASE + 9)
107 #define AR71XX_MISC_IRQ_TIMER4 (AR71XX_MISC_IRQ_BASE + 10)
108 #define AR71XX_MISC_IRQ_DDR_PERF (AR71XX_MISC_IRQ_BASE + 11)
109 #define AR71XX_MISC_IRQ_ENET_LINK (AR71XX_MISC_IRQ_BASE + 12)
111 #define AR71XX_GPIO_IRQ(_x) (AR71XX_GPIO_IRQ_BASE + (_x))
113 #define AR71XX_PCI_IRQ_DEV0 (AR71XX_PCI_IRQ_BASE + 0)
114 #define AR71XX_PCI_IRQ_DEV1 (AR71XX_PCI_IRQ_BASE + 1)
115 #define AR71XX_PCI_IRQ_DEV2 (AR71XX_PCI_IRQ_BASE + 2)
116 #define AR71XX_PCI_IRQ_CORE (AR71XX_PCI_IRQ_BASE + 4)
118 extern u32 ar71xx_ahb_freq
;
119 extern u32 ar71xx_cpu_freq
;
120 extern u32 ar71xx_ddr_freq
;
121 extern u32 ar71xx_ref_freq
;
123 enum ar71xx_soc_type
{
140 extern enum ar71xx_soc_type ar71xx_soc
;
145 #define AR71XX_PLL_REG_CPU_CONFIG 0x00
146 #define AR71XX_PLL_REG_SEC_CONFIG 0x04
147 #define AR71XX_PLL_REG_ETH0_INT_CLOCK 0x10
148 #define AR71XX_PLL_REG_ETH1_INT_CLOCK 0x14
150 #define AR71XX_PLL_DIV_SHIFT 3
151 #define AR71XX_PLL_DIV_MASK 0x1f
152 #define AR71XX_CPU_DIV_SHIFT 16
153 #define AR71XX_CPU_DIV_MASK 0x3
154 #define AR71XX_DDR_DIV_SHIFT 18
155 #define AR71XX_DDR_DIV_MASK 0x3
156 #define AR71XX_AHB_DIV_SHIFT 20
157 #define AR71XX_AHB_DIV_MASK 0x7
159 #define AR71XX_ETH0_PLL_SHIFT 17
160 #define AR71XX_ETH1_PLL_SHIFT 19
162 #define AR724X_PLL_REG_CPU_CONFIG 0x00
163 #define AR724X_PLL_REG_PCIE_CONFIG 0x18
165 #define AR724X_PLL_DIV_SHIFT 0
166 #define AR724X_PLL_DIV_MASK 0x3ff
167 #define AR724X_PLL_REF_DIV_SHIFT 10
168 #define AR724X_PLL_REF_DIV_MASK 0xf
169 #define AR724X_AHB_DIV_SHIFT 19
170 #define AR724X_AHB_DIV_MASK 0x1
171 #define AR724X_DDR_DIV_SHIFT 22
172 #define AR724X_DDR_DIV_MASK 0x3
174 #define AR7242_PLL_REG_ETH0_INT_CLOCK 0x2c
176 #define AR91XX_PLL_REG_CPU_CONFIG 0x00
177 #define AR91XX_PLL_REG_ETH_CONFIG 0x04
178 #define AR91XX_PLL_REG_ETH0_INT_CLOCK 0x14
179 #define AR91XX_PLL_REG_ETH1_INT_CLOCK 0x18
181 #define AR91XX_PLL_DIV_SHIFT 0
182 #define AR91XX_PLL_DIV_MASK 0x3ff
183 #define AR91XX_DDR_DIV_SHIFT 22
184 #define AR91XX_DDR_DIV_MASK 0x3
185 #define AR91XX_AHB_DIV_SHIFT 19
186 #define AR91XX_AHB_DIV_MASK 0x1
188 #define AR91XX_ETH0_PLL_SHIFT 20
189 #define AR91XX_ETH1_PLL_SHIFT 22
191 #define AR933X_PLL_CPU_CONFIG_REG 0x00
192 #define AR933X_PLL_CLOCK_CTRL_REG 0x08
194 #define AR933X_PLL_CPU_CONFIG_NINT_SHIFT 10
195 #define AR933X_PLL_CPU_CONFIG_NINT_MASK 0x3f
196 #define AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT 16
197 #define AR933X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f
198 #define AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT 23
199 #define AR933X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7
201 #define AR933X_PLL_CLOCK_CTRL_BYPASS BIT(2)
202 #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT 5
203 #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK 0x3
204 #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT 10
205 #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK 0x3
206 #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT 15
207 #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK 0x7
209 #define AR934X_PLL_REG_CPU_CONFIG 0x00
210 #define AR934X_PLL_REG_DDR_CTRL_CLOCK 0x8
212 #define AR934X_CPU_PLL_CFG_OUTDIV_MSB 21
213 #define AR934X_CPU_PLL_CFG_OUTDIV_LSB 19
214 #define AR934X_CPU_PLL_CFG_OUTDIV_MASK 0x00380000
216 #define AR934X_CPU_PLL_CFG_OUTDIV_GET(x) \
217 (((x) & AR934X_CPU_PLL_CFG_OUTDIV_MASK) >> \
218 AR934X_CPU_PLL_CFG_OUTDIV_LSB)
220 #define AR934X_DDR_PLL_CFG_OUTDIV_MSB 25
221 #define AR934X_DDR_PLL_CFG_OUTDIV_LSB 23
222 #define AR934X_DDR_PLL_CFG_OUTDIV_MASK 0x03800000
224 #define AR934X_DDR_PLL_CFG_OUTDIV_GET(x) \
225 (((x) & AR934X_DDR_PLL_CFG_OUTDIV_MASK) >> \
226 AR934X_DDR_PLL_CFG_OUTDIV_LSB)
228 #define AR934X_DDR_PLL_CFG_OUTDIV_SET(x) \
229 (((x) << AR934X_DDR_PLL_CFG_OUTDIV_LSB) & \
230 AR934X_DDR_PLL_CFG_OUTDIV_MASK)
232 #define AR934X_CPU_PLL_CFG_REFDIV_MSB 16
233 #define AR934X_CPU_PLL_CFG_REFDIV_LSB 12
234 #define AR934X_CPU_PLL_CFG_REFDIV_MASK 0x0001f000
236 #define AR934X_CPU_PLL_CFG_REFDIV_GET(x) \
237 (((x) & AR934X_CPU_PLL_CFG_REFDIV_MASK) >> \
238 AR934X_CPU_PLL_CFG_REFDIV_LSB)
240 #define AR934X_CPU_PLL_CFG_REFDIV_SET(x) \
241 (((x) << AR934X_CPU_PLL_CFG_REFDIV_LSB) & \
242 AR934X_CPU_PLL_CFG_REFDIV_MASK)
244 #define AR934X_CPU_PLL_CFG_REFDIV_RESET 2
246 #define AR934X_CPU_PLL_CFG_NINT_MSB 11
247 #define AR934X_CPU_PLL_CFG_NINT_LSB 6
248 #define AR934X_CPU_PLL_CFG_NINT_MASK 0x00000fc0
250 #define AR934X_CPU_PLL_CFG_NINT_GET(x) \
251 (((x) & AR934X_CPU_PLL_CFG_NINT_MASK) >> \
252 AR934X_CPU_PLL_CFG_NINT_LSB)
254 #define AR934X_CPU_PLL_CFG_NINT_SET(x) \
255 (((x) << AR934X_CPU_PLL_CFG_NINT_LSB) & \
256 AR934X_CPU_PLL_CFG_NINT_MASK)
258 #define AR934X_CPU_PLL_CFG_NINT_RESET 20
260 #define AR934X_CPU_PLL_CFG_NFRAC_MSB 5
261 #define AR934X_CPU_PLL_CFG_NFRAC_LSB 0
262 #define AR934X_CPU_PLL_CFG_NFRAC_MASK 0x0000003f
264 #define AR934X_CPU_PLL_CFG_NFRAC_GET(x) \
265 (((x) & AR934X_CPU_PLL_CFG_NFRAC_MASK) >> \
266 AR934X_CPU_PLL_CFG_NFRAC_LSB)
268 #define AR934X_CPU_PLL_CFG_NFRAC_SET(x) \
269 (((x) << AR934X_CPU_PLL_CFG_NFRAC_LSB) & \
270 AR934X_CPU_PLL_CFG_NFRAC_MASK)
272 #define AR934X_DDR_PLL_CFG_REFDIV_MSB 20
273 #define AR934X_DDR_PLL_CFG_REFDIV_LSB 16
274 #define AR934X_DDR_PLL_CFG_REFDIV_MASK 0x001f0000
276 #define AR934X_DDR_PLL_CFG_REFDIV_GET(x) \
277 (((x) & AR934X_DDR_PLL_CFG_REFDIV_MASK) >> \
278 AR934X_DDR_PLL_CFG_REFDIV_LSB)
280 #define AR934X_DDR_PLL_CFG_REFDIV_SET(x) \
281 (((x) << AR934X_DDR_PLL_CFG_REFDIV_LSB) & \
282 AR934X_DDR_PLL_CFG_REFDIV_MASK)
284 #define AR934X_DDR_PLL_CFG_REFDIV_RESET 2
286 #define AR934X_DDR_PLL_CFG_NINT_MSB 15
287 #define AR934X_DDR_PLL_CFG_NINT_LSB 10
288 #define AR934X_DDR_PLL_CFG_NINT_MASK 0x0000fc00
290 #define AR934X_DDR_PLL_CFG_NINT_GET(x) \
291 (((x) & AR934X_DDR_PLL_CFG_NINT_MASK) >> \
292 AR934X_DDR_PLL_CFG_NINT_LSB)
294 #define AR934X_DDR_PLL_CFG_NINT_SET(x) \
295 (((x) << AR934X_DDR_PLL_CFG_NINT_LSB) & \
296 AR934X_DDR_PLL_CFG_NINT_MASK)
298 #define AR934X_DDR_PLL_CFG_NINT_RESET 20
300 #define AR934X_DDR_PLL_CFG_NFRAC_MSB 9
301 #define AR934X_DDR_PLL_CFG_NFRAC_LSB 0
302 #define AR934X_DDR_PLL_CFG_NFRAC_MASK 0x000003ff
304 #define AR934X_DDR_PLL_CFG_NFRAC_GET(x) \
305 (((x) & AR934X_DDR_PLL_CFG_NFRAC_MASK) >> \
306 AR934X_DDR_PLL_CFG_NFRAC_LSB)
308 #define AR934X_DDR_PLL_CFG_NFRAC_SET(x) \
309 (((x) << AR934X_DDR_PLL_CFG_NFRAC_LSB) & \
310 AR934X_DDR_PLL_CFG_NFRAC_MASK)
312 #define AR934X_DDR_PLL_CFG_NFRAC_RESET 512
314 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MSB 19
315 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB 15
316 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK 0x000f8000
318 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_GET(x) \
319 (((x) & AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK) >> \
320 AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB)
322 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_SET(x) \
323 (((x) << AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_LSB) & \
324 AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK)
326 #define AR934X_CPU_DDR_CLK_CTRL_AHB_POST_DIV_RESET 0
328 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MSB 14
329 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB 10
330 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK 0x00007c00
332 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_GET(x) \
333 (((x) & AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK) >> \
334 AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB)
336 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_SET(x) \
337 (((x) << AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_LSB) & \
338 AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK)
340 #define AR934X_CPU_DDR_CLK_CTRL_DDR_POST_DIV_RESET 0
342 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MSB 9
343 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB 5
344 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK 0x000003e0
346 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_GET(x) \
347 (((x) & AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK) >> \
348 AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB)
350 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_SET(x) \
351 (((x) << AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_LSB) & \
352 AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK)
354 #define AR934X_CPU_DDR_CLK_CTRL_CPU_POST_DIV_RESET 0
356 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MSB 24
357 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB 24
358 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK 0x01000000
360 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_GET(x) \
361 (((x) & AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK) >> \
362 AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB)
364 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_SET(x) \
365 (((x) << AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_LSB) & \
366 AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_MASK)
368 #define AR934X_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL_RESET 1
370 extern void __iomem
*ar71xx_pll_base
;
372 static inline void ar71xx_pll_wr(unsigned reg
, u32 val
)
374 __raw_writel(val
, ar71xx_pll_base
+ reg
);
377 static inline u32
ar71xx_pll_rr(unsigned reg
)
379 return __raw_readl(ar71xx_pll_base
+ reg
);
385 #define USB_CTRL_REG_FLADJ 0x00
386 #define USB_CTRL_REG_CONFIG 0x04
388 extern void __iomem
*ar71xx_usb_ctrl_base
;
390 static inline void ar71xx_usb_ctrl_wr(unsigned reg
, u32 val
)
392 __raw_writel(val
, ar71xx_usb_ctrl_base
+ reg
);
395 static inline u32
ar71xx_usb_ctrl_rr(unsigned reg
)
397 return __raw_readl(ar71xx_usb_ctrl_base
+ reg
);
403 #define GPIO_REG_OE 0x00
404 #define GPIO_REG_IN 0x04
405 #define GPIO_REG_OUT 0x08
406 #define GPIO_REG_SET 0x0c
407 #define GPIO_REG_CLEAR 0x10
408 #define GPIO_REG_INT_MODE 0x14
409 #define GPIO_REG_INT_TYPE 0x18
410 #define GPIO_REG_INT_POLARITY 0x1c
411 #define GPIO_REG_INT_PENDING 0x20
412 #define GPIO_REG_INT_ENABLE 0x24
413 #define GPIO_REG_FUNC 0x28
415 #define AR71XX_GPIO_FUNC_STEREO_EN BIT(17)
416 #define AR71XX_GPIO_FUNC_SLIC_EN BIT(16)
417 #define AR71XX_GPIO_FUNC_SPI_CS2_EN BIT(13)
418 #define AR71XX_GPIO_FUNC_SPI_CS1_EN BIT(12)
419 #define AR71XX_GPIO_FUNC_UART_EN BIT(8)
420 #define AR71XX_GPIO_FUNC_USB_OC_EN BIT(4)
421 #define AR71XX_GPIO_FUNC_USB_CLK_EN BIT(0)
423 #define AR71XX_GPIO_COUNT 16
425 #define AR724X_GPIO_FUNC_GE0_MII_CLK_EN BIT(19)
426 #define AR724X_GPIO_FUNC_SPI_EN BIT(18)
427 #define AR724X_GPIO_FUNC_SPI_CS_EN2 BIT(14)
428 #define AR724X_GPIO_FUNC_SPI_CS_EN1 BIT(13)
429 #define AR724X_GPIO_FUNC_CLK_OBS5_EN BIT(12)
430 #define AR724X_GPIO_FUNC_CLK_OBS4_EN BIT(11)
431 #define AR724X_GPIO_FUNC_CLK_OBS3_EN BIT(10)
432 #define AR724X_GPIO_FUNC_CLK_OBS2_EN BIT(9)
433 #define AR724X_GPIO_FUNC_CLK_OBS1_EN BIT(8)
434 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN BIT(7)
435 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN BIT(6)
436 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN BIT(5)
437 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN BIT(4)
438 #define AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN BIT(3)
439 #define AR724X_GPIO_FUNC_UART_RTS_CTS_EN BIT(2)
440 #define AR724X_GPIO_FUNC_UART_EN BIT(1)
441 #define AR724X_GPIO_FUNC_JTAG_DISABLE BIT(0)
443 #define AR724X_GPIO_COUNT 18
445 #define AR91XX_GPIO_FUNC_WMAC_LED_EN BIT(22)
446 #define AR91XX_GPIO_FUNC_EXP_PORT_CS_EN BIT(21)
447 #define AR91XX_GPIO_FUNC_I2S_REFCLKEN BIT(20)
448 #define AR91XX_GPIO_FUNC_I2S_MCKEN BIT(19)
449 #define AR91XX_GPIO_FUNC_I2S1_EN BIT(18)
450 #define AR91XX_GPIO_FUNC_I2S0_EN BIT(17)
451 #define AR91XX_GPIO_FUNC_SLIC_EN BIT(16)
452 #define AR91XX_GPIO_FUNC_UART_RTSCTS_EN BIT(9)
453 #define AR91XX_GPIO_FUNC_UART_EN BIT(8)
454 #define AR91XX_GPIO_FUNC_USB_CLK_EN BIT(4)
456 #define AR91XX_GPIO_COUNT 22
458 #define AR933X_GPIO_COUNT 30
460 #define AR934X_GPIO_FUNC_SPI_CS_1_EN BIT(14)
461 #define AR934X_GPIO_FUNC_SPI_CS_0_EN BIT(13)
463 #define AR934X_GPIO_COUNT 32
464 #define AR934X_GPIO_FUNC_DDR_DQOE_EN BIT(17)
466 extern void __iomem
*ar71xx_gpio_base
;
468 static inline void ar71xx_gpio_wr(unsigned reg
, u32 value
)
470 __raw_writel(value
, ar71xx_gpio_base
+ reg
);
473 static inline u32
ar71xx_gpio_rr(unsigned reg
)
475 return __raw_readl(ar71xx_gpio_base
+ reg
);
478 void ar71xx_gpio_init(void) __init
;
479 void ar71xx_gpio_function_enable(u32 mask
);
480 void ar71xx_gpio_function_disable(u32 mask
);
481 void ar71xx_gpio_function_setup(u32 set
, u32 clear
);
486 #define AR71XX_DDR_REG_PCI_WIN0 0x7c
487 #define AR71XX_DDR_REG_PCI_WIN1 0x80
488 #define AR71XX_DDR_REG_PCI_WIN2 0x84
489 #define AR71XX_DDR_REG_PCI_WIN3 0x88
490 #define AR71XX_DDR_REG_PCI_WIN4 0x8c
491 #define AR71XX_DDR_REG_PCI_WIN5 0x90
492 #define AR71XX_DDR_REG_PCI_WIN6 0x94
493 #define AR71XX_DDR_REG_PCI_WIN7 0x98
494 #define AR71XX_DDR_REG_FLUSH_GE0 0x9c
495 #define AR71XX_DDR_REG_FLUSH_GE1 0xa0
496 #define AR71XX_DDR_REG_FLUSH_USB 0xa4
497 #define AR71XX_DDR_REG_FLUSH_PCI 0xa8
499 #define AR724X_DDR_REG_FLUSH_GE0 0x7c
500 #define AR724X_DDR_REG_FLUSH_GE1 0x80
501 #define AR724X_DDR_REG_FLUSH_USB 0x84
502 #define AR724X_DDR_REG_FLUSH_PCIE 0x88
504 #define AR91XX_DDR_REG_FLUSH_GE0 0x7c
505 #define AR91XX_DDR_REG_FLUSH_GE1 0x80
506 #define AR91XX_DDR_REG_FLUSH_USB 0x84
507 #define AR91XX_DDR_REG_FLUSH_WMAC 0x88
509 #define AR933X_DDR_REG_FLUSH_GE0 0x7c
510 #define AR933X_DDR_REG_FLUSH_GE1 0x80
511 #define AR933X_DDR_REG_FLUSH_USB 0x84
512 #define AR933X_DDR_REG_FLUSH_WMAC 0x88
514 #define AR934X_DDR_REG_FLUSH_GE0 0x9c
515 #define AR934X_DDR_REG_FLUSH_GE1 0xa0
516 #define AR934X_DDR_REG_FLUSH_USB 0xa4
517 #define AR934X_DDR_REG_FLUSH_PCIE 0xa8
520 #define PCI_WIN0_OFFS 0x10000000
521 #define PCI_WIN1_OFFS 0x11000000
522 #define PCI_WIN2_OFFS 0x12000000
523 #define PCI_WIN3_OFFS 0x13000000
524 #define PCI_WIN4_OFFS 0x14000000
525 #define PCI_WIN5_OFFS 0x15000000
526 #define PCI_WIN6_OFFS 0x16000000
527 #define PCI_WIN7_OFFS 0x07000000
529 extern void __iomem
*ar71xx_ddr_base
;
531 static inline void ar71xx_ddr_wr(unsigned reg
, u32 val
)
533 __raw_writel(val
, ar71xx_ddr_base
+ reg
);
536 static inline u32
ar71xx_ddr_rr(unsigned reg
)
538 return __raw_readl(ar71xx_ddr_base
+ reg
);
541 void ar71xx_ddr_flush(u32 reg
);
546 #define AR71XX_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + PCI_WIN7_OFFS + 0x10000)
547 #define AR71XX_PCI_CFG_SIZE 0x100
549 #define PCI_REG_CRP_AD_CBE 0x00
550 #define PCI_REG_CRP_WRDATA 0x04
551 #define PCI_REG_CRP_RDDATA 0x08
552 #define PCI_REG_CFG_AD 0x0c
553 #define PCI_REG_CFG_CBE 0x10
554 #define PCI_REG_CFG_WRDATA 0x14
555 #define PCI_REG_CFG_RDDATA 0x18
556 #define PCI_REG_PCI_ERR 0x1c
557 #define PCI_REG_PCI_ERR_ADDR 0x20
558 #define PCI_REG_AHB_ERR 0x24
559 #define PCI_REG_AHB_ERR_ADDR 0x28
561 #define PCI_CRP_CMD_WRITE 0x00010000
562 #define PCI_CRP_CMD_READ 0x00000000
563 #define PCI_CFG_CMD_READ 0x0000000a
564 #define PCI_CFG_CMD_WRITE 0x0000000b
566 #define PCI_IDSEL_ADL_START 17
568 #define AR724X_PCI_CFG_BASE (AR71XX_PCI_MEM_BASE + 0x4000000)
569 #define AR724X_PCI_CFG_SIZE 0x1000
571 #define AR724X_PCI_REG_APP 0x00
572 #define AR724X_PCI_REG_RESET 0x18
573 #define AR724X_PCI_REG_INT_STATUS 0x4c
574 #define AR724X_PCI_REG_INT_MASK 0x50
576 #define AR724X_PCI_APP_LTSSM_ENABLE BIT(0)
577 #define AR724X_PCI_RESET_LINK_UP BIT(0)
579 #define AR724X_PCI_INT_DEV0 BIT(14)
584 #define AR71XX_RESET_REG_TIMER 0x00
585 #define AR71XX_RESET_REG_TIMER_RELOAD 0x04
586 #define AR71XX_RESET_REG_WDOG_CTRL 0x08
587 #define AR71XX_RESET_REG_WDOG 0x0c
588 #define AR71XX_RESET_REG_MISC_INT_STATUS 0x10
589 #define AR71XX_RESET_REG_MISC_INT_ENABLE 0x14
590 #define AR71XX_RESET_REG_PCI_INT_STATUS 0x18
591 #define AR71XX_RESET_REG_PCI_INT_ENABLE 0x1c
592 #define AR71XX_RESET_REG_GLOBAL_INT_STATUS 0x20
593 #define AR71XX_RESET_REG_RESET_MODULE 0x24
594 #define AR71XX_RESET_REG_PERFC_CTRL 0x2c
595 #define AR71XX_RESET_REG_PERFC0 0x30
596 #define AR71XX_RESET_REG_PERFC1 0x34
597 #define AR71XX_RESET_REG_REV_ID 0x90
599 #define AR91XX_RESET_REG_GLOBAL_INT_STATUS 0x18
600 #define AR91XX_RESET_REG_RESET_MODULE 0x1c
601 #define AR91XX_RESET_REG_PERF_CTRL 0x20
602 #define AR91XX_RESET_REG_PERFC0 0x24
603 #define AR91XX_RESET_REG_PERFC1 0x28
605 #define AR724X_RESET_REG_RESET_MODULE 0x1c
607 #define AR933X_RESET_REG_RESET_MODULE 0x1c
608 #define AR933X_RESET_REG_BOOTSTRAP 0xac
609 #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
611 #define AR934X_RESET_REG_RESET_MODULE 0x1c
612 #define AR934X_RESET_REG_BOOTSTRAP 0xb0
613 /* 0 - 25MHz 1 - 40 MHz */
614 #define AR934X_REF_CLK_40 (1 << 4)
616 #define WDOG_CTRL_LAST_RESET BIT(31)
617 #define WDOG_CTRL_ACTION_MASK 3
618 #define WDOG_CTRL_ACTION_NONE 0 /* no action */
619 #define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */
620 #define WDOG_CTRL_ACTION_NMI 2 /* NMI */
621 #define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */
623 #define MISC_INT_ENET_LINK BIT(12)
624 #define MISC_INT_DDR_PERF BIT(11)
625 #define MISC_INT_TIMER4 BIT(10)
626 #define MISC_INT_TIMER3 BIT(9)
627 #define MISC_INT_TIMER2 BIT(8)
628 #define MISC_INT_DMA BIT(7)
629 #define MISC_INT_OHCI BIT(6)
630 #define MISC_INT_PERFC BIT(5)
631 #define MISC_INT_WDOG BIT(4)
632 #define MISC_INT_UART BIT(3)
633 #define MISC_INT_GPIO BIT(2)
634 #define MISC_INT_ERROR BIT(1)
635 #define MISC_INT_TIMER BIT(0)
637 #define PCI_INT_CORE BIT(4)
638 #define PCI_INT_DEV2 BIT(2)
639 #define PCI_INT_DEV1 BIT(1)
640 #define PCI_INT_DEV0 BIT(0)
642 #define RESET_MODULE_EXTERNAL BIT(28)
643 #define RESET_MODULE_FULL_CHIP BIT(24)
644 #define RESET_MODULE_AMBA2WMAC BIT(22)
645 #define RESET_MODULE_CPU_NMI BIT(21)
646 #define RESET_MODULE_CPU_COLD BIT(20)
647 #define RESET_MODULE_DMA BIT(19)
648 #define RESET_MODULE_SLIC BIT(18)
649 #define RESET_MODULE_STEREO BIT(17)
650 #define RESET_MODULE_DDR BIT(16)
651 #define RESET_MODULE_GE1_MAC BIT(13)
652 #define RESET_MODULE_GE1_PHY BIT(12)
653 #define RESET_MODULE_USBSUS_OVERRIDE BIT(10)
654 #define RESET_MODULE_GE0_MAC BIT(9)
655 #define RESET_MODULE_GE0_PHY BIT(8)
656 #define RESET_MODULE_USB_OHCI_DLL BIT(6)
657 #define RESET_MODULE_USB_HOST BIT(5)
658 #define RESET_MODULE_USB_PHY BIT(4)
659 #define RESET_MODULE_USB_OHCI_DLL_7240 BIT(3)
660 #define RESET_MODULE_PCI_BUS BIT(1)
661 #define RESET_MODULE_PCI_CORE BIT(0)
663 #define AR724X_RESET_GE1_MDIO BIT(23)
664 #define AR724X_RESET_GE0_MDIO BIT(22)
665 #define AR724X_RESET_PCIE_PHY_SERIAL BIT(10)
666 #define AR724X_RESET_PCIE_PHY BIT(7)
667 #define AR724X_RESET_PCIE BIT(6)
668 #define AR724X_RESET_USB_HOST BIT(5)
669 #define AR724X_RESET_USB_PHY BIT(4)
670 #define AR724X_RESET_USBSUS_OVERRIDE BIT(3)
672 #define AR933X_RESET_GE1_MDIO BIT(23)
673 #define AR933X_RESET_GE0_MDIO BIT(22)
674 #define AR933X_RESET_GE1_MAC BIT(13)
675 #define AR933X_RESET_GE0_MAC BIT(9)
677 #define REV_ID_MAJOR_MASK 0xfff0
678 #define REV_ID_MAJOR_AR71XX 0x00a0
679 #define REV_ID_MAJOR_AR913X 0x00b0
680 #define REV_ID_MAJOR_AR7240 0x00c0
681 #define REV_ID_MAJOR_AR7241 0x0100
682 #define REV_ID_MAJOR_AR7242 0x1100
683 #define REV_ID_MAJOR_AR9330 0x0110
684 #define REV_ID_MAJOR_AR9331 0x1110
685 #define REV_ID_MAJOR_AR9341 0x0120
686 #define REV_ID_MAJOR_AR9342 0x1120
687 #define REV_ID_MAJOR_AR9344 0x2120
689 #define AR71XX_REV_ID_MINOR_MASK 0x3
690 #define AR71XX_REV_ID_MINOR_AR7130 0x0
691 #define AR71XX_REV_ID_MINOR_AR7141 0x1
692 #define AR71XX_REV_ID_MINOR_AR7161 0x2
693 #define AR71XX_REV_ID_REVISION_MASK 0x3
694 #define AR71XX_REV_ID_REVISION_SHIFT 2
696 #define AR91XX_REV_ID_MINOR_MASK 0x3
697 #define AR91XX_REV_ID_MINOR_AR9130 0x0
698 #define AR91XX_REV_ID_MINOR_AR9132 0x1
699 #define AR91XX_REV_ID_REVISION_MASK 0x3
700 #define AR91XX_REV_ID_REVISION_SHIFT 2
702 #define AR724X_REV_ID_REVISION_MASK 0x3
704 #define AR933X_REV_ID_REVISION_MASK 0xf
706 #define AR934X_REV_ID_REVISION_MASK 0xf
708 extern void __iomem
*ar71xx_reset_base
;
710 static inline void ar71xx_reset_wr(unsigned reg
, u32 val
)
712 __raw_writel(val
, ar71xx_reset_base
+ reg
);
715 static inline u32
ar71xx_reset_rr(unsigned reg
)
717 return __raw_readl(ar71xx_reset_base
+ reg
);
720 void ar71xx_device_stop(u32 mask
);
721 void ar71xx_device_start(u32 mask
);
722 int ar71xx_device_stopped(u32 mask
);
727 #define SPI_REG_FS 0x00 /* Function Select */
728 #define SPI_REG_CTRL 0x04 /* SPI Control */
729 #define SPI_REG_IOC 0x08 /* SPI I/O Control */
730 #define SPI_REG_RDS 0x0c /* Read Data Shift */
732 #define SPI_FS_GPIO BIT(0) /* Enable GPIO mode */
734 #define SPI_CTRL_RD BIT(6) /* Remap Disable */
735 #define SPI_CTRL_DIV_MASK 0x3f
737 #define SPI_IOC_DO BIT(0) /* Data Out pin */
738 #define SPI_IOC_CLK BIT(8) /* CLK pin */
739 #define SPI_IOC_CS(n) BIT(16 + (n))
740 #define SPI_IOC_CS0 SPI_IOC_CS(0)
741 #define SPI_IOC_CS1 SPI_IOC_CS(1)
742 #define SPI_IOC_CS2 SPI_IOC_CS(2)
743 #define SPI_IOC_CS_ALL (SPI_IOC_CS0 | SPI_IOC_CS1 | SPI_IOC_CS2)
745 void ar71xx_flash_acquire(void);
746 void ar71xx_flash_release(void);
751 #define MII_REG_MII0_CTRL 0x00
752 #define MII_REG_MII1_CTRL 0x04
754 #define MII0_CTRL_IF_GMII 0
755 #define MII0_CTRL_IF_MII 1
756 #define MII0_CTRL_IF_RGMII 2
757 #define MII0_CTRL_IF_RMII 3
759 #define MII1_CTRL_IF_RGMII 0
760 #define MII1_CTRL_IF_RMII 1
762 #endif /* __ASSEMBLER__ */
764 #endif /* __ASM_MACH_AR71XX_H */