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/mv_xor.h>
28 #include <plat/orion_nand.h>
29 #include <plat/time.h>
32 /*****************************************************************************
34 ****************************************************************************/
35 static struct map_desc kirkwood_io_desc[] __initdata = {
37 .virtual = KIRKWOOD_PCIE_IO_VIRT_BASE,
38 .pfn = __phys_to_pfn(KIRKWOOD_PCIE_IO_PHYS_BASE),
39 .length = KIRKWOOD_PCIE_IO_SIZE,
42 .virtual = KIRKWOOD_REGS_VIRT_BASE,
43 .pfn = __phys_to_pfn(KIRKWOOD_REGS_PHYS_BASE),
44 .length = KIRKWOOD_REGS_SIZE,
49 void __init kirkwood_map_io(void)
51 iotable_init(kirkwood_io_desc, ARRAY_SIZE(kirkwood_io_desc));
55 /*****************************************************************************
57 ****************************************************************************/
58 static struct orion_ehci_data kirkwood_ehci_data = {
59 .dram = &kirkwood_mbus_dram_info,
60 .phy_version = EHCI_PHY_NA,
63 static u64 ehci_dmamask = 0xffffffffUL;
66 /*****************************************************************************
68 ****************************************************************************/
69 static struct resource kirkwood_ehci_resources[] = {
71 .start = USB_PHYS_BASE,
72 .end = USB_PHYS_BASE + 0x0fff,
73 .flags = IORESOURCE_MEM,
75 .start = IRQ_KIRKWOOD_USB,
76 .end = IRQ_KIRKWOOD_USB,
77 .flags = IORESOURCE_IRQ,
81 static struct platform_device kirkwood_ehci = {
85 .dma_mask = &ehci_dmamask,
86 .coherent_dma_mask = 0xffffffff,
87 .platform_data = &kirkwood_ehci_data,
89 .resource = kirkwood_ehci_resources,
90 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
93 void __init kirkwood_ehci_init(void)
95 platform_device_register(&kirkwood_ehci);
99 /*****************************************************************************
101 ****************************************************************************/
102 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
103 .dram = &kirkwood_mbus_dram_info,
106 static struct resource kirkwood_ge00_shared_resources[] = {
109 .start = GE00_PHYS_BASE + 0x2000,
110 .end = GE00_PHYS_BASE + 0x3fff,
111 .flags = IORESOURCE_MEM,
113 .name = "ge00 err irq",
114 .start = IRQ_KIRKWOOD_GE00_ERR,
115 .end = IRQ_KIRKWOOD_GE00_ERR,
116 .flags = IORESOURCE_IRQ,
120 static struct platform_device kirkwood_ge00_shared = {
121 .name = MV643XX_ETH_SHARED_NAME,
124 .platform_data = &kirkwood_ge00_shared_data,
126 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
127 .resource = kirkwood_ge00_shared_resources,
130 static struct resource kirkwood_ge00_resources[] = {
133 .start = IRQ_KIRKWOOD_GE00_SUM,
134 .end = IRQ_KIRKWOOD_GE00_SUM,
135 .flags = IORESOURCE_IRQ,
139 static struct platform_device kirkwood_ge00 = {
140 .name = MV643XX_ETH_NAME,
143 .resource = kirkwood_ge00_resources,
146 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
148 eth_data->shared = &kirkwood_ge00_shared;
149 kirkwood_ge00.dev.platform_data = eth_data;
151 platform_device_register(&kirkwood_ge00_shared);
152 platform_device_register(&kirkwood_ge00);
156 /*****************************************************************************
158 ****************************************************************************/
159 struct mv643xx_eth_shared_platform_data kirkwood_ge01_shared_data = {
160 .dram = &kirkwood_mbus_dram_info,
161 .shared_smi = &kirkwood_ge00_shared,
164 static struct resource kirkwood_ge01_shared_resources[] = {
167 .start = GE01_PHYS_BASE + 0x2000,
168 .end = GE01_PHYS_BASE + 0x3fff,
169 .flags = IORESOURCE_MEM,
171 .name = "ge01 err irq",
172 .start = IRQ_KIRKWOOD_GE01_ERR,
173 .end = IRQ_KIRKWOOD_GE01_ERR,
174 .flags = IORESOURCE_IRQ,
178 static struct platform_device kirkwood_ge01_shared = {
179 .name = MV643XX_ETH_SHARED_NAME,
182 .platform_data = &kirkwood_ge01_shared_data,
184 .num_resources = ARRAY_SIZE(kirkwood_ge01_shared_resources),
185 .resource = kirkwood_ge01_shared_resources,
188 static struct resource kirkwood_ge01_resources[] = {
191 .start = IRQ_KIRKWOOD_GE01_SUM,
192 .end = IRQ_KIRKWOOD_GE01_SUM,
193 .flags = IORESOURCE_IRQ,
197 static struct platform_device kirkwood_ge01 = {
198 .name = MV643XX_ETH_NAME,
201 .resource = kirkwood_ge01_resources,
204 void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
206 eth_data->shared = &kirkwood_ge01_shared;
207 kirkwood_ge01.dev.platform_data = eth_data;
209 platform_device_register(&kirkwood_ge01_shared);
210 platform_device_register(&kirkwood_ge01);
214 /*****************************************************************************
216 ****************************************************************************/
217 static struct resource kirkwood_switch_resources[] = {
221 .flags = IORESOURCE_IRQ,
225 static struct platform_device kirkwood_switch_device = {
229 .resource = kirkwood_switch_resources,
232 void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
237 kirkwood_switch_resources[0].start = irq;
238 kirkwood_switch_resources[0].end = irq;
239 kirkwood_switch_device.num_resources = 1;
242 d->netdev = &kirkwood_ge00.dev;
243 for (i = 0; i < d->nr_chips; i++)
244 d->chip[i].mii_bus = &kirkwood_ge00_shared.dev;
245 kirkwood_switch_device.dev.platform_data = d;
247 platform_device_register(&kirkwood_switch_device);
251 /*****************************************************************************
253 ****************************************************************************/
254 static struct resource kirkwood_rtc_resource = {
255 .start = RTC_PHYS_BASE,
256 .end = RTC_PHYS_BASE + SZ_16 - 1,
257 .flags = IORESOURCE_MEM,
260 void __init kirkwood_rtc_init(void)
262 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
266 /*****************************************************************************
268 ****************************************************************************/
269 static struct resource kirkwood_sata_resources[] = {
272 .start = SATA_PHYS_BASE,
273 .end = SATA_PHYS_BASE + 0x5000 - 1,
274 .flags = IORESOURCE_MEM,
277 .start = IRQ_KIRKWOOD_SATA,
278 .end = IRQ_KIRKWOOD_SATA,
279 .flags = IORESOURCE_IRQ,
283 static struct platform_device kirkwood_sata = {
287 .coherent_dma_mask = 0xffffffff,
289 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
290 .resource = kirkwood_sata_resources,
293 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
295 sata_data->dram = &kirkwood_mbus_dram_info;
296 kirkwood_sata.dev.platform_data = sata_data;
297 platform_device_register(&kirkwood_sata);
301 /*****************************************************************************
303 ****************************************************************************/
304 static struct orion_spi_info kirkwood_spi_plat_data = {
307 static struct resource kirkwood_spi_resources[] = {
309 .start = SPI_PHYS_BASE,
310 .end = SPI_PHYS_BASE + SZ_512 - 1,
311 .flags = IORESOURCE_MEM,
315 static struct platform_device kirkwood_spi = {
318 .resource = kirkwood_spi_resources,
320 .platform_data = &kirkwood_spi_plat_data,
322 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
325 void __init kirkwood_spi_init()
327 platform_device_register(&kirkwood_spi);
331 /*****************************************************************************
333 ****************************************************************************/
334 static struct plat_serial8250_port kirkwood_uart0_data[] = {
336 .mapbase = UART0_PHYS_BASE,
337 .membase = (char *)UART0_VIRT_BASE,
338 .irq = IRQ_KIRKWOOD_UART_0,
339 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
347 static struct resource kirkwood_uart0_resources[] = {
349 .start = UART0_PHYS_BASE,
350 .end = UART0_PHYS_BASE + 0xff,
351 .flags = IORESOURCE_MEM,
353 .start = IRQ_KIRKWOOD_UART_0,
354 .end = IRQ_KIRKWOOD_UART_0,
355 .flags = IORESOURCE_IRQ,
359 static struct platform_device kirkwood_uart0 = {
360 .name = "serial8250",
363 .platform_data = kirkwood_uart0_data,
365 .resource = kirkwood_uart0_resources,
366 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
369 void __init kirkwood_uart0_init(void)
371 platform_device_register(&kirkwood_uart0);
375 /*****************************************************************************
377 ****************************************************************************/
378 static struct plat_serial8250_port kirkwood_uart1_data[] = {
380 .mapbase = UART1_PHYS_BASE,
381 .membase = (char *)UART1_VIRT_BASE,
382 .irq = IRQ_KIRKWOOD_UART_1,
383 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
391 static struct resource kirkwood_uart1_resources[] = {
393 .start = UART1_PHYS_BASE,
394 .end = UART1_PHYS_BASE + 0xff,
395 .flags = IORESOURCE_MEM,
397 .start = IRQ_KIRKWOOD_UART_1,
398 .end = IRQ_KIRKWOOD_UART_1,
399 .flags = IORESOURCE_IRQ,
403 static struct platform_device kirkwood_uart1 = {
404 .name = "serial8250",
407 .platform_data = kirkwood_uart1_data,
409 .resource = kirkwood_uart1_resources,
410 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
413 void __init kirkwood_uart1_init(void)
415 platform_device_register(&kirkwood_uart1);
419 /*****************************************************************************
421 ****************************************************************************/
422 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
423 .dram = &kirkwood_mbus_dram_info,
426 static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
429 /*****************************************************************************
431 ****************************************************************************/
432 static struct resource kirkwood_xor0_shared_resources[] = {
435 .start = XOR0_PHYS_BASE,
436 .end = XOR0_PHYS_BASE + 0xff,
437 .flags = IORESOURCE_MEM,
439 .name = "xor 0 high",
440 .start = XOR0_HIGH_PHYS_BASE,
441 .end = XOR0_HIGH_PHYS_BASE + 0xff,
442 .flags = IORESOURCE_MEM,
446 static struct platform_device kirkwood_xor0_shared = {
447 .name = MV_XOR_SHARED_NAME,
450 .platform_data = &kirkwood_xor_shared_data,
452 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
453 .resource = kirkwood_xor0_shared_resources,
456 static struct resource kirkwood_xor00_resources[] = {
458 .start = IRQ_KIRKWOOD_XOR_00,
459 .end = IRQ_KIRKWOOD_XOR_00,
460 .flags = IORESOURCE_IRQ,
464 static struct mv_xor_platform_data kirkwood_xor00_data = {
465 .shared = &kirkwood_xor0_shared,
467 .pool_size = PAGE_SIZE,
470 static struct platform_device kirkwood_xor00_channel = {
473 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
474 .resource = kirkwood_xor00_resources,
476 .dma_mask = &kirkwood_xor_dmamask,
477 .coherent_dma_mask = DMA_64BIT_MASK,
478 .platform_data = (void *)&kirkwood_xor00_data,
482 static struct resource kirkwood_xor01_resources[] = {
484 .start = IRQ_KIRKWOOD_XOR_01,
485 .end = IRQ_KIRKWOOD_XOR_01,
486 .flags = IORESOURCE_IRQ,
490 static struct mv_xor_platform_data kirkwood_xor01_data = {
491 .shared = &kirkwood_xor0_shared,
493 .pool_size = PAGE_SIZE,
496 static struct platform_device kirkwood_xor01_channel = {
499 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
500 .resource = kirkwood_xor01_resources,
502 .dma_mask = &kirkwood_xor_dmamask,
503 .coherent_dma_mask = DMA_64BIT_MASK,
504 .platform_data = (void *)&kirkwood_xor01_data,
508 void __init kirkwood_xor0_init(void)
510 platform_device_register(&kirkwood_xor0_shared);
513 * two engines can't do memset simultaneously, this limitation
514 * satisfied by removing memset support from one of the engines.
516 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
517 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
518 platform_device_register(&kirkwood_xor00_channel);
520 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
521 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
522 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
523 platform_device_register(&kirkwood_xor01_channel);
527 /*****************************************************************************
529 ****************************************************************************/
530 static struct resource kirkwood_xor1_shared_resources[] = {
533 .start = XOR1_PHYS_BASE,
534 .end = XOR1_PHYS_BASE + 0xff,
535 .flags = IORESOURCE_MEM,
537 .name = "xor 1 high",
538 .start = XOR1_HIGH_PHYS_BASE,
539 .end = XOR1_HIGH_PHYS_BASE + 0xff,
540 .flags = IORESOURCE_MEM,
544 static struct platform_device kirkwood_xor1_shared = {
545 .name = MV_XOR_SHARED_NAME,
548 .platform_data = &kirkwood_xor_shared_data,
550 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
551 .resource = kirkwood_xor1_shared_resources,
554 static struct resource kirkwood_xor10_resources[] = {
556 .start = IRQ_KIRKWOOD_XOR_10,
557 .end = IRQ_KIRKWOOD_XOR_10,
558 .flags = IORESOURCE_IRQ,
562 static struct mv_xor_platform_data kirkwood_xor10_data = {
563 .shared = &kirkwood_xor1_shared,
565 .pool_size = PAGE_SIZE,
568 static struct platform_device kirkwood_xor10_channel = {
571 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
572 .resource = kirkwood_xor10_resources,
574 .dma_mask = &kirkwood_xor_dmamask,
575 .coherent_dma_mask = DMA_64BIT_MASK,
576 .platform_data = (void *)&kirkwood_xor10_data,
580 static struct resource kirkwood_xor11_resources[] = {
582 .start = IRQ_KIRKWOOD_XOR_11,
583 .end = IRQ_KIRKWOOD_XOR_11,
584 .flags = IORESOURCE_IRQ,
588 static struct mv_xor_platform_data kirkwood_xor11_data = {
589 .shared = &kirkwood_xor1_shared,
591 .pool_size = PAGE_SIZE,
594 static struct platform_device kirkwood_xor11_channel = {
597 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
598 .resource = kirkwood_xor11_resources,
600 .dma_mask = &kirkwood_xor_dmamask,
601 .coherent_dma_mask = DMA_64BIT_MASK,
602 .platform_data = (void *)&kirkwood_xor11_data,
606 void __init kirkwood_xor1_init(void)
608 platform_device_register(&kirkwood_xor1_shared);
611 * two engines can't do memset simultaneously, this limitation
612 * satisfied by removing memset support from one of the engines.
614 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
615 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
616 platform_device_register(&kirkwood_xor10_channel);
618 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
619 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
620 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
621 platform_device_register(&kirkwood_xor11_channel);
625 /*****************************************************************************
627 ****************************************************************************/
630 int __init kirkwood_find_tclk(void)
634 kirkwood_pcie_id(&dev, &rev);
635 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
641 static void kirkwood_timer_init(void)
643 kirkwood_tclk = kirkwood_find_tclk();
644 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
647 struct sys_timer kirkwood_timer = {
648 .init = kirkwood_timer_init,
652 /*****************************************************************************
654 ****************************************************************************/
656 * Identify device ID and revision.
658 static char * __init kirkwood_id(void)
662 kirkwood_pcie_id(&dev, &rev);
664 if (dev == MV88F6281_DEV_ID) {
665 if (rev == MV88F6281_REV_Z0)
666 return "MV88F6281-Z0";
667 else if (rev == MV88F6281_REV_A0)
668 return "MV88F6281-A0";
670 return "MV88F6281-Rev-Unsupported";
671 } else if (dev == MV88F6192_DEV_ID) {
672 if (rev == MV88F6192_REV_Z0)
673 return "MV88F6192-Z0";
674 else if (rev == MV88F6192_REV_A0)
675 return "MV88F6192-A0";
677 return "MV88F6192-Rev-Unsupported";
678 } else if (dev == MV88F6180_DEV_ID) {
679 if (rev == MV88F6180_REV_A0)
680 return "MV88F6180-Rev-A0";
682 return "MV88F6180-Rev-Unsupported";
684 return "Device-Unknown";
688 static void __init kirkwood_l2_init(void)
690 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
691 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
694 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
699 void __init kirkwood_init(void)
701 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
702 kirkwood_id(), kirkwood_tclk);
703 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
704 kirkwood_ge01_shared_data.t_clk = kirkwood_tclk;
705 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
706 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
707 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
709 kirkwood_setup_cpu_mbus();
711 #ifdef CONFIG_CACHE_FEROCEON_L2