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/ohci.h>
14 #include <mach/pxa27x_keypad.h>
15 #include <mach/pxa2xx_spi.h>
16 #include <mach/camera.h>
17 #include <mach/audio.h>
18 #include <mach/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;
78 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
80 memcpy(&pxa_udc_info, info, sizeof *info);
83 static struct resource pxa2xx_udc_resources[] = {
87 .flags = IORESOURCE_MEM,
92 .flags = IORESOURCE_IRQ,
96 static u64 udc_dma_mask = ~(u32)0;
98 struct platform_device pxa25x_device_udc = {
101 .resource = pxa2xx_udc_resources,
102 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
104 .platform_data = &pxa_udc_info,
105 .dma_mask = &udc_dma_mask,
109 struct platform_device pxa27x_device_udc = {
110 .name = "pxa27x-udc",
112 .resource = pxa2xx_udc_resources,
113 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
115 .platform_data = &pxa_udc_info,
116 .dma_mask = &udc_dma_mask,
120 static struct resource pxafb_resources[] = {
124 .flags = IORESOURCE_MEM,
129 .flags = IORESOURCE_IRQ,
133 static u64 fb_dma_mask = ~(u64)0;
135 struct platform_device pxa_device_fb = {
139 .dma_mask = &fb_dma_mask,
140 .coherent_dma_mask = 0xffffffff,
142 .num_resources = ARRAY_SIZE(pxafb_resources),
143 .resource = pxafb_resources,
146 void __init set_pxa_fb_info(struct pxafb_mach_info *info)
148 pxa_register_device(&pxa_device_fb, info);
151 void __init set_pxa_fb_parent(struct device *parent_dev)
153 pxa_device_fb.dev.parent = parent_dev;
156 static struct resource pxa_resource_ffuart[] = {
160 .flags = IORESOURCE_MEM,
164 .flags = IORESOURCE_IRQ,
168 struct platform_device pxa_device_ffuart= {
169 .name = "pxa2xx-uart",
171 .resource = pxa_resource_ffuart,
172 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
175 static struct resource pxa_resource_btuart[] = {
179 .flags = IORESOURCE_MEM,
183 .flags = IORESOURCE_IRQ,
187 struct platform_device pxa_device_btuart = {
188 .name = "pxa2xx-uart",
190 .resource = pxa_resource_btuart,
191 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
194 static struct resource pxa_resource_stuart[] = {
198 .flags = IORESOURCE_MEM,
202 .flags = IORESOURCE_IRQ,
206 struct platform_device pxa_device_stuart = {
207 .name = "pxa2xx-uart",
209 .resource = pxa_resource_stuart,
210 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
213 static struct resource pxa_resource_hwuart[] = {
217 .flags = IORESOURCE_MEM,
221 .flags = IORESOURCE_IRQ,
225 struct platform_device pxa_device_hwuart = {
226 .name = "pxa2xx-uart",
228 .resource = pxa_resource_hwuart,
229 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
232 static struct resource pxai2c_resources[] = {
236 .flags = IORESOURCE_MEM,
240 .flags = IORESOURCE_IRQ,
244 struct platform_device pxa_device_i2c = {
245 .name = "pxa2xx-i2c",
247 .resource = pxai2c_resources,
248 .num_resources = ARRAY_SIZE(pxai2c_resources),
251 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
253 pxa_register_device(&pxa_device_i2c, info);
257 static struct resource pxa27x_resources_i2c_power[] = {
261 .flags = IORESOURCE_MEM,
265 .flags = IORESOURCE_IRQ,
269 struct platform_device pxa27x_device_i2c_power = {
270 .name = "pxa2xx-i2c",
272 .resource = pxa27x_resources_i2c_power,
273 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
278 static struct resource pxa3xx_resources_i2c_power[] = {
282 .flags = IORESOURCE_MEM,
286 .flags = IORESOURCE_IRQ,
290 struct platform_device pxa3xx_device_i2c_power = {
291 .name = "pxa2xx-i2c",
293 .resource = pxa3xx_resources_i2c_power,
294 .num_resources = ARRAY_SIZE(pxa3xx_resources_i2c_power),
298 static struct resource pxai2s_resources[] = {
302 .flags = IORESOURCE_MEM,
306 .flags = IORESOURCE_IRQ,
310 struct platform_device pxa_device_i2s = {
311 .name = "pxa2xx-i2s",
313 .resource = pxai2s_resources,
314 .num_resources = ARRAY_SIZE(pxai2s_resources),
317 static u64 pxaficp_dmamask = ~(u32)0;
319 struct platform_device pxa_device_ficp = {
323 .dma_mask = &pxaficp_dmamask,
324 .coherent_dma_mask = 0xffffffff,
328 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
330 pxa_register_device(&pxa_device_ficp, info);
333 struct platform_device pxa_device_rtc = {
334 .name = "sa1100-rtc",
338 static struct resource pxa_ac97_resources[] = {
341 .end = 0x40500000 + 0xfff,
342 .flags = IORESOURCE_MEM,
347 .flags = IORESOURCE_IRQ,
351 static u64 pxa_ac97_dmamask = 0xffffffffUL;
353 struct platform_device pxa_device_ac97 = {
354 .name = "pxa2xx-ac97",
357 .dma_mask = &pxa_ac97_dmamask,
358 .coherent_dma_mask = 0xffffffff,
360 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
361 .resource = pxa_ac97_resources,
364 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
366 pxa_register_device(&pxa_device_ac97, ops);
371 static struct resource pxa25x_resource_pwm0[] = {
375 .flags = IORESOURCE_MEM,
379 struct platform_device pxa25x_device_pwm0 = {
380 .name = "pxa25x-pwm",
382 .resource = pxa25x_resource_pwm0,
383 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
386 static struct resource pxa25x_resource_pwm1[] = {
390 .flags = IORESOURCE_MEM,
394 struct platform_device pxa25x_device_pwm1 = {
395 .name = "pxa25x-pwm",
397 .resource = pxa25x_resource_pwm1,
398 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
401 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
403 static struct resource pxa25x_resource_ssp[] = {
407 .flags = IORESOURCE_MEM,
412 .flags = IORESOURCE_IRQ,
418 .flags = IORESOURCE_DMA,
424 .flags = IORESOURCE_DMA,
428 struct platform_device pxa25x_device_ssp = {
429 .name = "pxa25x-ssp",
432 .dma_mask = &pxa25x_ssp_dma_mask,
433 .coherent_dma_mask = DMA_BIT_MASK(32),
435 .resource = pxa25x_resource_ssp,
436 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
439 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
441 static struct resource pxa25x_resource_nssp[] = {
445 .flags = IORESOURCE_MEM,
450 .flags = IORESOURCE_IRQ,
456 .flags = IORESOURCE_DMA,
462 .flags = IORESOURCE_DMA,
466 struct platform_device pxa25x_device_nssp = {
467 .name = "pxa25x-nssp",
470 .dma_mask = &pxa25x_nssp_dma_mask,
471 .coherent_dma_mask = DMA_BIT_MASK(32),
473 .resource = pxa25x_resource_nssp,
474 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
477 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
479 static struct resource pxa25x_resource_assp[] = {
483 .flags = IORESOURCE_MEM,
488 .flags = IORESOURCE_IRQ,
494 .flags = IORESOURCE_DMA,
500 .flags = IORESOURCE_DMA,
504 struct platform_device pxa25x_device_assp = {
505 /* ASSP is basically equivalent to NSSP */
506 .name = "pxa25x-nssp",
509 .dma_mask = &pxa25x_assp_dma_mask,
510 .coherent_dma_mask = DMA_BIT_MASK(32),
512 .resource = pxa25x_resource_assp,
513 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
515 #endif /* CONFIG_PXA25x */
517 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
519 static struct resource pxa27x_resource_keypad[] = {
523 .flags = IORESOURCE_MEM,
528 .flags = IORESOURCE_IRQ,
532 struct platform_device pxa27x_device_keypad = {
533 .name = "pxa27x-keypad",
535 .resource = pxa27x_resource_keypad,
536 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
539 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
541 pxa_register_device(&pxa27x_device_keypad, info);
544 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
546 static struct resource pxa27x_resource_ohci[] = {
550 .flags = IORESOURCE_MEM,
555 .flags = IORESOURCE_IRQ,
559 struct platform_device pxa27x_device_ohci = {
560 .name = "pxa27x-ohci",
563 .dma_mask = &pxa27x_ohci_dma_mask,
564 .coherent_dma_mask = DMA_BIT_MASK(32),
566 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
567 .resource = pxa27x_resource_ohci,
570 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
572 pxa_register_device(&pxa27x_device_ohci, info);
575 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
577 static struct resource pxa27x_resource_ssp1[] = {
581 .flags = IORESOURCE_MEM,
586 .flags = IORESOURCE_IRQ,
592 .flags = IORESOURCE_DMA,
598 .flags = IORESOURCE_DMA,
602 struct platform_device pxa27x_device_ssp1 = {
603 .name = "pxa27x-ssp",
606 .dma_mask = &pxa27x_ssp1_dma_mask,
607 .coherent_dma_mask = DMA_BIT_MASK(32),
609 .resource = pxa27x_resource_ssp1,
610 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
613 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
615 static struct resource pxa27x_resource_ssp2[] = {
619 .flags = IORESOURCE_MEM,
624 .flags = IORESOURCE_IRQ,
630 .flags = IORESOURCE_DMA,
636 .flags = IORESOURCE_DMA,
640 struct platform_device pxa27x_device_ssp2 = {
641 .name = "pxa27x-ssp",
644 .dma_mask = &pxa27x_ssp2_dma_mask,
645 .coherent_dma_mask = DMA_BIT_MASK(32),
647 .resource = pxa27x_resource_ssp2,
648 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
651 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
653 static struct resource pxa27x_resource_ssp3[] = {
657 .flags = IORESOURCE_MEM,
662 .flags = IORESOURCE_IRQ,
668 .flags = IORESOURCE_DMA,
674 .flags = IORESOURCE_DMA,
678 struct platform_device pxa27x_device_ssp3 = {
679 .name = "pxa27x-ssp",
682 .dma_mask = &pxa27x_ssp3_dma_mask,
683 .coherent_dma_mask = DMA_BIT_MASK(32),
685 .resource = pxa27x_resource_ssp3,
686 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
689 static struct resource pxa27x_resource_pwm0[] = {
693 .flags = IORESOURCE_MEM,
697 struct platform_device pxa27x_device_pwm0 = {
698 .name = "pxa27x-pwm",
700 .resource = pxa27x_resource_pwm0,
701 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
704 static struct resource pxa27x_resource_pwm1[] = {
708 .flags = IORESOURCE_MEM,
712 struct platform_device pxa27x_device_pwm1 = {
713 .name = "pxa27x-pwm",
715 .resource = pxa27x_resource_pwm1,
716 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
719 static struct resource pxa27x_resource_camera[] = {
723 .flags = IORESOURCE_MEM,
728 .flags = IORESOURCE_IRQ,
732 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
734 static struct platform_device pxa27x_device_camera = {
735 .name = "pxa27x-camera",
736 .id = 0, /* This is used to put cameras on this interface */
738 .dma_mask = &pxa27x_dma_mask_camera,
739 .coherent_dma_mask = 0xffffffff,
741 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
742 .resource = pxa27x_resource_camera,
745 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
747 pxa_register_device(&pxa27x_device_camera, info);
749 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
752 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
754 static struct resource pxa3xx_resource_ssp4[] = {
758 .flags = IORESOURCE_MEM,
763 .flags = IORESOURCE_IRQ,
769 .flags = IORESOURCE_DMA,
775 .flags = IORESOURCE_DMA,
779 struct platform_device pxa3xx_device_ssp4 = {
780 /* PXA3xx SSP is basically equivalent to PXA27x */
781 .name = "pxa27x-ssp",
784 .dma_mask = &pxa3xx_ssp4_dma_mask,
785 .coherent_dma_mask = DMA_BIT_MASK(32),
787 .resource = pxa3xx_resource_ssp4,
788 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
791 static struct resource pxa3xx_resources_mci2[] = {
795 .flags = IORESOURCE_MEM,
800 .flags = IORESOURCE_IRQ,
805 .flags = IORESOURCE_DMA,
810 .flags = IORESOURCE_DMA,
814 struct platform_device pxa3xx_device_mci2 = {
815 .name = "pxa2xx-mci",
818 .dma_mask = &pxamci_dmamask,
819 .coherent_dma_mask = 0xffffffff,
821 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
822 .resource = pxa3xx_resources_mci2,
825 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
827 pxa_register_device(&pxa3xx_device_mci2, info);
830 static struct resource pxa3xx_resources_mci3[] = {
834 .flags = IORESOURCE_MEM,
839 .flags = IORESOURCE_IRQ,
844 .flags = IORESOURCE_DMA,
849 .flags = IORESOURCE_DMA,
853 struct platform_device pxa3xx_device_mci3 = {
854 .name = "pxa2xx-mci",
857 .dma_mask = &pxamci_dmamask,
858 .coherent_dma_mask = 0xffffffff,
860 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
861 .resource = pxa3xx_resources_mci3,
864 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
866 pxa_register_device(&pxa3xx_device_mci3, info);
869 static struct resource pxa3xx_resources_nand[] = {
873 .flags = IORESOURCE_MEM,
878 .flags = IORESOURCE_IRQ,
881 /* DRCMR for Data DMA */
884 .flags = IORESOURCE_DMA,
887 /* DRCMR for Command DMA */
890 .flags = IORESOURCE_DMA,
894 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
896 struct platform_device pxa3xx_device_nand = {
897 .name = "pxa3xx-nand",
900 .dma_mask = &pxa3xx_nand_dma_mask,
901 .coherent_dma_mask = DMA_BIT_MASK(32),
903 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
904 .resource = pxa3xx_resources_nand,
907 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
909 pxa_register_device(&pxa3xx_device_nand, info);
911 #endif /* CONFIG_PXA3xx */
913 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
914 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
915 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
917 struct platform_device *pd;
919 pd = platform_device_alloc("pxa2xx-spi", id);
921 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
926 pd->dev.platform_data = info;
927 platform_device_add(pd);