2 * arch/arm/plat-orion/common.c
4 * Marvell Orion SoC common setup code used by multiple mach-/common.c
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/dma-mapping.h>
15 #include <linux/serial_8250.h>
16 #include <linux/ata_platform.h>
17 #include <linux/mv643xx_eth.h>
18 #include <linux/mv643xx_i2c.h>
20 #include <linux/spi/orion_spi.h>
21 #include <plat/orion_wdt.h>
22 #include <plat/mv_xor.h>
23 #include <plat/ehci-orion.h>
24 #include <mach/bridge-regs.h>
26 /* Fill in the resources structure and link it into the platform
27 device structure. There is always a memory region, and nearly
28 always an interrupt.*/
29 static void fill_resources(struct platform_device *device,
30 struct resource *resources,
31 resource_size_t mapbase,
35 device->resource = resources;
36 device->num_resources = 1;
37 resources[0].flags = IORESOURCE_MEM;
38 resources[0].start = mapbase;
39 resources[0].end = mapbase + size;
42 device->num_resources++;
43 resources[1].flags = IORESOURCE_IRQ;
44 resources[1].start = irq;
45 resources[1].end = irq;
49 /*****************************************************************************
51 ****************************************************************************/
52 static void __init uart_complete(
53 struct platform_device *orion_uart,
54 struct plat_serial8250_port *data,
55 struct resource *resources,
57 resource_size_t mapbase,
61 data->mapbase = mapbase;
62 data->membase = (void __iomem *)membase;
64 data->uartclk = uartclk;
65 orion_uart->dev.platform_data = data;
67 fill_resources(orion_uart, resources, mapbase, 0xff, irq);
68 platform_device_register(orion_uart);
71 /*****************************************************************************
73 ****************************************************************************/
74 static struct plat_serial8250_port orion_uart0_data[] = {
76 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
83 static struct resource orion_uart0_resources[2];
85 static struct platform_device orion_uart0 = {
87 .id = PLAT8250_DEV_PLATFORM,
90 void __init orion_uart0_init(unsigned int membase,
91 resource_size_t mapbase,
95 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
96 membase, mapbase, irq, uartclk);
99 /*****************************************************************************
101 ****************************************************************************/
102 static struct plat_serial8250_port orion_uart1_data[] = {
104 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
111 static struct resource orion_uart1_resources[2];
113 static struct platform_device orion_uart1 = {
114 .name = "serial8250",
115 .id = PLAT8250_DEV_PLATFORM1,
118 void __init orion_uart1_init(unsigned int membase,
119 resource_size_t mapbase,
121 unsigned int uartclk)
123 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
124 membase, mapbase, irq, uartclk);
127 /*****************************************************************************
129 ****************************************************************************/
130 static struct plat_serial8250_port orion_uart2_data[] = {
132 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
139 static struct resource orion_uart2_resources[2];
141 static struct platform_device orion_uart2 = {
142 .name = "serial8250",
143 .id = PLAT8250_DEV_PLATFORM2,
146 void __init orion_uart2_init(unsigned int membase,
147 resource_size_t mapbase,
149 unsigned int uartclk)
151 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
152 membase, mapbase, irq, uartclk);
155 /*****************************************************************************
157 ****************************************************************************/
158 static struct plat_serial8250_port orion_uart3_data[] = {
160 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
167 static struct resource orion_uart3_resources[2];
169 static struct platform_device orion_uart3 = {
170 .name = "serial8250",
174 void __init orion_uart3_init(unsigned int membase,
175 resource_size_t mapbase,
177 unsigned int uartclk)
179 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
180 membase, mapbase, irq, uartclk);
183 /*****************************************************************************
185 ****************************************************************************/
186 static struct resource orion_rtc_resource[2];
188 void __init orion_rtc_init(unsigned long mapbase,
191 orion_rtc_resource[0].start = mapbase;
192 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
193 orion_rtc_resource[0].flags = IORESOURCE_MEM;
194 orion_rtc_resource[1].start = irq;
195 orion_rtc_resource[1].end = irq;
196 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
198 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
201 /*****************************************************************************
203 ****************************************************************************/
204 static __init void ge_complete(
205 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
207 struct resource *orion_ge_resource, unsigned long irq,
208 struct platform_device *orion_ge_shared,
209 struct mv643xx_eth_platform_data *eth_data,
210 struct platform_device *orion_ge)
212 orion_ge_shared_data->t_clk = tclk;
213 orion_ge_resource->start = irq;
214 orion_ge_resource->end = irq;
215 eth_data->shared = orion_ge_shared;
216 orion_ge->dev.platform_data = eth_data;
218 platform_device_register(orion_ge_shared);
219 platform_device_register(orion_ge);
222 /*****************************************************************************
224 ****************************************************************************/
225 struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
227 static struct resource orion_ge00_shared_resources[] = {
231 .name = "ge00 err irq",
235 static struct platform_device orion_ge00_shared = {
236 .name = MV643XX_ETH_SHARED_NAME,
239 .platform_data = &orion_ge00_shared_data,
243 static struct resource orion_ge00_resources[] = {
246 .flags = IORESOURCE_IRQ,
250 static struct platform_device orion_ge00 = {
251 .name = MV643XX_ETH_NAME,
254 .resource = orion_ge00_resources,
256 .coherent_dma_mask = DMA_BIT_MASK(32),
260 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
261 unsigned long mapbase,
263 unsigned long irq_err,
266 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
267 mapbase + 0x2000, SZ_16K - 1, irq_err);
268 ge_complete(&orion_ge00_shared_data, tclk,
269 orion_ge00_resources, irq, &orion_ge00_shared,
270 eth_data, &orion_ge00);
273 /*****************************************************************************
275 ****************************************************************************/
276 struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
277 .shared_smi = &orion_ge00_shared,
280 static struct resource orion_ge01_shared_resources[] = {
284 .name = "ge01 err irq",
288 static struct platform_device orion_ge01_shared = {
289 .name = MV643XX_ETH_SHARED_NAME,
292 .platform_data = &orion_ge01_shared_data,
296 static struct resource orion_ge01_resources[] = {
299 .flags = IORESOURCE_IRQ,
303 static struct platform_device orion_ge01 = {
304 .name = MV643XX_ETH_NAME,
307 .resource = orion_ge01_resources,
309 .coherent_dma_mask = DMA_BIT_MASK(32),
313 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
314 unsigned long mapbase,
316 unsigned long irq_err,
319 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
320 mapbase + 0x2000, SZ_16K - 1, irq_err);
321 ge_complete(&orion_ge01_shared_data, tclk,
322 orion_ge01_resources, irq, &orion_ge01_shared,
323 eth_data, &orion_ge01);
326 /*****************************************************************************
328 ****************************************************************************/
329 struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
330 .shared_smi = &orion_ge00_shared,
333 static struct resource orion_ge10_shared_resources[] = {
337 .name = "ge10 err irq",
341 static struct platform_device orion_ge10_shared = {
342 .name = MV643XX_ETH_SHARED_NAME,
345 .platform_data = &orion_ge10_shared_data,
349 static struct resource orion_ge10_resources[] = {
352 .flags = IORESOURCE_IRQ,
356 static struct platform_device orion_ge10 = {
357 .name = MV643XX_ETH_NAME,
360 .resource = orion_ge10_resources,
362 .coherent_dma_mask = DMA_BIT_MASK(32),
366 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
367 unsigned long mapbase,
369 unsigned long irq_err,
372 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
373 mapbase + 0x2000, SZ_16K - 1, irq_err);
374 ge_complete(&orion_ge10_shared_data, tclk,
375 orion_ge10_resources, irq, &orion_ge10_shared,
376 eth_data, &orion_ge10);
379 /*****************************************************************************
381 ****************************************************************************/
382 struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
383 .shared_smi = &orion_ge00_shared,
386 static struct resource orion_ge11_shared_resources[] = {
390 .name = "ge11 err irq",
394 static struct platform_device orion_ge11_shared = {
395 .name = MV643XX_ETH_SHARED_NAME,
398 .platform_data = &orion_ge11_shared_data,
402 static struct resource orion_ge11_resources[] = {
405 .flags = IORESOURCE_IRQ,
409 static struct platform_device orion_ge11 = {
410 .name = MV643XX_ETH_NAME,
413 .resource = orion_ge11_resources,
415 .coherent_dma_mask = DMA_BIT_MASK(32),
419 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
420 unsigned long mapbase,
422 unsigned long irq_err,
425 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
426 mapbase + 0x2000, SZ_16K - 1, irq_err);
427 ge_complete(&orion_ge11_shared_data, tclk,
428 orion_ge11_resources, irq, &orion_ge11_shared,
429 eth_data, &orion_ge11);
432 /*****************************************************************************
434 ****************************************************************************/
435 static struct resource orion_switch_resources[] = {
439 .flags = IORESOURCE_IRQ,
443 static struct platform_device orion_switch_device = {
447 .resource = orion_switch_resources,
450 void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
455 orion_switch_resources[0].start = irq;
456 orion_switch_resources[0].end = irq;
457 orion_switch_device.num_resources = 1;
460 d->netdev = &orion_ge00.dev;
461 for (i = 0; i < d->nr_chips; i++)
462 d->chip[i].mii_bus = &orion_ge00_shared.dev;
463 orion_switch_device.dev.platform_data = d;
465 platform_device_register(&orion_switch_device);
468 /*****************************************************************************
470 ****************************************************************************/
471 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
473 .timeout = 1000, /* Default timeout of 1 second */
476 static struct resource orion_i2c_resources[2];
478 static struct platform_device orion_i2c = {
479 .name = MV64XXX_I2C_CTLR_NAME,
482 .platform_data = &orion_i2c_pdata,
486 static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
488 .timeout = 1000, /* Default timeout of 1 second */
491 static struct resource orion_i2c_1_resources[2];
493 static struct platform_device orion_i2c_1 = {
494 .name = MV64XXX_I2C_CTLR_NAME,
497 .platform_data = &orion_i2c_1_pdata,
501 void __init orion_i2c_init(unsigned long mapbase,
503 unsigned long freq_m)
505 orion_i2c_pdata.freq_m = freq_m;
506 fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
508 platform_device_register(&orion_i2c);
511 void __init orion_i2c_1_init(unsigned long mapbase,
513 unsigned long freq_m)
515 orion_i2c_1_pdata.freq_m = freq_m;
516 fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
518 platform_device_register(&orion_i2c_1);
521 /*****************************************************************************
523 ****************************************************************************/
524 static struct orion_spi_info orion_spi_plat_data;
525 static struct resource orion_spi_resources;
527 static struct platform_device orion_spi = {
531 .platform_data = &orion_spi_plat_data,
535 static struct orion_spi_info orion_spi_1_plat_data;
536 static struct resource orion_spi_1_resources;
538 static struct platform_device orion_spi_1 = {
542 .platform_data = &orion_spi_1_plat_data,
546 /* Note: The SPI silicon core does have interrupts. However the
547 * current Linux software driver does not use interrupts. */
549 void __init orion_spi_init(unsigned long mapbase,
552 orion_spi_plat_data.tclk = tclk;
553 fill_resources(&orion_spi, &orion_spi_resources,
554 mapbase, SZ_512 - 1, NO_IRQ);
555 platform_device_register(&orion_spi);
558 void __init orion_spi_1_init(unsigned long mapbase,
561 orion_spi_1_plat_data.tclk = tclk;
562 fill_resources(&orion_spi_1, &orion_spi_1_resources,
563 mapbase, SZ_512 - 1, NO_IRQ);
564 platform_device_register(&orion_spi_1);
567 /*****************************************************************************
569 ****************************************************************************/
570 static struct orion_wdt_platform_data orion_wdt_data;
572 static struct resource orion_wdt_resource =
573 DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28);
575 static struct platform_device orion_wdt_device = {
579 .platform_data = &orion_wdt_data,
581 .resource = &orion_wdt_resource,
585 void __init orion_wdt_init(unsigned long tclk)
587 orion_wdt_data.tclk = tclk;
588 platform_device_register(&orion_wdt_device);
591 /*****************************************************************************
593 ****************************************************************************/
594 static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
596 void __init orion_xor_init_channels(
597 struct mv_xor_platform_data *orion_xor0_data,
598 struct platform_device *orion_xor0_channel,
599 struct mv_xor_platform_data *orion_xor1_data,
600 struct platform_device *orion_xor1_channel)
603 * two engines can't do memset simultaneously, this limitation
604 * satisfied by removing memset support from one of the engines.
606 dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
607 dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
608 platform_device_register(orion_xor0_channel);
610 dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
611 dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
612 dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
613 platform_device_register(orion_xor1_channel);
616 /*****************************************************************************
618 ****************************************************************************/
619 static struct resource orion_xor0_shared_resources[] = {
622 .flags = IORESOURCE_MEM,
624 .name = "xor 0 high",
625 .flags = IORESOURCE_MEM,
629 static struct platform_device orion_xor0_shared = {
630 .name = MV_XOR_SHARED_NAME,
632 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
633 .resource = orion_xor0_shared_resources,
636 static struct resource orion_xor00_resources[] = {
638 .flags = IORESOURCE_IRQ,
642 static struct mv_xor_platform_data orion_xor00_data = {
643 .shared = &orion_xor0_shared,
645 .pool_size = PAGE_SIZE,
648 static struct platform_device orion_xor00_channel = {
651 .num_resources = ARRAY_SIZE(orion_xor00_resources),
652 .resource = orion_xor00_resources,
654 .dma_mask = &orion_xor_dmamask,
655 .coherent_dma_mask = DMA_BIT_MASK(64),
656 .platform_data = &orion_xor00_data,
660 static struct resource orion_xor01_resources[] = {
662 .flags = IORESOURCE_IRQ,
666 static struct mv_xor_platform_data orion_xor01_data = {
667 .shared = &orion_xor0_shared,
669 .pool_size = PAGE_SIZE,
672 static struct platform_device orion_xor01_channel = {
675 .num_resources = ARRAY_SIZE(orion_xor01_resources),
676 .resource = orion_xor01_resources,
678 .dma_mask = &orion_xor_dmamask,
679 .coherent_dma_mask = DMA_BIT_MASK(64),
680 .platform_data = &orion_xor01_data,
684 void __init orion_xor0_init(unsigned long mapbase_low,
685 unsigned long mapbase_high,
689 orion_xor0_shared_resources[0].start = mapbase_low;
690 orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
691 orion_xor0_shared_resources[1].start = mapbase_high;
692 orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
694 orion_xor00_resources[0].start = irq_0;
695 orion_xor00_resources[0].end = irq_0;
696 orion_xor01_resources[0].start = irq_1;
697 orion_xor01_resources[0].end = irq_1;
699 platform_device_register(&orion_xor0_shared);
701 orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
702 &orion_xor01_data, &orion_xor01_channel);
705 /*****************************************************************************
707 ****************************************************************************/
708 static struct resource orion_xor1_shared_resources[] = {
711 .flags = IORESOURCE_MEM,
713 .name = "xor 1 high",
714 .flags = IORESOURCE_MEM,
718 static struct platform_device orion_xor1_shared = {
719 .name = MV_XOR_SHARED_NAME,
721 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
722 .resource = orion_xor1_shared_resources,
725 static struct resource orion_xor10_resources[] = {
727 .flags = IORESOURCE_IRQ,
731 static struct mv_xor_platform_data orion_xor10_data = {
732 .shared = &orion_xor1_shared,
734 .pool_size = PAGE_SIZE,
737 static struct platform_device orion_xor10_channel = {
740 .num_resources = ARRAY_SIZE(orion_xor10_resources),
741 .resource = orion_xor10_resources,
743 .dma_mask = &orion_xor_dmamask,
744 .coherent_dma_mask = DMA_BIT_MASK(64),
745 .platform_data = &orion_xor10_data,
749 static struct resource orion_xor11_resources[] = {
751 .flags = IORESOURCE_IRQ,
755 static struct mv_xor_platform_data orion_xor11_data = {
756 .shared = &orion_xor1_shared,
758 .pool_size = PAGE_SIZE,
761 static struct platform_device orion_xor11_channel = {
764 .num_resources = ARRAY_SIZE(orion_xor11_resources),
765 .resource = orion_xor11_resources,
767 .dma_mask = &orion_xor_dmamask,
768 .coherent_dma_mask = DMA_BIT_MASK(64),
769 .platform_data = &orion_xor11_data,
773 void __init orion_xor1_init(unsigned long mapbase_low,
774 unsigned long mapbase_high,
778 orion_xor1_shared_resources[0].start = mapbase_low;
779 orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
780 orion_xor1_shared_resources[1].start = mapbase_high;
781 orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
783 orion_xor10_resources[0].start = irq_0;
784 orion_xor10_resources[0].end = irq_0;
785 orion_xor11_resources[0].start = irq_1;
786 orion_xor11_resources[0].end = irq_1;
788 platform_device_register(&orion_xor1_shared);
790 orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
791 &orion_xor11_data, &orion_xor11_channel);
794 /*****************************************************************************
796 ****************************************************************************/
797 static struct orion_ehci_data orion_ehci_data;
798 static u64 ehci_dmamask = DMA_BIT_MASK(32);
801 /*****************************************************************************
803 ****************************************************************************/
804 static struct resource orion_ehci_resources[2];
806 static struct platform_device orion_ehci = {
807 .name = "orion-ehci",
810 .dma_mask = &ehci_dmamask,
811 .coherent_dma_mask = DMA_BIT_MASK(32),
812 .platform_data = &orion_ehci_data,
816 void __init orion_ehci_init(unsigned long mapbase,
818 enum orion_ehci_phy_ver phy_version)
820 orion_ehci_data.phy_version = phy_version;
821 fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
824 platform_device_register(&orion_ehci);
827 /*****************************************************************************
829 ****************************************************************************/
830 static struct resource orion_ehci_1_resources[2];
832 static struct platform_device orion_ehci_1 = {
833 .name = "orion-ehci",
836 .dma_mask = &ehci_dmamask,
837 .coherent_dma_mask = DMA_BIT_MASK(32),
838 .platform_data = &orion_ehci_data,
842 void __init orion_ehci_1_init(unsigned long mapbase,
845 fill_resources(&orion_ehci_1, orion_ehci_1_resources,
846 mapbase, SZ_4K - 1, irq);
848 platform_device_register(&orion_ehci_1);
851 /*****************************************************************************
853 ****************************************************************************/
854 static struct resource orion_ehci_2_resources[2];
856 static struct platform_device orion_ehci_2 = {
857 .name = "orion-ehci",
860 .dma_mask = &ehci_dmamask,
861 .coherent_dma_mask = DMA_BIT_MASK(32),
862 .platform_data = &orion_ehci_data,
866 void __init orion_ehci_2_init(unsigned long mapbase,
869 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
870 mapbase, SZ_4K - 1, irq);
872 platform_device_register(&orion_ehci_2);
875 /*****************************************************************************
877 ****************************************************************************/
878 static struct resource orion_sata_resources[2] = {
886 static struct platform_device orion_sata = {
890 .coherent_dma_mask = DMA_BIT_MASK(32),
894 void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
895 unsigned long mapbase,
898 orion_sata.dev.platform_data = sata_data;
899 fill_resources(&orion_sata, orion_sata_resources,
900 mapbase, 0x5000 - 1, irq);
902 platform_device_register(&orion_sata);
905 /*****************************************************************************
906 * Cryptographic Engines and Security Accelerator (CESA)
907 ****************************************************************************/
908 static struct resource orion_crypto_resources[] = {
912 .name = "crypto interrupt",
915 .flags = IORESOURCE_MEM,
919 static struct platform_device orion_crypto = {
924 void __init orion_crypto_init(unsigned long mapbase,
925 unsigned long srambase,
926 unsigned long sram_size,
929 fill_resources(&orion_crypto, orion_crypto_resources,
930 mapbase, 0xffff, irq);
931 orion_crypto.num_resources = 3;
932 orion_crypto_resources[2].start = srambase;
933 orion_crypto_resources[2].end = srambase + sram_size - 1;
935 platform_device_register(&orion_crypto);