[brcm63xx] fix some SPI register definitions and platform-device registration code
[openwrt/svn-archive/archive.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 BCM6338_CPU_ID 0x6338
13 #define BCM6348_CPU_ID 0x6348
14 #define BCM6358_CPU_ID 0x6358
15
16 void __init bcm63xx_cpu_init(void);
17 u16 __bcm63xx_get_cpu_id(void);
18 u16 bcm63xx_get_cpu_rev(void);
19 unsigned int bcm63xx_get_cpu_freq(void);
20
21 #ifdef CONFIG_BCM63XX_CPU_6338
22 # ifdef bcm63xx_get_cpu_id
23 # undef bcm63xx_get_cpu_id
24 # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
25 # define BCMCPU_RUNTIME_DETECT
26 # else
27 # define bcm63xx_get_cpu_id() BCM6338_CPU_ID
28 # endif
29 # define BCMCPU_IS_6338() (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
30 #else
31 # define BCMCPU_IS_6338() (0)
32 #endif
33
34 #ifdef CONFIG_BCM63XX_CPU_6348
35 # ifdef bcm63xx_get_cpu_id
36 # undef bcm63xx_get_cpu_id
37 # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
38 # define BCMCPU_RUNTIME_DETECT
39 # else
40 # define bcm63xx_get_cpu_id() BCM6348_CPU_ID
41 # endif
42 # define BCMCPU_IS_6348() (bcm63xx_get_cpu_id() == BCM6348_CPU_ID)
43 #else
44 # define BCMCPU_IS_6348() (0)
45 #endif
46
47 #ifdef CONFIG_BCM63XX_CPU_6358
48 # ifdef bcm63xx_get_cpu_id
49 # undef bcm63xx_get_cpu_id
50 # define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
51 # define BCMCPU_RUNTIME_DETECT
52 # else
53 # define bcm63xx_get_cpu_id() BCM6358_CPU_ID
54 # endif
55 # define BCMCPU_IS_6358() (bcm63xx_get_cpu_id() == BCM6358_CPU_ID)
56 #else
57 # define BCMCPU_IS_6358() (0)
58 #endif
59
60 #ifndef bcm63xx_get_cpu_id
61 #error "No CPU support configured"
62 #endif
63
64 /*
65 * While registers sets are (mostly) the same across 63xx CPU, base
66 * address of these sets do change.
67 */
68 enum bcm63xx_regs_set {
69 RSET_DSL_LMEM = 0,
70 RSET_PERF,
71 RSET_TIMER,
72 RSET_WDT,
73 RSET_UART0,
74 RSET_GPIO,
75 RSET_SPI,
76 RSET_UDC0,
77 RSET_OHCI0,
78 RSET_OHCI_PRIV,
79 RSET_USBH_PRIV,
80 RSET_MPI,
81 RSET_PCMCIA,
82 RSET_DSL,
83 RSET_ENET0,
84 RSET_ENET1,
85 RSET_ENETDMA,
86 RSET_EHCI0,
87 RSET_SDRAM,
88 RSET_MEMC,
89 RSET_DDR,
90 };
91
92 #define RSET_DSL_LMEM_SIZE (64 * 1024 * 4)
93 #define RSET_DSL_SIZE 4096
94 #define RSET_WDT_SIZE 12
95 #define RSET_ENET_SIZE 2048
96 #define RSET_ENETDMA_SIZE 2048
97 #define RSET_UART_SIZE 24
98 #define RSET_SPI_SIZE 256
99 #define RSET_UDC_SIZE 256
100 #define RSET_OHCI_SIZE 256
101 #define RSET_EHCI_SIZE 256
102 #define RSET_PCMCIA_SIZE 12
103
104 /*
105 * 6338 register sets base address
106 */
107
108 #define BCM_6338_PERF_BASE (0xfffe0000)
109 #define BCM_6338_TIMER_BASE (0xfffe0000)
110 #define BCM_6338_WDT_BASE (0xfffe001c)
111 #define BCM_6338_UART0_BASE (0xfffe0300)
112 #define BCM_6338_GPIO_BASE (0xfffe0400)
113 #define BCM_6338_SPI_BASE (0xfffe0c00)
114 #define BCM_6338_SAR_BASE (0xfffe2000)
115 #define BCM_6338_MEMC_BASE (0xfffe3100)
116
117 /*
118 * 6348 register sets base address
119 */
120 #define BCM_6348_DSL_LMEM_BASE (0xfff00000)
121 #define BCM_6348_PERF_BASE (0xfffe0000)
122 #define BCM_6348_TIMER_BASE (0xfffe0200)
123 #define BCM_6348_WDT_BASE (0xfffe021c)
124 #define BCM_6348_UART0_BASE (0xfffe0300)
125 #define BCM_6348_GPIO_BASE (0xfffe0400)
126 #define BCM_6348_SPI_BASE (0xfffe0c00)
127 #define BCM_6348_UDC0_BASE (0xfffe1000)
128 #define BCM_6348_OHCI0_BASE (0xfffe1b00)
129 #define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00)
130 #define BCM_6348_USBH_PRIV_BASE (0xdeadbeef)
131 #define BCM_6348_MPI_BASE (0xfffe2000)
132 #define BCM_6348_PCMCIA_BASE (0xfffe2054)
133 #define BCM_6348_SDRAM_REGS_BASE (0xfffe2300)
134 #define BCM_6348_DSL_BASE (0xfffe3000)
135 #define BCM_6348_ENET0_BASE (0xfffe6000)
136 #define BCM_6348_ENET1_BASE (0xfffe6800)
137 #define BCM_6348_ENETDMA_BASE (0xfffe7000)
138 #define BCM_6348_EHCI0_BASE (0xdeadbeef)
139 #define BCM_6348_SDRAM_BASE (0xfffe2300)
140 #define BCM_6348_MEMC_BASE (0xdeadbeef)
141 #define BCM_6348_DDR_BASE (0xdeadbeef)
142
143 /*
144 * 6358 register sets base address
145 */
146 #define BCM_6358_DSL_LMEM_BASE (0xfff00000)
147 #define BCM_6358_PERF_BASE (0xfffe0000)
148 #define BCM_6358_TIMER_BASE (0xfffe0040)
149 #define BCM_6358_WDT_BASE (0xfffe005c)
150 #define BCM_6358_GPIO_BASE (0xfffe0080)
151 #define BCM_6358_UART0_BASE (0xfffe0100)
152 #define BCM_6358_UDC0_BASE (0xfffe0400)
153 #define BCM_6358_SPI_BASE (0xfffe0800)
154 #define BCM_6358_MPI_BASE (0xfffe1000)
155 #define BCM_6358_PCMCIA_BASE (0xfffe1054)
156 #define BCM_6358_OHCI0_BASE (0xfffe1400)
157 #define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef)
158 #define BCM_6358_USBH_PRIV_BASE (0xfffe1500)
159 #define BCM_6358_SDRAM_REGS_BASE (0xfffe2300)
160 #define BCM_6358_DSL_BASE (0xfffe3000)
161 #define BCM_6358_ENET0_BASE (0xfffe4000)
162 #define BCM_6358_ENET1_BASE (0xfffe4800)
163 #define BCM_6358_ENETDMA_BASE (0xfffe5000)
164 #define BCM_6358_EHCI0_BASE (0xfffe1300)
165 #define BCM_6358_SDRAM_BASE (0xdeadbeef)
166 #define BCM_6358_MEMC_BASE (0xfffe1200)
167 #define BCM_6358_DDR_BASE (0xfffe12a0)
168
169
170 extern const unsigned long *bcm63xx_regs_base;
171
172 static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
173 {
174 #ifdef BCMCPU_RUNTIME_DETECT
175 return bcm63xx_regs_base[set];
176 #else
177 #ifdef CONFIG_BCM63XX_CPU_6338
178 switch (set) {
179 case RSET_PERF:
180 return BCM_6338_PERF_BASE;
181 case RSET_TIMER:
182 return BCM_6338_TIMER_BASE;
183 case RSET_WDT:
184 return BCM_6338_WDT_BASE;
185 case RSET_UART0:
186 return BCM_6338_UART0_BASE;
187 case RSET_GPIO:
188 return BCM_6338_GPIO_BASE;
189 case RSET_SPI:
190 return BCM_6338_SPI_BASE;
191 case RSET_MEMC:
192 return BCM_6338_MEMC_BASE;
193 }
194 #endif
195 #ifdef CONFIG_BCM63XX_CPU_6348
196 switch (set) {
197 case RSET_DSL_LMEM:
198 return BCM_6348_DSL_LMEM_BASE;
199 case RSET_PERF:
200 return BCM_6348_PERF_BASE;
201 case RSET_TIMER:
202 return BCM_6348_TIMER_BASE;
203 case RSET_WDT:
204 return BCM_6348_WDT_BASE;
205 case RSET_UART0:
206 return BCM_6348_UART0_BASE;
207 case RSET_GPIO:
208 return BCM_6348_GPIO_BASE;
209 case RSET_SPI:
210 return BCM_6348_SPI_BASE;
211 case RSET_UDC0:
212 return BCM_6348_UDC0_BASE;
213 case RSET_OHCI0:
214 return BCM_6348_OHCI0_BASE;
215 case RSET_OHCI_PRIV:
216 return BCM_6348_OHCI_PRIV_BASE;
217 case RSET_USBH_PRIV:
218 return BCM_6348_USBH_PRIV_BASE;
219 case RSET_MPI:
220 return BCM_6348_MPI_BASE;
221 case RSET_PCMCIA:
222 return BCM_6348_PCMCIA_BASE;
223 case RSET_DSL:
224 return BCM_6348_DSL_BASE;
225 case RSET_ENET0:
226 return BCM_6348_ENET0_BASE;
227 case RSET_ENET1:
228 return BCM_6348_ENET1_BASE;
229 case RSET_ENETDMA:
230 return BCM_6348_ENETDMA_BASE;
231 case RSET_EHCI0:
232 return BCM_6348_EHCI0_BASE;
233 case RSET_SDRAM:
234 return BCM_6348_SDRAM_BASE;
235 case RSET_MEMC:
236 return BCM_6348_MEMC_BASE;
237 case RSET_DDR:
238 return BCM_6348_DDR_BASE;
239 }
240 #endif
241 #ifdef CONFIG_BCM63XX_CPU_6358
242 switch (set) {
243 case RSET_DSL_LMEM:
244 return BCM_6358_DSL_LMEM_BASE;
245 case RSET_PERF:
246 return BCM_6358_PERF_BASE;
247 case RSET_TIMER:
248 return BCM_6358_TIMER_BASE;
249 case RSET_WDT:
250 return BCM_6358_WDT_BASE;
251 case RSET_UART0:
252 return BCM_6358_UART0_BASE;
253 case RSET_GPIO:
254 return BCM_6358_GPIO_BASE;
255 case RSET_SPI:
256 return BCM_6358_SPI_BASE;
257 case RSET_UDC0:
258 return BCM_6358_UDC0_BASE;
259 case RSET_OHCI0:
260 return BCM_6358_OHCI0_BASE;
261 case RSET_OHCI_PRIV:
262 return BCM_6358_OHCI_PRIV_BASE;
263 case RSET_USBH_PRIV:
264 return BCM_6358_USBH_PRIV_BASE;
265 case RSET_MPI:
266 return BCM_6358_MPI_BASE;
267 case RSET_PCMCIA:
268 return BCM_6358_PCMCIA_BASE;
269 case RSET_ENET0:
270 return BCM_6358_ENET0_BASE;
271 case RSET_ENET1:
272 return BCM_6358_ENET1_BASE;
273 case RSET_ENETDMA:
274 return BCM_6358_ENETDMA_BASE;
275 case RSET_DSL:
276 return BCM_6358_DSL_BASE;
277 case RSET_EHCI0:
278 return BCM_6358_EHCI0_BASE;
279 case RSET_SDRAM:
280 return BCM_6358_SDRAM_BASE;
281 case RSET_MEMC:
282 return BCM_6358_MEMC_BASE;
283 case RSET_DDR:
284 return BCM_6358_DDR_BASE;
285 }
286 #endif
287 #endif
288 /* unreached */
289 return 0;
290 }
291
292 /*
293 * SPI register layout is not compatible
294 * accross CPU versions but it is software
295 * compatible
296 */
297
298 enum bcm63xx_regs_spi {
299 SPI_CMD,
300 SPI_INT_STATUS,
301 SPI_INT_MASK_ST,
302 SPI_INT_MASK,
303 SPI_ST,
304 SPI_CLK_CFG,
305 SPI_FILL_BYTE,
306 SPI_MSG_TAIL,
307 SPI_RX_TAIL,
308 SPI_MSG_CTL,
309 SPI_MSG_DATA,
310 SPI_RX_DATA,
311 };
312
313 extern const unsigned long *bcm63xx_regs_spi;
314
315 static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
316 {
317 #ifdef BCMCPU_RUNTIME_DETECT
318 return bcm63xx_regs_spi[reg];
319 #else
320 #ifdef CONFIG_BCM63XX_CPU_6338
321 switch (reg) {
322 case SPI_CMD:
323 return SPI_BCM_6338_SPI_CMD;
324 case SPI_INT_STATUS:
325 return SPI_BCM_6338_SPI_INT_STATUS;
326 case SPI_INT_MASK_ST:
327 return SPI_BCM_6338_SPI_MASK_INT_ST;
328 case SPI_INT_MASK:
329 return SPI_BCM_6338_SPI_INT_MASK;
330 case SPI_ST:
331 return SPI_BCM_6338_SPI_ST;
332 case SPI_CLK_CFG:
333 return SPI_BCM_6338_SPI_CLK_CFG;
334 case SPI_FILL_BYTE:
335 return SPI_BCM_6338_SPI_FILL_BYTE;
336 case SPI_MSG_TAIL:
337 return SPI_BCM_6338_SPI_MSG_TAIL;
338 case SPI_RX_TAIL:
339 return SPI_BCM_6338_SPI_RX_TAIL;
340 case SPI_MSG_CTL:
341 return SPI_BCM_6338_SPI_MSG_CTL;
342 case SPI_MSG_DATA:
343 return SPI_BCM_6338_SPI_MSG_DATA;
344 case SPI_RX_DATA:
345 return SPI_BCM_6338_SPI_RX_DATA;
346 }
347 #endif
348 #ifdef CONFIG_BCM63XX_CPU_6348
349 switch (reg) {
350 case SPI_CMD:
351 return SPI_BCM_6348_SPI_CMD;
352 case SPI_INT_MASK_ST:
353 return SPI_BCM_6348_SPI_MASK_INT_ST;
354 case SPI_INT_STATUS:
355 return SPI_BCM_6348_SPI_INT_STATUS;
356 case SPI_ST:
357 return SPI_BCM_6348_SPI_ST;
358 case SPI_CLK_CFG:
359 return SPI_BCM_6348_SPI_CLK_CFG;
360 case SPI_FILL_BYTE:
361 return SPI_BCM_6348_SPI_FILL_BYTE;
362 case SPI_MSG_TAIL:
363 return SPI_BCM_6348_SPI_MSG_TAIL;
364 case SPI_RX_TAIL:
365 return SPI_BCM_6348_SPI_RX_TAIL;
366 case SPI_MSG_CTL:
367 return SPI_BCM_6348_SPI_MSG_CTL;
368 case SPI_MSG_DATA:
369 return SPI_BCM_6348_SPI_MSG_DATA;
370 case SPI_BCM_6348_SPI_RX_DATA:
371 return SPI_BCM_6348_SPI_RX_DATA;
372 }
373 #endif
374 #ifdef CONFIG_BCM63XX_CPU_6358
375 switch (reg) {
376 case SPI_CMD:
377 return SPI_BCM_6358_SPI_CMD;
378 case SPI_INT_STATUS:
379 return SPI_BCM_6358_SPI_INT_STATUS;
380 case SPI_INT_MASK_ST:
381 return SPI_BCM_6358_SPI_MASK_INT_ST;
382 case SPI_INT_MASK:
383 return SPI_BCM_6358_SPI_INT_MASK;
384 case SPI_ST:
385 return SPI_BCM_6358_SPI_STATUS;
386 case SPI_CLK_CFG:
387 return SPI_BCM_6358_SPI_CLK_CFG;
388 case SPI_FILL_BYTE:
389 return SPI_BCM_6358_SPI_FILL_BYTE;
390 case SPI_MSG_TAIL:
391 return SPI_BCM_6358_SPI_MSG_TAIL;
392 case SPI_RX_TAIL:
393 return SPI_BCM_6358_SPI_RX_TAIL;
394 case SPI_MSG_CTL:
395 return SPI_BCM_6358_MSG_CTL;
396 case SPI_MSG_DATA:
397 return SPI_BCM_6358_SPI_MSG_DATA;
398 case SPI_RX_DATA:
399 return SPI_BCM_6358_SPI_RX_DATA;
400 }
401 #endif
402 #endif
403 return 0;
404 }
405
406 /*
407 * IRQ number changes across CPU too
408 */
409 enum bcm63xx_irq {
410 IRQ_TIMER = 0,
411 IRQ_UART0,
412 IRQ_SPI,
413 IRQ_DSL,
414 IRQ_ENET0,
415 IRQ_ENET1,
416 IRQ_ENET_PHY,
417 IRQ_OHCI0,
418 IRQ_EHCI0,
419 IRQ_PCMCIA0,
420 IRQ_ENET0_RXDMA,
421 IRQ_ENET0_TXDMA,
422 IRQ_ENET1_RXDMA,
423 IRQ_ENET1_TXDMA,
424 IRQ_PCI,
425 IRQ_PCMCIA,
426 };
427
428 /*
429 * 6338 irqs
430 */
431 #define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
432 #define BCM_6338_SPI_IR (IRQ_INTERNAL_BASE + 1)
433 #define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
434 #define BCM_6338_DG_IRQ (IRQ_INTERNAL_BASE + 4)
435 #define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5)
436 #define BCM_6338_ATM_IRQ (IRQ_INTERNAL_BASE + 6)
437 #define BCM_6338_USBS_IRQ (IRQ_INTERNAL_BASE + 7)
438 #define BCM_6338_ENET0_IRQ (IRQ_INTERNAL_BASE + 8)
439 #define BCM_6338_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 9)
440 #define BCM_6338_SDRAM_IRQ (IRQ_INTERNAL_BASE + 10)
441 #define BCM_6338_USB_CNTL_RX_DMA_IRQ (IRQ_INTERNAL_BASE + 11)
442 #define BCM_6338_USB_CNTL_TX_DMA_IRQ (IRQ_INTERNAL_BASE + 12)
443 #define BCM_6338_USB_BULK_RX_DMA_IRQ (IRQ_INTERNAL_BASE + 13)
444 #define BCM_6338_USB_BULK_TX_DMA_IRQ (IRQ_INTERNAL_BASE + 14)
445 #define BCM_6338_ENET0_RXDMA_IRQ (IRQ_INTERNAL_BASE + 15)
446 #define BCM_6338_ENET0_TXDMA_IRQ (IRQ_INTERNAL_BASE + 16)
447 #define BCM_6338_SDIO_IRQ (IRQ_INTERNAL_BASE + 17)
448
449 /*
450 * 6348 irqs
451 */
452 #define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
453 #define BCM_6348_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
454 #define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
455 #define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
456 #define BCM_6348_ENET1_IRQ (IRQ_INTERNAL_BASE + 7)
457 #define BCM_6348_ENET0_IRQ (IRQ_INTERNAL_BASE + 8)
458 #define BCM_6348_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 9)
459 #define BCM_6348_OHCI0_IRQ (IRQ_INTERNAL_BASE + 12)
460 #define BCM_6348_ENET0_RXDMA_IRQ (IRQ_INTERNAL_BASE + 20)
461 #define BCM_6348_ENET0_TXDMA_IRQ (IRQ_INTERNAL_BASE + 21)
462 #define BCM_6348_ENET1_RXDMA_IRQ (IRQ_INTERNAL_BASE + 22)
463 #define BCM_6348_ENET1_TXDMA_IRQ (IRQ_INTERNAL_BASE + 23)
464 #define BCM_6348_PCMCIA_IRQ (IRQ_INTERNAL_BASE + 24)
465 #define BCM_6348_PCI_IRQ (IRQ_INTERNAL_BASE + 24)
466
467 /*
468 * 6358 irqs
469 */
470 #define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
471 #define BCM_6358_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
472 #define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
473 #define BCM_6358_OHCI0_IRQ (IRQ_INTERNAL_BASE + 5)
474 #define BCM_6358_ENET1_IRQ (IRQ_INTERNAL_BASE + 6)
475 #define BCM_6358_ENET0_IRQ (IRQ_INTERNAL_BASE + 8)
476 #define BCM_6358_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 9)
477 #define BCM_6358_EHCI0_IRQ (IRQ_INTERNAL_BASE + 10)
478 #define BCM_6358_ENET0_RXDMA_IRQ (IRQ_INTERNAL_BASE + 15)
479 #define BCM_6358_ENET0_TXDMA_IRQ (IRQ_INTERNAL_BASE + 16)
480 #define BCM_6358_ENET1_RXDMA_IRQ (IRQ_INTERNAL_BASE + 17)
481 #define BCM_6358_ENET1_TXDMA_IRQ (IRQ_INTERNAL_BASE + 18)
482 #define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29)
483 #define BCM_6358_PCI_IRQ (IRQ_INTERNAL_BASE + 31)
484 #define BCM_6358_PCMCIA_IRQ (IRQ_INTERNAL_BASE + 24)
485
486 extern const int *bcm63xx_irqs;
487
488 static inline int bcm63xx_get_irq_number(enum bcm63xx_irq irq)
489 {
490 return bcm63xx_irqs[irq];
491 }
492
493 /*
494 * return installed memory size
495 */
496 unsigned int bcm63xx_get_memory_size(void);
497
498 #endif /* !BCM63XX_CPU_H_ */