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 static struct resource kirkwood_switch_resources[] = {
163 .flags = IORESOURCE_IRQ,
167 static struct platform_device kirkwood_switch_device = {
171 .resource = kirkwood_switch_resources,
174 void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
177 kirkwood_switch_resources[0].start = irq;
178 kirkwood_switch_resources[0].end = irq;
179 kirkwood_switch_device.num_resources = 1;
182 d->mii_bus = &kirkwood_ge00_shared.dev;
183 d->netdev = &kirkwood_ge00.dev;
184 kirkwood_switch_device.dev.platform_data = d;
186 platform_device_register(&kirkwood_switch_device);
190 /*****************************************************************************
192 ****************************************************************************/
193 static struct resource kirkwood_rtc_resource = {
194 .start = RTC_PHYS_BASE,
195 .end = RTC_PHYS_BASE + SZ_16 - 1,
196 .flags = IORESOURCE_MEM,
199 void __init kirkwood_rtc_init(void)
201 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
205 /*****************************************************************************
207 ****************************************************************************/
208 static struct resource kirkwood_sata_resources[] = {
211 .start = SATA_PHYS_BASE,
212 .end = SATA_PHYS_BASE + 0x5000 - 1,
213 .flags = IORESOURCE_MEM,
216 .start = IRQ_KIRKWOOD_SATA,
217 .end = IRQ_KIRKWOOD_SATA,
218 .flags = IORESOURCE_IRQ,
222 static struct platform_device kirkwood_sata = {
226 .coherent_dma_mask = 0xffffffff,
228 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
229 .resource = kirkwood_sata_resources,
232 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
234 sata_data->dram = &kirkwood_mbus_dram_info;
235 kirkwood_sata.dev.platform_data = sata_data;
236 platform_device_register(&kirkwood_sata);
240 /*****************************************************************************
242 ****************************************************************************/
243 static struct orion_spi_info kirkwood_spi_plat_data = {
246 static struct resource kirkwood_spi_resources[] = {
248 .start = SPI_PHYS_BASE,
249 .end = SPI_PHYS_BASE + SZ_512 - 1,
250 .flags = IORESOURCE_MEM,
254 static struct platform_device kirkwood_spi = {
257 .resource = kirkwood_spi_resources,
259 .platform_data = &kirkwood_spi_plat_data,
261 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
264 void __init kirkwood_spi_init()
266 platform_device_register(&kirkwood_spi);
270 /*****************************************************************************
272 ****************************************************************************/
273 static struct plat_serial8250_port kirkwood_uart0_data[] = {
275 .mapbase = UART0_PHYS_BASE,
276 .membase = (char *)UART0_VIRT_BASE,
277 .irq = IRQ_KIRKWOOD_UART_0,
278 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
286 static struct resource kirkwood_uart0_resources[] = {
288 .start = UART0_PHYS_BASE,
289 .end = UART0_PHYS_BASE + 0xff,
290 .flags = IORESOURCE_MEM,
292 .start = IRQ_KIRKWOOD_UART_0,
293 .end = IRQ_KIRKWOOD_UART_0,
294 .flags = IORESOURCE_IRQ,
298 static struct platform_device kirkwood_uart0 = {
299 .name = "serial8250",
302 .platform_data = kirkwood_uart0_data,
304 .resource = kirkwood_uart0_resources,
305 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
308 void __init kirkwood_uart0_init(void)
310 platform_device_register(&kirkwood_uart0);
314 /*****************************************************************************
316 ****************************************************************************/
317 static struct plat_serial8250_port kirkwood_uart1_data[] = {
319 .mapbase = UART1_PHYS_BASE,
320 .membase = (char *)UART1_VIRT_BASE,
321 .irq = IRQ_KIRKWOOD_UART_1,
322 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
330 static struct resource kirkwood_uart1_resources[] = {
332 .start = UART1_PHYS_BASE,
333 .end = UART1_PHYS_BASE + 0xff,
334 .flags = IORESOURCE_MEM,
336 .start = IRQ_KIRKWOOD_UART_1,
337 .end = IRQ_KIRKWOOD_UART_1,
338 .flags = IORESOURCE_IRQ,
342 static struct platform_device kirkwood_uart1 = {
343 .name = "serial8250",
346 .platform_data = kirkwood_uart1_data,
348 .resource = kirkwood_uart1_resources,
349 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
352 void __init kirkwood_uart1_init(void)
354 platform_device_register(&kirkwood_uart1);
358 /*****************************************************************************
360 ****************************************************************************/
361 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
362 .dram = &kirkwood_mbus_dram_info,
365 static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
368 /*****************************************************************************
370 ****************************************************************************/
371 static struct resource kirkwood_xor0_shared_resources[] = {
374 .start = XOR0_PHYS_BASE,
375 .end = XOR0_PHYS_BASE + 0xff,
376 .flags = IORESOURCE_MEM,
378 .name = "xor 0 high",
379 .start = XOR0_HIGH_PHYS_BASE,
380 .end = XOR0_HIGH_PHYS_BASE + 0xff,
381 .flags = IORESOURCE_MEM,
385 static struct platform_device kirkwood_xor0_shared = {
386 .name = MV_XOR_SHARED_NAME,
389 .platform_data = &kirkwood_xor_shared_data,
391 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
392 .resource = kirkwood_xor0_shared_resources,
395 static struct resource kirkwood_xor00_resources[] = {
397 .start = IRQ_KIRKWOOD_XOR_00,
398 .end = IRQ_KIRKWOOD_XOR_00,
399 .flags = IORESOURCE_IRQ,
403 static struct mv_xor_platform_data kirkwood_xor00_data = {
404 .shared = &kirkwood_xor0_shared,
406 .pool_size = PAGE_SIZE,
409 static struct platform_device kirkwood_xor00_channel = {
412 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
413 .resource = kirkwood_xor00_resources,
415 .dma_mask = &kirkwood_xor_dmamask,
416 .coherent_dma_mask = DMA_64BIT_MASK,
417 .platform_data = (void *)&kirkwood_xor00_data,
421 static struct resource kirkwood_xor01_resources[] = {
423 .start = IRQ_KIRKWOOD_XOR_01,
424 .end = IRQ_KIRKWOOD_XOR_01,
425 .flags = IORESOURCE_IRQ,
429 static struct mv_xor_platform_data kirkwood_xor01_data = {
430 .shared = &kirkwood_xor0_shared,
432 .pool_size = PAGE_SIZE,
435 static struct platform_device kirkwood_xor01_channel = {
438 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
439 .resource = kirkwood_xor01_resources,
441 .dma_mask = &kirkwood_xor_dmamask,
442 .coherent_dma_mask = DMA_64BIT_MASK,
443 .platform_data = (void *)&kirkwood_xor01_data,
447 void __init kirkwood_xor0_init(void)
449 platform_device_register(&kirkwood_xor0_shared);
452 * two engines can't do memset simultaneously, this limitation
453 * satisfied by removing memset support from one of the engines.
455 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
456 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
457 platform_device_register(&kirkwood_xor00_channel);
459 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
460 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
461 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
462 platform_device_register(&kirkwood_xor01_channel);
466 /*****************************************************************************
468 ****************************************************************************/
469 static struct resource kirkwood_xor1_shared_resources[] = {
472 .start = XOR1_PHYS_BASE,
473 .end = XOR1_PHYS_BASE + 0xff,
474 .flags = IORESOURCE_MEM,
476 .name = "xor 1 high",
477 .start = XOR1_HIGH_PHYS_BASE,
478 .end = XOR1_HIGH_PHYS_BASE + 0xff,
479 .flags = IORESOURCE_MEM,
483 static struct platform_device kirkwood_xor1_shared = {
484 .name = MV_XOR_SHARED_NAME,
487 .platform_data = &kirkwood_xor_shared_data,
489 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
490 .resource = kirkwood_xor1_shared_resources,
493 static struct resource kirkwood_xor10_resources[] = {
495 .start = IRQ_KIRKWOOD_XOR_10,
496 .end = IRQ_KIRKWOOD_XOR_10,
497 .flags = IORESOURCE_IRQ,
501 static struct mv_xor_platform_data kirkwood_xor10_data = {
502 .shared = &kirkwood_xor1_shared,
504 .pool_size = PAGE_SIZE,
507 static struct platform_device kirkwood_xor10_channel = {
510 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
511 .resource = kirkwood_xor10_resources,
513 .dma_mask = &kirkwood_xor_dmamask,
514 .coherent_dma_mask = DMA_64BIT_MASK,
515 .platform_data = (void *)&kirkwood_xor10_data,
519 static struct resource kirkwood_xor11_resources[] = {
521 .start = IRQ_KIRKWOOD_XOR_11,
522 .end = IRQ_KIRKWOOD_XOR_11,
523 .flags = IORESOURCE_IRQ,
527 static struct mv_xor_platform_data kirkwood_xor11_data = {
528 .shared = &kirkwood_xor1_shared,
530 .pool_size = PAGE_SIZE,
533 static struct platform_device kirkwood_xor11_channel = {
536 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
537 .resource = kirkwood_xor11_resources,
539 .dma_mask = &kirkwood_xor_dmamask,
540 .coherent_dma_mask = DMA_64BIT_MASK,
541 .platform_data = (void *)&kirkwood_xor11_data,
545 void __init kirkwood_xor1_init(void)
547 platform_device_register(&kirkwood_xor1_shared);
550 * two engines can't do memset simultaneously, this limitation
551 * satisfied by removing memset support from one of the engines.
553 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
554 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
555 platform_device_register(&kirkwood_xor10_channel);
557 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
558 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
559 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
560 platform_device_register(&kirkwood_xor11_channel);
564 /*****************************************************************************
566 ****************************************************************************/
569 int __init kirkwood_find_tclk(void)
573 kirkwood_pcie_id(&dev, &rev);
574 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
580 static void kirkwood_timer_init(void)
582 kirkwood_tclk = kirkwood_find_tclk();
583 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
586 struct sys_timer kirkwood_timer = {
587 .init = kirkwood_timer_init,
591 /*****************************************************************************
593 ****************************************************************************/
595 * Identify device ID and revision.
597 static char * __init kirkwood_id(void)
601 kirkwood_pcie_id(&dev, &rev);
603 if (dev == MV88F6281_DEV_ID) {
604 if (rev == MV88F6281_REV_Z0)
605 return "MV88F6281-Z0";
606 else if (rev == MV88F6281_REV_A0)
607 return "MV88F6281-A0";
609 return "MV88F6281-Rev-Unsupported";
610 } else if (dev == MV88F6192_DEV_ID) {
611 if (rev == MV88F6192_REV_Z0)
612 return "MV88F6192-Z0";
613 else if (rev == MV88F6192_REV_A0)
614 return "MV88F6192-A0";
616 return "MV88F6192-Rev-Unsupported";
617 } else if (dev == MV88F6180_DEV_ID) {
618 if (rev == MV88F6180_REV_A0)
619 return "MV88F6180-Rev-A0";
621 return "MV88F6180-Rev-Unsupported";
623 return "Device-Unknown";
627 static void __init kirkwood_l2_init(void)
629 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
630 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
633 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
638 void __init kirkwood_init(void)
640 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
641 kirkwood_id(), kirkwood_tclk);
642 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
643 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
644 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
645 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
647 kirkwood_setup_cpu_mbus();
649 #ifdef CONFIG_CACHE_FEROCEON_L2