29b61fd547d9ab469231501214c0d58fdfceb40d
[openwrt.git] / target / linux / brcm63xx / files / include / asm-mips / mach-bcm63xx / bcm63xx_cpu.h
1 #ifndef BCM63XX_CPU_H_
2 #define BCM63XX_CPU_H_
3
4 #include <linux/types.h>
5 #include <linux/init.h>
6
7 /*
8  * Macro to fetch bcm63xx cpu id and revision, should be optimized at
9  * compile time if only one CPU support is enabled (idea stolen from
10  * arm mach-types)
11  */
12 #define BCM6348_CPU_ID          0x6348
13 #define BCM6358_CPU_ID          0x6358
14
15 void __init bcm63xx_cpu_init(void);
16 u16 __bcm63xx_get_cpu_id(void);
17 u16 bcm63xx_get_cpu_rev(void);
18 unsigned int bcm63xx_get_cpu_freq(void);
19
20 #ifdef CONFIG_BCM63XX_CPU_6348
21 # ifdef bcm63xx_get_cpu_id
22 #  undef bcm63xx_get_cpu_id
23 #  define bcm63xx_get_cpu_id()  __bcm63xx_get_cpu_id()
24 #  define BCMCPU_RUNTIME_DETECT
25 # else
26 #  define bcm63xx_get_cpu_id()  BCM6348_CPU_ID
27 # endif
28 # define BCMCPU_IS_6348()       (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
29 #else
30 # define BCMCPU_IS_6348()       (0)
31 #endif
32
33 #ifdef CONFIG_BCM63XX_CPU_6358
34 # ifdef bcm63xx_get_cpu_id
35 #  undef bcm63xx_get_cpu_id
36 #  define bcm63xx_get_cpu_id()  __bcm63xx_get_cpu_id()
37 #  define BCMCPU_RUNTIME_DETECT
38 # else
39 #  define bcm63xx_get_cpu_id()  BCM6358_CPU_ID
40 # endif
41 # define BCMCPU_IS_6358()       (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
42 #else
43 # define BCMCPU_IS_6358()       (0)
44 #endif
45
46 #ifndef bcm63xx_get_cpu_id
47 #error "No CPU support configured"
48 #endif
49
50 /*
51  * While registers sets are (mostly) the same across 63xx CPU, base
52  * address of these sets do change.
53  */
54 enum bcm63xx_regs_set {
55         RSET_DSL_LMEM = 0,
56         RSET_PERF,
57         RSET_TIMER,
58         RSET_WDT,
59         RSET_UART0,
60         RSET_GPIO,
61         RSET_SPI,
62         RSET_UDC0,
63         RSET_OHCI0,
64         RSET_OHCI_PRIV,
65         RSET_USBH_PRIV,
66         RSET_MPI,
67         RSET_PCMCIA,
68         RSET_DSL,
69         RSET_ENET0,
70         RSET_ENET1,
71         RSET_ENETDMA,
72         RSET_EHCI0,
73         RSET_SDRAM,
74         RSET_MEMC,
75         RSET_DDR,
76 };
77
78 #define RSET_DSL_LMEM_SIZE              (64 * 1024 * 4)
79 #define RSET_DSL_SIZE                   4096
80 #define RSET_WDT_SIZE                   12
81 #define RSET_ENET_SIZE                  2048
82 #define RSET_ENETDMA_SIZE               2048
83 #define RSET_UART_SIZE                  24
84 #define RSET_UDC_SIZE                   256
85 #define RSET_OHCI_SIZE                  256
86 #define RSET_EHCI_SIZE                  256
87 #define RSET_PCMCIA_SIZE                12
88
89 /*
90  * 6348 register sets base address
91  */
92 #define BCM_6348_DSL_LMEM_BASE          (0xfff00000)
93 #define BCM_6348_PERF_BASE              (0xfffe0000)
94 #define BCM_6348_TIMER_BASE             (0xfffe0200)
95 #define BCM_6348_WDT_BASE               (0xfffe021c)
96 #define BCM_6348_UART0_BASE             (0xfffe0300)
97 #define BCM_6348_GPIO_BASE              (0xfffe0400)
98 #define BCM_6348_SPI_BASE               (0xfffe0c00)
99 #define BCM_6348_UDC0_BASE              (0xfffe1000)
100 #define BCM_6348_OHCI0_BASE             (0xfffe1b00)
101 #define BCM_6348_OHCI_PRIV_BASE         (0xfffe1c00)
102 #define BCM_6348_USBH_PRIV_BASE         (0xdeadbeef)
103 #define BCM_6348_MPI_BASE               (0xfffe2000)
104 #define BCM_6348_PCMCIA_BASE            (0xfffe2054)
105 #define BCM_6348_SDRAM_REGS_BASE        (0xfffe2300)
106 #define BCM_6348_DSL_BASE               (0xfffe3000)
107 #define BCM_6348_ENET0_BASE             (0xfffe6000)
108 #define BCM_6348_ENET1_BASE             (0xfffe6800)
109 #define BCM_6348_ENETDMA_BASE           (0xfffe7000)
110 #define BCM_6348_EHCI0_BASE             (0xdeadbeef)
111 #define BCM_6348_SDRAM_BASE             (0xfffe2300)
112 #define BCM_6348_MEMC_BASE              (0xdeadbeef)
113 #define BCM_6348_DDR_BASE               (0xdeadbeef)
114
115 /*
116  * 6358 register sets base address
117  */
118 #define BCM_6358_DSL_LMEM_BASE          (0xfff00000)
119 #define BCM_6358_PERF_BASE              (0xfffe0000)
120 #define BCM_6358_TIMER_BASE             (0xfffe0040)
121 #define BCM_6358_WDT_BASE               (0xfffe005c)
122 #define BCM_6358_UART0_BASE             (0xfffe0100)
123 #define BCM_6358_GPIO_BASE              (0xfffe0080)
124 #define BCM_6358_SPI_BASE               (0xdeadbeef)
125 #define BCM_6358_UDC0_BASE              (0xfffe0800)
126 #define BCM_6358_OHCI0_BASE             (0xfffe1400)
127 #define BCM_6358_OHCI_PRIV_BASE         (0xdeadbeef)
128 #define BCM_6358_USBH_PRIV_BASE         (0xfffe1500)
129 #define BCM_6358_MPI_BASE               (0xfffe1000)
130 #define BCM_6358_PCMCIA_BASE            (0xfffe1054)
131 #define BCM_6358_SDRAM_REGS_BASE        (0xfffe2300)
132 #define BCM_6358_DSL_BASE               (0xfffe3000)
133 #define BCM_6358_ENET0_BASE             (0xfffe4000)
134 #define BCM_6358_ENET1_BASE             (0xfffe4800)
135 #define BCM_6358_ENETDMA_BASE           (0xfffe5000)
136 #define BCM_6358_EHCI0_BASE             (0xfffe1300)
137 #define BCM_6358_SDRAM_BASE             (0xdeadbeef)
138 #define BCM_6358_MEMC_BASE              (0xfffe1200)
139 #define BCM_6358_DDR_BASE               (0xfffe12a0)
140
141
142 extern const unsigned long *bcm63xx_regs_base;
143
144 static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
145 {
146 #ifdef BCMCPU_RUNTIME_DETECT
147         return bcm63xx_regs_base[set];
148 #else
149 #ifdef CONFIG_BCM63XX_CPU_6348
150         switch (set) {
151         case RSET_DSL_LMEM:
152                 return BCM_6348_DSL_LMEM_BASE;
153         case RSET_PERF:
154                 return BCM_6348_PERF_BASE;
155         case RSET_TIMER:
156                 return BCM_6348_TIMER_BASE;
157         case RSET_WDT:
158                 return BCM_6348_WDT_BASE;
159         case RSET_UART0:
160                 return BCM_6348_UART0_BASE;
161         case RSET_GPIO:
162                 return BCM_6348_GPIO_BASE;
163         case RSET_SPI:
164                 return BCM_6348_SPI_BASE;
165         case RSET_UDC0:
166                 return BCM_6348_UDC0_BASE;
167         case RSET_OHCI0:
168                 return BCM_6348_OHCI0_BASE;
169         case RSET_OHCI_PRIV:
170                 return BCM_6348_OHCI_PRIV_BASE;
171         case RSET_USBH_PRIV:
172                 return BCM_6348_USBH_PRIV_BASE;
173         case RSET_MPI:
174                 return BCM_6348_MPI_BASE;
175         case RSET_PCMCIA:
176                 return BCM_6348_PCMCIA_BASE;
177         case RSET_DSL:
178                 return BCM_6348_DSL_BASE;
179         case RSET_ENET0:
180                 return BCM_6348_ENET0_BASE;
181         case RSET_ENET1:
182                 return BCM_6348_ENET1_BASE;
183         case RSET_ENETDMA:
184                 return BCM_6348_ENETDMA_BASE;
185         case RSET_EHCI0:
186                 return BCM_6348_EHCI0_BASE;
187         case RSET_SDRAM:
188                 return BCM_6348_SDRAM_BASE;
189         case RSET_MEMC:
190                 return BCM_6348_MEMC_BASE;
191         case RSET_DDR:
192                 return BCM_6348_DDR_BASE;
193         }
194 #endif
195 #ifdef CONFIG_BCM63XX_CPU_6358
196         switch (set) {
197         case RSET_DSL_LMEM:
198                 return BCM_6358_DSL_LMEM_BASE;
199         case RSET_PERF:
200                 return BCM_6358_PERF_BASE;
201         case RSET_TIMER:
202                 return BCM_6358_TIMER_BASE;
203         case RSET_WDT:
204                 return BCM_6358_WDT_BASE;
205         case RSET_UART0:
206                 return BCM_6358_UART0_BASE;
207         case RSET_GPIO:
208                 return BCM_6358_GPIO_BASE;
209         case RSET_SPI:
210                 return BCM_6358_SPI_BASE;
211         case RSET_UDC0:
212                 return BCM_6358_UDC0_BASE;
213         case RSET_OHCI0:
214                 return BCM_6358_OHCI0_BASE;
215         case RSET_OHCI_PRIV:
216                 return BCM_6358_OHCI_PRIV_BASE;
217         case RSET_USBH_PRIV:
218                 return BCM_6358_USBH_PRIV_BASE;
219         case RSET_MPI:
220                 return BCM_6358_MPI_BASE;
221         case RSET_PCMCIA:
222                 return BCM_6358_PCMCIA_BASE;
223         case RSET_ENET0:
224                 return BCM_6358_ENET0_BASE;
225         case RSET_ENET1:
226                 return BCM_6358_ENET1_BASE;
227         case RSET_ENETDMA:
228                 return BCM_6358_ENETDMA_BASE;
229         case RSET_DSL:
230                 return BCM_6358_DSL_BASE;
231         case RSET_EHCI0:
232                 return BCM_6358_EHCI0_BASE;
233         case RSET_SDRAM:
234                 return BCM_6358_SDRAM_BASE;
235         case RSET_MEMC:
236                 return BCM_6358_MEMC_BASE;
237         case RSET_DDR:
238                 return BCM_6358_DDR_BASE;
239         }
240 #endif
241 #endif
242         /* unreached */
243         return 0;
244 }
245
246 /*
247  * IRQ number changes across CPU too
248  */
249 enum bcm63xx_irq {
250         IRQ_TIMER = 0,
251         IRQ_UART0,
252         IRQ_DSL,
253         IRQ_ENET0,
254         IRQ_ENET1,
255         IRQ_ENET_PHY,
256         IRQ_OHCI0,
257         IRQ_EHCI0,
258         IRQ_PCMCIA0,
259         IRQ_ENET0_RXDMA,
260         IRQ_ENET0_TXDMA,
261         IRQ_ENET1_RXDMA,
262         IRQ_ENET1_TXDMA,
263         IRQ_PCI,
264         IRQ_PCMCIA,
265 };
266
267 /*
268  * 6348 irqs
269  */
270 #define BCM_6348_TIMER_IRQ              (IRQ_INTERNAL_BASE + 0)
271 #define BCM_6348_UART0_IRQ              (IRQ_INTERNAL_BASE + 2)
272 #define BCM_6348_DSL_IRQ                (IRQ_INTERNAL_BASE + 4)
273 #define BCM_6348_ENET1_IRQ              (IRQ_INTERNAL_BASE + 7)
274 #define BCM_6348_ENET0_IRQ              (IRQ_INTERNAL_BASE + 8)
275 #define BCM_6348_ENET_PHY_IRQ           (IRQ_INTERNAL_BASE + 9)
276 #define BCM_6348_OHCI0_IRQ              (IRQ_INTERNAL_BASE + 12)
277 #define BCM_6348_ENET0_RXDMA_IRQ        (IRQ_INTERNAL_BASE + 20)
278 #define BCM_6348_ENET0_TXDMA_IRQ        (IRQ_INTERNAL_BASE + 21)
279 #define BCM_6348_ENET1_RXDMA_IRQ        (IRQ_INTERNAL_BASE + 22)
280 #define BCM_6348_ENET1_TXDMA_IRQ        (IRQ_INTERNAL_BASE + 23)
281 #define BCM_6348_PCMCIA_IRQ             (IRQ_INTERNAL_BASE + 24)
282 #define BCM_6348_PCI_IRQ                (IRQ_INTERNAL_BASE + 24)
283
284 /*
285  * 6358 irqs
286  */
287 #define BCM_6358_TIMER_IRQ              (IRQ_INTERNAL_BASE + 0)
288 #define BCM_6358_UART0_IRQ              (IRQ_INTERNAL_BASE + 2)
289 #define BCM_6358_OHCI0_IRQ              (IRQ_INTERNAL_BASE + 5)
290 #define BCM_6358_ENET1_IRQ              (IRQ_INTERNAL_BASE + 6)
291 #define BCM_6358_ENET0_IRQ              (IRQ_INTERNAL_BASE + 8)
292 #define BCM_6358_ENET_PHY_IRQ           (IRQ_INTERNAL_BASE + 9)
293 #define BCM_6358_EHCI0_IRQ              (IRQ_INTERNAL_BASE + 10)
294 #define BCM_6358_ENET0_RXDMA_IRQ        (IRQ_INTERNAL_BASE + 15)
295 #define BCM_6358_ENET0_TXDMA_IRQ        (IRQ_INTERNAL_BASE + 16)
296 #define BCM_6358_ENET1_RXDMA_IRQ        (IRQ_INTERNAL_BASE + 17)
297 #define BCM_6358_ENET1_TXDMA_IRQ        (IRQ_INTERNAL_BASE + 18)
298 #define BCM_6358_DSL_IRQ                (IRQ_INTERNAL_BASE + 29)
299 #define BCM_6358_PCI_IRQ                (IRQ_INTERNAL_BASE + 31)
300 #define BCM_6358_PCMCIA_IRQ             (IRQ_INTERNAL_BASE + 24)
301
302 extern const int *bcm63xx_irqs;
303
304 static inline int bcm63xx_get_irq_number(enum bcm63xx_irq irq)
305 {
306         return bcm63xx_irqs[irq];
307 }
308
309 /*
310  * return installed memory size
311  */
312 unsigned int bcm63xx_get_memory_size(void);
313
314 #endif /* !BCM63XX_CPU_H_ */