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,
62 static u64 ehci_dmamask = 0xffffffffUL;
65 /*****************************************************************************
67 ****************************************************************************/
68 static struct resource kirkwood_ehci_resources[] = {
70 .start = USB_PHYS_BASE,
71 .end = USB_PHYS_BASE + 0x0fff,
72 .flags = IORESOURCE_MEM,
74 .start = IRQ_KIRKWOOD_USB,
75 .end = IRQ_KIRKWOOD_USB,
76 .flags = IORESOURCE_IRQ,
80 static struct platform_device kirkwood_ehci = {
84 .dma_mask = &ehci_dmamask,
85 .coherent_dma_mask = 0xffffffff,
86 .platform_data = &kirkwood_ehci_data,
88 .resource = kirkwood_ehci_resources,
89 .num_resources = ARRAY_SIZE(kirkwood_ehci_resources),
92 void __init kirkwood_ehci_init(void)
94 platform_device_register(&kirkwood_ehci);
98 /*****************************************************************************
100 ****************************************************************************/
101 struct mv643xx_eth_shared_platform_data kirkwood_ge00_shared_data = {
102 .dram = &kirkwood_mbus_dram_info,
105 static struct resource kirkwood_ge00_shared_resources[] = {
108 .start = GE00_PHYS_BASE + 0x2000,
109 .end = GE00_PHYS_BASE + 0x3fff,
110 .flags = IORESOURCE_MEM,
112 .name = "ge00 err irq",
113 .start = IRQ_KIRKWOOD_GE00_ERR,
114 .end = IRQ_KIRKWOOD_GE00_ERR,
115 .flags = IORESOURCE_IRQ,
119 static struct platform_device kirkwood_ge00_shared = {
120 .name = MV643XX_ETH_SHARED_NAME,
123 .platform_data = &kirkwood_ge00_shared_data,
125 .num_resources = ARRAY_SIZE(kirkwood_ge00_shared_resources),
126 .resource = kirkwood_ge00_shared_resources,
129 static struct resource kirkwood_ge00_resources[] = {
132 .start = IRQ_KIRKWOOD_GE00_SUM,
133 .end = IRQ_KIRKWOOD_GE00_SUM,
134 .flags = IORESOURCE_IRQ,
138 static struct platform_device kirkwood_ge00 = {
139 .name = MV643XX_ETH_NAME,
142 .resource = kirkwood_ge00_resources,
145 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
147 eth_data->shared = &kirkwood_ge00_shared;
148 kirkwood_ge00.dev.platform_data = eth_data;
150 platform_device_register(&kirkwood_ge00_shared);
151 platform_device_register(&kirkwood_ge00);
155 /*****************************************************************************
157 ****************************************************************************/
158 static struct resource kirkwood_switch_resources[] = {
162 .flags = IORESOURCE_IRQ,
166 static struct platform_device kirkwood_switch_device = {
170 .resource = kirkwood_switch_resources,
173 void __init kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq)
176 kirkwood_switch_resources[0].start = irq;
177 kirkwood_switch_resources[0].end = irq;
178 kirkwood_switch_device.num_resources = 1;
181 d->mii_bus = &kirkwood_ge00_shared.dev;
182 d->netdev = &kirkwood_ge00.dev;
183 kirkwood_switch_device.dev.platform_data = d;
185 platform_device_register(&kirkwood_switch_device);
189 /*****************************************************************************
191 ****************************************************************************/
192 static struct resource kirkwood_rtc_resource = {
193 .start = RTC_PHYS_BASE,
194 .end = RTC_PHYS_BASE + SZ_16 - 1,
195 .flags = IORESOURCE_MEM,
198 void __init kirkwood_rtc_init(void)
200 platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1);
204 /*****************************************************************************
206 ****************************************************************************/
207 static struct resource kirkwood_sata_resources[] = {
210 .start = SATA_PHYS_BASE,
211 .end = SATA_PHYS_BASE + 0x5000 - 1,
212 .flags = IORESOURCE_MEM,
215 .start = IRQ_KIRKWOOD_SATA,
216 .end = IRQ_KIRKWOOD_SATA,
217 .flags = IORESOURCE_IRQ,
221 static struct platform_device kirkwood_sata = {
225 .coherent_dma_mask = 0xffffffff,
227 .num_resources = ARRAY_SIZE(kirkwood_sata_resources),
228 .resource = kirkwood_sata_resources,
231 void __init kirkwood_sata_init(struct mv_sata_platform_data *sata_data)
233 sata_data->dram = &kirkwood_mbus_dram_info;
234 kirkwood_sata.dev.platform_data = sata_data;
235 platform_device_register(&kirkwood_sata);
239 /*****************************************************************************
241 ****************************************************************************/
242 static struct orion_spi_info kirkwood_spi_plat_data = {
245 static struct resource kirkwood_spi_resources[] = {
247 .start = SPI_PHYS_BASE,
248 .end = SPI_PHYS_BASE + SZ_512 - 1,
249 .flags = IORESOURCE_MEM,
253 static struct platform_device kirkwood_spi = {
256 .resource = kirkwood_spi_resources,
258 .platform_data = &kirkwood_spi_plat_data,
260 .num_resources = ARRAY_SIZE(kirkwood_spi_resources),
263 void __init kirkwood_spi_init()
265 platform_device_register(&kirkwood_spi);
269 /*****************************************************************************
271 ****************************************************************************/
272 static struct plat_serial8250_port kirkwood_uart0_data[] = {
274 .mapbase = UART0_PHYS_BASE,
275 .membase = (char *)UART0_VIRT_BASE,
276 .irq = IRQ_KIRKWOOD_UART_0,
277 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
285 static struct resource kirkwood_uart0_resources[] = {
287 .start = UART0_PHYS_BASE,
288 .end = UART0_PHYS_BASE + 0xff,
289 .flags = IORESOURCE_MEM,
291 .start = IRQ_KIRKWOOD_UART_0,
292 .end = IRQ_KIRKWOOD_UART_0,
293 .flags = IORESOURCE_IRQ,
297 static struct platform_device kirkwood_uart0 = {
298 .name = "serial8250",
301 .platform_data = kirkwood_uart0_data,
303 .resource = kirkwood_uart0_resources,
304 .num_resources = ARRAY_SIZE(kirkwood_uart0_resources),
307 void __init kirkwood_uart0_init(void)
309 platform_device_register(&kirkwood_uart0);
313 /*****************************************************************************
315 ****************************************************************************/
316 static struct plat_serial8250_port kirkwood_uart1_data[] = {
318 .mapbase = UART1_PHYS_BASE,
319 .membase = (char *)UART1_VIRT_BASE,
320 .irq = IRQ_KIRKWOOD_UART_1,
321 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
329 static struct resource kirkwood_uart1_resources[] = {
331 .start = UART1_PHYS_BASE,
332 .end = UART1_PHYS_BASE + 0xff,
333 .flags = IORESOURCE_MEM,
335 .start = IRQ_KIRKWOOD_UART_1,
336 .end = IRQ_KIRKWOOD_UART_1,
337 .flags = IORESOURCE_IRQ,
341 static struct platform_device kirkwood_uart1 = {
342 .name = "serial8250",
345 .platform_data = kirkwood_uart1_data,
347 .resource = kirkwood_uart1_resources,
348 .num_resources = ARRAY_SIZE(kirkwood_uart1_resources),
351 void __init kirkwood_uart1_init(void)
353 platform_device_register(&kirkwood_uart1);
357 /*****************************************************************************
359 ****************************************************************************/
360 static struct mv_xor_platform_shared_data kirkwood_xor_shared_data = {
361 .dram = &kirkwood_mbus_dram_info,
364 static u64 kirkwood_xor_dmamask = DMA_32BIT_MASK;
367 /*****************************************************************************
369 ****************************************************************************/
370 static struct resource kirkwood_xor0_shared_resources[] = {
373 .start = XOR0_PHYS_BASE,
374 .end = XOR0_PHYS_BASE + 0xff,
375 .flags = IORESOURCE_MEM,
377 .name = "xor 0 high",
378 .start = XOR0_HIGH_PHYS_BASE,
379 .end = XOR0_HIGH_PHYS_BASE + 0xff,
380 .flags = IORESOURCE_MEM,
384 static struct platform_device kirkwood_xor0_shared = {
385 .name = MV_XOR_SHARED_NAME,
388 .platform_data = &kirkwood_xor_shared_data,
390 .num_resources = ARRAY_SIZE(kirkwood_xor0_shared_resources),
391 .resource = kirkwood_xor0_shared_resources,
394 static struct resource kirkwood_xor00_resources[] = {
396 .start = IRQ_KIRKWOOD_XOR_00,
397 .end = IRQ_KIRKWOOD_XOR_00,
398 .flags = IORESOURCE_IRQ,
402 static struct mv_xor_platform_data kirkwood_xor00_data = {
403 .shared = &kirkwood_xor0_shared,
405 .pool_size = PAGE_SIZE,
408 static struct platform_device kirkwood_xor00_channel = {
411 .num_resources = ARRAY_SIZE(kirkwood_xor00_resources),
412 .resource = kirkwood_xor00_resources,
414 .dma_mask = &kirkwood_xor_dmamask,
415 .coherent_dma_mask = DMA_64BIT_MASK,
416 .platform_data = (void *)&kirkwood_xor00_data,
420 static struct resource kirkwood_xor01_resources[] = {
422 .start = IRQ_KIRKWOOD_XOR_01,
423 .end = IRQ_KIRKWOOD_XOR_01,
424 .flags = IORESOURCE_IRQ,
428 static struct mv_xor_platform_data kirkwood_xor01_data = {
429 .shared = &kirkwood_xor0_shared,
431 .pool_size = PAGE_SIZE,
434 static struct platform_device kirkwood_xor01_channel = {
437 .num_resources = ARRAY_SIZE(kirkwood_xor01_resources),
438 .resource = kirkwood_xor01_resources,
440 .dma_mask = &kirkwood_xor_dmamask,
441 .coherent_dma_mask = DMA_64BIT_MASK,
442 .platform_data = (void *)&kirkwood_xor01_data,
446 void __init kirkwood_xor0_init(void)
448 platform_device_register(&kirkwood_xor0_shared);
451 * two engines can't do memset simultaneously, this limitation
452 * satisfied by removing memset support from one of the engines.
454 dma_cap_set(DMA_MEMCPY, kirkwood_xor00_data.cap_mask);
455 dma_cap_set(DMA_XOR, kirkwood_xor00_data.cap_mask);
456 platform_device_register(&kirkwood_xor00_channel);
458 dma_cap_set(DMA_MEMCPY, kirkwood_xor01_data.cap_mask);
459 dma_cap_set(DMA_MEMSET, kirkwood_xor01_data.cap_mask);
460 dma_cap_set(DMA_XOR, kirkwood_xor01_data.cap_mask);
461 platform_device_register(&kirkwood_xor01_channel);
465 /*****************************************************************************
467 ****************************************************************************/
468 static struct resource kirkwood_xor1_shared_resources[] = {
471 .start = XOR1_PHYS_BASE,
472 .end = XOR1_PHYS_BASE + 0xff,
473 .flags = IORESOURCE_MEM,
475 .name = "xor 1 high",
476 .start = XOR1_HIGH_PHYS_BASE,
477 .end = XOR1_HIGH_PHYS_BASE + 0xff,
478 .flags = IORESOURCE_MEM,
482 static struct platform_device kirkwood_xor1_shared = {
483 .name = MV_XOR_SHARED_NAME,
486 .platform_data = &kirkwood_xor_shared_data,
488 .num_resources = ARRAY_SIZE(kirkwood_xor1_shared_resources),
489 .resource = kirkwood_xor1_shared_resources,
492 static struct resource kirkwood_xor10_resources[] = {
494 .start = IRQ_KIRKWOOD_XOR_10,
495 .end = IRQ_KIRKWOOD_XOR_10,
496 .flags = IORESOURCE_IRQ,
500 static struct mv_xor_platform_data kirkwood_xor10_data = {
501 .shared = &kirkwood_xor1_shared,
503 .pool_size = PAGE_SIZE,
506 static struct platform_device kirkwood_xor10_channel = {
509 .num_resources = ARRAY_SIZE(kirkwood_xor10_resources),
510 .resource = kirkwood_xor10_resources,
512 .dma_mask = &kirkwood_xor_dmamask,
513 .coherent_dma_mask = DMA_64BIT_MASK,
514 .platform_data = (void *)&kirkwood_xor10_data,
518 static struct resource kirkwood_xor11_resources[] = {
520 .start = IRQ_KIRKWOOD_XOR_11,
521 .end = IRQ_KIRKWOOD_XOR_11,
522 .flags = IORESOURCE_IRQ,
526 static struct mv_xor_platform_data kirkwood_xor11_data = {
527 .shared = &kirkwood_xor1_shared,
529 .pool_size = PAGE_SIZE,
532 static struct platform_device kirkwood_xor11_channel = {
535 .num_resources = ARRAY_SIZE(kirkwood_xor11_resources),
536 .resource = kirkwood_xor11_resources,
538 .dma_mask = &kirkwood_xor_dmamask,
539 .coherent_dma_mask = DMA_64BIT_MASK,
540 .platform_data = (void *)&kirkwood_xor11_data,
544 void __init kirkwood_xor1_init(void)
546 platform_device_register(&kirkwood_xor1_shared);
549 * two engines can't do memset simultaneously, this limitation
550 * satisfied by removing memset support from one of the engines.
552 dma_cap_set(DMA_MEMCPY, kirkwood_xor10_data.cap_mask);
553 dma_cap_set(DMA_XOR, kirkwood_xor10_data.cap_mask);
554 platform_device_register(&kirkwood_xor10_channel);
556 dma_cap_set(DMA_MEMCPY, kirkwood_xor11_data.cap_mask);
557 dma_cap_set(DMA_MEMSET, kirkwood_xor11_data.cap_mask);
558 dma_cap_set(DMA_XOR, kirkwood_xor11_data.cap_mask);
559 platform_device_register(&kirkwood_xor11_channel);
563 /*****************************************************************************
565 ****************************************************************************/
568 int __init kirkwood_find_tclk(void)
572 kirkwood_pcie_id(&dev, &rev);
573 if (dev == MV88F6281_DEV_ID && rev == MV88F6281_REV_A0)
579 static void kirkwood_timer_init(void)
581 kirkwood_tclk = kirkwood_find_tclk();
582 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
585 struct sys_timer kirkwood_timer = {
586 .init = kirkwood_timer_init,
590 /*****************************************************************************
592 ****************************************************************************/
594 * Identify device ID and revision.
596 static char * __init kirkwood_id(void)
600 kirkwood_pcie_id(&dev, &rev);
602 if (dev == MV88F6281_DEV_ID) {
603 if (rev == MV88F6281_REV_Z0)
604 return "MV88F6281-Z0";
605 else if (rev == MV88F6281_REV_A0)
606 return "MV88F6281-A0";
608 return "MV88F6281-Rev-Unsupported";
609 } else if (dev == MV88F6192_DEV_ID) {
610 if (rev == MV88F6192_REV_Z0)
611 return "MV88F6192-Z0";
612 else if (rev == MV88F6192_REV_A0)
613 return "MV88F6192-A0";
615 return "MV88F6192-Rev-Unsupported";
616 } else if (dev == MV88F6180_DEV_ID) {
617 if (rev == MV88F6180_REV_A0)
618 return "MV88F6180-Rev-A0";
620 return "MV88F6180-Rev-Unsupported";
622 return "Device-Unknown";
626 static void __init kirkwood_l2_init(void)
628 #ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
629 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
632 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
637 void __init kirkwood_init(void)
639 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
640 kirkwood_id(), kirkwood_tclk);
641 kirkwood_ge00_shared_data.t_clk = kirkwood_tclk;
642 kirkwood_spi_plat_data.tclk = kirkwood_tclk;
643 kirkwood_uart0_data[0].uartclk = kirkwood_tclk;
644 kirkwood_uart1_data[0].uartclk = kirkwood_tclk;
646 kirkwood_setup_cpu_mbus();
648 #ifdef CONFIG_CACHE_FEROCEON_L2