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>
8 #include <mach/pxafb.h>
10 #include <mach/irda.h>
11 #include <mach/ohci.h>
12 #include <mach/pxa27x_keypad.h>
13 #include <mach/pxa2xx_spi.h>
14 #include <mach/camera.h>
15 #include <mach/audio.h>
16 #include <mach/hardware.h>
18 #include <plat/pxa3xx_nand.h>
23 void __init pxa_register_device(struct platform_device *dev, void *data)
27 dev->dev.platform_data = data;
29 ret = platform_device_register(dev);
31 dev_err(&dev->dev, "unable to register device: %d\n", ret);
34 static struct resource pxamci_resources[] = {
38 .flags = IORESOURCE_MEM,
43 .flags = IORESOURCE_IRQ,
48 .flags = IORESOURCE_DMA,
53 .flags = IORESOURCE_DMA,
57 static u64 pxamci_dmamask = 0xffffffffUL;
59 struct platform_device pxa_device_mci = {
63 .dma_mask = &pxamci_dmamask,
64 .coherent_dma_mask = 0xffffffff,
66 .num_resources = ARRAY_SIZE(pxamci_resources),
67 .resource = pxamci_resources,
70 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
72 pxa_register_device(&pxa_device_mci, info);
76 static struct pxa2xx_udc_mach_info pxa_udc_info = {
81 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
83 memcpy(&pxa_udc_info, info, sizeof *info);
86 static struct resource pxa2xx_udc_resources[] = {
90 .flags = IORESOURCE_MEM,
95 .flags = IORESOURCE_IRQ,
99 static u64 udc_dma_mask = ~(u32)0;
101 struct platform_device pxa25x_device_udc = {
102 .name = "pxa25x-udc",
104 .resource = pxa2xx_udc_resources,
105 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
107 .platform_data = &pxa_udc_info,
108 .dma_mask = &udc_dma_mask,
112 struct platform_device pxa27x_device_udc = {
113 .name = "pxa27x-udc",
115 .resource = pxa2xx_udc_resources,
116 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
118 .platform_data = &pxa_udc_info,
119 .dma_mask = &udc_dma_mask,
123 static struct resource pxafb_resources[] = {
127 .flags = IORESOURCE_MEM,
132 .flags = IORESOURCE_IRQ,
136 static u64 fb_dma_mask = ~(u64)0;
138 struct platform_device pxa_device_fb = {
142 .dma_mask = &fb_dma_mask,
143 .coherent_dma_mask = 0xffffffff,
145 .num_resources = ARRAY_SIZE(pxafb_resources),
146 .resource = pxafb_resources,
149 void __init set_pxa_fb_info(struct pxafb_mach_info *info)
151 pxa_register_device(&pxa_device_fb, info);
154 void __init set_pxa_fb_parent(struct device *parent_dev)
156 pxa_device_fb.dev.parent = parent_dev;
159 static struct resource pxa_resource_ffuart[] = {
163 .flags = IORESOURCE_MEM,
167 .flags = IORESOURCE_IRQ,
171 struct platform_device pxa_device_ffuart = {
172 .name = "pxa2xx-uart",
174 .resource = pxa_resource_ffuart,
175 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
178 void __init pxa_set_ffuart_info(void *info)
180 pxa_register_device(&pxa_device_ffuart, info);
183 static struct resource pxa_resource_btuart[] = {
187 .flags = IORESOURCE_MEM,
191 .flags = IORESOURCE_IRQ,
195 struct platform_device pxa_device_btuart = {
196 .name = "pxa2xx-uart",
198 .resource = pxa_resource_btuart,
199 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
202 void __init pxa_set_btuart_info(void *info)
204 pxa_register_device(&pxa_device_btuart, info);
207 static struct resource pxa_resource_stuart[] = {
211 .flags = IORESOURCE_MEM,
215 .flags = IORESOURCE_IRQ,
219 struct platform_device pxa_device_stuart = {
220 .name = "pxa2xx-uart",
222 .resource = pxa_resource_stuart,
223 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
226 void __init pxa_set_stuart_info(void *info)
228 pxa_register_device(&pxa_device_stuart, info);
231 static struct resource pxa_resource_hwuart[] = {
235 .flags = IORESOURCE_MEM,
239 .flags = IORESOURCE_IRQ,
243 struct platform_device pxa_device_hwuart = {
244 .name = "pxa2xx-uart",
246 .resource = pxa_resource_hwuart,
247 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
250 void __init pxa_set_hwuart_info(void *info)
253 pxa_register_device(&pxa_device_hwuart, info);
255 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
258 static struct resource pxai2c_resources[] = {
262 .flags = IORESOURCE_MEM,
266 .flags = IORESOURCE_IRQ,
270 struct platform_device pxa_device_i2c = {
271 .name = "pxa2xx-i2c",
273 .resource = pxai2c_resources,
274 .num_resources = ARRAY_SIZE(pxai2c_resources),
277 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
279 pxa_register_device(&pxa_device_i2c, info);
283 static struct resource pxa27x_resources_i2c_power[] = {
287 .flags = IORESOURCE_MEM,
291 .flags = IORESOURCE_IRQ,
295 struct platform_device pxa27x_device_i2c_power = {
296 .name = "pxa2xx-i2c",
298 .resource = pxa27x_resources_i2c_power,
299 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
304 static struct resource pxa3xx_resources_i2c_power[] = {
308 .flags = IORESOURCE_MEM,
312 .flags = IORESOURCE_IRQ,
316 struct platform_device pxa3xx_device_i2c_power = {
317 .name = "pxa3xx-pwri2c",
319 .resource = pxa3xx_resources_i2c_power,
320 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
324 static struct resource pxai2s_resources[] = {
328 .flags = IORESOURCE_MEM,
332 .flags = IORESOURCE_IRQ,
336 struct platform_device pxa_device_i2s = {
337 .name = "pxa2xx-i2s",
339 .resource = pxai2s_resources,
340 .num_resources = ARRAY_SIZE(pxai2s_resources),
343 struct platform_device pxa_device_asoc_ssp1 = {
344 .name = "pxa-ssp-dai",
348 struct platform_device pxa_device_asoc_ssp2= {
349 .name = "pxa-ssp-dai",
353 struct platform_device pxa_device_asoc_ssp3 = {
354 .name = "pxa-ssp-dai",
358 struct platform_device pxa_device_asoc_ssp4 = {
359 .name = "pxa-ssp-dai",
363 struct platform_device pxa_device_asoc_platform = {
364 .name = "pxa-pcm-audio",
368 static u64 pxaficp_dmamask = ~(u32)0;
370 struct platform_device pxa_device_ficp = {
374 .dma_mask = &pxaficp_dmamask,
375 .coherent_dma_mask = 0xffffffff,
379 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
381 pxa_register_device(&pxa_device_ficp, info);
384 static struct resource pxa_rtc_resources[] = {
387 .end = 0x40900000 + 0x3b,
388 .flags = IORESOURCE_MEM,
393 .flags = IORESOURCE_IRQ,
396 .start = IRQ_RTCAlrm,
398 .flags = IORESOURCE_IRQ,
402 struct platform_device sa1100_device_rtc = {
403 .name = "sa1100-rtc",
407 struct platform_device pxa_device_rtc = {
410 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
411 .resource = pxa_rtc_resources,
414 static struct resource pxa_ac97_resources[] = {
417 .end = 0x40500000 + 0xfff,
418 .flags = IORESOURCE_MEM,
423 .flags = IORESOURCE_IRQ,
427 static u64 pxa_ac97_dmamask = 0xffffffffUL;
429 struct platform_device pxa_device_ac97 = {
430 .name = "pxa2xx-ac97",
433 .dma_mask = &pxa_ac97_dmamask,
434 .coherent_dma_mask = 0xffffffff,
436 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
437 .resource = pxa_ac97_resources,
440 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
442 pxa_register_device(&pxa_device_ac97, ops);
447 static struct resource pxa25x_resource_pwm0[] = {
451 .flags = IORESOURCE_MEM,
455 struct platform_device pxa25x_device_pwm0 = {
456 .name = "pxa25x-pwm",
458 .resource = pxa25x_resource_pwm0,
459 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
462 static struct resource pxa25x_resource_pwm1[] = {
466 .flags = IORESOURCE_MEM,
470 struct platform_device pxa25x_device_pwm1 = {
471 .name = "pxa25x-pwm",
473 .resource = pxa25x_resource_pwm1,
474 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
477 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
479 static struct resource pxa25x_resource_ssp[] = {
483 .flags = IORESOURCE_MEM,
488 .flags = IORESOURCE_IRQ,
494 .flags = IORESOURCE_DMA,
500 .flags = IORESOURCE_DMA,
504 struct platform_device pxa25x_device_ssp = {
505 .name = "pxa25x-ssp",
508 .dma_mask = &pxa25x_ssp_dma_mask,
509 .coherent_dma_mask = DMA_BIT_MASK(32),
511 .resource = pxa25x_resource_ssp,
512 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
515 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
517 static struct resource pxa25x_resource_nssp[] = {
521 .flags = IORESOURCE_MEM,
526 .flags = IORESOURCE_IRQ,
532 .flags = IORESOURCE_DMA,
538 .flags = IORESOURCE_DMA,
542 struct platform_device pxa25x_device_nssp = {
543 .name = "pxa25x-nssp",
546 .dma_mask = &pxa25x_nssp_dma_mask,
547 .coherent_dma_mask = DMA_BIT_MASK(32),
549 .resource = pxa25x_resource_nssp,
550 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
553 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
555 static struct resource pxa25x_resource_assp[] = {
559 .flags = IORESOURCE_MEM,
564 .flags = IORESOURCE_IRQ,
570 .flags = IORESOURCE_DMA,
576 .flags = IORESOURCE_DMA,
580 struct platform_device pxa25x_device_assp = {
581 /* ASSP is basically equivalent to NSSP */
582 .name = "pxa25x-nssp",
585 .dma_mask = &pxa25x_assp_dma_mask,
586 .coherent_dma_mask = DMA_BIT_MASK(32),
588 .resource = pxa25x_resource_assp,
589 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
591 #endif /* CONFIG_PXA25x */
593 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
595 static struct resource pxa27x_resource_keypad[] = {
599 .flags = IORESOURCE_MEM,
604 .flags = IORESOURCE_IRQ,
608 struct platform_device pxa27x_device_keypad = {
609 .name = "pxa27x-keypad",
611 .resource = pxa27x_resource_keypad,
612 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
615 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
617 pxa_register_device(&pxa27x_device_keypad, info);
620 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
622 static struct resource pxa27x_resource_ohci[] = {
626 .flags = IORESOURCE_MEM,
631 .flags = IORESOURCE_IRQ,
635 struct platform_device pxa27x_device_ohci = {
636 .name = "pxa27x-ohci",
639 .dma_mask = &pxa27x_ohci_dma_mask,
640 .coherent_dma_mask = DMA_BIT_MASK(32),
642 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
643 .resource = pxa27x_resource_ohci,
646 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
648 pxa_register_device(&pxa27x_device_ohci, info);
651 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
653 static struct resource pxa27x_resource_ssp1[] = {
657 .flags = IORESOURCE_MEM,
662 .flags = IORESOURCE_IRQ,
668 .flags = IORESOURCE_DMA,
674 .flags = IORESOURCE_DMA,
678 struct platform_device pxa27x_device_ssp1 = {
679 .name = "pxa27x-ssp",
682 .dma_mask = &pxa27x_ssp1_dma_mask,
683 .coherent_dma_mask = DMA_BIT_MASK(32),
685 .resource = pxa27x_resource_ssp1,
686 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
689 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
691 static struct resource pxa27x_resource_ssp2[] = {
695 .flags = IORESOURCE_MEM,
700 .flags = IORESOURCE_IRQ,
706 .flags = IORESOURCE_DMA,
712 .flags = IORESOURCE_DMA,
716 struct platform_device pxa27x_device_ssp2 = {
717 .name = "pxa27x-ssp",
720 .dma_mask = &pxa27x_ssp2_dma_mask,
721 .coherent_dma_mask = DMA_BIT_MASK(32),
723 .resource = pxa27x_resource_ssp2,
724 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
727 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
729 static struct resource pxa27x_resource_ssp3[] = {
733 .flags = IORESOURCE_MEM,
738 .flags = IORESOURCE_IRQ,
744 .flags = IORESOURCE_DMA,
750 .flags = IORESOURCE_DMA,
754 struct platform_device pxa27x_device_ssp3 = {
755 .name = "pxa27x-ssp",
758 .dma_mask = &pxa27x_ssp3_dma_mask,
759 .coherent_dma_mask = DMA_BIT_MASK(32),
761 .resource = pxa27x_resource_ssp3,
762 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
765 static struct resource pxa27x_resource_pwm0[] = {
769 .flags = IORESOURCE_MEM,
773 struct platform_device pxa27x_device_pwm0 = {
774 .name = "pxa27x-pwm",
776 .resource = pxa27x_resource_pwm0,
777 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
780 static struct resource pxa27x_resource_pwm1[] = {
784 .flags = IORESOURCE_MEM,
788 struct platform_device pxa27x_device_pwm1 = {
789 .name = "pxa27x-pwm",
791 .resource = pxa27x_resource_pwm1,
792 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
795 static struct resource pxa27x_resource_camera[] = {
799 .flags = IORESOURCE_MEM,
804 .flags = IORESOURCE_IRQ,
808 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
810 static struct platform_device pxa27x_device_camera = {
811 .name = "pxa27x-camera",
812 .id = 0, /* This is used to put cameras on this interface */
814 .dma_mask = &pxa27x_dma_mask_camera,
815 .coherent_dma_mask = 0xffffffff,
817 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
818 .resource = pxa27x_resource_camera,
821 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
823 pxa_register_device(&pxa27x_device_camera, info);
825 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
828 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
830 static struct resource pxa3xx_resource_ssp4[] = {
834 .flags = IORESOURCE_MEM,
839 .flags = IORESOURCE_IRQ,
845 .flags = IORESOURCE_DMA,
851 .flags = IORESOURCE_DMA,
855 struct platform_device pxa3xx_device_ssp4 = {
856 /* PXA3xx SSP is basically equivalent to PXA27x */
857 .name = "pxa27x-ssp",
860 .dma_mask = &pxa3xx_ssp4_dma_mask,
861 .coherent_dma_mask = DMA_BIT_MASK(32),
863 .resource = pxa3xx_resource_ssp4,
864 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
867 static struct resource pxa3xx_resources_mci2[] = {
871 .flags = IORESOURCE_MEM,
876 .flags = IORESOURCE_IRQ,
881 .flags = IORESOURCE_DMA,
886 .flags = IORESOURCE_DMA,
890 struct platform_device pxa3xx_device_mci2 = {
891 .name = "pxa2xx-mci",
894 .dma_mask = &pxamci_dmamask,
895 .coherent_dma_mask = 0xffffffff,
897 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
898 .resource = pxa3xx_resources_mci2,
901 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
903 pxa_register_device(&pxa3xx_device_mci2, info);
906 static struct resource pxa3xx_resources_mci3[] = {
910 .flags = IORESOURCE_MEM,
915 .flags = IORESOURCE_IRQ,
920 .flags = IORESOURCE_DMA,
925 .flags = IORESOURCE_DMA,
929 struct platform_device pxa3xx_device_mci3 = {
930 .name = "pxa2xx-mci",
933 .dma_mask = &pxamci_dmamask,
934 .coherent_dma_mask = 0xffffffff,
936 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
937 .resource = pxa3xx_resources_mci3,
940 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
942 pxa_register_device(&pxa3xx_device_mci3, info);
945 static struct resource pxa3xx_resources_nand[] = {
949 .flags = IORESOURCE_MEM,
954 .flags = IORESOURCE_IRQ,
957 /* DRCMR for Data DMA */
960 .flags = IORESOURCE_DMA,
963 /* DRCMR for Command DMA */
966 .flags = IORESOURCE_DMA,
970 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
972 struct platform_device pxa3xx_device_nand = {
973 .name = "pxa3xx-nand",
976 .dma_mask = &pxa3xx_nand_dma_mask,
977 .coherent_dma_mask = DMA_BIT_MASK(32),
979 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
980 .resource = pxa3xx_resources_nand,
983 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
985 pxa_register_device(&pxa3xx_device_nand, info);
988 static struct resource pxa3xx_resources_gcu[] = {
992 .flags = IORESOURCE_MEM,
997 .flags = IORESOURCE_IRQ,
1001 static u64 pxa3xx_gcu_dmamask = DMA_BIT_MASK(32);
1003 struct platform_device pxa3xx_device_gcu = {
1004 .name = "pxa3xx-gcu",
1006 .num_resources = ARRAY_SIZE(pxa3xx_resources_gcu),
1007 .resource = pxa3xx_resources_gcu,
1009 .dma_mask = &pxa3xx_gcu_dmamask,
1010 .coherent_dma_mask = 0xffffffff,
1014 #endif /* CONFIG_PXA3xx */
1016 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1017 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1018 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
1020 struct platform_device *pd;
1022 pd = platform_device_alloc("pxa2xx-spi", id);
1024 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
1029 pd->dev.platform_data = info;
1030 platform_device_add(pd);