2 * arch/arm/mach-orion5x/common.c
4 * Core functions for Marvell Orion 5x SoCs
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/serial_8250.h>
17 #include <linux/mbus.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/mv643xx_i2c.h>
20 #include <linux/ata_platform.h>
21 #include <linux/spi/orion_spi.h>
24 #include <asm/setup.h>
25 #include <asm/timex.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/time.h>
29 #include <mach/hardware.h>
30 #include <mach/orion5x.h>
31 #include <plat/ehci-orion.h>
32 #include <plat/mv_xor.h>
33 #include <plat/orion_nand.h>
34 #include <plat/orion5x_wdt.h>
35 #include <plat/time.h>
38 /*****************************************************************************
40 ****************************************************************************/
41 static struct map_desc orion5x_io_desc[] __initdata = {
43 .virtual = ORION5X_REGS_VIRT_BASE,
44 .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE),
45 .length = ORION5X_REGS_SIZE,
48 .virtual = ORION5X_PCIE_IO_VIRT_BASE,
49 .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE),
50 .length = ORION5X_PCIE_IO_SIZE,
53 .virtual = ORION5X_PCI_IO_VIRT_BASE,
54 .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE),
55 .length = ORION5X_PCI_IO_SIZE,
58 .virtual = ORION5X_PCIE_WA_VIRT_BASE,
59 .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE),
60 .length = ORION5X_PCIE_WA_SIZE,
65 void __init orion5x_map_io(void)
67 iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
71 /*****************************************************************************
73 ****************************************************************************/
74 static struct orion_ehci_data orion5x_ehci_data = {
75 .dram = &orion5x_mbus_dram_info,
76 .phy_version = EHCI_PHY_ORION,
79 static u64 ehci_dmamask = 0xffffffffUL;
82 /*****************************************************************************
84 ****************************************************************************/
85 static struct resource orion5x_ehci0_resources[] = {
87 .start = ORION5X_USB0_PHYS_BASE,
88 .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1,
89 .flags = IORESOURCE_MEM,
91 .start = IRQ_ORION5X_USB0_CTRL,
92 .end = IRQ_ORION5X_USB0_CTRL,
93 .flags = IORESOURCE_IRQ,
97 static struct platform_device orion5x_ehci0 = {
101 .dma_mask = &ehci_dmamask,
102 .coherent_dma_mask = 0xffffffff,
103 .platform_data = &orion5x_ehci_data,
105 .resource = orion5x_ehci0_resources,
106 .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
109 void __init orion5x_ehci0_init(void)
111 platform_device_register(&orion5x_ehci0);
115 /*****************************************************************************
117 ****************************************************************************/
118 static struct resource orion5x_ehci1_resources[] = {
120 .start = ORION5X_USB1_PHYS_BASE,
121 .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
122 .flags = IORESOURCE_MEM,
124 .start = IRQ_ORION5X_USB1_CTRL,
125 .end = IRQ_ORION5X_USB1_CTRL,
126 .flags = IORESOURCE_IRQ,
130 static struct platform_device orion5x_ehci1 = {
131 .name = "orion-ehci",
134 .dma_mask = &ehci_dmamask,
135 .coherent_dma_mask = 0xffffffff,
136 .platform_data = &orion5x_ehci_data,
138 .resource = orion5x_ehci1_resources,
139 .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
142 void __init orion5x_ehci1_init(void)
144 platform_device_register(&orion5x_ehci1);
148 /*****************************************************************************
150 ****************************************************************************/
151 struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
152 .dram = &orion5x_mbus_dram_info,
155 static struct resource orion5x_eth_shared_resources[] = {
157 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
158 .end = ORION5X_ETH_PHYS_BASE + 0x3fff,
159 .flags = IORESOURCE_MEM,
161 .start = IRQ_ORION5X_ETH_ERR,
162 .end = IRQ_ORION5X_ETH_ERR,
163 .flags = IORESOURCE_IRQ,
167 static struct platform_device orion5x_eth_shared = {
168 .name = MV643XX_ETH_SHARED_NAME,
171 .platform_data = &orion5x_eth_shared_data,
173 .num_resources = ARRAY_SIZE(orion5x_eth_shared_resources),
174 .resource = orion5x_eth_shared_resources,
177 static struct resource orion5x_eth_resources[] = {
180 .start = IRQ_ORION5X_ETH_SUM,
181 .end = IRQ_ORION5X_ETH_SUM,
182 .flags = IORESOURCE_IRQ,
186 static struct platform_device orion5x_eth = {
187 .name = MV643XX_ETH_NAME,
190 .resource = orion5x_eth_resources,
193 void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
195 eth_data->shared = &orion5x_eth_shared;
196 orion5x_eth.dev.platform_data = eth_data;
198 platform_device_register(&orion5x_eth_shared);
199 platform_device_register(&orion5x_eth);
203 /*****************************************************************************
205 ****************************************************************************/
206 static struct resource orion5x_switch_resources[] = {
210 .flags = IORESOURCE_IRQ,
214 static struct platform_device orion5x_switch_device = {
218 .resource = orion5x_switch_resources,
221 void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq)
226 orion5x_switch_resources[0].start = irq;
227 orion5x_switch_resources[0].end = irq;
228 orion5x_switch_device.num_resources = 1;
231 d->netdev = &orion5x_eth.dev;
232 for (i = 0; i < d->nr_chips; i++)
233 d->chip[i].mii_bus = &orion5x_eth_shared.dev;
234 orion5x_switch_device.dev.platform_data = d;
236 platform_device_register(&orion5x_switch_device);
240 /*****************************************************************************
242 ****************************************************************************/
243 static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
244 .freq_m = 8, /* assumes 166 MHz TCLK */
246 .timeout = 1000, /* Default timeout of 1 second */
249 static struct resource orion5x_i2c_resources[] = {
251 .start = I2C_PHYS_BASE,
252 .end = I2C_PHYS_BASE + 0x1f,
253 .flags = IORESOURCE_MEM,
255 .start = IRQ_ORION5X_I2C,
256 .end = IRQ_ORION5X_I2C,
257 .flags = IORESOURCE_IRQ,
261 static struct platform_device orion5x_i2c = {
262 .name = MV64XXX_I2C_CTLR_NAME,
264 .num_resources = ARRAY_SIZE(orion5x_i2c_resources),
265 .resource = orion5x_i2c_resources,
267 .platform_data = &orion5x_i2c_pdata,
271 void __init orion5x_i2c_init(void)
273 platform_device_register(&orion5x_i2c);
277 /*****************************************************************************
279 ****************************************************************************/
280 static struct resource orion5x_sata_resources[] = {
283 .start = ORION5X_SATA_PHYS_BASE,
284 .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1,
285 .flags = IORESOURCE_MEM,
288 .start = IRQ_ORION5X_SATA,
289 .end = IRQ_ORION5X_SATA,
290 .flags = IORESOURCE_IRQ,
294 static struct platform_device orion5x_sata = {
298 .coherent_dma_mask = 0xffffffff,
300 .num_resources = ARRAY_SIZE(orion5x_sata_resources),
301 .resource = orion5x_sata_resources,
304 void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data)
306 sata_data->dram = &orion5x_mbus_dram_info;
307 orion5x_sata.dev.platform_data = sata_data;
308 platform_device_register(&orion5x_sata);
312 /*****************************************************************************
314 ****************************************************************************/
315 static struct orion_spi_info orion5x_spi_plat_data = {
317 .enable_clock_fix = 1,
320 static struct resource orion5x_spi_resources[] = {
323 .start = SPI_PHYS_BASE,
324 .end = SPI_PHYS_BASE + 0x1f,
325 .flags = IORESOURCE_MEM,
329 static struct platform_device orion5x_spi = {
333 .platform_data = &orion5x_spi_plat_data,
335 .num_resources = ARRAY_SIZE(orion5x_spi_resources),
336 .resource = orion5x_spi_resources,
339 void __init orion5x_spi_init()
341 platform_device_register(&orion5x_spi);
345 /*****************************************************************************
347 ****************************************************************************/
348 static struct plat_serial8250_port orion5x_uart0_data[] = {
350 .mapbase = UART0_PHYS_BASE,
351 .membase = (char *)UART0_VIRT_BASE,
352 .irq = IRQ_ORION5X_UART0,
353 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
361 static struct resource orion5x_uart0_resources[] = {
363 .start = UART0_PHYS_BASE,
364 .end = UART0_PHYS_BASE + 0xff,
365 .flags = IORESOURCE_MEM,
367 .start = IRQ_ORION5X_UART0,
368 .end = IRQ_ORION5X_UART0,
369 .flags = IORESOURCE_IRQ,
373 static struct platform_device orion5x_uart0 = {
374 .name = "serial8250",
375 .id = PLAT8250_DEV_PLATFORM,
377 .platform_data = orion5x_uart0_data,
379 .resource = orion5x_uart0_resources,
380 .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
383 void __init orion5x_uart0_init(void)
385 platform_device_register(&orion5x_uart0);
389 /*****************************************************************************
391 ****************************************************************************/
392 static struct plat_serial8250_port orion5x_uart1_data[] = {
394 .mapbase = UART1_PHYS_BASE,
395 .membase = (char *)UART1_VIRT_BASE,
396 .irq = IRQ_ORION5X_UART1,
397 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
405 static struct resource orion5x_uart1_resources[] = {
407 .start = UART1_PHYS_BASE,
408 .end = UART1_PHYS_BASE + 0xff,
409 .flags = IORESOURCE_MEM,
411 .start = IRQ_ORION5X_UART1,
412 .end = IRQ_ORION5X_UART1,
413 .flags = IORESOURCE_IRQ,
417 static struct platform_device orion5x_uart1 = {
418 .name = "serial8250",
419 .id = PLAT8250_DEV_PLATFORM1,
421 .platform_data = orion5x_uart1_data,
423 .resource = orion5x_uart1_resources,
424 .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
427 void __init orion5x_uart1_init(void)
429 platform_device_register(&orion5x_uart1);
433 /*****************************************************************************
435 ****************************************************************************/
436 struct mv_xor_platform_shared_data orion5x_xor_shared_data = {
437 .dram = &orion5x_mbus_dram_info,
440 static struct resource orion5x_xor_shared_resources[] = {
443 .start = ORION5X_XOR_PHYS_BASE,
444 .end = ORION5X_XOR_PHYS_BASE + 0xff,
445 .flags = IORESOURCE_MEM,
448 .start = ORION5X_XOR_PHYS_BASE + 0x200,
449 .end = ORION5X_XOR_PHYS_BASE + 0x2ff,
450 .flags = IORESOURCE_MEM,
454 static struct platform_device orion5x_xor_shared = {
455 .name = MV_XOR_SHARED_NAME,
458 .platform_data = &orion5x_xor_shared_data,
460 .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources),
461 .resource = orion5x_xor_shared_resources,
464 static u64 orion5x_xor_dmamask = DMA_BIT_MASK(32);
466 static struct resource orion5x_xor0_resources[] = {
468 .start = IRQ_ORION5X_XOR0,
469 .end = IRQ_ORION5X_XOR0,
470 .flags = IORESOURCE_IRQ,
474 static struct mv_xor_platform_data orion5x_xor0_data = {
475 .shared = &orion5x_xor_shared,
477 .pool_size = PAGE_SIZE,
480 static struct platform_device orion5x_xor0_channel = {
483 .num_resources = ARRAY_SIZE(orion5x_xor0_resources),
484 .resource = orion5x_xor0_resources,
486 .dma_mask = &orion5x_xor_dmamask,
487 .coherent_dma_mask = DMA_BIT_MASK(64),
488 .platform_data = (void *)&orion5x_xor0_data,
492 static struct resource orion5x_xor1_resources[] = {
494 .start = IRQ_ORION5X_XOR1,
495 .end = IRQ_ORION5X_XOR1,
496 .flags = IORESOURCE_IRQ,
500 static struct mv_xor_platform_data orion5x_xor1_data = {
501 .shared = &orion5x_xor_shared,
503 .pool_size = PAGE_SIZE,
506 static struct platform_device orion5x_xor1_channel = {
509 .num_resources = ARRAY_SIZE(orion5x_xor1_resources),
510 .resource = orion5x_xor1_resources,
512 .dma_mask = &orion5x_xor_dmamask,
513 .coherent_dma_mask = DMA_BIT_MASK(64),
514 .platform_data = (void *)&orion5x_xor1_data,
518 void __init orion5x_xor_init(void)
520 platform_device_register(&orion5x_xor_shared);
523 * two engines can't do memset simultaneously, this limitation
524 * satisfied by removing memset support from one of the engines.
526 dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask);
527 dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask);
528 platform_device_register(&orion5x_xor0_channel);
530 dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask);
531 dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask);
532 dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask);
533 platform_device_register(&orion5x_xor1_channel);
537 /*****************************************************************************
539 ****************************************************************************/
540 static struct orion5x_wdt_platform_data orion5x_wdt_data = {
544 static struct platform_device orion5x_wdt_device = {
545 .name = "orion5x_wdt",
548 .platform_data = &orion5x_wdt_data,
553 void __init orion5x_wdt_init(void)
555 orion5x_wdt_data.tclk = orion5x_tclk;
556 platform_device_register(&orion5x_wdt_device);
560 /*****************************************************************************
562 ****************************************************************************/
565 int __init orion5x_find_tclk(void)
569 orion5x_pcie_id(&dev, &rev);
570 if (dev == MV88F6183_DEV_ID &&
571 (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0)
577 static void orion5x_timer_init(void)
579 orion5x_tclk = orion5x_find_tclk();
580 orion_time_init(IRQ_ORION5X_BRIDGE, orion5x_tclk);
583 struct sys_timer orion5x_timer = {
584 .init = orion5x_timer_init,
588 /*****************************************************************************
590 ****************************************************************************/
592 * Identify device ID and rev from PCIe configuration header space '0'.
594 static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name)
596 orion5x_pcie_id(dev, rev);
598 if (*dev == MV88F5281_DEV_ID) {
599 if (*rev == MV88F5281_REV_D2) {
600 *dev_name = "MV88F5281-D2";
601 } else if (*rev == MV88F5281_REV_D1) {
602 *dev_name = "MV88F5281-D1";
603 } else if (*rev == MV88F5281_REV_D0) {
604 *dev_name = "MV88F5281-D0";
606 *dev_name = "MV88F5281-Rev-Unsupported";
608 } else if (*dev == MV88F5182_DEV_ID) {
609 if (*rev == MV88F5182_REV_A2) {
610 *dev_name = "MV88F5182-A2";
612 *dev_name = "MV88F5182-Rev-Unsupported";
614 } else if (*dev == MV88F5181_DEV_ID) {
615 if (*rev == MV88F5181_REV_B1) {
616 *dev_name = "MV88F5181-Rev-B1";
617 } else if (*rev == MV88F5181L_REV_A1) {
618 *dev_name = "MV88F5181L-Rev-A1";
620 *dev_name = "MV88F5181(L)-Rev-Unsupported";
622 } else if (*dev == MV88F6183_DEV_ID) {
623 if (*rev == MV88F6183_REV_B0) {
624 *dev_name = "MV88F6183-Rev-B0";
626 *dev_name = "MV88F6183-Rev-Unsupported";
629 *dev_name = "Device-Unknown";
633 void __init orion5x_init(void)
638 orion5x_id(&dev, &rev, &dev_name);
639 printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk);
641 orion5x_eth_shared_data.t_clk = orion5x_tclk;
642 orion5x_spi_plat_data.tclk = orion5x_tclk;
643 orion5x_uart0_data[0].uartclk = orion5x_tclk;
644 orion5x_uart1_data[0].uartclk = orion5x_tclk;
647 * Setup Orion address map
649 orion5x_setup_cpu_mbus_bridge();
652 * Don't issue "Wait for Interrupt" instruction if we are
653 * running on D0 5281 silicon.
655 if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) {
656 printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n");
661 * Register watchdog driver
667 * Many orion-based systems have buggy bootloader implementations.
668 * This is a common fixup for bogus memory tags.
670 void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
671 char **from, struct meminfo *meminfo)
673 for (; t->hdr.size; t = tag_next(t))
674 if (t->hdr.tag == ATAG_MEM &&
675 (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
676 t->u.mem.start & ~PAGE_MASK)) {
678 "Clearing invalid memory bank %dKB@0x%08x\n",
679 t->u.mem.size / 1024, t->u.mem.start);