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/irqs.h>
16 #include <mach/ohci.h>
17 #include <plat/pxa27x_keypad.h>
18 #include <mach/camera.h>
19 #include <mach/audio.h>
20 #include <mach/hardware.h>
21 #include <plat/pxa3xx_nand.h>
26 void __init pxa_register_device(struct platform_device *dev, void *data)
30 dev->dev.platform_data = data;
32 ret = platform_device_register(dev);
34 dev_err(&dev->dev, "unable to register device: %d\n", ret);
37 static struct resource pxa_resource_pmu = {
40 .flags = IORESOURCE_IRQ,
43 struct platform_device pxa_device_pmu = {
45 .id = ARM_PMU_DEVICE_CPU,
46 .resource = &pxa_resource_pmu,
50 static struct resource pxamci_resources[] = {
54 .flags = IORESOURCE_MEM,
59 .flags = IORESOURCE_IRQ,
64 .flags = IORESOURCE_DMA,
69 .flags = IORESOURCE_DMA,
73 static u64 pxamci_dmamask = 0xffffffffUL;
75 struct platform_device pxa_device_mci = {
79 .dma_mask = &pxamci_dmamask,
80 .coherent_dma_mask = 0xffffffff,
82 .num_resources = ARRAY_SIZE(pxamci_resources),
83 .resource = pxamci_resources,
86 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
88 pxa_register_device(&pxa_device_mci, info);
92 static struct pxa2xx_udc_mach_info pxa_udc_info = {
96 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
98 memcpy(&pxa_udc_info, info, sizeof *info);
101 static struct resource pxa2xx_udc_resources[] = {
105 .flags = IORESOURCE_MEM,
110 .flags = IORESOURCE_IRQ,
114 static u64 udc_dma_mask = ~(u32)0;
116 struct platform_device pxa25x_device_udc = {
117 .name = "pxa25x-udc",
119 .resource = pxa2xx_udc_resources,
120 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
122 .platform_data = &pxa_udc_info,
123 .dma_mask = &udc_dma_mask,
127 struct platform_device pxa27x_device_udc = {
128 .name = "pxa27x-udc",
130 .resource = pxa2xx_udc_resources,
131 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
133 .platform_data = &pxa_udc_info,
134 .dma_mask = &udc_dma_mask,
139 static struct resource pxa3xx_u2d_resources[] = {
143 .flags = IORESOURCE_MEM,
148 .flags = IORESOURCE_IRQ,
152 struct platform_device pxa3xx_device_u2d = {
153 .name = "pxa3xx-u2d",
155 .resource = pxa3xx_u2d_resources,
156 .num_resources = ARRAY_SIZE(pxa3xx_u2d_resources),
159 void __init pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info)
161 pxa_register_device(&pxa3xx_device_u2d, info);
163 #endif /* CONFIG_PXA3xx */
165 static struct resource pxafb_resources[] = {
169 .flags = IORESOURCE_MEM,
174 .flags = IORESOURCE_IRQ,
178 static u64 fb_dma_mask = ~(u64)0;
180 struct platform_device pxa_device_fb = {
184 .dma_mask = &fb_dma_mask,
185 .coherent_dma_mask = 0xffffffff,
187 .num_resources = ARRAY_SIZE(pxafb_resources),
188 .resource = pxafb_resources,
191 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info)
193 pxa_device_fb.dev.parent = parent;
194 pxa_register_device(&pxa_device_fb, info);
197 static struct resource pxa_resource_ffuart[] = {
201 .flags = IORESOURCE_MEM,
205 .flags = IORESOURCE_IRQ,
209 struct platform_device pxa_device_ffuart = {
210 .name = "pxa2xx-uart",
212 .resource = pxa_resource_ffuart,
213 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
216 void __init pxa_set_ffuart_info(void *info)
218 pxa_register_device(&pxa_device_ffuart, info);
221 static struct resource pxa_resource_btuart[] = {
225 .flags = IORESOURCE_MEM,
229 .flags = IORESOURCE_IRQ,
233 struct platform_device pxa_device_btuart = {
234 .name = "pxa2xx-uart",
236 .resource = pxa_resource_btuart,
237 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
240 void __init pxa_set_btuart_info(void *info)
242 pxa_register_device(&pxa_device_btuart, info);
245 static struct resource pxa_resource_stuart[] = {
249 .flags = IORESOURCE_MEM,
253 .flags = IORESOURCE_IRQ,
257 struct platform_device pxa_device_stuart = {
258 .name = "pxa2xx-uart",
260 .resource = pxa_resource_stuart,
261 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
264 void __init pxa_set_stuart_info(void *info)
266 pxa_register_device(&pxa_device_stuart, info);
269 static struct resource pxa_resource_hwuart[] = {
273 .flags = IORESOURCE_MEM,
277 .flags = IORESOURCE_IRQ,
281 struct platform_device pxa_device_hwuart = {
282 .name = "pxa2xx-uart",
284 .resource = pxa_resource_hwuart,
285 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
288 void __init pxa_set_hwuart_info(void *info)
291 pxa_register_device(&pxa_device_hwuart, info);
293 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
296 static struct resource pxai2c_resources[] = {
300 .flags = IORESOURCE_MEM,
304 .flags = IORESOURCE_IRQ,
308 struct platform_device pxa_device_i2c = {
309 .name = "pxa2xx-i2c",
311 .resource = pxai2c_resources,
312 .num_resources = ARRAY_SIZE(pxai2c_resources),
315 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
317 pxa_register_device(&pxa_device_i2c, info);
321 static struct resource pxa27x_resources_i2c_power[] = {
325 .flags = IORESOURCE_MEM,
329 .flags = IORESOURCE_IRQ,
333 struct platform_device pxa27x_device_i2c_power = {
334 .name = "pxa2xx-i2c",
336 .resource = pxa27x_resources_i2c_power,
337 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
341 static struct resource pxai2s_resources[] = {
345 .flags = IORESOURCE_MEM,
349 .flags = IORESOURCE_IRQ,
353 struct platform_device pxa_device_i2s = {
354 .name = "pxa2xx-i2s",
356 .resource = pxai2s_resources,
357 .num_resources = ARRAY_SIZE(pxai2s_resources),
360 struct platform_device pxa_device_asoc_ssp1 = {
361 .name = "pxa-ssp-dai",
365 struct platform_device pxa_device_asoc_ssp2= {
366 .name = "pxa-ssp-dai",
370 struct platform_device pxa_device_asoc_ssp3 = {
371 .name = "pxa-ssp-dai",
375 struct platform_device pxa_device_asoc_ssp4 = {
376 .name = "pxa-ssp-dai",
380 struct platform_device pxa_device_asoc_platform = {
381 .name = "pxa-pcm-audio",
385 static u64 pxaficp_dmamask = ~(u32)0;
387 static struct resource pxa_ir_resources[] = {
391 .flags = IORESOURCE_IRQ,
396 .flags = IORESOURCE_IRQ,
400 struct platform_device pxa_device_ficp = {
403 .num_resources = ARRAY_SIZE(pxa_ir_resources),
404 .resource = pxa_ir_resources,
406 .dma_mask = &pxaficp_dmamask,
407 .coherent_dma_mask = 0xffffffff,
411 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
413 pxa_register_device(&pxa_device_ficp, info);
416 static struct resource pxa_rtc_resources[] = {
419 .end = 0x40900000 + 0x3b,
420 .flags = IORESOURCE_MEM,
426 .flags = IORESOURCE_IRQ,
429 .start = IRQ_RTCAlrm,
432 .flags = IORESOURCE_IRQ,
436 struct platform_device pxa_device_rtc = {
439 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
440 .resource = pxa_rtc_resources,
443 static struct resource sa1100_rtc_resources[] = {
448 .flags = IORESOURCE_IRQ,
450 .start = IRQ_RTCAlrm,
453 .flags = IORESOURCE_IRQ,
457 struct platform_device sa1100_device_rtc = {
458 .name = "sa1100-rtc",
460 .num_resources = ARRAY_SIZE(sa1100_rtc_resources),
461 .resource = sa1100_rtc_resources,
464 static struct resource pxa_ac97_resources[] = {
467 .end = 0x40500000 + 0xfff,
468 .flags = IORESOURCE_MEM,
473 .flags = IORESOURCE_IRQ,
477 static u64 pxa_ac97_dmamask = 0xffffffffUL;
479 struct platform_device pxa_device_ac97 = {
480 .name = "pxa2xx-ac97",
483 .dma_mask = &pxa_ac97_dmamask,
484 .coherent_dma_mask = 0xffffffff,
486 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
487 .resource = pxa_ac97_resources,
490 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
492 pxa_register_device(&pxa_device_ac97, ops);
497 static struct resource pxa25x_resource_pwm0[] = {
501 .flags = IORESOURCE_MEM,
505 struct platform_device pxa25x_device_pwm0 = {
506 .name = "pxa25x-pwm",
508 .resource = pxa25x_resource_pwm0,
509 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
512 static struct resource pxa25x_resource_pwm1[] = {
516 .flags = IORESOURCE_MEM,
520 struct platform_device pxa25x_device_pwm1 = {
521 .name = "pxa25x-pwm",
523 .resource = pxa25x_resource_pwm1,
524 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
527 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
529 static struct resource pxa25x_resource_ssp[] = {
533 .flags = IORESOURCE_MEM,
538 .flags = IORESOURCE_IRQ,
544 .flags = IORESOURCE_DMA,
550 .flags = IORESOURCE_DMA,
554 struct platform_device pxa25x_device_ssp = {
555 .name = "pxa25x-ssp",
558 .dma_mask = &pxa25x_ssp_dma_mask,
559 .coherent_dma_mask = DMA_BIT_MASK(32),
561 .resource = pxa25x_resource_ssp,
562 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
565 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
567 static struct resource pxa25x_resource_nssp[] = {
571 .flags = IORESOURCE_MEM,
576 .flags = IORESOURCE_IRQ,
582 .flags = IORESOURCE_DMA,
588 .flags = IORESOURCE_DMA,
592 struct platform_device pxa25x_device_nssp = {
593 .name = "pxa25x-nssp",
596 .dma_mask = &pxa25x_nssp_dma_mask,
597 .coherent_dma_mask = DMA_BIT_MASK(32),
599 .resource = pxa25x_resource_nssp,
600 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
603 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
605 static struct resource pxa25x_resource_assp[] = {
609 .flags = IORESOURCE_MEM,
614 .flags = IORESOURCE_IRQ,
620 .flags = IORESOURCE_DMA,
626 .flags = IORESOURCE_DMA,
630 struct platform_device pxa25x_device_assp = {
631 /* ASSP is basically equivalent to NSSP */
632 .name = "pxa25x-nssp",
635 .dma_mask = &pxa25x_assp_dma_mask,
636 .coherent_dma_mask = DMA_BIT_MASK(32),
638 .resource = pxa25x_resource_assp,
639 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
641 #endif /* CONFIG_PXA25x */
643 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
644 static struct resource pxa27x_resource_camera[] = {
648 .flags = IORESOURCE_MEM,
653 .flags = IORESOURCE_IRQ,
657 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
659 static struct platform_device pxa27x_device_camera = {
660 .name = "pxa27x-camera",
661 .id = 0, /* This is used to put cameras on this interface */
663 .dma_mask = &pxa27x_dma_mask_camera,
664 .coherent_dma_mask = 0xffffffff,
666 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
667 .resource = pxa27x_resource_camera,
670 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
672 pxa_register_device(&pxa27x_device_camera, info);
675 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
677 static struct resource pxa27x_resource_ohci[] = {
681 .flags = IORESOURCE_MEM,
686 .flags = IORESOURCE_IRQ,
690 struct platform_device pxa27x_device_ohci = {
691 .name = "pxa27x-ohci",
694 .dma_mask = &pxa27x_ohci_dma_mask,
695 .coherent_dma_mask = DMA_BIT_MASK(32),
697 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
698 .resource = pxa27x_resource_ohci,
701 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
703 pxa_register_device(&pxa27x_device_ohci, info);
705 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
707 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
708 static struct resource pxa27x_resource_keypad[] = {
712 .flags = IORESOURCE_MEM,
717 .flags = IORESOURCE_IRQ,
721 struct platform_device pxa27x_device_keypad = {
722 .name = "pxa27x-keypad",
724 .resource = pxa27x_resource_keypad,
725 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
728 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
730 pxa_register_device(&pxa27x_device_keypad, info);
733 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
735 static struct resource pxa27x_resource_ssp1[] = {
739 .flags = IORESOURCE_MEM,
744 .flags = IORESOURCE_IRQ,
750 .flags = IORESOURCE_DMA,
756 .flags = IORESOURCE_DMA,
760 struct platform_device pxa27x_device_ssp1 = {
761 .name = "pxa27x-ssp",
764 .dma_mask = &pxa27x_ssp1_dma_mask,
765 .coherent_dma_mask = DMA_BIT_MASK(32),
767 .resource = pxa27x_resource_ssp1,
768 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
771 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
773 static struct resource pxa27x_resource_ssp2[] = {
777 .flags = IORESOURCE_MEM,
782 .flags = IORESOURCE_IRQ,
788 .flags = IORESOURCE_DMA,
794 .flags = IORESOURCE_DMA,
798 struct platform_device pxa27x_device_ssp2 = {
799 .name = "pxa27x-ssp",
802 .dma_mask = &pxa27x_ssp2_dma_mask,
803 .coherent_dma_mask = DMA_BIT_MASK(32),
805 .resource = pxa27x_resource_ssp2,
806 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
809 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
811 static struct resource pxa27x_resource_ssp3[] = {
815 .flags = IORESOURCE_MEM,
820 .flags = IORESOURCE_IRQ,
826 .flags = IORESOURCE_DMA,
832 .flags = IORESOURCE_DMA,
836 struct platform_device pxa27x_device_ssp3 = {
837 .name = "pxa27x-ssp",
840 .dma_mask = &pxa27x_ssp3_dma_mask,
841 .coherent_dma_mask = DMA_BIT_MASK(32),
843 .resource = pxa27x_resource_ssp3,
844 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
847 static struct resource pxa27x_resource_pwm0[] = {
851 .flags = IORESOURCE_MEM,
855 struct platform_device pxa27x_device_pwm0 = {
856 .name = "pxa27x-pwm",
858 .resource = pxa27x_resource_pwm0,
859 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
862 static struct resource pxa27x_resource_pwm1[] = {
866 .flags = IORESOURCE_MEM,
870 struct platform_device pxa27x_device_pwm1 = {
871 .name = "pxa27x-pwm",
873 .resource = pxa27x_resource_pwm1,
874 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
876 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx || CONFIG_PXA95x*/
879 static struct resource pxa3xx_resources_mci2[] = {
883 .flags = IORESOURCE_MEM,
888 .flags = IORESOURCE_IRQ,
893 .flags = IORESOURCE_DMA,
898 .flags = IORESOURCE_DMA,
902 struct platform_device pxa3xx_device_mci2 = {
903 .name = "pxa2xx-mci",
906 .dma_mask = &pxamci_dmamask,
907 .coherent_dma_mask = 0xffffffff,
909 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
910 .resource = pxa3xx_resources_mci2,
913 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
915 pxa_register_device(&pxa3xx_device_mci2, info);
918 static struct resource pxa3xx_resources_mci3[] = {
922 .flags = IORESOURCE_MEM,
927 .flags = IORESOURCE_IRQ,
932 .flags = IORESOURCE_DMA,
937 .flags = IORESOURCE_DMA,
941 struct platform_device pxa3xx_device_mci3 = {
942 .name = "pxa2xx-mci",
945 .dma_mask = &pxamci_dmamask,
946 .coherent_dma_mask = 0xffffffff,
948 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
949 .resource = pxa3xx_resources_mci3,
952 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
954 pxa_register_device(&pxa3xx_device_mci3, info);
957 static struct resource pxa3xx_resources_gcu[] = {
961 .flags = IORESOURCE_MEM,
966 .flags = IORESOURCE_IRQ,
970 static u64 pxa3xx_gcu_dmamask = DMA_BIT_MASK(32);
972 struct platform_device pxa3xx_device_gcu = {
973 .name = "pxa3xx-gcu",
975 .num_resources = ARRAY_SIZE(pxa3xx_resources_gcu),
976 .resource = pxa3xx_resources_gcu,
978 .dma_mask = &pxa3xx_gcu_dmamask,
979 .coherent_dma_mask = 0xffffffff,
983 #endif /* CONFIG_PXA3xx */
985 #if defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x)
986 static struct resource pxa3xx_resources_i2c_power[] = {
990 .flags = IORESOURCE_MEM,
994 .flags = IORESOURCE_IRQ,
998 struct platform_device pxa3xx_device_i2c_power = {
999 .name = "pxa3xx-pwri2c",
1001 .resource = pxa3xx_resources_i2c_power,
1002 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
1005 static struct resource pxa3xx_resources_nand[] = {
1007 .start = 0x43100000,
1009 .flags = IORESOURCE_MEM,
1014 .flags = IORESOURCE_IRQ,
1017 /* DRCMR for Data DMA */
1020 .flags = IORESOURCE_DMA,
1023 /* DRCMR for Command DMA */
1026 .flags = IORESOURCE_DMA,
1030 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
1032 struct platform_device pxa3xx_device_nand = {
1033 .name = "pxa3xx-nand",
1036 .dma_mask = &pxa3xx_nand_dma_mask,
1037 .coherent_dma_mask = DMA_BIT_MASK(32),
1039 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
1040 .resource = pxa3xx_resources_nand,
1043 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
1045 pxa_register_device(&pxa3xx_device_nand, info);
1048 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
1050 static struct resource pxa3xx_resource_ssp4[] = {
1052 .start = 0x41a00000,
1054 .flags = IORESOURCE_MEM,
1059 .flags = IORESOURCE_IRQ,
1065 .flags = IORESOURCE_DMA,
1071 .flags = IORESOURCE_DMA,
1075 struct platform_device pxa3xx_device_ssp4 = {
1076 /* PXA3xx SSP is basically equivalent to PXA27x */
1077 .name = "pxa27x-ssp",
1080 .dma_mask = &pxa3xx_ssp4_dma_mask,
1081 .coherent_dma_mask = DMA_BIT_MASK(32),
1083 .resource = pxa3xx_resource_ssp4,
1084 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
1086 #endif /* CONFIG_PXA3xx || CONFIG_PXA95x */
1088 struct resource pxa_resource_gpio[] = {
1090 .start = 0x40e00000,
1092 .flags = IORESOURCE_MEM,
1097 .flags = IORESOURCE_IRQ,
1102 .flags = IORESOURCE_IRQ,
1104 .start = IRQ_GPIO_2_x,
1105 .end = IRQ_GPIO_2_x,
1107 .flags = IORESOURCE_IRQ,
1111 struct platform_device pxa_device_gpio = {
1114 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
1115 .resource = pxa_resource_gpio,
1118 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1119 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1120 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
1122 struct platform_device *pd;
1124 pd = platform_device_alloc("pxa2xx-spi", id);
1126 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
1131 pd->dev.platform_data = info;
1132 platform_device_add(pd);