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/mbus.h>
17 #include <linux/ata_platform.h>
18 #include <linux/mv643xx_eth.h>
19 #include <linux/mv643xx_i2c.h>
21 #include <linux/spi/orion_spi.h>
22 #include <plat/orion_wdt.h>
23 #include <plat/mv_xor.h>
24 #include <plat/ehci-orion.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,
206 struct mbus_dram_target_info *mbus_dram_info, int tclk,
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->dram = mbus_dram_info;
213 orion_ge_shared_data->t_clk = tclk;
214 orion_ge_resource->start = irq;
215 orion_ge_resource->end = irq;
216 eth_data->shared = orion_ge_shared;
217 orion_ge->dev.platform_data = eth_data;
219 platform_device_register(orion_ge_shared);
220 platform_device_register(orion_ge);
223 /*****************************************************************************
225 ****************************************************************************/
226 struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
228 static struct resource orion_ge00_shared_resources[] = {
232 .name = "ge00 err irq",
236 static struct platform_device orion_ge00_shared = {
237 .name = MV643XX_ETH_SHARED_NAME,
240 .platform_data = &orion_ge00_shared_data,
244 static struct resource orion_ge00_resources[] = {
247 .flags = IORESOURCE_IRQ,
251 static struct platform_device orion_ge00 = {
252 .name = MV643XX_ETH_NAME,
255 .resource = orion_ge00_resources,
257 .coherent_dma_mask = DMA_BIT_MASK(32),
261 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
262 struct mbus_dram_target_info *mbus_dram_info,
263 unsigned long mapbase,
265 unsigned long irq_err,
268 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
269 mapbase + 0x2000, SZ_16K - 1, irq_err);
270 ge_complete(&orion_ge00_shared_data, mbus_dram_info, tclk,
271 orion_ge00_resources, irq, &orion_ge00_shared,
272 eth_data, &orion_ge00);
275 /*****************************************************************************
277 ****************************************************************************/
278 struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
279 .shared_smi = &orion_ge00_shared,
282 static struct resource orion_ge01_shared_resources[] = {
286 .name = "ge01 err irq",
290 static struct platform_device orion_ge01_shared = {
291 .name = MV643XX_ETH_SHARED_NAME,
294 .platform_data = &orion_ge01_shared_data,
298 static struct resource orion_ge01_resources[] = {
301 .flags = IORESOURCE_IRQ,
305 static struct platform_device orion_ge01 = {
306 .name = MV643XX_ETH_NAME,
309 .resource = orion_ge01_resources,
311 .coherent_dma_mask = DMA_BIT_MASK(32),
315 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
316 struct mbus_dram_target_info *mbus_dram_info,
317 unsigned long mapbase,
319 unsigned long irq_err,
322 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
323 mapbase + 0x2000, SZ_16K - 1, irq_err);
324 ge_complete(&orion_ge01_shared_data, mbus_dram_info, tclk,
325 orion_ge01_resources, irq, &orion_ge01_shared,
326 eth_data, &orion_ge01);
329 /*****************************************************************************
331 ****************************************************************************/
332 struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
333 .shared_smi = &orion_ge00_shared,
336 static struct resource orion_ge10_shared_resources[] = {
340 .name = "ge10 err irq",
344 static struct platform_device orion_ge10_shared = {
345 .name = MV643XX_ETH_SHARED_NAME,
348 .platform_data = &orion_ge10_shared_data,
352 static struct resource orion_ge10_resources[] = {
355 .flags = IORESOURCE_IRQ,
359 static struct platform_device orion_ge10 = {
360 .name = MV643XX_ETH_NAME,
363 .resource = orion_ge10_resources,
365 .coherent_dma_mask = DMA_BIT_MASK(32),
369 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
370 struct mbus_dram_target_info *mbus_dram_info,
371 unsigned long mapbase,
373 unsigned long irq_err,
376 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
377 mapbase + 0x2000, SZ_16K - 1, irq_err);
378 ge_complete(&orion_ge10_shared_data, mbus_dram_info, tclk,
379 orion_ge10_resources, irq, &orion_ge10_shared,
380 eth_data, &orion_ge10);
383 /*****************************************************************************
385 ****************************************************************************/
386 struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
387 .shared_smi = &orion_ge00_shared,
390 static struct resource orion_ge11_shared_resources[] = {
394 .name = "ge11 err irq",
398 static struct platform_device orion_ge11_shared = {
399 .name = MV643XX_ETH_SHARED_NAME,
402 .platform_data = &orion_ge11_shared_data,
406 static struct resource orion_ge11_resources[] = {
409 .flags = IORESOURCE_IRQ,
413 static struct platform_device orion_ge11 = {
414 .name = MV643XX_ETH_NAME,
417 .resource = orion_ge11_resources,
419 .coherent_dma_mask = DMA_BIT_MASK(32),
423 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
424 struct mbus_dram_target_info *mbus_dram_info,
425 unsigned long mapbase,
427 unsigned long irq_err,
430 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
431 mapbase + 0x2000, SZ_16K - 1, irq_err);
432 ge_complete(&orion_ge11_shared_data, mbus_dram_info, tclk,
433 orion_ge11_resources, irq, &orion_ge11_shared,
434 eth_data, &orion_ge11);
437 /*****************************************************************************
439 ****************************************************************************/
440 static struct resource orion_switch_resources[] = {
444 .flags = IORESOURCE_IRQ,
448 static struct platform_device orion_switch_device = {
452 .resource = orion_switch_resources,
455 void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
460 orion_switch_resources[0].start = irq;
461 orion_switch_resources[0].end = irq;
462 orion_switch_device.num_resources = 1;
465 d->netdev = &orion_ge00.dev;
466 for (i = 0; i < d->nr_chips; i++)
467 d->chip[i].mii_bus = &orion_ge00_shared.dev;
468 orion_switch_device.dev.platform_data = d;
470 platform_device_register(&orion_switch_device);
473 /*****************************************************************************
475 ****************************************************************************/
476 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
478 .timeout = 1000, /* Default timeout of 1 second */
481 static struct resource orion_i2c_resources[2];
483 static struct platform_device orion_i2c = {
484 .name = MV64XXX_I2C_CTLR_NAME,
487 .platform_data = &orion_i2c_pdata,
491 static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
493 .timeout = 1000, /* Default timeout of 1 second */
496 static struct resource orion_i2c_1_resources[2];
498 static struct platform_device orion_i2c_1 = {
499 .name = MV64XXX_I2C_CTLR_NAME,
502 .platform_data = &orion_i2c_1_pdata,
506 void __init orion_i2c_init(unsigned long mapbase,
508 unsigned long freq_m)
510 orion_i2c_pdata.freq_m = freq_m;
511 fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
513 platform_device_register(&orion_i2c);
516 void __init orion_i2c_1_init(unsigned long mapbase,
518 unsigned long freq_m)
520 orion_i2c_1_pdata.freq_m = freq_m;
521 fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
523 platform_device_register(&orion_i2c_1);
526 /*****************************************************************************
528 ****************************************************************************/
529 static struct orion_spi_info orion_spi_plat_data;
530 static struct resource orion_spi_resources;
532 static struct platform_device orion_spi = {
536 .platform_data = &orion_spi_plat_data,
540 static struct orion_spi_info orion_spi_1_plat_data;
541 static struct resource orion_spi_1_resources;
543 static struct platform_device orion_spi_1 = {
547 .platform_data = &orion_spi_1_plat_data,
551 /* Note: The SPI silicon core does have interrupts. However the
552 * current Linux software driver does not use interrupts. */
554 void __init orion_spi_init(unsigned long mapbase,
557 orion_spi_plat_data.tclk = tclk;
558 fill_resources(&orion_spi, &orion_spi_resources,
559 mapbase, SZ_512 - 1, NO_IRQ);
560 platform_device_register(&orion_spi);
563 void __init orion_spi_1_init(unsigned long mapbase,
566 orion_spi_1_plat_data.tclk = tclk;
567 fill_resources(&orion_spi_1, &orion_spi_1_resources,
568 mapbase, SZ_512 - 1, NO_IRQ);
569 platform_device_register(&orion_spi_1);
572 /*****************************************************************************
574 ****************************************************************************/
575 static struct orion_wdt_platform_data orion_wdt_data;
577 static struct platform_device orion_wdt_device = {
581 .platform_data = &orion_wdt_data,
586 void __init orion_wdt_init(unsigned long tclk)
588 orion_wdt_data.tclk = tclk;
589 platform_device_register(&orion_wdt_device);
592 /*****************************************************************************
594 ****************************************************************************/
595 static struct mv_xor_platform_shared_data orion_xor_shared_data;
597 static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
599 void __init orion_xor_init_channels(
600 struct mv_xor_platform_data *orion_xor0_data,
601 struct platform_device *orion_xor0_channel,
602 struct mv_xor_platform_data *orion_xor1_data,
603 struct platform_device *orion_xor1_channel)
606 * two engines can't do memset simultaneously, this limitation
607 * satisfied by removing memset support from one of the engines.
609 dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
610 dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
611 platform_device_register(orion_xor0_channel);
613 dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
614 dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
615 dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
616 platform_device_register(orion_xor1_channel);
619 /*****************************************************************************
621 ****************************************************************************/
622 static struct resource orion_xor0_shared_resources[] = {
625 .flags = IORESOURCE_MEM,
627 .name = "xor 0 high",
628 .flags = IORESOURCE_MEM,
632 static struct platform_device orion_xor0_shared = {
633 .name = MV_XOR_SHARED_NAME,
636 .platform_data = &orion_xor_shared_data,
638 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
639 .resource = orion_xor0_shared_resources,
642 static struct resource orion_xor00_resources[] = {
644 .flags = IORESOURCE_IRQ,
648 static struct mv_xor_platform_data orion_xor00_data = {
649 .shared = &orion_xor0_shared,
651 .pool_size = PAGE_SIZE,
654 static struct platform_device orion_xor00_channel = {
657 .num_resources = ARRAY_SIZE(orion_xor00_resources),
658 .resource = orion_xor00_resources,
660 .dma_mask = &orion_xor_dmamask,
661 .coherent_dma_mask = DMA_BIT_MASK(64),
662 .platform_data = &orion_xor00_data,
666 static struct resource orion_xor01_resources[] = {
668 .flags = IORESOURCE_IRQ,
672 static struct mv_xor_platform_data orion_xor01_data = {
673 .shared = &orion_xor0_shared,
675 .pool_size = PAGE_SIZE,
678 static struct platform_device orion_xor01_channel = {
681 .num_resources = ARRAY_SIZE(orion_xor01_resources),
682 .resource = orion_xor01_resources,
684 .dma_mask = &orion_xor_dmamask,
685 .coherent_dma_mask = DMA_BIT_MASK(64),
686 .platform_data = &orion_xor01_data,
690 void __init orion_xor0_init(struct mbus_dram_target_info *mbus_dram_info,
691 unsigned long mapbase_low,
692 unsigned long mapbase_high,
696 orion_xor_shared_data.dram = mbus_dram_info;
698 orion_xor0_shared_resources[0].start = mapbase_low;
699 orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
700 orion_xor0_shared_resources[1].start = mapbase_high;
701 orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
703 orion_xor00_resources[0].start = irq_0;
704 orion_xor00_resources[0].end = irq_0;
705 orion_xor01_resources[0].start = irq_1;
706 orion_xor01_resources[0].end = irq_1;
708 platform_device_register(&orion_xor0_shared);
710 orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
711 &orion_xor01_data, &orion_xor01_channel);
714 /*****************************************************************************
716 ****************************************************************************/
717 static struct resource orion_xor1_shared_resources[] = {
720 .flags = IORESOURCE_MEM,
722 .name = "xor 1 high",
723 .flags = IORESOURCE_MEM,
727 static struct platform_device orion_xor1_shared = {
728 .name = MV_XOR_SHARED_NAME,
731 .platform_data = &orion_xor_shared_data,
733 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
734 .resource = orion_xor1_shared_resources,
737 static struct resource orion_xor10_resources[] = {
739 .flags = IORESOURCE_IRQ,
743 static struct mv_xor_platform_data orion_xor10_data = {
744 .shared = &orion_xor1_shared,
746 .pool_size = PAGE_SIZE,
749 static struct platform_device orion_xor10_channel = {
752 .num_resources = ARRAY_SIZE(orion_xor10_resources),
753 .resource = orion_xor10_resources,
755 .dma_mask = &orion_xor_dmamask,
756 .coherent_dma_mask = DMA_BIT_MASK(64),
757 .platform_data = &orion_xor10_data,
761 static struct resource orion_xor11_resources[] = {
763 .flags = IORESOURCE_IRQ,
767 static struct mv_xor_platform_data orion_xor11_data = {
768 .shared = &orion_xor1_shared,
770 .pool_size = PAGE_SIZE,
773 static struct platform_device orion_xor11_channel = {
776 .num_resources = ARRAY_SIZE(orion_xor11_resources),
777 .resource = orion_xor11_resources,
779 .dma_mask = &orion_xor_dmamask,
780 .coherent_dma_mask = DMA_BIT_MASK(64),
781 .platform_data = &orion_xor11_data,
785 void __init orion_xor1_init(unsigned long mapbase_low,
786 unsigned long mapbase_high,
790 orion_xor1_shared_resources[0].start = mapbase_low;
791 orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
792 orion_xor1_shared_resources[1].start = mapbase_high;
793 orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
795 orion_xor10_resources[0].start = irq_0;
796 orion_xor10_resources[0].end = irq_0;
797 orion_xor11_resources[0].start = irq_1;
798 orion_xor11_resources[0].end = irq_1;
800 platform_device_register(&orion_xor1_shared);
802 orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
803 &orion_xor11_data, &orion_xor11_channel);
806 /*****************************************************************************
808 ****************************************************************************/
809 static struct orion_ehci_data orion_ehci_data = {
810 .phy_version = EHCI_PHY_NA,
813 static u64 ehci_dmamask = DMA_BIT_MASK(32);
816 /*****************************************************************************
818 ****************************************************************************/
819 static struct resource orion_ehci_resources[2];
821 static struct platform_device orion_ehci = {
822 .name = "orion-ehci",
825 .dma_mask = &ehci_dmamask,
826 .coherent_dma_mask = DMA_BIT_MASK(32),
827 .platform_data = &orion_ehci_data,
831 void __init orion_ehci_init(struct mbus_dram_target_info *mbus_dram_info,
832 unsigned long mapbase,
835 orion_ehci_data.dram = mbus_dram_info;
836 fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
839 platform_device_register(&orion_ehci);
842 /*****************************************************************************
844 ****************************************************************************/
845 static struct resource orion_ehci_1_resources[2];
847 static struct platform_device orion_ehci_1 = {
848 .name = "orion-ehci",
851 .dma_mask = &ehci_dmamask,
852 .coherent_dma_mask = DMA_BIT_MASK(32),
853 .platform_data = &orion_ehci_data,
857 void __init orion_ehci_1_init(struct mbus_dram_target_info *mbus_dram_info,
858 unsigned long mapbase,
861 orion_ehci_data.dram = mbus_dram_info;
862 fill_resources(&orion_ehci_1, orion_ehci_1_resources,
863 mapbase, SZ_4K - 1, irq);
865 platform_device_register(&orion_ehci_1);
868 /*****************************************************************************
870 ****************************************************************************/
871 static struct resource orion_ehci_2_resources[2];
873 static struct platform_device orion_ehci_2 = {
874 .name = "orion-ehci",
877 .dma_mask = &ehci_dmamask,
878 .coherent_dma_mask = DMA_BIT_MASK(32),
879 .platform_data = &orion_ehci_data,
883 void __init orion_ehci_2_init(struct mbus_dram_target_info *mbus_dram_info,
884 unsigned long mapbase,
887 orion_ehci_data.dram = mbus_dram_info;
888 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
889 mapbase, SZ_4K - 1, irq);
891 platform_device_register(&orion_ehci_2);
894 /*****************************************************************************
896 ****************************************************************************/
897 static struct resource orion_sata_resources[2] = {
905 static struct platform_device orion_sata = {
909 .coherent_dma_mask = DMA_BIT_MASK(32),
913 void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
914 struct mbus_dram_target_info *mbus_dram_info,
915 unsigned long mapbase,
918 sata_data->dram = mbus_dram_info;
919 orion_sata.dev.platform_data = sata_data;
920 fill_resources(&orion_sata, orion_sata_resources,
921 mapbase, 0x5000 - 1, irq);
923 platform_device_register(&orion_sata);
926 /*****************************************************************************
927 * Cryptographic Engines and Security Accelerator (CESA)
928 ****************************************************************************/
929 static struct resource orion_crypto_resources[] = {
933 .name = "crypto interrupt",
936 .flags = IORESOURCE_MEM,
940 static struct platform_device orion_crypto = {
945 void __init orion_crypto_init(unsigned long mapbase,
946 unsigned long srambase,
947 unsigned long sram_size,
950 fill_resources(&orion_crypto, orion_crypto_resources,
951 mapbase, 0xffff, irq);
952 orion_crypto.num_resources = 3;
953 orion_crypto_resources[2].start = srambase;
954 orion_crypto_resources[2].end = srambase + sram_size - 1;
956 platform_device_register(&orion_crypto);