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/clk.h>
18 #include <linux/clkdev.h>
19 #include <linux/mv643xx_eth.h>
20 #include <linux/mv643xx_i2c.h>
22 #include <plat/mv_xor.h>
23 #include <plat/ehci-orion.h>
24 #include <mach/bridge-regs.h>
26 /* Create a clkdev entry for a given device/clk */
27 void __init orion_clkdev_add(const char *con_id, const char *dev_id,
30 struct clk_lookup *cl;
32 cl = clkdev_alloc(clk, con_id, dev_id);
37 /* Create clkdev entries for all orion platforms except kirkwood.
38 Kirkwood has gated clocks for some of its peripherals, so creates
39 its own clkdev entries. For all the other orion devices, create
40 clkdev entries to the tclk. */
41 void __init orion_clkdev_init(struct clk *tclk)
43 orion_clkdev_add(NULL, "orion_spi.0", tclk);
44 orion_clkdev_add(NULL, "orion_spi.1", tclk);
45 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".0", tclk);
46 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".1", tclk);
47 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".2", tclk);
48 orion_clkdev_add(NULL, MV643XX_ETH_NAME ".3", tclk);
49 orion_clkdev_add(NULL, "orion_wdt", tclk);
52 /* Fill in the resources structure and link it into the platform
53 device structure. There is always a memory region, and nearly
54 always an interrupt.*/
55 static void fill_resources(struct platform_device *device,
56 struct resource *resources,
57 resource_size_t mapbase,
61 device->resource = resources;
62 device->num_resources = 1;
63 resources[0].flags = IORESOURCE_MEM;
64 resources[0].start = mapbase;
65 resources[0].end = mapbase + size;
68 device->num_resources++;
69 resources[1].flags = IORESOURCE_IRQ;
70 resources[1].start = irq;
71 resources[1].end = irq;
75 /*****************************************************************************
77 ****************************************************************************/
78 static unsigned long __init uart_get_clk_rate(struct clk *clk)
80 clk_prepare_enable(clk);
81 return clk_get_rate(clk);
84 static void __init uart_complete(
85 struct platform_device *orion_uart,
86 struct plat_serial8250_port *data,
87 struct resource *resources,
89 resource_size_t mapbase,
93 data->mapbase = mapbase;
94 data->membase = (void __iomem *)membase;
96 data->uartclk = uart_get_clk_rate(clk);
97 orion_uart->dev.platform_data = data;
99 fill_resources(orion_uart, resources, mapbase, 0xff, irq);
100 platform_device_register(orion_uart);
103 /*****************************************************************************
105 ****************************************************************************/
106 static struct plat_serial8250_port orion_uart0_data[] = {
108 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
115 static struct resource orion_uart0_resources[2];
117 static struct platform_device orion_uart0 = {
118 .name = "serial8250",
119 .id = PLAT8250_DEV_PLATFORM,
122 void __init orion_uart0_init(unsigned int membase,
123 resource_size_t mapbase,
127 uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources,
128 membase, mapbase, irq, clk);
131 /*****************************************************************************
133 ****************************************************************************/
134 static struct plat_serial8250_port orion_uart1_data[] = {
136 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
143 static struct resource orion_uart1_resources[2];
145 static struct platform_device orion_uart1 = {
146 .name = "serial8250",
147 .id = PLAT8250_DEV_PLATFORM1,
150 void __init orion_uart1_init(unsigned int membase,
151 resource_size_t mapbase,
155 uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources,
156 membase, mapbase, irq, clk);
159 /*****************************************************************************
161 ****************************************************************************/
162 static struct plat_serial8250_port orion_uart2_data[] = {
164 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
171 static struct resource orion_uart2_resources[2];
173 static struct platform_device orion_uart2 = {
174 .name = "serial8250",
175 .id = PLAT8250_DEV_PLATFORM2,
178 void __init orion_uart2_init(unsigned int membase,
179 resource_size_t mapbase,
183 uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources,
184 membase, mapbase, irq, clk);
187 /*****************************************************************************
189 ****************************************************************************/
190 static struct plat_serial8250_port orion_uart3_data[] = {
192 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
199 static struct resource orion_uart3_resources[2];
201 static struct platform_device orion_uart3 = {
202 .name = "serial8250",
206 void __init orion_uart3_init(unsigned int membase,
207 resource_size_t mapbase,
211 uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources,
212 membase, mapbase, irq, clk);
215 /*****************************************************************************
217 ****************************************************************************/
218 static struct resource orion_rtc_resource[2];
220 void __init orion_rtc_init(unsigned long mapbase,
223 orion_rtc_resource[0].start = mapbase;
224 orion_rtc_resource[0].end = mapbase + SZ_32 - 1;
225 orion_rtc_resource[0].flags = IORESOURCE_MEM;
226 orion_rtc_resource[1].start = irq;
227 orion_rtc_resource[1].end = irq;
228 orion_rtc_resource[1].flags = IORESOURCE_IRQ;
230 platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2);
233 /*****************************************************************************
235 ****************************************************************************/
236 static __init void ge_complete(
237 struct mv643xx_eth_shared_platform_data *orion_ge_shared_data,
238 struct resource *orion_ge_resource, unsigned long irq,
239 struct platform_device *orion_ge_shared,
240 struct mv643xx_eth_platform_data *eth_data,
241 struct platform_device *orion_ge)
243 orion_ge_resource->start = irq;
244 orion_ge_resource->end = irq;
245 eth_data->shared = orion_ge_shared;
246 orion_ge->dev.platform_data = eth_data;
248 platform_device_register(orion_ge_shared);
249 platform_device_register(orion_ge);
252 /*****************************************************************************
254 ****************************************************************************/
255 struct mv643xx_eth_shared_platform_data orion_ge00_shared_data;
257 static struct resource orion_ge00_shared_resources[] = {
261 .name = "ge00 err irq",
265 static struct platform_device orion_ge00_shared = {
266 .name = MV643XX_ETH_SHARED_NAME,
269 .platform_data = &orion_ge00_shared_data,
273 static struct resource orion_ge00_resources[] = {
276 .flags = IORESOURCE_IRQ,
280 static struct platform_device orion_ge00 = {
281 .name = MV643XX_ETH_NAME,
284 .resource = orion_ge00_resources,
286 .coherent_dma_mask = DMA_BIT_MASK(32),
290 void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data,
291 unsigned long mapbase,
293 unsigned long irq_err)
295 fill_resources(&orion_ge00_shared, orion_ge00_shared_resources,
296 mapbase + 0x2000, SZ_16K - 1, irq_err);
297 ge_complete(&orion_ge00_shared_data,
298 orion_ge00_resources, irq, &orion_ge00_shared,
299 eth_data, &orion_ge00);
302 /*****************************************************************************
304 ****************************************************************************/
305 struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = {
306 .shared_smi = &orion_ge00_shared,
309 static struct resource orion_ge01_shared_resources[] = {
313 .name = "ge01 err irq",
317 static struct platform_device orion_ge01_shared = {
318 .name = MV643XX_ETH_SHARED_NAME,
321 .platform_data = &orion_ge01_shared_data,
325 static struct resource orion_ge01_resources[] = {
328 .flags = IORESOURCE_IRQ,
332 static struct platform_device orion_ge01 = {
333 .name = MV643XX_ETH_NAME,
336 .resource = orion_ge01_resources,
338 .coherent_dma_mask = DMA_BIT_MASK(32),
342 void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data,
343 unsigned long mapbase,
345 unsigned long irq_err)
347 fill_resources(&orion_ge01_shared, orion_ge01_shared_resources,
348 mapbase + 0x2000, SZ_16K - 1, irq_err);
349 ge_complete(&orion_ge01_shared_data,
350 orion_ge01_resources, irq, &orion_ge01_shared,
351 eth_data, &orion_ge01);
354 /*****************************************************************************
356 ****************************************************************************/
357 struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = {
358 .shared_smi = &orion_ge00_shared,
361 static struct resource orion_ge10_shared_resources[] = {
365 .name = "ge10 err irq",
369 static struct platform_device orion_ge10_shared = {
370 .name = MV643XX_ETH_SHARED_NAME,
373 .platform_data = &orion_ge10_shared_data,
377 static struct resource orion_ge10_resources[] = {
380 .flags = IORESOURCE_IRQ,
384 static struct platform_device orion_ge10 = {
385 .name = MV643XX_ETH_NAME,
388 .resource = orion_ge10_resources,
390 .coherent_dma_mask = DMA_BIT_MASK(32),
394 void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data,
395 unsigned long mapbase,
397 unsigned long irq_err)
399 fill_resources(&orion_ge10_shared, orion_ge10_shared_resources,
400 mapbase + 0x2000, SZ_16K - 1, irq_err);
401 ge_complete(&orion_ge10_shared_data,
402 orion_ge10_resources, irq, &orion_ge10_shared,
403 eth_data, &orion_ge10);
406 /*****************************************************************************
408 ****************************************************************************/
409 struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = {
410 .shared_smi = &orion_ge00_shared,
413 static struct resource orion_ge11_shared_resources[] = {
417 .name = "ge11 err irq",
421 static struct platform_device orion_ge11_shared = {
422 .name = MV643XX_ETH_SHARED_NAME,
425 .platform_data = &orion_ge11_shared_data,
429 static struct resource orion_ge11_resources[] = {
432 .flags = IORESOURCE_IRQ,
436 static struct platform_device orion_ge11 = {
437 .name = MV643XX_ETH_NAME,
440 .resource = orion_ge11_resources,
442 .coherent_dma_mask = DMA_BIT_MASK(32),
446 void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data,
447 unsigned long mapbase,
449 unsigned long irq_err)
451 fill_resources(&orion_ge11_shared, orion_ge11_shared_resources,
452 mapbase + 0x2000, SZ_16K - 1, irq_err);
453 ge_complete(&orion_ge11_shared_data,
454 orion_ge11_resources, irq, &orion_ge11_shared,
455 eth_data, &orion_ge11);
458 /*****************************************************************************
460 ****************************************************************************/
461 static struct resource orion_switch_resources[] = {
465 .flags = IORESOURCE_IRQ,
469 static struct platform_device orion_switch_device = {
473 .resource = orion_switch_resources,
476 void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq)
481 orion_switch_resources[0].start = irq;
482 orion_switch_resources[0].end = irq;
483 orion_switch_device.num_resources = 1;
486 d->netdev = &orion_ge00.dev;
487 for (i = 0; i < d->nr_chips; i++)
488 d->chip[i].mii_bus = &orion_ge00_shared.dev;
489 orion_switch_device.dev.platform_data = d;
491 platform_device_register(&orion_switch_device);
494 /*****************************************************************************
496 ****************************************************************************/
497 static struct mv64xxx_i2c_pdata orion_i2c_pdata = {
499 .timeout = 1000, /* Default timeout of 1 second */
502 static struct resource orion_i2c_resources[2];
504 static struct platform_device orion_i2c = {
505 .name = MV64XXX_I2C_CTLR_NAME,
508 .platform_data = &orion_i2c_pdata,
512 static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = {
514 .timeout = 1000, /* Default timeout of 1 second */
517 static struct resource orion_i2c_1_resources[2];
519 static struct platform_device orion_i2c_1 = {
520 .name = MV64XXX_I2C_CTLR_NAME,
523 .platform_data = &orion_i2c_1_pdata,
527 void __init orion_i2c_init(unsigned long mapbase,
529 unsigned long freq_m)
531 orion_i2c_pdata.freq_m = freq_m;
532 fill_resources(&orion_i2c, orion_i2c_resources, mapbase,
534 platform_device_register(&orion_i2c);
537 void __init orion_i2c_1_init(unsigned long mapbase,
539 unsigned long freq_m)
541 orion_i2c_1_pdata.freq_m = freq_m;
542 fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase,
544 platform_device_register(&orion_i2c_1);
547 /*****************************************************************************
549 ****************************************************************************/
550 static struct resource orion_spi_resources;
552 static struct platform_device orion_spi = {
557 static struct resource orion_spi_1_resources;
559 static struct platform_device orion_spi_1 = {
564 /* Note: The SPI silicon core does have interrupts. However the
565 * current Linux software driver does not use interrupts. */
567 void __init orion_spi_init(unsigned long mapbase)
569 fill_resources(&orion_spi, &orion_spi_resources,
570 mapbase, SZ_512 - 1, NO_IRQ);
571 platform_device_register(&orion_spi);
574 void __init orion_spi_1_init(unsigned long mapbase)
576 fill_resources(&orion_spi_1, &orion_spi_1_resources,
577 mapbase, SZ_512 - 1, NO_IRQ);
578 platform_device_register(&orion_spi_1);
581 /*****************************************************************************
583 ****************************************************************************/
584 static struct resource orion_wdt_resource =
585 DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
587 static struct platform_device orion_wdt_device = {
591 .resource = &orion_wdt_resource,
594 void __init orion_wdt_init(void)
596 platform_device_register(&orion_wdt_device);
599 /*****************************************************************************
601 ****************************************************************************/
602 static u64 orion_xor_dmamask = DMA_BIT_MASK(32);
604 void __init orion_xor_init_channels(
605 struct mv_xor_platform_data *orion_xor0_data,
606 struct platform_device *orion_xor0_channel,
607 struct mv_xor_platform_data *orion_xor1_data,
608 struct platform_device *orion_xor1_channel)
611 * two engines can't do memset simultaneously, this limitation
612 * satisfied by removing memset support from one of the engines.
614 dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask);
615 dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask);
616 platform_device_register(orion_xor0_channel);
618 dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask);
619 dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask);
620 dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask);
621 platform_device_register(orion_xor1_channel);
624 /*****************************************************************************
626 ****************************************************************************/
627 static struct resource orion_xor0_shared_resources[] = {
630 .flags = IORESOURCE_MEM,
632 .name = "xor 0 high",
633 .flags = IORESOURCE_MEM,
637 static struct platform_device orion_xor0_shared = {
638 .name = MV_XOR_SHARED_NAME,
640 .num_resources = ARRAY_SIZE(orion_xor0_shared_resources),
641 .resource = orion_xor0_shared_resources,
644 static struct resource orion_xor00_resources[] = {
646 .flags = IORESOURCE_IRQ,
650 static struct mv_xor_platform_data orion_xor00_data = {
651 .shared = &orion_xor0_shared,
653 .pool_size = PAGE_SIZE,
656 static struct platform_device orion_xor00_channel = {
659 .num_resources = ARRAY_SIZE(orion_xor00_resources),
660 .resource = orion_xor00_resources,
662 .dma_mask = &orion_xor_dmamask,
663 .coherent_dma_mask = DMA_BIT_MASK(64),
664 .platform_data = &orion_xor00_data,
668 static struct resource orion_xor01_resources[] = {
670 .flags = IORESOURCE_IRQ,
674 static struct mv_xor_platform_data orion_xor01_data = {
675 .shared = &orion_xor0_shared,
677 .pool_size = PAGE_SIZE,
680 static struct platform_device orion_xor01_channel = {
683 .num_resources = ARRAY_SIZE(orion_xor01_resources),
684 .resource = orion_xor01_resources,
686 .dma_mask = &orion_xor_dmamask,
687 .coherent_dma_mask = DMA_BIT_MASK(64),
688 .platform_data = &orion_xor01_data,
692 void __init orion_xor0_init(unsigned long mapbase_low,
693 unsigned long mapbase_high,
697 orion_xor0_shared_resources[0].start = mapbase_low;
698 orion_xor0_shared_resources[0].end = mapbase_low + 0xff;
699 orion_xor0_shared_resources[1].start = mapbase_high;
700 orion_xor0_shared_resources[1].end = mapbase_high + 0xff;
702 orion_xor00_resources[0].start = irq_0;
703 orion_xor00_resources[0].end = irq_0;
704 orion_xor01_resources[0].start = irq_1;
705 orion_xor01_resources[0].end = irq_1;
707 platform_device_register(&orion_xor0_shared);
709 orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel,
710 &orion_xor01_data, &orion_xor01_channel);
713 /*****************************************************************************
715 ****************************************************************************/
716 static struct resource orion_xor1_shared_resources[] = {
719 .flags = IORESOURCE_MEM,
721 .name = "xor 1 high",
722 .flags = IORESOURCE_MEM,
726 static struct platform_device orion_xor1_shared = {
727 .name = MV_XOR_SHARED_NAME,
729 .num_resources = ARRAY_SIZE(orion_xor1_shared_resources),
730 .resource = orion_xor1_shared_resources,
733 static struct resource orion_xor10_resources[] = {
735 .flags = IORESOURCE_IRQ,
739 static struct mv_xor_platform_data orion_xor10_data = {
740 .shared = &orion_xor1_shared,
742 .pool_size = PAGE_SIZE,
745 static struct platform_device orion_xor10_channel = {
748 .num_resources = ARRAY_SIZE(orion_xor10_resources),
749 .resource = orion_xor10_resources,
751 .dma_mask = &orion_xor_dmamask,
752 .coherent_dma_mask = DMA_BIT_MASK(64),
753 .platform_data = &orion_xor10_data,
757 static struct resource orion_xor11_resources[] = {
759 .flags = IORESOURCE_IRQ,
763 static struct mv_xor_platform_data orion_xor11_data = {
764 .shared = &orion_xor1_shared,
766 .pool_size = PAGE_SIZE,
769 static struct platform_device orion_xor11_channel = {
772 .num_resources = ARRAY_SIZE(orion_xor11_resources),
773 .resource = orion_xor11_resources,
775 .dma_mask = &orion_xor_dmamask,
776 .coherent_dma_mask = DMA_BIT_MASK(64),
777 .platform_data = &orion_xor11_data,
781 void __init orion_xor1_init(unsigned long mapbase_low,
782 unsigned long mapbase_high,
786 orion_xor1_shared_resources[0].start = mapbase_low;
787 orion_xor1_shared_resources[0].end = mapbase_low + 0xff;
788 orion_xor1_shared_resources[1].start = mapbase_high;
789 orion_xor1_shared_resources[1].end = mapbase_high + 0xff;
791 orion_xor10_resources[0].start = irq_0;
792 orion_xor10_resources[0].end = irq_0;
793 orion_xor11_resources[0].start = irq_1;
794 orion_xor11_resources[0].end = irq_1;
796 platform_device_register(&orion_xor1_shared);
798 orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel,
799 &orion_xor11_data, &orion_xor11_channel);
802 /*****************************************************************************
804 ****************************************************************************/
805 static struct orion_ehci_data orion_ehci_data;
806 static u64 ehci_dmamask = DMA_BIT_MASK(32);
809 /*****************************************************************************
811 ****************************************************************************/
812 static struct resource orion_ehci_resources[2];
814 static struct platform_device orion_ehci = {
815 .name = "orion-ehci",
818 .dma_mask = &ehci_dmamask,
819 .coherent_dma_mask = DMA_BIT_MASK(32),
820 .platform_data = &orion_ehci_data,
824 void __init orion_ehci_init(unsigned long mapbase,
826 enum orion_ehci_phy_ver phy_version)
828 orion_ehci_data.phy_version = phy_version;
829 fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1,
832 platform_device_register(&orion_ehci);
835 /*****************************************************************************
837 ****************************************************************************/
838 static struct resource orion_ehci_1_resources[2];
840 static struct platform_device orion_ehci_1 = {
841 .name = "orion-ehci",
844 .dma_mask = &ehci_dmamask,
845 .coherent_dma_mask = DMA_BIT_MASK(32),
846 .platform_data = &orion_ehci_data,
850 void __init orion_ehci_1_init(unsigned long mapbase,
853 fill_resources(&orion_ehci_1, orion_ehci_1_resources,
854 mapbase, SZ_4K - 1, irq);
856 platform_device_register(&orion_ehci_1);
859 /*****************************************************************************
861 ****************************************************************************/
862 static struct resource orion_ehci_2_resources[2];
864 static struct platform_device orion_ehci_2 = {
865 .name = "orion-ehci",
868 .dma_mask = &ehci_dmamask,
869 .coherent_dma_mask = DMA_BIT_MASK(32),
870 .platform_data = &orion_ehci_data,
874 void __init orion_ehci_2_init(unsigned long mapbase,
877 fill_resources(&orion_ehci_2, orion_ehci_2_resources,
878 mapbase, SZ_4K - 1, irq);
880 platform_device_register(&orion_ehci_2);
883 /*****************************************************************************
885 ****************************************************************************/
886 static struct resource orion_sata_resources[2] = {
894 static struct platform_device orion_sata = {
898 .coherent_dma_mask = DMA_BIT_MASK(32),
902 void __init orion_sata_init(struct mv_sata_platform_data *sata_data,
903 unsigned long mapbase,
906 orion_sata.dev.platform_data = sata_data;
907 fill_resources(&orion_sata, orion_sata_resources,
908 mapbase, 0x5000 - 1, irq);
910 platform_device_register(&orion_sata);
913 /*****************************************************************************
914 * Cryptographic Engines and Security Accelerator (CESA)
915 ****************************************************************************/
916 static struct resource orion_crypto_resources[] = {
920 .name = "crypto interrupt",
923 .flags = IORESOURCE_MEM,
927 static struct platform_device orion_crypto = {
932 void __init orion_crypto_init(unsigned long mapbase,
933 unsigned long srambase,
934 unsigned long sram_size,
937 fill_resources(&orion_crypto, orion_crypto_resources,
938 mapbase, 0xffff, irq);
939 orion_crypto.num_resources = 3;
940 orion_crypto_resources[2].start = srambase;
941 orion_crypto_resources[2].end = srambase + sram_size - 1;
943 platform_device_register(&orion_crypto);