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>
7 #include <mach/pxa-regs.h>
9 #include <mach/pxafb.h>
11 #include <mach/irda.h>
13 #include <mach/mfp-pxa27x.h>
14 #include <mach/ohci.h>
15 #include <mach/pxa27x_keypad.h>
16 #include <mach/pxa2xx_spi.h>
17 #include <mach/camera.h>
18 #include <mach/audio.h>
19 #include <mach/pxa3xx_nand.h>
24 void __init pxa_register_device(struct platform_device *dev, void *data)
28 dev->dev.platform_data = data;
30 ret = platform_device_register(dev);
32 dev_err(&dev->dev, "unable to register device: %d\n", ret);
35 static struct resource pxamci_resources[] = {
39 .flags = IORESOURCE_MEM,
44 .flags = IORESOURCE_IRQ,
49 .flags = IORESOURCE_DMA,
54 .flags = IORESOURCE_DMA,
58 static u64 pxamci_dmamask = 0xffffffffUL;
60 struct platform_device pxa_device_mci = {
64 .dma_mask = &pxamci_dmamask,
65 .coherent_dma_mask = 0xffffffff,
67 .num_resources = ARRAY_SIZE(pxamci_resources),
68 .resource = pxamci_resources,
71 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
73 pxa_register_device(&pxa_device_mci, info);
77 static struct pxa2xx_udc_mach_info pxa_udc_info;
79 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
81 memcpy(&pxa_udc_info, info, sizeof *info);
84 static struct resource pxa2xx_udc_resources[] = {
88 .flags = IORESOURCE_MEM,
93 .flags = IORESOURCE_IRQ,
97 static u64 udc_dma_mask = ~(u32)0;
99 struct platform_device pxa25x_device_udc = {
100 .name = "pxa25x-udc",
102 .resource = pxa2xx_udc_resources,
103 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
105 .platform_data = &pxa_udc_info,
106 .dma_mask = &udc_dma_mask,
110 struct platform_device pxa27x_device_udc = {
111 .name = "pxa27x-udc",
113 .resource = pxa2xx_udc_resources,
114 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
116 .platform_data = &pxa_udc_info,
117 .dma_mask = &udc_dma_mask,
121 static struct resource pxafb_resources[] = {
125 .flags = IORESOURCE_MEM,
130 .flags = IORESOURCE_IRQ,
134 static u64 fb_dma_mask = ~(u64)0;
136 struct platform_device pxa_device_fb = {
140 .dma_mask = &fb_dma_mask,
141 .coherent_dma_mask = 0xffffffff,
143 .num_resources = ARRAY_SIZE(pxafb_resources),
144 .resource = pxafb_resources,
147 void __init set_pxa_fb_info(struct pxafb_mach_info *info)
149 pxa_register_device(&pxa_device_fb, info);
152 void __init set_pxa_fb_parent(struct device *parent_dev)
154 pxa_device_fb.dev.parent = parent_dev;
157 static struct resource pxa_resource_ffuart[] = {
161 .flags = IORESOURCE_MEM,
165 .flags = IORESOURCE_IRQ,
169 struct platform_device pxa_device_ffuart= {
170 .name = "pxa2xx-uart",
172 .resource = pxa_resource_ffuart,
173 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
176 static struct resource pxa_resource_btuart[] = {
180 .flags = IORESOURCE_MEM,
184 .flags = IORESOURCE_IRQ,
188 struct platform_device pxa_device_btuart = {
189 .name = "pxa2xx-uart",
191 .resource = pxa_resource_btuart,
192 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
195 static struct resource pxa_resource_stuart[] = {
199 .flags = IORESOURCE_MEM,
203 .flags = IORESOURCE_IRQ,
207 struct platform_device pxa_device_stuart = {
208 .name = "pxa2xx-uart",
210 .resource = pxa_resource_stuart,
211 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
214 static struct resource pxa_resource_hwuart[] = {
218 .flags = IORESOURCE_MEM,
222 .flags = IORESOURCE_IRQ,
226 struct platform_device pxa_device_hwuart = {
227 .name = "pxa2xx-uart",
229 .resource = pxa_resource_hwuart,
230 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
233 static struct resource pxai2c_resources[] = {
237 .flags = IORESOURCE_MEM,
241 .flags = IORESOURCE_IRQ,
245 struct platform_device pxa_device_i2c = {
246 .name = "pxa2xx-i2c",
248 .resource = pxai2c_resources,
249 .num_resources = ARRAY_SIZE(pxai2c_resources),
252 static unsigned long pxa27x_i2c_mfp_cfg[] = {
257 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
260 pxa2xx_mfp_config(ARRAY_AND_SIZE(pxa27x_i2c_mfp_cfg));
261 pxa_register_device(&pxa_device_i2c, info);
265 static struct resource pxa27x_resources_i2c_power[] = {
269 .flags = IORESOURCE_MEM,
273 .flags = IORESOURCE_IRQ,
277 struct platform_device pxa27x_device_i2c_power = {
278 .name = "pxa2xx-i2c",
280 .resource = pxa27x_resources_i2c_power,
281 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
286 static struct resource pxa3xx_resources_i2c_power[] = {
290 .flags = IORESOURCE_MEM,
294 .flags = IORESOURCE_IRQ,
298 struct platform_device pxa3xx_device_i2c_power = {
299 .name = "pxa2xx-i2c",
301 .resource = pxa3xx_resources_i2c_power,
302 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
306 static struct resource pxai2s_resources[] = {
310 .flags = IORESOURCE_MEM,
314 .flags = IORESOURCE_IRQ,
318 struct platform_device pxa_device_i2s = {
319 .name = "pxa2xx-i2s",
321 .resource = pxai2s_resources,
322 .num_resources = ARRAY_SIZE(pxai2s_resources),
325 static u64 pxaficp_dmamask = ~(u32)0;
327 struct platform_device pxa_device_ficp = {
331 .dma_mask = &pxaficp_dmamask,
332 .coherent_dma_mask = 0xffffffff,
336 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
338 pxa_register_device(&pxa_device_ficp, info);
341 struct platform_device pxa_device_rtc = {
342 .name = "sa1100-rtc",
346 static struct resource pxa_ac97_resources[] = {
349 .end = 0x40500000 + 0xfff,
350 .flags = IORESOURCE_MEM,
355 .flags = IORESOURCE_IRQ,
359 static u64 pxa_ac97_dmamask = 0xffffffffUL;
361 struct platform_device pxa_device_ac97 = {
362 .name = "pxa2xx-ac97",
365 .dma_mask = &pxa_ac97_dmamask,
366 .coherent_dma_mask = 0xffffffff,
368 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
369 .resource = pxa_ac97_resources,
372 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
374 pxa_register_device(&pxa_device_ac97, ops);
379 static struct resource pxa25x_resource_pwm0[] = {
383 .flags = IORESOURCE_MEM,
387 struct platform_device pxa25x_device_pwm0 = {
388 .name = "pxa25x-pwm",
390 .resource = pxa25x_resource_pwm0,
391 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
394 static struct resource pxa25x_resource_pwm1[] = {
398 .flags = IORESOURCE_MEM,
402 struct platform_device pxa25x_device_pwm1 = {
403 .name = "pxa25x-pwm",
405 .resource = pxa25x_resource_pwm1,
406 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
409 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
411 static struct resource pxa25x_resource_ssp[] = {
415 .flags = IORESOURCE_MEM,
420 .flags = IORESOURCE_IRQ,
426 .flags = IORESOURCE_DMA,
432 .flags = IORESOURCE_DMA,
436 struct platform_device pxa25x_device_ssp = {
437 .name = "pxa25x-ssp",
440 .dma_mask = &pxa25x_ssp_dma_mask,
441 .coherent_dma_mask = DMA_BIT_MASK(32),
443 .resource = pxa25x_resource_ssp,
444 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
447 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
449 static struct resource pxa25x_resource_nssp[] = {
453 .flags = IORESOURCE_MEM,
458 .flags = IORESOURCE_IRQ,
464 .flags = IORESOURCE_DMA,
470 .flags = IORESOURCE_DMA,
474 struct platform_device pxa25x_device_nssp = {
475 .name = "pxa25x-nssp",
478 .dma_mask = &pxa25x_nssp_dma_mask,
479 .coherent_dma_mask = DMA_BIT_MASK(32),
481 .resource = pxa25x_resource_nssp,
482 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
485 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
487 static struct resource pxa25x_resource_assp[] = {
491 .flags = IORESOURCE_MEM,
496 .flags = IORESOURCE_IRQ,
502 .flags = IORESOURCE_DMA,
508 .flags = IORESOURCE_DMA,
512 struct platform_device pxa25x_device_assp = {
513 /* ASSP is basically equivalent to NSSP */
514 .name = "pxa25x-nssp",
517 .dma_mask = &pxa25x_assp_dma_mask,
518 .coherent_dma_mask = DMA_BIT_MASK(32),
520 .resource = pxa25x_resource_assp,
521 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
523 #endif /* CONFIG_PXA25x */
525 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
527 static struct resource pxa27x_resource_keypad[] = {
531 .flags = IORESOURCE_MEM,
536 .flags = IORESOURCE_IRQ,
540 struct platform_device pxa27x_device_keypad = {
541 .name = "pxa27x-keypad",
543 .resource = pxa27x_resource_keypad,
544 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
547 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
549 pxa_register_device(&pxa27x_device_keypad, info);
552 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
554 static struct resource pxa27x_resource_ohci[] = {
558 .flags = IORESOURCE_MEM,
563 .flags = IORESOURCE_IRQ,
567 struct platform_device pxa27x_device_ohci = {
568 .name = "pxa27x-ohci",
571 .dma_mask = &pxa27x_ohci_dma_mask,
572 .coherent_dma_mask = DMA_BIT_MASK(32),
574 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
575 .resource = pxa27x_resource_ohci,
578 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
580 pxa_register_device(&pxa27x_device_ohci, info);
583 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
585 static struct resource pxa27x_resource_ssp1[] = {
589 .flags = IORESOURCE_MEM,
594 .flags = IORESOURCE_IRQ,
600 .flags = IORESOURCE_DMA,
606 .flags = IORESOURCE_DMA,
610 struct platform_device pxa27x_device_ssp1 = {
611 .name = "pxa27x-ssp",
614 .dma_mask = &pxa27x_ssp1_dma_mask,
615 .coherent_dma_mask = DMA_BIT_MASK(32),
617 .resource = pxa27x_resource_ssp1,
618 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
621 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
623 static struct resource pxa27x_resource_ssp2[] = {
627 .flags = IORESOURCE_MEM,
632 .flags = IORESOURCE_IRQ,
638 .flags = IORESOURCE_DMA,
644 .flags = IORESOURCE_DMA,
648 struct platform_device pxa27x_device_ssp2 = {
649 .name = "pxa27x-ssp",
652 .dma_mask = &pxa27x_ssp2_dma_mask,
653 .coherent_dma_mask = DMA_BIT_MASK(32),
655 .resource = pxa27x_resource_ssp2,
656 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
659 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
661 static struct resource pxa27x_resource_ssp3[] = {
665 .flags = IORESOURCE_MEM,
670 .flags = IORESOURCE_IRQ,
676 .flags = IORESOURCE_DMA,
682 .flags = IORESOURCE_DMA,
686 struct platform_device pxa27x_device_ssp3 = {
687 .name = "pxa27x-ssp",
690 .dma_mask = &pxa27x_ssp3_dma_mask,
691 .coherent_dma_mask = DMA_BIT_MASK(32),
693 .resource = pxa27x_resource_ssp3,
694 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
697 static struct resource pxa27x_resource_pwm0[] = {
701 .flags = IORESOURCE_MEM,
705 struct platform_device pxa27x_device_pwm0 = {
706 .name = "pxa27x-pwm",
708 .resource = pxa27x_resource_pwm0,
709 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
712 static struct resource pxa27x_resource_pwm1[] = {
716 .flags = IORESOURCE_MEM,
720 struct platform_device pxa27x_device_pwm1 = {
721 .name = "pxa27x-pwm",
723 .resource = pxa27x_resource_pwm1,
724 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
727 static struct resource pxa27x_resource_camera[] = {
731 .flags = IORESOURCE_MEM,
736 .flags = IORESOURCE_IRQ,
740 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
742 static struct platform_device pxa27x_device_camera = {
743 .name = "pxa27x-camera",
744 .id = 0, /* This is used to put cameras on this interface */
746 .dma_mask = &pxa27x_dma_mask_camera,
747 .coherent_dma_mask = 0xffffffff,
749 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
750 .resource = pxa27x_resource_camera,
753 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
755 pxa_register_device(&pxa27x_device_camera, info);
757 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
760 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
762 static struct resource pxa3xx_resource_ssp4[] = {
766 .flags = IORESOURCE_MEM,
771 .flags = IORESOURCE_IRQ,
777 .flags = IORESOURCE_DMA,
783 .flags = IORESOURCE_DMA,
787 struct platform_device pxa3xx_device_ssp4 = {
788 /* PXA3xx SSP is basically equivalent to PXA27x */
789 .name = "pxa27x-ssp",
792 .dma_mask = &pxa3xx_ssp4_dma_mask,
793 .coherent_dma_mask = DMA_BIT_MASK(32),
795 .resource = pxa3xx_resource_ssp4,
796 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
799 static struct resource pxa3xx_resources_mci2[] = {
803 .flags = IORESOURCE_MEM,
808 .flags = IORESOURCE_IRQ,
813 .flags = IORESOURCE_DMA,
818 .flags = IORESOURCE_DMA,
822 struct platform_device pxa3xx_device_mci2 = {
823 .name = "pxa2xx-mci",
826 .dma_mask = &pxamci_dmamask,
827 .coherent_dma_mask = 0xffffffff,
829 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
830 .resource = pxa3xx_resources_mci2,
833 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
835 pxa_register_device(&pxa3xx_device_mci2, info);
838 static struct resource pxa3xx_resources_mci3[] = {
842 .flags = IORESOURCE_MEM,
847 .flags = IORESOURCE_IRQ,
852 .flags = IORESOURCE_DMA,
857 .flags = IORESOURCE_DMA,
861 struct platform_device pxa3xx_device_mci3 = {
862 .name = "pxa2xx-mci",
865 .dma_mask = &pxamci_dmamask,
866 .coherent_dma_mask = 0xffffffff,
868 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
869 .resource = pxa3xx_resources_mci3,
872 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
874 pxa_register_device(&pxa3xx_device_mci3, info);
877 static struct resource pxa3xx_resources_nand[] = {
881 .flags = IORESOURCE_MEM,
886 .flags = IORESOURCE_IRQ,
889 /* DRCMR for Data DMA */
892 .flags = IORESOURCE_DMA,
895 /* DRCMR for Command DMA */
898 .flags = IORESOURCE_DMA,
902 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
904 struct platform_device pxa3xx_device_nand = {
905 .name = "pxa3xx-nand",
908 .dma_mask = &pxa3xx_nand_dma_mask,
909 .coherent_dma_mask = DMA_BIT_MASK(32),
911 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
912 .resource = pxa3xx_resources_nand,
915 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
917 pxa_register_device(&pxa3xx_device_nand, info);
919 #endif /* CONFIG_PXA3xx */
921 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
922 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
923 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
925 struct platform_device *pd;
927 pd = platform_device_alloc("pxa2xx-spi", id);
929 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
934 pd->dev.platform_data = info;
935 platform_device_add(pd);