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/mv643xx_i2c.h>
18 #include <linux/ata_platform.h>
19 #include <linux/spi/orion_spi.h>
22 #include <asm/timex.h>
23 #include <asm/mach/map.h>
24 #include <asm/mach/time.h>
25 #include <mach/kirkwood.h>
26 #include <mach/bridge-regs.h>
27 #include <plat/cache-feroceon-l2.h>
28 #include <plat/ehci-orion.h>
29 #include <plat/mvsdio.h>
30 #include <plat/mv_xor.h>
31 #include <plat/orion_nand.h>
32 #include <plat/time.h>
35 /*****************************************************************************
37 ****************************************************************************/
38 static struct map_desc kirkwood_io_desc[] __initdata = {
40 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
41 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
42 .length = KIRKWOOD_PCIE_IO_SIZE,
45 .virtual = KIRKWOOD_REGS_VIRT_BASE,
46 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
47 .length = KIRKWOOD_REGS_SIZE,
52 void __init kirkwood_map_io(void)
54 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
58 /*****************************************************************************
60 ****************************************************************************/
61 static struct orion_ehci_data kirkwood_ehci_data = {
62 .dram = &kirkwood_mbus_dram_info,
63 .phy_version = EHCI_PHY_NA,
66 static u64 ehci_dmamask = 0xffffffffUL;
69 /*****************************************************************************
71 ****************************************************************************/
72 static struct resource kirkwood_ehci_resources[] = {
74 .start = USB_PHYS_BASE,
75 .end = USB_PHYS_BASE + 0x0fff,
76 .flags = IORESOURCE_MEM,
78 .start = IRQ_KIRKWOOD_USB,
79 .end = IRQ_KIRKWOOD_USB,
80 .flags = IORESOURCE_IRQ,
84 static struct platform_device kirkwood_ehci = {
88 .dma_mask = &ehci_dmamask,
89 .coherent_dma_mask = 0xffffffff,
90 .platform_data = &kirkwood_ehci_data,
92 .resource = kirkwood_ehci_resources,
93 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
96 void __init kirkwood_ehci_init(void)
98 platform_device_register(&kirkwood_ehci);
102 /*****************************************************************************
104 ****************************************************************************/
105 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
106 .dram = &kirkwood_mbus_dram_info,
109 static struct resource kirkwood_ge00_shared_resources[] = {
112 .start = GE00_PHYS_BASE + 0x2000,
113 .end = GE00_PHYS_BASE + 0x3fff,
114 .flags = IORESOURCE_MEM,
116 .name = "ge00 err irq",
117 .start = IRQ_KIRKWOOD_GE00_ERR,
118 .end = IRQ_KIRKWOOD_GE00_ERR,
119 .flags = IORESOURCE_IRQ,
123 static struct platform_device kirkwood_ge00_shared = {
124 .name = MV643XX_ETH_SHARED_NAME,
127 .platform_data = &kirkwood_ge00_shared_data,
129 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
130 .resource = kirkwood_ge00_shared_resources,
133 static struct resource kirkwood_ge00_resources[] = {
136 .start = IRQ_KIRKWOOD_GE00_SUM,
137 .end = IRQ_KIRKWOOD_GE00_SUM,
138 .flags = IORESOURCE_IRQ,
142 static struct platform_device kirkwood_ge00 = {
143 .name = MV643XX_ETH_NAME,
146 .resource = kirkwood_ge00_resources,
149 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
151 eth_data->shared = &kirkwood_ge00_shared;
152 kirkwood_ge00.dev.platform_data = eth_data;
154 platform_device_register(&kirkwood_ge00_shared);
155 platform_device_register(&kirkwood_ge00);
159 /*****************************************************************************
161 ****************************************************************************/
162 struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
163 .dram = &kirkwood_mbus_dram_info,
164 .shared_smi = &kirkwood_ge00_shared,
167 static struct resource kirkwood_ge01_shared_resources[] = {
170 .start = GE01_PHYS_BASE + 0x2000,
171 .end = GE01_PHYS_BASE + 0x3fff,
172 .flags = IORESOURCE_MEM,
174 .name = "ge01 err irq",
175 .start = IRQ_KIRKWOOD_GE01_ERR,
176 .end = IRQ_KIRKWOOD_GE01_ERR,
177 .flags = IORESOURCE_IRQ,
181 static struct platform_device kirkwood_ge01_shared = {
182 .name = MV643XX_ETH_SHARED_NAME,
185 .platform_data = &kirkwood_ge01_shared_data,
187 .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
188 .resource = kirkwood_ge01_shared_resources,
191 static struct resource kirkwood_ge01_resources[] = {
194 .start = IRQ_KIRKWOOD_GE01_SUM,
195 .end = IRQ_KIRKWOOD_GE01_SUM,
196 .flags = IORESOURCE_IRQ,
200 static struct platform_device kirkwood_ge01 = {
201 .name = MV643XX_ETH_NAME,
204 .resource = kirkwood_ge01_resources,
207 void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
209 eth_data->shared = &kirkwood_ge01_shared;
210 kirkwood_ge01.dev.platform_data = eth_data;
212 platform_device_register(&kirkwood_ge01_shared);
213 platform_device_register(&kirkwood_ge01);
217 /*****************************************************************************
219 ****************************************************************************/
220 static struct resource kirkwood_switch_resources[] = {
224 .flags = IORESOURCE_IRQ,
228 static struct platform_device kirkwood_switch_device = {
232 .resource = kirkwood_switch_resources,
235 void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
240 kirkwood_switch_resources[0].start = irq;
241 kirkwood_switch_resources[0].end = irq;
242 kirkwood_switch_device.num_resources = 1;
245 d->netdev = &kirkwood_ge00.dev;
246 for (i = 0; i < d->nr_chips; i++)
247 d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
248 kirkwood_switch_device.dev.platform_data = d;
250 platform_device_register(&kirkwood_switch_device);
254 /*****************************************************************************
256 ****************************************************************************/
257 static struct resource kirkwood_rtc_resource = {
258 .start = RTC_PHYS_BASE,
259 .end = RTC_PHYS_BASE + SZ_16 - 1,
260 .flags = IORESOURCE_MEM,
263 static void __init kirkwood_rtc_init(void)
265 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
269 /*****************************************************************************
271 ****************************************************************************/
272 static struct resource kirkwood_sata_resources[] = {
275 .start = SATA_PHYS_BASE,
276 .end = SATA_PHYS_BASE + 0x5000 - 1,
277 .flags = IORESOURCE_MEM,
280 .start = IRQ_KIRKWOOD_SATA,
281 .end = IRQ_KIRKWOOD_SATA,
282 .flags = IORESOURCE_IRQ,
286 static struct platform_device kirkwood_sata = {
290 .coherent_dma_mask = 0xffffffff,
292 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
293 .resource = kirkwood_sata_resources,
296 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
298 sata_data->dram = &kirkwood_mbus_dram_info;
299 kirkwood_sata.dev.platform_data = sata_data;
300 platform_device_register(&kirkwood_sata);
304 /*****************************************************************************
306 ****************************************************************************/
307 static struct resource mvsdio_resources[] = {
309 .start = SDIO_PHYS_BASE,
310 .end = SDIO_PHYS_BASE + SZ_1K - 1,
311 .flags = IORESOURCE_MEM,
314 .start = IRQ_KIRKWOOD_SDIO,
315 .end = IRQ_KIRKWOOD_SDIO,
316 .flags = IORESOURCE_IRQ,
320 static u64 mvsdio_dmamask = 0xffffffffUL;
322 static struct platform_device kirkwood_sdio = {
326 .dma_mask = &mvsdio_dmamask,
327 .coherent_dma_mask = 0xffffffff,
329 .num_resources = ARRAY_SIZE(mvsdio_resources),
330 .resource = mvsdio_resources,
333 void __init kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data)
337 kirkwood_pcie_id(&dev, &rev);
338 if (rev == 0) /* catch all Kirkwood Z0's */
339 mvsdio_data->clock = 100000000;
341 mvsdio_data->clock = 200000000;
342 mvsdio_data->dram = &kirkwood_mbus_dram_info;
343 kirkwood_sdio.dev.platform_data = mvsdio_data;
344 platform_device_register(&kirkwood_sdio);
348 /*****************************************************************************
350 ****************************************************************************/
351 static struct orion_spi_info kirkwood_spi_plat_data = {
354 static struct resource kirkwood_spi_resources[] = {
356 .start = SPI_PHYS_BASE,
357 .end = SPI_PHYS_BASE + SZ_512 - 1,
358 .flags = IORESOURCE_MEM,
362 static struct platform_device kirkwood_spi = {
365 .resource = kirkwood_spi_resources,
367 .platform_data = &kirkwood_spi_plat_data,
369 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
372 void __init kirkwood_spi_init()
374 platform_device_register(&kirkwood_spi);
378 /*****************************************************************************
380 ****************************************************************************/
381 static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = {
382 .freq_m = 8, /* assumes 166 MHz TCLK */
384 .timeout = 1000, /* Default timeout of 1 second */
387 static struct resource kirkwood_i2c_resources[] = {
389 .start = I2C_PHYS_BASE,
390 .end = I2C_PHYS_BASE + 0x1f,
391 .flags = IORESOURCE_MEM,
393 .start = IRQ_KIRKWOOD_TWSI,
394 .end = IRQ_KIRKWOOD_TWSI,
395 .flags = IORESOURCE_IRQ,
399 static struct platform_device kirkwood_i2c = {
400 .name = MV64XXX_I2C_CTLR_NAME,
402 .num_resources = ARRAY_SIZE(kirkwood_i2c_resources),
403 .resource = kirkwood_i2c_resources,
405 .platform_data = &kirkwood_i2c_pdata,
409 void __init kirkwood_i2c_init(void)
411 platform_device_register(&kirkwood_i2c);
415 /*****************************************************************************
417 ****************************************************************************/
418 static struct plat_serial8250_port kirkwood_uart0_data[] = {
420 .mapbase = UART0_PHYS_BASE,
421 .membase = (char *)UART0_VIRT_BASE,
422 .irq = IRQ_KIRKWOOD_UART_0,
423 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
431 static struct resource kirkwood_uart0_resources[] = {
433 .start = UART0_PHYS_BASE,
434 .end = UART0_PHYS_BASE + 0xff,
435 .flags = IORESOURCE_MEM,
437 .start = IRQ_KIRKWOOD_UART_0,
438 .end = IRQ_KIRKWOOD_UART_0,
439 .flags = IORESOURCE_IRQ,
443 static struct platform_device kirkwood_uart0 = {
444 .name = "serial8250",
447 .platform_data = kirkwood_uart0_data,
449 .resource = kirkwood_uart0_resources,
450 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
453 void __init kirkwood_uart0_init(void)
455 platform_device_register(&kirkwood_uart0);
459 /*****************************************************************************
461 ****************************************************************************/
462 static struct plat_serial8250_port kirkwood_uart1_data[] = {
464 .mapbase = UART1_PHYS_BASE,
465 .membase = (char *)UART1_VIRT_BASE,
466 .irq = IRQ_KIRKWOOD_UART_1,
467 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
475 static struct resource kirkwood_uart1_resources[] = {
477 .start = UART1_PHYS_BASE,
478 .end = UART1_PHYS_BASE + 0xff,
479 .flags = IORESOURCE_MEM,
481 .start = IRQ_KIRKWOOD_UART_1,
482 .end = IRQ_KIRKWOOD_UART_1,
483 .flags = IORESOURCE_IRQ,
487 static struct platform_device kirkwood_uart1 = {
488 .name = "serial8250",
491 .platform_data = kirkwood_uart1_data,
493 .resource = kirkwood_uart1_resources,
494 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
497 void __init kirkwood_uart1_init(void)
499 platform_device_register(&kirkwood_uart1);
503 /*****************************************************************************
505 ****************************************************************************/
506 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
507 .dram = &kirkwood_mbus_dram_info,
510 static u64 kirkwood_xor_dmamask = DMA_BIT_MASK(32);
513 /*****************************************************************************
515 ****************************************************************************/
516 static struct resource kirkwood_xor0_shared_resources[] = {
519 .start = XOR0_PHYS_BASE,
520 .end = XOR0_PHYS_BASE + 0xff,
521 .flags = IORESOURCE_MEM,
523 .name = "xor 0 high",
524 .start = XOR0_HIGH_PHYS_BASE,
525 .end = XOR0_HIGH_PHYS_BASE + 0xff,
526 .flags = IORESOURCE_MEM,
530 static struct platform_device kirkwood_xor0_shared = {
531 .name = MV_XOR_SHARED_NAME,
534 .platform_data = &kirkwood_xor_shared_data,
536 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
537 .resource = kirkwood_xor0_shared_resources,
540 static struct resource kirkwood_xor00_resources[] = {
542 .start = IRQ_KIRKWOOD_XOR_00,
543 .end = IRQ_KIRKWOOD_XOR_00,
544 .flags = IORESOURCE_IRQ,
548 static struct mv_xor_platform_data kirkwood_xor00_data = {
549 .shared = &kirkwood_xor0_shared,
551 .pool_size = PAGE_SIZE,
554 static struct platform_device kirkwood_xor00_channel = {
557 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
558 .resource = kirkwood_xor00_resources,
560 .dma_mask = &kirkwood_xor_dmamask,
561 .coherent_dma_mask = DMA_BIT_MASK(64),
562 .platform_data = (void *)&kirkwood_xor00_data,
566 static struct resource kirkwood_xor01_resources[] = {
568 .start = IRQ_KIRKWOOD_XOR_01,
569 .end = IRQ_KIRKWOOD_XOR_01,
570 .flags = IORESOURCE_IRQ,
574 static struct mv_xor_platform_data kirkwood_xor01_data = {
575 .shared = &kirkwood_xor0_shared,
577 .pool_size = PAGE_SIZE,
580 static struct platform_device kirkwood_xor01_channel = {
583 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
584 .resource = kirkwood_xor01_resources,
586 .dma_mask = &kirkwood_xor_dmamask,
587 .coherent_dma_mask = DMA_BIT_MASK(64),
588 .platform_data = (void *)&kirkwood_xor01_data,
592 static void __init kirkwood_xor0_init(void)
594 platform_device_register(&kirkwood_xor0_shared);
597 * two engines can't do memset simultaneously, this limitation
598 * satisfied by removing memset support from one of the engines.
600 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
601 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
602 platform_device_register(&kirkwood_xor00_channel);
604 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
605 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
606 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
607 platform_device_register(&kirkwood_xor01_channel);
611 /*****************************************************************************
613 ****************************************************************************/
614 static struct resource kirkwood_xor1_shared_resources[] = {
617 .start = XOR1_PHYS_BASE,
618 .end = XOR1_PHYS_BASE + 0xff,
619 .flags = IORESOURCE_MEM,
621 .name = "xor 1 high",
622 .start = XOR1_HIGH_PHYS_BASE,
623 .end = XOR1_HIGH_PHYS_BASE + 0xff,
624 .flags = IORESOURCE_MEM,
628 static struct platform_device kirkwood_xor1_shared = {
629 .name = MV_XOR_SHARED_NAME,
632 .platform_data = &kirkwood_xor_shared_data,
634 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
635 .resource = kirkwood_xor1_shared_resources,
638 static struct resource kirkwood_xor10_resources[] = {
640 .start = IRQ_KIRKWOOD_XOR_10,
641 .end = IRQ_KIRKWOOD_XOR_10,
642 .flags = IORESOURCE_IRQ,
646 static struct mv_xor_platform_data kirkwood_xor10_data = {
647 .shared = &kirkwood_xor1_shared,
649 .pool_size = PAGE_SIZE,
652 static struct platform_device kirkwood_xor10_channel = {
655 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
656 .resource = kirkwood_xor10_resources,
658 .dma_mask = &kirkwood_xor_dmamask,
659 .coherent_dma_mask = DMA_BIT_MASK(64),
660 .platform_data = (void *)&kirkwood_xor10_data,
664 static struct resource kirkwood_xor11_resources[] = {
666 .start = IRQ_KIRKWOOD_XOR_11,
667 .end = IRQ_KIRKWOOD_XOR_11,
668 .flags = IORESOURCE_IRQ,
672 static struct mv_xor_platform_data kirkwood_xor11_data = {
673 .shared = &kirkwood_xor1_shared,
675 .pool_size = PAGE_SIZE,
678 static struct platform_device kirkwood_xor11_channel = {
681 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
682 .resource = kirkwood_xor11_resources,
684 .dma_mask = &kirkwood_xor_dmamask,
685 .coherent_dma_mask = DMA_BIT_MASK(64),
686 .platform_data = (void *)&kirkwood_xor11_data,
690 static void __init kirkwood_xor1_init(void)
692 platform_device_register(&kirkwood_xor1_shared);
695 * two engines can't do memset simultaneously, this limitation
696 * satisfied by removing memset support from one of the engines.
698 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
699 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
700 platform_device_register(&kirkwood_xor10_channel);
702 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
703 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
704 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
705 platform_device_register(&kirkwood_xor11_channel);
709 /*****************************************************************************
711 ****************************************************************************/
714 int __init kirkwood_find_tclk(void)
718 kirkwood_pcie_id(&dev, &rev);
719 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
725 static void kirkwood_timer_init(void)
727 kirkwood_tclk = kirkwood_find_tclk();
728 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
731 struct sys_timer kirkwood_timer = {
732 .init = kirkwood_timer_init,
736 /*****************************************************************************
738 ****************************************************************************/
740 * Identify device ID and revision.
742 static char * __init kirkwood_id(void)
746 kirkwood_pcie_id(&dev, &rev);
748 if (dev == MV88F6281_DEV_ID) {
749 if (rev == MV88F6281_REV_Z0)
750 return "MV88F6281-Z0";
751 else if (rev == MV88F6281_REV_A0)
752 return "MV88F6281-A0";
754 return "MV88F6281-Rev-Unsupported";
755 } else if (dev == MV88F6192_DEV_ID) {
756 if (rev == MV88F6192_REV_Z0)
757 return "MV88F6192-Z0";
758 else if (rev == MV88F6192_REV_A0)
759 return "MV88F6192-A0";
761 return "MV88F6192-Rev-Unsupported";
762 } else if (dev == MV88F6180_DEV_ID) {
763 if (rev == MV88F6180_REV_A0)
764 return "MV88F6180-Rev-A0";
766 return "MV88F6180-Rev-Unsupported";
768 return "Device-Unknown";
772 static void __init kirkwood_l2_init(void)
774 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
775 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
778 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
783 void __init kirkwood_init(void)
785 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
786 kirkwood_id(), kirkwood_tclk);
787 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
788 kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
789 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
790 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
791 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
793 kirkwood_setup_cpu_mbus();
795 #ifdef CONFIG_CACHE_FEROCEON_L2
799 /* internal devices that every board has */
801 kirkwood_xor0_init();
802 kirkwood_xor1_init();