2 * arch/arm/mach-kirkwood/common.c
4 * Core functions for Marvell Kirkwood SoCs
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/mv643xx_eth.h>
17 #include <linux/ata_platform.h>
18 #include <linux/spi/orion_spi.h>
21 #include <asm/timex.h>
22 #include <asm/mach/map.h>
23 #include <asm/mach/time.h>
24 #include <mach/kirkwood.h>
25 #include <plat/cache-feroceon-l2.h>
26 #include <plat/ehci-orion.h>
27 #include <plat/mvsdio.h>
28 #include <plat/mv_xor.h>
29 #include <plat/orion_nand.h>
30 #include <plat/time.h>
33 /*****************************************************************************
35 ****************************************************************************/
36 static struct map_desc kirkwood_io_desc
[] __initdata
= {
38 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE
,
39 .pfn
= __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE
),
40 .length
= KIRKWOOD_PCIE_IO_SIZE
,
43 .virtual = KIRKWOOD_REGS_VIRT_BASE
,
44 .pfn
= __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE
),
45 .length
= KIRKWOOD_REGS_SIZE
,
50 void __init
kirkwood_map_io(void)
52 iotable_init(kirkwood_io_desc
, ARRAY_SIZE(kirkwood_io_desc
));
56 /*****************************************************************************
58 ****************************************************************************/
59 static struct orion_ehci_data kirkwood_ehci_data
= {
60 .dram
= &kirkwood_mbus_dram_info
,
61 .phy_version
= EHCI_PHY_NA
,
64 static u64 ehci_dmamask
= 0xffffffffUL
;
67 /*****************************************************************************
69 ****************************************************************************/
70 static struct resource kirkwood_ehci_resources
[] = {
72 .start
= USB_PHYS_BASE
,
73 .end
= USB_PHYS_BASE
+ 0x0fff,
74 .flags
= IORESOURCE_MEM
,
76 .start
= IRQ_KIRKWOOD_USB
,
77 .end
= IRQ_KIRKWOOD_USB
,
78 .flags
= IORESOURCE_IRQ
,
82 static struct platform_device kirkwood_ehci
= {
86 .dma_mask
= &ehci_dmamask
,
87 .coherent_dma_mask
= 0xffffffff,
88 .platform_data
= &kirkwood_ehci_data
,
90 .resource
= kirkwood_ehci_resources
,
91 .num_resources
= ARRAY_SIZE(kirkwood_ehci_resources
),
94 void __init
kirkwood_ehci_init(void)
96 platform_device_register(&kirkwood_ehci
);
100 /*****************************************************************************
102 ****************************************************************************/
103 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data
= {
104 .dram
= &kirkwood_mbus_dram_info
,
107 static struct resource kirkwood_ge00_shared_resources
[] = {
110 .start
= GE00_PHYS_BASE
+ 0x2000,
111 .end
= GE00_PHYS_BASE
+ 0x3fff,
112 .flags
= IORESOURCE_MEM
,
114 .name
= "ge00 err irq",
115 .start
= IRQ_KIRKWOOD_GE00_ERR
,
116 .end
= IRQ_KIRKWOOD_GE00_ERR
,
117 .flags
= IORESOURCE_IRQ
,
121 static struct platform_device kirkwood_ge00_shared
= {
122 .name
= MV643XX_ETH_SHARED_NAME
,
125 .platform_data
= &kirkwood_ge00_shared_data
,
127 .num_resources
= ARRAY_SIZE(kirkwood_ge00_shared_resources
),
128 .resource
= kirkwood_ge00_shared_resources
,
131 static struct resource kirkwood_ge00_resources
[] = {
134 .start
= IRQ_KIRKWOOD_GE00_SUM
,
135 .end
= IRQ_KIRKWOOD_GE00_SUM
,
136 .flags
= IORESOURCE_IRQ
,
140 static struct platform_device kirkwood_ge00
= {
141 .name
= MV643XX_ETH_NAME
,
144 .resource
= kirkwood_ge00_resources
,
147 void __init
kirkwood_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
149 eth_data
->shared
= &kirkwood_ge00_shared
;
150 kirkwood_ge00
.dev
.platform_data
= eth_data
;
152 platform_device_register(&kirkwood_ge00_shared
);
153 platform_device_register(&kirkwood_ge00
);
157 /*****************************************************************************
159 ****************************************************************************/
160 struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data
= {
161 .dram
= &kirkwood_mbus_dram_info
,
162 .shared_smi
= &kirkwood_ge00_shared
,
165 static struct resource kirkwood_ge01_shared_resources
[] = {
168 .start
= GE01_PHYS_BASE
+ 0x2000,
169 .end
= GE01_PHYS_BASE
+ 0x3fff,
170 .flags
= IORESOURCE_MEM
,
172 .name
= "ge01 err irq",
173 .start
= IRQ_KIRKWOOD_GE01_ERR
,
174 .end
= IRQ_KIRKWOOD_GE01_ERR
,
175 .flags
= IORESOURCE_IRQ
,
179 static struct platform_device kirkwood_ge01_shared
= {
180 .name
= MV643XX_ETH_SHARED_NAME
,
183 .platform_data
= &kirkwood_ge01_shared_data
,
185 .num_resources
= ARRAY_SIZE(kirkwood_ge01_shared_resources
),
186 .resource
= kirkwood_ge01_shared_resources
,
189 static struct resource kirkwood_ge01_resources
[] = {
192 .start
= IRQ_KIRKWOOD_GE01_SUM
,
193 .end
= IRQ_KIRKWOOD_GE01_SUM
,
194 .flags
= IORESOURCE_IRQ
,
198 static struct platform_device kirkwood_ge01
= {
199 .name
= MV643XX_ETH_NAME
,
202 .resource
= kirkwood_ge01_resources
,
205 void __init
kirkwood_ge01_init(struct mv643xx_eth_platform_data
*eth_data
)
207 eth_data
->shared
= &kirkwood_ge01_shared
;
208 kirkwood_ge01
.dev
.platform_data
= eth_data
;
210 platform_device_register(&kirkwood_ge01_shared
);
211 platform_device_register(&kirkwood_ge01
);
215 /*****************************************************************************
217 ****************************************************************************/
218 static struct resource kirkwood_switch_resources
[] = {
222 .flags
= IORESOURCE_IRQ
,
226 static struct platform_device kirkwood_switch_device
= {
230 .resource
= kirkwood_switch_resources
,
233 void __init
kirkwood_ge00_switch_init(struct dsa_platform_data
*d
, int irq
)
236 kirkwood_switch_resources
[0].start
= irq
;
237 kirkwood_switch_resources
[0].end
= irq
;
238 kirkwood_switch_device
.num_resources
= 1;
241 d
->mii_bus
= &kirkwood_ge00_shared
.dev
;
242 d
->netdev
= &kirkwood_ge00
.dev
;
243 kirkwood_switch_device
.dev
.platform_data
= d
;
245 platform_device_register(&kirkwood_switch_device
);
249 /*****************************************************************************
251 ****************************************************************************/
252 static struct resource kirkwood_rtc_resource
= {
253 .start
= RTC_PHYS_BASE
,
254 .end
= RTC_PHYS_BASE
+ SZ_16
- 1,
255 .flags
= IORESOURCE_MEM
,
258 static void __init
kirkwood_rtc_init(void)
260 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource
, 1);
264 /*****************************************************************************
266 ****************************************************************************/
267 static struct resource kirkwood_sata_resources
[] = {
270 .start
= SATA_PHYS_BASE
,
271 .end
= SATA_PHYS_BASE
+ 0x5000 - 1,
272 .flags
= IORESOURCE_MEM
,
275 .start
= IRQ_KIRKWOOD_SATA
,
276 .end
= IRQ_KIRKWOOD_SATA
,
277 .flags
= IORESOURCE_IRQ
,
281 static struct platform_device kirkwood_sata
= {
285 .coherent_dma_mask
= 0xffffffff,
287 .num_resources
= ARRAY_SIZE(kirkwood_sata_resources
),
288 .resource
= kirkwood_sata_resources
,
291 void __init
kirkwood_sata_init(struct mv_sata_platform_data
*sata_data
)
293 sata_data
->dram
= &kirkwood_mbus_dram_info
;
294 kirkwood_sata
.dev
.platform_data
= sata_data
;
295 platform_device_register(&kirkwood_sata
);
299 /*****************************************************************************
301 ****************************************************************************/
302 static struct resource mvsdio_resources
[] = {
304 .start
= SDIO_PHYS_BASE
,
305 .end
= SDIO_PHYS_BASE
+ SZ_1K
- 1,
306 .flags
= IORESOURCE_MEM
,
309 .start
= IRQ_KIRKWOOD_SDIO
,
310 .end
= IRQ_KIRKWOOD_SDIO
,
311 .flags
= IORESOURCE_IRQ
,
315 static u64 mvsdio_dmamask
= 0xffffffffUL
;
317 static struct platform_device kirkwood_sdio
= {
321 .dma_mask
= &mvsdio_dmamask
,
322 .coherent_dma_mask
= 0xffffffff,
324 .num_resources
= ARRAY_SIZE(mvsdio_resources
),
325 .resource
= mvsdio_resources
,
328 void __init
kirkwood_sdio_init(struct mvsdio_platform_data
*mvsdio_data
)
332 kirkwood_pcie_id(&dev
, &rev
);
333 if (rev
== 0) /* catch all Kirkwood Z0's */
334 mvsdio_data
->clock
= 100000000;
336 mvsdio_data
->clock
= 200000000;
337 mvsdio_data
->dram
= &kirkwood_mbus_dram_info
;
338 kirkwood_sdio
.dev
.platform_data
= mvsdio_data
;
339 platform_device_register(&kirkwood_sdio
);
343 /*****************************************************************************
345 ****************************************************************************/
346 static struct orion_spi_info kirkwood_spi_plat_data
= {
349 static struct resource kirkwood_spi_resources
[] = {
351 .start
= SPI_PHYS_BASE
,
352 .end
= SPI_PHYS_BASE
+ SZ_512
- 1,
353 .flags
= IORESOURCE_MEM
,
357 static struct platform_device kirkwood_spi
= {
360 .resource
= kirkwood_spi_resources
,
362 .platform_data
= &kirkwood_spi_plat_data
,
364 .num_resources
= ARRAY_SIZE(kirkwood_spi_resources
),
367 void __init
kirkwood_spi_init()
369 platform_device_register(&kirkwood_spi
);
373 /*****************************************************************************
375 ****************************************************************************/
376 static struct plat_serial8250_port kirkwood_uart0_data
[] = {
378 .mapbase
= UART0_PHYS_BASE
,
379 .membase
= (char *)UART0_VIRT_BASE
,
380 .irq
= IRQ_KIRKWOOD_UART_0
,
381 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
389 static struct resource kirkwood_uart0_resources
[] = {
391 .start
= UART0_PHYS_BASE
,
392 .end
= UART0_PHYS_BASE
+ 0xff,
393 .flags
= IORESOURCE_MEM
,
395 .start
= IRQ_KIRKWOOD_UART_0
,
396 .end
= IRQ_KIRKWOOD_UART_0
,
397 .flags
= IORESOURCE_IRQ
,
401 static struct platform_device kirkwood_uart0
= {
402 .name
= "serial8250",
405 .platform_data
= kirkwood_uart0_data
,
407 .resource
= kirkwood_uart0_resources
,
408 .num_resources
= ARRAY_SIZE(kirkwood_uart0_resources
),
411 void __init
kirkwood_uart0_init(void)
413 platform_device_register(&kirkwood_uart0
);
417 /*****************************************************************************
419 ****************************************************************************/
420 static struct plat_serial8250_port kirkwood_uart1_data
[] = {
422 .mapbase
= UART1_PHYS_BASE
,
423 .membase
= (char *)UART1_VIRT_BASE
,
424 .irq
= IRQ_KIRKWOOD_UART_1
,
425 .flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
,
433 static struct resource kirkwood_uart1_resources
[] = {
435 .start
= UART1_PHYS_BASE
,
436 .end
= UART1_PHYS_BASE
+ 0xff,
437 .flags
= IORESOURCE_MEM
,
439 .start
= IRQ_KIRKWOOD_UART_1
,
440 .end
= IRQ_KIRKWOOD_UART_1
,
441 .flags
= IORESOURCE_IRQ
,
445 static struct platform_device kirkwood_uart1
= {
446 .name
= "serial8250",
449 .platform_data
= kirkwood_uart1_data
,
451 .resource
= kirkwood_uart1_resources
,
452 .num_resources
= ARRAY_SIZE(kirkwood_uart1_resources
),
455 void __init
kirkwood_uart1_init(void)
457 platform_device_register(&kirkwood_uart1
);
461 /*****************************************************************************
463 ****************************************************************************/
464 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data
= {
465 .dram
= &kirkwood_mbus_dram_info
,
468 static u64 kirkwood_xor_dmamask
= DMA_32BIT_MASK
;
471 /*****************************************************************************
473 ****************************************************************************/
474 static struct resource kirkwood_xor0_shared_resources
[] = {
477 .start
= XOR0_PHYS_BASE
,
478 .end
= XOR0_PHYS_BASE
+ 0xff,
479 .flags
= IORESOURCE_MEM
,
481 .name
= "xor 0 high",
482 .start
= XOR0_HIGH_PHYS_BASE
,
483 .end
= XOR0_HIGH_PHYS_BASE
+ 0xff,
484 .flags
= IORESOURCE_MEM
,
488 static struct platform_device kirkwood_xor0_shared
= {
489 .name
= MV_XOR_SHARED_NAME
,
492 .platform_data
= &kirkwood_xor_shared_data
,
494 .num_resources
= ARRAY_SIZE(kirkwood_xor0_shared_resources
),
495 .resource
= kirkwood_xor0_shared_resources
,
498 static struct resource kirkwood_xor00_resources
[] = {
500 .start
= IRQ_KIRKWOOD_XOR_00
,
501 .end
= IRQ_KIRKWOOD_XOR_00
,
502 .flags
= IORESOURCE_IRQ
,
506 static struct mv_xor_platform_data kirkwood_xor00_data
= {
507 .shared
= &kirkwood_xor0_shared
,
509 .pool_size
= PAGE_SIZE
,
512 static struct platform_device kirkwood_xor00_channel
= {
515 .num_resources
= ARRAY_SIZE(kirkwood_xor00_resources
),
516 .resource
= kirkwood_xor00_resources
,
518 .dma_mask
= &kirkwood_xor_dmamask
,
519 .coherent_dma_mask
= DMA_64BIT_MASK
,
520 .platform_data
= (void *)&kirkwood_xor00_data
,
524 static struct resource kirkwood_xor01_resources
[] = {
526 .start
= IRQ_KIRKWOOD_XOR_01
,
527 .end
= IRQ_KIRKWOOD_XOR_01
,
528 .flags
= IORESOURCE_IRQ
,
532 static struct mv_xor_platform_data kirkwood_xor01_data
= {
533 .shared
= &kirkwood_xor0_shared
,
535 .pool_size
= PAGE_SIZE
,
538 static struct platform_device kirkwood_xor01_channel
= {
541 .num_resources
= ARRAY_SIZE(kirkwood_xor01_resources
),
542 .resource
= kirkwood_xor01_resources
,
544 .dma_mask
= &kirkwood_xor_dmamask
,
545 .coherent_dma_mask
= DMA_64BIT_MASK
,
546 .platform_data
= (void *)&kirkwood_xor01_data
,
550 static void __init
kirkwood_xor0_init(void)
552 platform_device_register(&kirkwood_xor0_shared
);
555 * two engines can't do memset simultaneously, this limitation
556 * satisfied by removing memset support from one of the engines.
558 dma_cap_set(DMA_MEMCPY
, kirkwood_xor00_data
.cap_mask
);
559 dma_cap_set(DMA_XOR
, kirkwood_xor00_data
.cap_mask
);
560 platform_device_register(&kirkwood_xor00_channel
);
562 dma_cap_set(DMA_MEMCPY
, kirkwood_xor01_data
.cap_mask
);
563 dma_cap_set(DMA_MEMSET
, kirkwood_xor01_data
.cap_mask
);
564 dma_cap_set(DMA_XOR
, kirkwood_xor01_data
.cap_mask
);
565 platform_device_register(&kirkwood_xor01_channel
);
569 /*****************************************************************************
571 ****************************************************************************/
572 static struct resource kirkwood_xor1_shared_resources
[] = {
575 .start
= XOR1_PHYS_BASE
,
576 .end
= XOR1_PHYS_BASE
+ 0xff,
577 .flags
= IORESOURCE_MEM
,
579 .name
= "xor 1 high",
580 .start
= XOR1_HIGH_PHYS_BASE
,
581 .end
= XOR1_HIGH_PHYS_BASE
+ 0xff,
582 .flags
= IORESOURCE_MEM
,
586 static struct platform_device kirkwood_xor1_shared
= {
587 .name
= MV_XOR_SHARED_NAME
,
590 .platform_data
= &kirkwood_xor_shared_data
,
592 .num_resources
= ARRAY_SIZE(kirkwood_xor1_shared_resources
),
593 .resource
= kirkwood_xor1_shared_resources
,
596 static struct resource kirkwood_xor10_resources
[] = {
598 .start
= IRQ_KIRKWOOD_XOR_10
,
599 .end
= IRQ_KIRKWOOD_XOR_10
,
600 .flags
= IORESOURCE_IRQ
,
604 static struct mv_xor_platform_data kirkwood_xor10_data
= {
605 .shared
= &kirkwood_xor1_shared
,
607 .pool_size
= PAGE_SIZE
,
610 static struct platform_device kirkwood_xor10_channel
= {
613 .num_resources
= ARRAY_SIZE(kirkwood_xor10_resources
),
614 .resource
= kirkwood_xor10_resources
,
616 .dma_mask
= &kirkwood_xor_dmamask
,
617 .coherent_dma_mask
= DMA_64BIT_MASK
,
618 .platform_data
= (void *)&kirkwood_xor10_data
,
622 static struct resource kirkwood_xor11_resources
[] = {
624 .start
= IRQ_KIRKWOOD_XOR_11
,
625 .end
= IRQ_KIRKWOOD_XOR_11
,
626 .flags
= IORESOURCE_IRQ
,
630 static struct mv_xor_platform_data kirkwood_xor11_data
= {
631 .shared
= &kirkwood_xor1_shared
,
633 .pool_size
= PAGE_SIZE
,
636 static struct platform_device kirkwood_xor11_channel
= {
639 .num_resources
= ARRAY_SIZE(kirkwood_xor11_resources
),
640 .resource
= kirkwood_xor11_resources
,
642 .dma_mask
= &kirkwood_xor_dmamask
,
643 .coherent_dma_mask
= DMA_64BIT_MASK
,
644 .platform_data
= (void *)&kirkwood_xor11_data
,
648 static void __init
kirkwood_xor1_init(void)
650 platform_device_register(&kirkwood_xor1_shared
);
653 * two engines can't do memset simultaneously, this limitation
654 * satisfied by removing memset support from one of the engines.
656 dma_cap_set(DMA_MEMCPY
, kirkwood_xor10_data
.cap_mask
);
657 dma_cap_set(DMA_XOR
, kirkwood_xor10_data
.cap_mask
);
658 platform_device_register(&kirkwood_xor10_channel
);
660 dma_cap_set(DMA_MEMCPY
, kirkwood_xor11_data
.cap_mask
);
661 dma_cap_set(DMA_MEMSET
, kirkwood_xor11_data
.cap_mask
);
662 dma_cap_set(DMA_XOR
, kirkwood_xor11_data
.cap_mask
);
663 platform_device_register(&kirkwood_xor11_channel
);
667 /*****************************************************************************
669 ****************************************************************************/
672 int __init
kirkwood_find_tclk(void)
676 kirkwood_pcie_id(&dev
, &rev
);
677 if (dev
== MV88F6281_DEV_ID
&& rev
== MV88F6281_REV_A0
)
683 static void kirkwood_timer_init(void)
685 kirkwood_tclk
= kirkwood_find_tclk();
686 orion_time_init(IRQ_KIRKWOOD_BRIDGE
, kirkwood_tclk
);
689 struct sys_timer kirkwood_timer
= {
690 .init
= kirkwood_timer_init
,
694 /*****************************************************************************
696 ****************************************************************************/
698 * Identify device ID and revision.
700 static char * __init
kirkwood_id(void)
704 kirkwood_pcie_id(&dev
, &rev
);
706 if (dev
== MV88F6281_DEV_ID
) {
707 if (rev
== MV88F6281_REV_Z0
)
708 return "MV88F6281-Z0";
709 else if (rev
== MV88F6281_REV_A0
)
710 return "MV88F6281-A0";
712 return "MV88F6281-Rev-Unsupported";
713 } else if (dev
== MV88F6192_DEV_ID
) {
714 if (rev
== MV88F6192_REV_Z0
)
715 return "MV88F6192-Z0";
716 else if (rev
== MV88F6192_REV_A0
)
717 return "MV88F6192-A0";
719 return "MV88F6192-Rev-Unsupported";
720 } else if (dev
== MV88F6180_DEV_ID
) {
721 if (rev
== MV88F6180_REV_A0
)
722 return "MV88F6180-Rev-A0";
724 return "MV88F6180-Rev-Unsupported";
726 return "Device-Unknown";
730 static void __init
kirkwood_l2_init(void)
732 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
733 writel(readl(L2_CONFIG_REG
) | L2_WRITETHROUGH
, L2_CONFIG_REG
);
736 writel(readl(L2_CONFIG_REG
) & ~L2_WRITETHROUGH
, L2_CONFIG_REG
);
741 void __init
kirkwood_init(void)
743 printk(KERN_INFO
"Kirkwood: %s, TCLK=%d.\n",
744 kirkwood_id(), kirkwood_tclk
);
745 kirkwood_ge00_shared_data
.t_clk
= kirkwood_tclk
;
746 kirkwood_ge01_shared_data
.t_clk
= kirkwood_tclk
;
747 kirkwood_spi_plat_data
.tclk
= kirkwood_tclk
;
748 kirkwood_uart0_data
[0].uartclk
= kirkwood_tclk
;
749 kirkwood_uart1_data
[0].uartclk
= kirkwood_tclk
;
751 kirkwood_setup_cpu_mbus();
753 #ifdef CONFIG_CACHE_FEROCEON_L2
757 /* internal devices that every board has */
759 kirkwood_xor0_init();
760 kirkwood_xor1_init();