1 #include <linux/module.h>
2 #include <linux/kernel.h>
3 #include <linux/init.h>
4 #include <linux/platform_device.h>
5 #include <linux/dma-mapping.h>
6 #include <linux/spi/pxa2xx_spi.h>
7 #include <linux/i2c/pxa-i2c.h>
11 #include <mach/pxa3xx-u2d.h>
12 #include <mach/pxafb.h>
14 #include <mach/irda.h>
15 #include <mach/ohci.h>
16 #include <plat/pxa27x_keypad.h>
17 #include <mach/camera.h>
18 #include <mach/audio.h>
19 #include <mach/hardware.h>
20 #include <plat/pxa3xx_nand.h>
25 void __init pxa_register_device(struct platform_device *dev, void *data)
29 dev->dev.platform_data = data;
31 ret = platform_device_register(dev);
33 dev_err(&dev->dev, "unable to register device: %d\n", ret);
36 static struct resource pxa_resource_pmu = {
39 .flags = IORESOURCE_IRQ,
42 struct platform_device pxa_device_pmu = {
44 .id = ARM_PMU_DEVICE_CPU,
45 .resource = &pxa_resource_pmu,
49 static struct resource pxamci_resources[] = {
53 .flags = IORESOURCE_MEM,
58 .flags = IORESOURCE_IRQ,
63 .flags = IORESOURCE_DMA,
68 .flags = IORESOURCE_DMA,
72 static u64 pxamci_dmamask = 0xffffffffUL;
74 struct platform_device pxa_device_mci = {
78 .dma_mask = &pxamci_dmamask,
79 .coherent_dma_mask = 0xffffffff,
81 .num_resources = ARRAY_SIZE(pxamci_resources),
82 .resource = pxamci_resources,
85 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
87 pxa_register_device(&pxa_device_mci, info);
91 static struct pxa2xx_udc_mach_info pxa_udc_info = {
95 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
97 memcpy(&pxa_udc_info, info, sizeof *info);
100 static struct resource pxa2xx_udc_resources[] = {
104 .flags = IORESOURCE_MEM,
109 .flags = IORESOURCE_IRQ,
113 static u64 udc_dma_mask = ~(u32)0;
115 struct platform_device pxa25x_device_udc = {
116 .name = "pxa25x-udc",
118 .resource = pxa2xx_udc_resources,
119 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
121 .platform_data = &pxa_udc_info,
122 .dma_mask = &udc_dma_mask,
126 struct platform_device pxa27x_device_udc = {
127 .name = "pxa27x-udc",
129 .resource = pxa2xx_udc_resources,
130 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
132 .platform_data = &pxa_udc_info,
133 .dma_mask = &udc_dma_mask,
138 static struct resource pxa3xx_u2d_resources[] = {
142 .flags = IORESOURCE_MEM,
147 .flags = IORESOURCE_IRQ,
151 struct platform_device pxa3xx_device_u2d = {
152 .name = "pxa3xx-u2d",
154 .resource = pxa3xx_u2d_resources,
155 .num_resources = ARRAY_SIZE(pxa3xx_u2d_resources),
158 void __init pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info)
160 pxa_register_device(&pxa3xx_device_u2d, info);
162 #endif /* CONFIG_PXA3xx */
164 static struct resource pxafb_resources[] = {
168 .flags = IORESOURCE_MEM,
173 .flags = IORESOURCE_IRQ,
177 static u64 fb_dma_mask = ~(u64)0;
179 struct platform_device pxa_device_fb = {
183 .dma_mask = &fb_dma_mask,
184 .coherent_dma_mask = 0xffffffff,
186 .num_resources = ARRAY_SIZE(pxafb_resources),
187 .resource = pxafb_resources,
190 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info)
192 pxa_device_fb.dev.parent = parent;
193 pxa_register_device(&pxa_device_fb, info);
196 static struct resource pxa_resource_ffuart[] = {
200 .flags = IORESOURCE_MEM,
204 .flags = IORESOURCE_IRQ,
208 struct platform_device pxa_device_ffuart = {
209 .name = "pxa2xx-uart",
211 .resource = pxa_resource_ffuart,
212 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
215 void __init pxa_set_ffuart_info(void *info)
217 pxa_register_device(&pxa_device_ffuart, info);
220 static struct resource pxa_resource_btuart[] = {
224 .flags = IORESOURCE_MEM,
228 .flags = IORESOURCE_IRQ,
232 struct platform_device pxa_device_btuart = {
233 .name = "pxa2xx-uart",
235 .resource = pxa_resource_btuart,
236 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
239 void __init pxa_set_btuart_info(void *info)
241 pxa_register_device(&pxa_device_btuart, info);
244 static struct resource pxa_resource_stuart[] = {
248 .flags = IORESOURCE_MEM,
252 .flags = IORESOURCE_IRQ,
256 struct platform_device pxa_device_stuart = {
257 .name = "pxa2xx-uart",
259 .resource = pxa_resource_stuart,
260 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
263 void __init pxa_set_stuart_info(void *info)
265 pxa_register_device(&pxa_device_stuart, info);
268 static struct resource pxa_resource_hwuart[] = {
272 .flags = IORESOURCE_MEM,
276 .flags = IORESOURCE_IRQ,
280 struct platform_device pxa_device_hwuart = {
281 .name = "pxa2xx-uart",
283 .resource = pxa_resource_hwuart,
284 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
287 void __init pxa_set_hwuart_info(void *info)
290 pxa_register_device(&pxa_device_hwuart, info);
292 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
295 static struct resource pxai2c_resources[] = {
299 .flags = IORESOURCE_MEM,
303 .flags = IORESOURCE_IRQ,
307 struct platform_device pxa_device_i2c = {
308 .name = "pxa2xx-i2c",
310 .resource = pxai2c_resources,
311 .num_resources = ARRAY_SIZE(pxai2c_resources),
314 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
316 pxa_register_device(&pxa_device_i2c, info);
320 static struct resource pxa27x_resources_i2c_power[] = {
324 .flags = IORESOURCE_MEM,
328 .flags = IORESOURCE_IRQ,
332 struct platform_device pxa27x_device_i2c_power = {
333 .name = "pxa2xx-i2c",
335 .resource = pxa27x_resources_i2c_power,
336 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
340 static struct resource pxai2s_resources[] = {
344 .flags = IORESOURCE_MEM,
348 .flags = IORESOURCE_IRQ,
352 struct platform_device pxa_device_i2s = {
353 .name = "pxa2xx-i2s",
355 .resource = pxai2s_resources,
356 .num_resources = ARRAY_SIZE(pxai2s_resources),
359 struct platform_device pxa_device_asoc_ssp1 = {
360 .name = "pxa-ssp-dai",
364 struct platform_device pxa_device_asoc_ssp2= {
365 .name = "pxa-ssp-dai",
369 struct platform_device pxa_device_asoc_ssp3 = {
370 .name = "pxa-ssp-dai",
374 struct platform_device pxa_device_asoc_ssp4 = {
375 .name = "pxa-ssp-dai",
379 struct platform_device pxa_device_asoc_platform = {
380 .name = "pxa-pcm-audio",
384 static u64 pxaficp_dmamask = ~(u32)0;
386 struct platform_device pxa_device_ficp = {
390 .dma_mask = &pxaficp_dmamask,
391 .coherent_dma_mask = 0xffffffff,
395 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
397 pxa_register_device(&pxa_device_ficp, info);
400 static struct resource pxa_rtc_resources[] = {
403 .end = 0x40900000 + 0x3b,
404 .flags = IORESOURCE_MEM,
410 .flags = IORESOURCE_IRQ,
413 .start = IRQ_RTCAlrm,
416 .flags = IORESOURCE_IRQ,
420 struct platform_device pxa_device_rtc = {
423 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
424 .resource = pxa_rtc_resources,
427 static struct resource sa1100_rtc_resources[] = {
432 .flags = IORESOURCE_IRQ,
434 .start = IRQ_RTCAlrm,
437 .flags = IORESOURCE_IRQ,
441 struct platform_device sa1100_device_rtc = {
442 .name = "sa1100-rtc",
444 .num_resources = ARRAY_SIZE(sa1100_rtc_resources),
445 .resource = sa1100_rtc_resources,
448 static struct resource pxa_ac97_resources[] = {
451 .end = 0x40500000 + 0xfff,
452 .flags = IORESOURCE_MEM,
457 .flags = IORESOURCE_IRQ,
461 static u64 pxa_ac97_dmamask = 0xffffffffUL;
463 struct platform_device pxa_device_ac97 = {
464 .name = "pxa2xx-ac97",
467 .dma_mask = &pxa_ac97_dmamask,
468 .coherent_dma_mask = 0xffffffff,
470 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
471 .resource = pxa_ac97_resources,
474 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
476 pxa_register_device(&pxa_device_ac97, ops);
481 static struct resource pxa25x_resource_pwm0[] = {
485 .flags = IORESOURCE_MEM,
489 struct platform_device pxa25x_device_pwm0 = {
490 .name = "pxa25x-pwm",
492 .resource = pxa25x_resource_pwm0,
493 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
496 static struct resource pxa25x_resource_pwm1[] = {
500 .flags = IORESOURCE_MEM,
504 struct platform_device pxa25x_device_pwm1 = {
505 .name = "pxa25x-pwm",
507 .resource = pxa25x_resource_pwm1,
508 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
511 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
513 static struct resource pxa25x_resource_ssp[] = {
517 .flags = IORESOURCE_MEM,
522 .flags = IORESOURCE_IRQ,
528 .flags = IORESOURCE_DMA,
534 .flags = IORESOURCE_DMA,
538 struct platform_device pxa25x_device_ssp = {
539 .name = "pxa25x-ssp",
542 .dma_mask = &pxa25x_ssp_dma_mask,
543 .coherent_dma_mask = DMA_BIT_MASK(32),
545 .resource = pxa25x_resource_ssp,
546 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
549 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
551 static struct resource pxa25x_resource_nssp[] = {
555 .flags = IORESOURCE_MEM,
560 .flags = IORESOURCE_IRQ,
566 .flags = IORESOURCE_DMA,
572 .flags = IORESOURCE_DMA,
576 struct platform_device pxa25x_device_nssp = {
577 .name = "pxa25x-nssp",
580 .dma_mask = &pxa25x_nssp_dma_mask,
581 .coherent_dma_mask = DMA_BIT_MASK(32),
583 .resource = pxa25x_resource_nssp,
584 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
587 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
589 static struct resource pxa25x_resource_assp[] = {
593 .flags = IORESOURCE_MEM,
598 .flags = IORESOURCE_IRQ,
604 .flags = IORESOURCE_DMA,
610 .flags = IORESOURCE_DMA,
614 struct platform_device pxa25x_device_assp = {
615 /* ASSP is basically equivalent to NSSP */
616 .name = "pxa25x-nssp",
619 .dma_mask = &pxa25x_assp_dma_mask,
620 .coherent_dma_mask = DMA_BIT_MASK(32),
622 .resource = pxa25x_resource_assp,
623 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
625 #endif /* CONFIG_PXA25x */
627 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
628 static struct resource pxa27x_resource_camera[] = {
632 .flags = IORESOURCE_MEM,
637 .flags = IORESOURCE_IRQ,
641 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
643 static struct platform_device pxa27x_device_camera = {
644 .name = "pxa27x-camera",
645 .id = 0, /* This is used to put cameras on this interface */
647 .dma_mask = &pxa27x_dma_mask_camera,
648 .coherent_dma_mask = 0xffffffff,
650 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
651 .resource = pxa27x_resource_camera,
654 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
656 pxa_register_device(&pxa27x_device_camera, info);
659 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
661 static struct resource pxa27x_resource_ohci[] = {
665 .flags = IORESOURCE_MEM,
670 .flags = IORESOURCE_IRQ,
674 struct platform_device pxa27x_device_ohci = {
675 .name = "pxa27x-ohci",
678 .dma_mask = &pxa27x_ohci_dma_mask,
679 .coherent_dma_mask = DMA_BIT_MASK(32),
681 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
682 .resource = pxa27x_resource_ohci,
685 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
687 pxa_register_device(&pxa27x_device_ohci, info);
689 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
691 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
692 static struct resource pxa27x_resource_keypad[] = {
696 .flags = IORESOURCE_MEM,
701 .flags = IORESOURCE_IRQ,
705 struct platform_device pxa27x_device_keypad = {
706 .name = "pxa27x-keypad",
708 .resource = pxa27x_resource_keypad,
709 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
712 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
714 pxa_register_device(&pxa27x_device_keypad, info);
717 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
719 static struct resource pxa27x_resource_ssp1[] = {
723 .flags = IORESOURCE_MEM,
728 .flags = IORESOURCE_IRQ,
734 .flags = IORESOURCE_DMA,
740 .flags = IORESOURCE_DMA,
744 struct platform_device pxa27x_device_ssp1 = {
745 .name = "pxa27x-ssp",
748 .dma_mask = &pxa27x_ssp1_dma_mask,
749 .coherent_dma_mask = DMA_BIT_MASK(32),
751 .resource = pxa27x_resource_ssp1,
752 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
755 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
757 static struct resource pxa27x_resource_ssp2[] = {
761 .flags = IORESOURCE_MEM,
766 .flags = IORESOURCE_IRQ,
772 .flags = IORESOURCE_DMA,
778 .flags = IORESOURCE_DMA,
782 struct platform_device pxa27x_device_ssp2 = {
783 .name = "pxa27x-ssp",
786 .dma_mask = &pxa27x_ssp2_dma_mask,
787 .coherent_dma_mask = DMA_BIT_MASK(32),
789 .resource = pxa27x_resource_ssp2,
790 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
793 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
795 static struct resource pxa27x_resource_ssp3[] = {
799 .flags = IORESOURCE_MEM,
804 .flags = IORESOURCE_IRQ,
810 .flags = IORESOURCE_DMA,
816 .flags = IORESOURCE_DMA,
820 struct platform_device pxa27x_device_ssp3 = {
821 .name = "pxa27x-ssp",
824 .dma_mask = &pxa27x_ssp3_dma_mask,
825 .coherent_dma_mask = DMA_BIT_MASK(32),
827 .resource = pxa27x_resource_ssp3,
828 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
831 static struct resource pxa27x_resource_pwm0[] = {
835 .flags = IORESOURCE_MEM,
839 struct platform_device pxa27x_device_pwm0 = {
840 .name = "pxa27x-pwm",
842 .resource = pxa27x_resource_pwm0,
843 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
846 static struct resource pxa27x_resource_pwm1[] = {
850 .flags = IORESOURCE_MEM,
854 struct platform_device pxa27x_device_pwm1 = {
855 .name = "pxa27x-pwm",
857 .resource = pxa27x_resource_pwm1,
858 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
860 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx || CONFIG_PXA95x*/
863 static struct resource pxa3xx_resources_mci2[] = {
867 .flags = IORESOURCE_MEM,
872 .flags = IORESOURCE_IRQ,
877 .flags = IORESOURCE_DMA,
882 .flags = IORESOURCE_DMA,
886 struct platform_device pxa3xx_device_mci2 = {
887 .name = "pxa2xx-mci",
890 .dma_mask = &pxamci_dmamask,
891 .coherent_dma_mask = 0xffffffff,
893 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
894 .resource = pxa3xx_resources_mci2,
897 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
899 pxa_register_device(&pxa3xx_device_mci2, info);
902 static struct resource pxa3xx_resources_mci3[] = {
906 .flags = IORESOURCE_MEM,
911 .flags = IORESOURCE_IRQ,
916 .flags = IORESOURCE_DMA,
921 .flags = IORESOURCE_DMA,
925 struct platform_device pxa3xx_device_mci3 = {
926 .name = "pxa2xx-mci",
929 .dma_mask = &pxamci_dmamask,
930 .coherent_dma_mask = 0xffffffff,
932 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
933 .resource = pxa3xx_resources_mci3,
936 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
938 pxa_register_device(&pxa3xx_device_mci3, info);
941 static struct resource pxa3xx_resources_gcu[] = {
945 .flags = IORESOURCE_MEM,
950 .flags = IORESOURCE_IRQ,
954 static u64 pxa3xx_gcu_dmamask = DMA_BIT_MASK(32);
956 struct platform_device pxa3xx_device_gcu = {
957 .name = "pxa3xx-gcu",
959 .num_resources = ARRAY_SIZE(pxa3xx_resources_gcu),
960 .resource = pxa3xx_resources_gcu,
962 .dma_mask = &pxa3xx_gcu_dmamask,
963 .coherent_dma_mask = 0xffffffff,
967 #endif /* CONFIG_PXA3xx */
969 #if defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
970 static struct resource pxa3xx_resources_i2c_power[] = {
974 .flags = IORESOURCE_MEM,
978 .flags = IORESOURCE_IRQ,
982 struct platform_device pxa3xx_device_i2c_power = {
983 .name = "pxa3xx-pwri2c",
985 .resource = pxa3xx_resources_i2c_power,
986 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
989 static struct resource pxa3xx_resources_nand[] = {
993 .flags = IORESOURCE_MEM,
998 .flags = IORESOURCE_IRQ,
1001 /* DRCMR for Data DMA */
1004 .flags = IORESOURCE_DMA,
1007 /* DRCMR for Command DMA */
1010 .flags = IORESOURCE_DMA,
1014 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
1016 struct platform_device pxa3xx_device_nand = {
1017 .name = "pxa3xx-nand",
1020 .dma_mask = &pxa3xx_nand_dma_mask,
1021 .coherent_dma_mask = DMA_BIT_MASK(32),
1023 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
1024 .resource = pxa3xx_resources_nand,
1027 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
1029 pxa_register_device(&pxa3xx_device_nand, info);
1032 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
1034 static struct resource pxa3xx_resource_ssp4[] = {
1036 .start = 0x41a00000,
1038 .flags = IORESOURCE_MEM,
1043 .flags = IORESOURCE_IRQ,
1049 .flags = IORESOURCE_DMA,
1055 .flags = IORESOURCE_DMA,
1059 struct platform_device pxa3xx_device_ssp4 = {
1060 /* PXA3xx SSP is basically equivalent to PXA27x */
1061 .name = "pxa27x-ssp",
1064 .dma_mask = &pxa3xx_ssp4_dma_mask,
1065 .coherent_dma_mask = DMA_BIT_MASK(32),
1067 .resource = pxa3xx_resource_ssp4,
1068 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
1070 #endif /* CONFIG_PXA3xx || CONFIG_PXA95x */
1072 struct resource pxa_resource_gpio[] = {
1074 .start = 0x40e00000,
1076 .flags = IORESOURCE_MEM,
1081 .flags = IORESOURCE_IRQ,
1086 .flags = IORESOURCE_IRQ,
1088 .start = IRQ_GPIO_2_x,
1089 .end = IRQ_GPIO_2_x,
1091 .flags = IORESOURCE_IRQ,
1095 struct platform_device pxa_device_gpio = {
1098 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
1099 .resource = pxa_resource_gpio,
1102 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1103 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1104 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
1106 struct platform_device *pd;
1108 pd = platform_device_alloc("pxa2xx-spi", id);
1110 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
1115 pd->dev.platform_data = info;
1116 platform_device_add(pd);