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>
9 #include <mach/pxa3xx-u2d.h>
10 #include <mach/pxafb.h>
12 #include <mach/irda.h>
13 #include <mach/ohci.h>
14 #include <plat/pxa27x_keypad.h>
15 #include <mach/pxa2xx_spi.h>
16 #include <mach/camera.h>
17 #include <mach/audio.h>
18 #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 = {
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 set_pxa_fb_info(struct pxafb_mach_info *info)
193 pxa_register_device(&pxa_device_fb, info);
196 void __init set_pxa_fb_parent(struct device *parent_dev)
198 pxa_device_fb.dev.parent = parent_dev;
201 static struct resource pxa_resource_ffuart[] = {
205 .flags = IORESOURCE_MEM,
209 .flags = IORESOURCE_IRQ,
213 struct platform_device pxa_device_ffuart = {
214 .name = "pxa2xx-uart",
216 .resource = pxa_resource_ffuart,
217 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
220 void __init pxa_set_ffuart_info(void *info)
222 pxa_register_device(&pxa_device_ffuart, info);
225 static struct resource pxa_resource_btuart[] = {
229 .flags = IORESOURCE_MEM,
233 .flags = IORESOURCE_IRQ,
237 struct platform_device pxa_device_btuart = {
238 .name = "pxa2xx-uart",
240 .resource = pxa_resource_btuart,
241 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
244 void __init pxa_set_btuart_info(void *info)
246 pxa_register_device(&pxa_device_btuart, info);
249 static struct resource pxa_resource_stuart[] = {
253 .flags = IORESOURCE_MEM,
257 .flags = IORESOURCE_IRQ,
261 struct platform_device pxa_device_stuart = {
262 .name = "pxa2xx-uart",
264 .resource = pxa_resource_stuart,
265 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
268 void __init pxa_set_stuart_info(void *info)
270 pxa_register_device(&pxa_device_stuart, info);
273 static struct resource pxa_resource_hwuart[] = {
277 .flags = IORESOURCE_MEM,
281 .flags = IORESOURCE_IRQ,
285 struct platform_device pxa_device_hwuart = {
286 .name = "pxa2xx-uart",
288 .resource = pxa_resource_hwuart,
289 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
292 void __init pxa_set_hwuart_info(void *info)
295 pxa_register_device(&pxa_device_hwuart, info);
297 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
300 static struct resource pxai2c_resources[] = {
304 .flags = IORESOURCE_MEM,
308 .flags = IORESOURCE_IRQ,
312 struct platform_device pxa_device_i2c = {
313 .name = "pxa2xx-i2c",
315 .resource = pxai2c_resources,
316 .num_resources = ARRAY_SIZE(pxai2c_resources),
319 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
321 pxa_register_device(&pxa_device_i2c, info);
325 static struct resource pxa27x_resources_i2c_power[] = {
329 .flags = IORESOURCE_MEM,
333 .flags = IORESOURCE_IRQ,
337 struct platform_device pxa27x_device_i2c_power = {
338 .name = "pxa2xx-i2c",
340 .resource = pxa27x_resources_i2c_power,
341 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
346 static struct resource pxa3xx_resources_i2c_power[] = {
350 .flags = IORESOURCE_MEM,
354 .flags = IORESOURCE_IRQ,
358 struct platform_device pxa3xx_device_i2c_power = {
359 .name = "pxa3xx-pwri2c",
361 .resource = pxa3xx_resources_i2c_power,
362 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
366 static struct resource pxai2s_resources[] = {
370 .flags = IORESOURCE_MEM,
374 .flags = IORESOURCE_IRQ,
378 struct platform_device pxa_device_i2s = {
379 .name = "pxa2xx-i2s",
381 .resource = pxai2s_resources,
382 .num_resources = ARRAY_SIZE(pxai2s_resources),
385 static u64 pxaficp_dmamask = ~(u32)0;
387 struct platform_device pxa_device_ficp = {
391 .dma_mask = &pxaficp_dmamask,
392 .coherent_dma_mask = 0xffffffff,
396 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
398 pxa_register_device(&pxa_device_ficp, info);
401 static struct resource pxa_rtc_resources[] = {
404 .end = 0x40900000 + 0x3b,
405 .flags = IORESOURCE_MEM,
410 .flags = IORESOURCE_IRQ,
413 .start = IRQ_RTCAlrm,
415 .flags = IORESOURCE_IRQ,
419 struct platform_device sa1100_device_rtc = {
420 .name = "sa1100-rtc",
424 struct platform_device pxa_device_rtc = {
427 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
428 .resource = pxa_rtc_resources,
431 static struct resource pxa_ac97_resources[] = {
434 .end = 0x40500000 + 0xfff,
435 .flags = IORESOURCE_MEM,
440 .flags = IORESOURCE_IRQ,
444 static u64 pxa_ac97_dmamask = 0xffffffffUL;
446 struct platform_device pxa_device_ac97 = {
447 .name = "pxa2xx-ac97",
450 .dma_mask = &pxa_ac97_dmamask,
451 .coherent_dma_mask = 0xffffffff,
453 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
454 .resource = pxa_ac97_resources,
457 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
459 pxa_register_device(&pxa_device_ac97, ops);
464 static struct resource pxa25x_resource_pwm0[] = {
468 .flags = IORESOURCE_MEM,
472 struct platform_device pxa25x_device_pwm0 = {
473 .name = "pxa25x-pwm",
475 .resource = pxa25x_resource_pwm0,
476 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
479 static struct resource pxa25x_resource_pwm1[] = {
483 .flags = IORESOURCE_MEM,
487 struct platform_device pxa25x_device_pwm1 = {
488 .name = "pxa25x-pwm",
490 .resource = pxa25x_resource_pwm1,
491 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
494 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
496 static struct resource pxa25x_resource_ssp[] = {
500 .flags = IORESOURCE_MEM,
505 .flags = IORESOURCE_IRQ,
511 .flags = IORESOURCE_DMA,
517 .flags = IORESOURCE_DMA,
521 struct platform_device pxa25x_device_ssp = {
522 .name = "pxa25x-ssp",
525 .dma_mask = &pxa25x_ssp_dma_mask,
526 .coherent_dma_mask = DMA_BIT_MASK(32),
528 .resource = pxa25x_resource_ssp,
529 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
532 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
534 static struct resource pxa25x_resource_nssp[] = {
538 .flags = IORESOURCE_MEM,
543 .flags = IORESOURCE_IRQ,
549 .flags = IORESOURCE_DMA,
555 .flags = IORESOURCE_DMA,
559 struct platform_device pxa25x_device_nssp = {
560 .name = "pxa25x-nssp",
563 .dma_mask = &pxa25x_nssp_dma_mask,
564 .coherent_dma_mask = DMA_BIT_MASK(32),
566 .resource = pxa25x_resource_nssp,
567 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
570 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
572 static struct resource pxa25x_resource_assp[] = {
576 .flags = IORESOURCE_MEM,
581 .flags = IORESOURCE_IRQ,
587 .flags = IORESOURCE_DMA,
593 .flags = IORESOURCE_DMA,
597 struct platform_device pxa25x_device_assp = {
598 /* ASSP is basically equivalent to NSSP */
599 .name = "pxa25x-nssp",
602 .dma_mask = &pxa25x_assp_dma_mask,
603 .coherent_dma_mask = DMA_BIT_MASK(32),
605 .resource = pxa25x_resource_assp,
606 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
608 #endif /* CONFIG_PXA25x */
610 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
612 static struct resource pxa27x_resource_keypad[] = {
616 .flags = IORESOURCE_MEM,
621 .flags = IORESOURCE_IRQ,
625 struct platform_device pxa27x_device_keypad = {
626 .name = "pxa27x-keypad",
628 .resource = pxa27x_resource_keypad,
629 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
632 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
634 pxa_register_device(&pxa27x_device_keypad, info);
637 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
639 static struct resource pxa27x_resource_ohci[] = {
643 .flags = IORESOURCE_MEM,
648 .flags = IORESOURCE_IRQ,
652 struct platform_device pxa27x_device_ohci = {
653 .name = "pxa27x-ohci",
656 .dma_mask = &pxa27x_ohci_dma_mask,
657 .coherent_dma_mask = DMA_BIT_MASK(32),
659 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
660 .resource = pxa27x_resource_ohci,
663 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
665 pxa_register_device(&pxa27x_device_ohci, info);
668 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
670 static struct resource pxa27x_resource_ssp1[] = {
674 .flags = IORESOURCE_MEM,
679 .flags = IORESOURCE_IRQ,
685 .flags = IORESOURCE_DMA,
691 .flags = IORESOURCE_DMA,
695 struct platform_device pxa27x_device_ssp1 = {
696 .name = "pxa27x-ssp",
699 .dma_mask = &pxa27x_ssp1_dma_mask,
700 .coherent_dma_mask = DMA_BIT_MASK(32),
702 .resource = pxa27x_resource_ssp1,
703 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
706 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
708 static struct resource pxa27x_resource_ssp2[] = {
712 .flags = IORESOURCE_MEM,
717 .flags = IORESOURCE_IRQ,
723 .flags = IORESOURCE_DMA,
729 .flags = IORESOURCE_DMA,
733 struct platform_device pxa27x_device_ssp2 = {
734 .name = "pxa27x-ssp",
737 .dma_mask = &pxa27x_ssp2_dma_mask,
738 .coherent_dma_mask = DMA_BIT_MASK(32),
740 .resource = pxa27x_resource_ssp2,
741 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
744 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
746 static struct resource pxa27x_resource_ssp3[] = {
750 .flags = IORESOURCE_MEM,
755 .flags = IORESOURCE_IRQ,
761 .flags = IORESOURCE_DMA,
767 .flags = IORESOURCE_DMA,
771 struct platform_device pxa27x_device_ssp3 = {
772 .name = "pxa27x-ssp",
775 .dma_mask = &pxa27x_ssp3_dma_mask,
776 .coherent_dma_mask = DMA_BIT_MASK(32),
778 .resource = pxa27x_resource_ssp3,
779 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
782 static struct resource pxa27x_resource_pwm0[] = {
786 .flags = IORESOURCE_MEM,
790 struct platform_device pxa27x_device_pwm0 = {
791 .name = "pxa27x-pwm",
793 .resource = pxa27x_resource_pwm0,
794 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
797 static struct resource pxa27x_resource_pwm1[] = {
801 .flags = IORESOURCE_MEM,
805 struct platform_device pxa27x_device_pwm1 = {
806 .name = "pxa27x-pwm",
808 .resource = pxa27x_resource_pwm1,
809 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
812 static struct resource pxa27x_resource_camera[] = {
816 .flags = IORESOURCE_MEM,
821 .flags = IORESOURCE_IRQ,
825 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
827 static struct platform_device pxa27x_device_camera = {
828 .name = "pxa27x-camera",
829 .id = 0, /* This is used to put cameras on this interface */
831 .dma_mask = &pxa27x_dma_mask_camera,
832 .coherent_dma_mask = 0xffffffff,
834 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
835 .resource = pxa27x_resource_camera,
838 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
840 pxa_register_device(&pxa27x_device_camera, info);
842 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
845 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
847 static struct resource pxa3xx_resource_ssp4[] = {
851 .flags = IORESOURCE_MEM,
856 .flags = IORESOURCE_IRQ,
862 .flags = IORESOURCE_DMA,
868 .flags = IORESOURCE_DMA,
872 struct platform_device pxa3xx_device_ssp4 = {
873 /* PXA3xx SSP is basically equivalent to PXA27x */
874 .name = "pxa27x-ssp",
877 .dma_mask = &pxa3xx_ssp4_dma_mask,
878 .coherent_dma_mask = DMA_BIT_MASK(32),
880 .resource = pxa3xx_resource_ssp4,
881 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
884 static struct resource pxa3xx_resources_mci2[] = {
888 .flags = IORESOURCE_MEM,
893 .flags = IORESOURCE_IRQ,
898 .flags = IORESOURCE_DMA,
903 .flags = IORESOURCE_DMA,
907 struct platform_device pxa3xx_device_mci2 = {
908 .name = "pxa2xx-mci",
911 .dma_mask = &pxamci_dmamask,
912 .coherent_dma_mask = 0xffffffff,
914 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
915 .resource = pxa3xx_resources_mci2,
918 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
920 pxa_register_device(&pxa3xx_device_mci2, info);
923 static struct resource pxa3xx_resources_mci3[] = {
927 .flags = IORESOURCE_MEM,
932 .flags = IORESOURCE_IRQ,
937 .flags = IORESOURCE_DMA,
942 .flags = IORESOURCE_DMA,
946 struct platform_device pxa3xx_device_mci3 = {
947 .name = "pxa2xx-mci",
950 .dma_mask = &pxamci_dmamask,
951 .coherent_dma_mask = 0xffffffff,
953 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
954 .resource = pxa3xx_resources_mci3,
957 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
959 pxa_register_device(&pxa3xx_device_mci3, info);
962 static struct resource pxa3xx_resources_nand[] = {
966 .flags = IORESOURCE_MEM,
971 .flags = IORESOURCE_IRQ,
974 /* DRCMR for Data DMA */
977 .flags = IORESOURCE_DMA,
980 /* DRCMR for Command DMA */
983 .flags = IORESOURCE_DMA,
987 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
989 struct platform_device pxa3xx_device_nand = {
990 .name = "pxa3xx-nand",
993 .dma_mask = &pxa3xx_nand_dma_mask,
994 .coherent_dma_mask = DMA_BIT_MASK(32),
996 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
997 .resource = pxa3xx_resources_nand,
1000 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
1002 pxa_register_device(&pxa3xx_device_nand, info);
1005 static struct resource pxa3xx_resources_gcu[] = {
1007 .start = 0x54000000,
1009 .flags = IORESOURCE_MEM,
1014 .flags = IORESOURCE_IRQ,
1018 static u64 pxa3xx_gcu_dmamask = DMA_BIT_MASK(32);
1020 struct platform_device pxa3xx_device_gcu = {
1021 .name = "pxa3xx-gcu",
1023 .num_resources = ARRAY_SIZE(pxa3xx_resources_gcu),
1024 .resource = pxa3xx_resources_gcu,
1026 .dma_mask = &pxa3xx_gcu_dmamask,
1027 .coherent_dma_mask = 0xffffffff,
1031 #endif /* CONFIG_PXA3xx */
1033 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1034 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1035 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
1037 struct platform_device *pd;
1039 pd = platform_device_alloc("pxa2xx-spi", id);
1041 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
1046 pd->dev.platform_data = info;
1047 platform_device_add(pd);