lua: Fixed some cross-platform issues for PPC (and probably other architectures)
[openwrt.git] / target / linux / atheros / files / include / asm-mips / mach-atheros / ar5312 / ar5312.h
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved.
7 * Copyright (C) 2006 Imre Kaloz <kaloz@openwrt.org>
8 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
9 */
10
11 #ifndef AR5312_H
12 #define AR5312_H
13
14 #include <asm/addrspace.h>
15
16 /*
17 * IRQs
18 */
19
20 #define AR5312_IRQ_WLAN0_INTRS MIPS_CPU_IRQ_BASE+2 /* C0_CAUSE: 0x0400 */
21 #define AR5312_IRQ_ENET0_INTRS MIPS_CPU_IRQ_BASE+3 /* C0_CAUSE: 0x0800 */
22 #define AR5312_IRQ_ENET1_INTRS MIPS_CPU_IRQ_BASE+4 /* C0_CAUSE: 0x1000 */
23 #define AR5312_IRQ_WLAN1_INTRS MIPS_CPU_IRQ_BASE+5 /* C0_CAUSE: 0x2000 */
24 #define AR5312_IRQ_MISC_INTRS MIPS_CPU_IRQ_BASE+6 /* C0_CAUSE: 0x4000 */
25
26
27 /* Address Map */
28 #define AR531X_WLAN0 0x18000000
29 #define AR531X_WLAN1 0x18500000
30 #define AR531X_ENET0 0x18100000
31 #define AR531X_ENET1 0x18200000
32 #define AR531X_SDRAMCTL 0x18300000
33 #define AR531X_FLASHCTL 0x18400000
34 #define AR531X_APBBASE 0x1c000000
35 #define AR531X_FLASH 0x1e000000
36 #define AR531X_UART0 0xbc000003 /* UART MMR */
37
38 /*
39 * AR531X_NUM_ENET_MAC defines the number of ethernet MACs that
40 * should be considered available. The AR5312 supports 2 enet MACS,
41 * even though many reference boards only actually use 1 of them
42 * (i.e. Only MAC 0 is actually connected to an enet PHY or PHY switch.
43 * The AR2312 supports 1 enet MAC.
44 */
45 #define AR531X_NUM_ENET_MAC 2
46
47 /*
48 * Need these defines to determine true number of ethernet MACs
49 */
50 #define AR5212_AR5312_REV2 0x0052 /* AR5312 WMAC (AP31) */
51 #define AR5212_AR5312_REV7 0x0057 /* AR5312 WMAC (AP30-040) */
52 #define AR5212_AR2313_REV8 0x0058 /* AR2313 WMAC (AP43-030) */
53 #define AR531X_RADIO_MASK_OFF 0xc8
54 #define AR531X_RADIO0_MASK 0x0003
55 #define AR531X_RADIO1_MASK 0x000c
56 #define AR531X_RADIO1_S 2
57
58 /*
59 * AR531X_NUM_WMAC defines the number of Wireless MACs that\
60 * should be considered available.
61 */
62 #define AR531X_NUM_WMAC 2
63
64 /* Reset/Timer Block Address Map */
65 #define AR531X_RESETTMR (AR531X_APBBASE + 0x3000)
66 #define AR531X_TIMER (AR531X_RESETTMR + 0x0000) /* countdown timer */
67 #define AR531X_WD_CTRL (AR531X_RESETTMR + 0x0008) /* watchdog cntrl */
68 #define AR531X_WD_TIMER (AR531X_RESETTMR + 0x000c) /* watchdog timer */
69 #define AR531X_ISR (AR531X_RESETTMR + 0x0010) /* Intr Status Reg */
70 #define AR531X_IMR (AR531X_RESETTMR + 0x0014) /* Intr Mask Reg */
71 #define AR531X_RESET (AR531X_RESETTMR + 0x0020)
72 #define AR5312_CLOCKCTL1 (AR531X_RESETTMR + 0x0064)
73 #define AR5312_SCRATCH (AR531X_RESETTMR + 0x006c)
74 #define AR531X_PROCADDR (AR531X_RESETTMR + 0x0070)
75 #define AR531X_PROC1 (AR531X_RESETTMR + 0x0074)
76 #define AR531X_DMAADDR (AR531X_RESETTMR + 0x0078)
77 #define AR531X_DMA1 (AR531X_RESETTMR + 0x007c)
78 #define AR531X_ENABLE (AR531X_RESETTMR + 0x0080) /* interface enb */
79 #define AR531X_REV (AR531X_RESETTMR + 0x0090) /* revision */
80
81 /* AR531X_WD_CTRL register bit field definitions */
82 #define AR531X_WD_CTRL_IGNORE_EXPIRATION 0x0000
83 #define AR531X_WD_CTRL_NMI 0x0001
84 #define AR531X_WD_CTRL_RESET 0x0002
85
86 /* AR531X_ISR register bit field definitions */
87 #define AR531X_ISR_NONE 0x0000
88 #define AR531X_ISR_TIMER 0x0001
89 #define AR531X_ISR_AHBPROC 0x0002
90 #define AR531X_ISR_AHBDMA 0x0004
91 #define AR531X_ISR_GPIO 0x0008
92 #define AR531X_ISR_UART0 0x0010
93 #define AR531X_ISR_UART0DMA 0x0020
94 #define AR531X_ISR_WD 0x0040
95 #define AR531X_ISR_LOCAL 0x0080
96
97 /* AR531X_RESET register bit field definitions */
98 #define AR531X_RESET_SYSTEM 0x00000001 /* cold reset full system */
99 #define AR531X_RESET_PROC 0x00000002 /* cold reset MIPS core */
100 #define AR531X_RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
101 #define AR531X_RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
102 #define AR531X_RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
103 #define AR531X_RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
104 #define AR531X_RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
105 #define AR531X_RESET_UART0 0x00000100 /* cold reset UART0 (high speed) */
106 #define AR531X_RESET_WLAN1 0x00000200 /* cold reset WLAN MAC/BB */
107 #define AR531X_RESET_APB 0x00000400 /* cold reset APB (ar5312) */
108 #define AR531X_RESET_WARM_PROC 0x00001000 /* warm reset MIPS core */
109 #define AR531X_RESET_WARM_WLAN0_MAC 0x00002000 /* warm reset WLAN0 MAC */
110 #define AR531X_RESET_WARM_WLAN0_BB 0x00004000 /* warm reset WLAN0 BaseBand */
111 #define AR531X_RESET_NMI 0x00010000 /* send an NMI to the processor */
112 #define AR531X_RESET_WARM_WLAN1_MAC 0x00020000 /* warm reset WLAN1 mac */
113 #define AR531X_RESET_WARM_WLAN1_BB 0x00040000 /* warm reset WLAN1 baseband */
114 #define AR531X_RESET_LOCAL_BUS 0x00080000 /* reset local bus */
115 #define AR531X_RESET_WDOG 0x00100000 /* last reset was a watchdog */
116
117 #define AR531X_RESET_WMAC0_BITS \
118 AR531X_RESET_WLAN0 |\
119 AR531X_RESET_WARM_WLAN0_MAC |\
120 AR531X_RESET_WARM_WLAN0_BB
121
122 #define AR531X_RESERT_WMAC1_BITS \
123 AR531X_RESET_WLAN1 |\
124 AR531X_RESET_WARM_WLAN1_MAC |\
125 AR531X_RESET_WARM_WLAN1_BB
126
127 /* AR5312_CLOCKCTL1 register bit field definitions */
128 #define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
129 #define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
130 #define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
131 #define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
132 #define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
133
134 /* Valid for AR5312 and AR2312 */
135 #define AR5312_CLOCKCTL1_PREDIVIDE_MASK 0x00000030
136 #define AR5312_CLOCKCTL1_PREDIVIDE_SHIFT 4
137 #define AR5312_CLOCKCTL1_MULTIPLIER_MASK 0x00001f00
138 #define AR5312_CLOCKCTL1_MULTIPLIER_SHIFT 8
139 #define AR5312_CLOCKCTL1_DOUBLER_MASK 0x00010000
140
141 /* Valid for AR2313 */
142 #define AR2313_CLOCKCTL1_PREDIVIDE_MASK 0x00003000
143 #define AR2313_CLOCKCTL1_PREDIVIDE_SHIFT 12
144 #define AR2313_CLOCKCTL1_MULTIPLIER_MASK 0x001f0000
145 #define AR2313_CLOCKCTL1_MULTIPLIER_SHIFT 16
146 #define AR2313_CLOCKCTL1_DOUBLER_MASK 0x00000000
147
148
149 /* AR531X_ENABLE register bit field definitions */
150 #define AR531X_ENABLE_WLAN0 0x0001
151 #define AR531X_ENABLE_ENET0 0x0002
152 #define AR531X_ENABLE_ENET1 0x0004
153 #define AR531X_ENABLE_UART_AND_WLAN1_PIO 0x0008 /* UART, and WLAN1 PIOs */
154 #define AR531X_ENABLE_WLAN1_DMA 0x0010 /* WLAN1 DMAs */
155 #define AR531X_ENABLE_WLAN1 \
156 (AR531X_ENABLE_UART_AND_WLAN1_PIO | AR531X_ENABLE_WLAN1_DMA)
157
158 /* AR531X_REV register bit field definitions */
159 #define AR531X_REV_WMAC_MAJ 0xf000
160 #define AR531X_REV_WMAC_MAJ_S 12
161 #define AR531X_REV_WMAC_MIN 0x0f00
162 #define AR531X_REV_WMAC_MIN_S 8
163 #define AR531X_REV_MAJ 0x00f0
164 #define AR531X_REV_MAJ_S 4
165 #define AR531X_REV_MIN 0x000f
166 #define AR531X_REV_MIN_S 0
167 #define AR531X_REV_CHIP (AR531X_REV_MAJ|AR531X_REV_MIN)
168
169 /* Major revision numbers, bits 7..4 of Revision ID register */
170 #define AR531X_REV_MAJ_AR5312 0x4
171 #define AR531X_REV_MAJ_AR2313 0x5
172
173 /* Minor revision numbers, bits 3..0 of Revision ID register */
174 #define AR5312_REV_MIN_DUAL 0x0 /* Dual WLAN version */
175 #define AR5312_REV_MIN_SINGLE 0x1 /* Single WLAN version */
176
177 /* AR531X_FLASHCTL register bit field definitions */
178 #define FLASHCTL_IDCY 0x0000000f /* Idle cycle turn around time */
179 #define FLASHCTL_IDCY_S 0
180 #define FLASHCTL_WST1 0x000003e0 /* Wait state 1 */
181 #define FLASHCTL_WST1_S 5
182 #define FLASHCTL_RBLE 0x00000400 /* Read byte lane enable */
183 #define FLASHCTL_WST2 0x0000f800 /* Wait state 2 */
184 #define FLASHCTL_WST2_S 11
185 #define FLASHCTL_AC 0x00070000 /* Flash address check (added) */
186 #define FLASHCTL_AC_S 16
187 #define FLASHCTL_AC_128K 0x00000000
188 #define FLASHCTL_AC_256K 0x00010000
189 #define FLASHCTL_AC_512K 0x00020000
190 #define FLASHCTL_AC_1M 0x00030000
191 #define FLASHCTL_AC_2M 0x00040000
192 #define FLASHCTL_AC_4M 0x00050000
193 #define FLASHCTL_AC_8M 0x00060000
194 #define FLASHCTL_AC_RES 0x00070000 /* 16MB is not supported */
195 #define FLASHCTL_E 0x00080000 /* Flash bank enable (added) */
196 #define FLASHCTL_BUSERR 0x01000000 /* Bus transfer error status flag */
197 #define FLASHCTL_WPERR 0x02000000 /* Write protect error status flag */
198 #define FLASHCTL_WP 0x04000000 /* Write protect */
199 #define FLASHCTL_BM 0x08000000 /* Burst mode */
200 #define FLASHCTL_MW 0x30000000 /* Memory width */
201 #define FLASHCTL_MWx8 0x00000000 /* Memory width x8 */
202 #define FLASHCTL_MWx16 0x10000000 /* Memory width x16 */
203 #define FLASHCTL_MWx32 0x20000000 /* Memory width x32 (not supported) */
204 #define FLASHCTL_ATNR 0x00000000 /* Access type == no retry */
205 #define FLASHCTL_ATR 0x80000000 /* Access type == retry every */
206 #define FLASHCTL_ATR4 0xc0000000 /* Access type == retry every 4 */
207
208 /* ARM Flash Controller -- 3 flash banks with either x8 or x16 devices. */
209 #define AR531X_FLASHCTL0 (AR531X_FLASHCTL + 0x00)
210 #define AR531X_FLASHCTL1 (AR531X_FLASHCTL + 0x04)
211 #define AR531X_FLASHCTL2 (AR531X_FLASHCTL + 0x08)
212
213 /* ARM SDRAM Controller -- just enough to determine memory size */
214 #define AR531X_MEM_CFG1 (AR531X_SDRAMCTL + 0x04)
215 #define MEM_CFG1_AC0 0x00000700 /* bank 0: SDRAM addr check (added) */
216 #define MEM_CFG1_AC0_S 8
217 #define MEM_CFG1_AC1 0x00007000 /* bank 1: SDRAM addr check (added) */
218 #define MEM_CFG1_AC1_S 12
219
220 /* GPIO Address Map */
221 #define AR531X_GPIO (AR531X_APBBASE + 0x2000)
222 #define AR531X_GPIO_DO (AR531X_GPIO + 0x00) /* output register */
223 #define AR531X_GPIO_DI (AR531X_GPIO + 0x04) /* intput register */
224 #define AR531X_GPIO_CR (AR531X_GPIO + 0x08) /* control register */
225
226 /* GPIO Control Register bit field definitions */
227 #define AR531X_GPIO_CR_M(x) (1 << (x)) /* mask for i/o */
228 #define AR531X_GPIO_CR_O(x) (0 << (x)) /* mask for output */
229 #define AR531X_GPIO_CR_I(x) (1 << (x)) /* mask for input */
230 #define AR531X_GPIO_CR_INT(x) (1 << ((x)+8)) /* mask for interrupt */
231 #define AR531X_GPIO_CR_UART(x) (1 << ((x)+16)) /* uart multiplex */
232
233 #endif
234
This page took 0.053184 seconds and 5 git commands to generate.