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 <asm/arch/gpio.h>
8 #include <asm/arch/udc.h>
9 #include <asm/arch/pxafb.h>
10 #include <asm/arch/mmc.h>
11 #include <asm/arch/irda.h>
12 #include <asm/arch/i2c.h>
13 #include <asm/arch/mfp-pxa27x.h>
14 #include <asm/arch/ohci.h>
15 #include <asm/arch/pxa27x_keypad.h>
16 #include <asm/arch/pxa2xx_spi.h>
17 #include <asm/arch/camera.h>
18 #include <asm/arch/audio.h>
19 #include <asm/arch/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[] = {
159 .start = __PREG(FFUART),
160 .end = __PREG(FFUART) + 35,
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[] = {
178 .start = __PREG(BTUART),
179 .end = __PREG(BTUART) + 35,
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[] = {
197 .start = __PREG(STUART),
198 .end = __PREG(STUART) + 35,
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[] = {
216 .start = __PREG(HWUART),
217 .end = __PREG(HWUART) + 47,
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);
264 static struct resource pxai2s_resources[] = {
268 .flags = IORESOURCE_MEM,
272 .flags = IORESOURCE_IRQ,
276 struct platform_device pxa_device_i2s = {
277 .name = "pxa2xx-i2s",
279 .resource = pxai2s_resources,
280 .num_resources = ARRAY_SIZE(pxai2s_resources),
283 static u64 pxaficp_dmamask = ~(u32)0;
285 struct platform_device pxa_device_ficp = {
289 .dma_mask = &pxaficp_dmamask,
290 .coherent_dma_mask = 0xffffffff,
294 void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
296 pxa_register_device(&pxa_device_ficp, info);
299 struct platform_device pxa_device_rtc = {
300 .name = "sa1100-rtc",
304 static struct resource pxa_ac97_resources[] = {
307 .end = 0x40500000 + 0xfff,
308 .flags = IORESOURCE_MEM,
313 .flags = IORESOURCE_IRQ,
317 static u64 pxa_ac97_dmamask = 0xffffffffUL;
319 struct platform_device pxa_device_ac97 = {
320 .name = "pxa2xx-ac97",
323 .dma_mask = &pxa_ac97_dmamask,
324 .coherent_dma_mask = 0xffffffff,
326 .num_resources = ARRAY_SIZE(pxa_ac97_resources),
327 .resource = pxa_ac97_resources,
330 void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
332 pxa_register_device(&pxa_device_ac97, ops);
337 static struct resource pxa25x_resource_pwm0[] = {
341 .flags = IORESOURCE_MEM,
345 struct platform_device pxa25x_device_pwm0 = {
346 .name = "pxa25x-pwm",
348 .resource = pxa25x_resource_pwm0,
349 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
352 static struct resource pxa25x_resource_pwm1[] = {
356 .flags = IORESOURCE_MEM,
360 struct platform_device pxa25x_device_pwm1 = {
361 .name = "pxa25x-pwm",
363 .resource = pxa25x_resource_pwm1,
364 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
367 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
369 static struct resource pxa25x_resource_ssp[] = {
373 .flags = IORESOURCE_MEM,
378 .flags = IORESOURCE_IRQ,
384 .flags = IORESOURCE_DMA,
390 .flags = IORESOURCE_DMA,
394 struct platform_device pxa25x_device_ssp = {
395 .name = "pxa25x-ssp",
398 .dma_mask = &pxa25x_ssp_dma_mask,
399 .coherent_dma_mask = DMA_BIT_MASK(32),
401 .resource = pxa25x_resource_ssp,
402 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
405 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
407 static struct resource pxa25x_resource_nssp[] = {
411 .flags = IORESOURCE_MEM,
416 .flags = IORESOURCE_IRQ,
422 .flags = IORESOURCE_DMA,
428 .flags = IORESOURCE_DMA,
432 struct platform_device pxa25x_device_nssp = {
433 .name = "pxa25x-nssp",
436 .dma_mask = &pxa25x_nssp_dma_mask,
437 .coherent_dma_mask = DMA_BIT_MASK(32),
439 .resource = pxa25x_resource_nssp,
440 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
443 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
445 static struct resource pxa25x_resource_assp[] = {
449 .flags = IORESOURCE_MEM,
454 .flags = IORESOURCE_IRQ,
460 .flags = IORESOURCE_DMA,
466 .flags = IORESOURCE_DMA,
470 struct platform_device pxa25x_device_assp = {
471 /* ASSP is basically equivalent to NSSP */
472 .name = "pxa25x-nssp",
475 .dma_mask = &pxa25x_assp_dma_mask,
476 .coherent_dma_mask = DMA_BIT_MASK(32),
478 .resource = pxa25x_resource_assp,
479 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
481 #endif /* CONFIG_PXA25x */
483 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
485 static struct resource pxa27x_resource_keypad[] = {
489 .flags = IORESOURCE_MEM,
494 .flags = IORESOURCE_IRQ,
498 struct platform_device pxa27x_device_keypad = {
499 .name = "pxa27x-keypad",
501 .resource = pxa27x_resource_keypad,
502 .num_resources = ARRAY_SIZE(pxa27x_resource_keypad),
505 void __init pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info)
507 pxa_register_device(&pxa27x_device_keypad, info);
510 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
512 static struct resource pxa27x_resource_ohci[] = {
516 .flags = IORESOURCE_MEM,
521 .flags = IORESOURCE_IRQ,
525 struct platform_device pxa27x_device_ohci = {
526 .name = "pxa27x-ohci",
529 .dma_mask = &pxa27x_ohci_dma_mask,
530 .coherent_dma_mask = DMA_BIT_MASK(32),
532 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
533 .resource = pxa27x_resource_ohci,
536 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
538 pxa_register_device(&pxa27x_device_ohci, info);
541 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
543 static struct resource pxa27x_resource_ssp1[] = {
547 .flags = IORESOURCE_MEM,
552 .flags = IORESOURCE_IRQ,
558 .flags = IORESOURCE_DMA,
564 .flags = IORESOURCE_DMA,
568 struct platform_device pxa27x_device_ssp1 = {
569 .name = "pxa27x-ssp",
572 .dma_mask = &pxa27x_ssp1_dma_mask,
573 .coherent_dma_mask = DMA_BIT_MASK(32),
575 .resource = pxa27x_resource_ssp1,
576 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
579 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
581 static struct resource pxa27x_resource_ssp2[] = {
585 .flags = IORESOURCE_MEM,
590 .flags = IORESOURCE_IRQ,
596 .flags = IORESOURCE_DMA,
602 .flags = IORESOURCE_DMA,
606 struct platform_device pxa27x_device_ssp2 = {
607 .name = "pxa27x-ssp",
610 .dma_mask = &pxa27x_ssp2_dma_mask,
611 .coherent_dma_mask = DMA_BIT_MASK(32),
613 .resource = pxa27x_resource_ssp2,
614 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
617 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
619 static struct resource pxa27x_resource_ssp3[] = {
623 .flags = IORESOURCE_MEM,
628 .flags = IORESOURCE_IRQ,
634 .flags = IORESOURCE_DMA,
640 .flags = IORESOURCE_DMA,
644 struct platform_device pxa27x_device_ssp3 = {
645 .name = "pxa27x-ssp",
648 .dma_mask = &pxa27x_ssp3_dma_mask,
649 .coherent_dma_mask = DMA_BIT_MASK(32),
651 .resource = pxa27x_resource_ssp3,
652 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
655 static struct resource pxa27x_resource_pwm0[] = {
659 .flags = IORESOURCE_MEM,
663 struct platform_device pxa27x_device_pwm0 = {
664 .name = "pxa27x-pwm",
666 .resource = pxa27x_resource_pwm0,
667 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
670 static struct resource pxa27x_resource_pwm1[] = {
674 .flags = IORESOURCE_MEM,
678 struct platform_device pxa27x_device_pwm1 = {
679 .name = "pxa27x-pwm",
681 .resource = pxa27x_resource_pwm1,
682 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
685 static struct resource pxa27x_resource_camera[] = {
689 .flags = IORESOURCE_MEM,
694 .flags = IORESOURCE_IRQ,
698 static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
700 static struct platform_device pxa27x_device_camera = {
701 .name = "pxa27x-camera",
702 .id = 0, /* This is used to put cameras on this interface */
704 .dma_mask = &pxa27x_dma_mask_camera,
705 .coherent_dma_mask = 0xffffffff,
707 .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
708 .resource = pxa27x_resource_camera,
711 void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
713 pxa_register_device(&pxa27x_device_camera, info);
715 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
718 static u64 pxa3xx_ssp4_dma_mask = DMA_BIT_MASK(32);
720 static struct resource pxa3xx_resource_ssp4[] = {
724 .flags = IORESOURCE_MEM,
729 .flags = IORESOURCE_IRQ,
735 .flags = IORESOURCE_DMA,
741 .flags = IORESOURCE_DMA,
745 struct platform_device pxa3xx_device_ssp4 = {
746 /* PXA3xx SSP is basically equivalent to PXA27x */
747 .name = "pxa27x-ssp",
750 .dma_mask = &pxa3xx_ssp4_dma_mask,
751 .coherent_dma_mask = DMA_BIT_MASK(32),
753 .resource = pxa3xx_resource_ssp4,
754 .num_resources = ARRAY_SIZE(pxa3xx_resource_ssp4),
757 static struct resource pxa3xx_resources_mci2[] = {
761 .flags = IORESOURCE_MEM,
766 .flags = IORESOURCE_IRQ,
771 .flags = IORESOURCE_DMA,
776 .flags = IORESOURCE_DMA,
780 struct platform_device pxa3xx_device_mci2 = {
781 .name = "pxa2xx-mci",
784 .dma_mask = &pxamci_dmamask,
785 .coherent_dma_mask = 0xffffffff,
787 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci2),
788 .resource = pxa3xx_resources_mci2,
791 void __init pxa3xx_set_mci2_info(struct pxamci_platform_data *info)
793 pxa_register_device(&pxa3xx_device_mci2, info);
796 static struct resource pxa3xx_resources_mci3[] = {
800 .flags = IORESOURCE_MEM,
805 .flags = IORESOURCE_IRQ,
810 .flags = IORESOURCE_DMA,
815 .flags = IORESOURCE_DMA,
819 struct platform_device pxa3xx_device_mci3 = {
820 .name = "pxa2xx-mci",
823 .dma_mask = &pxamci_dmamask,
824 .coherent_dma_mask = 0xffffffff,
826 .num_resources = ARRAY_SIZE(pxa3xx_resources_mci3),
827 .resource = pxa3xx_resources_mci3,
830 void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
832 pxa_register_device(&pxa3xx_device_mci3, info);
835 static struct resource pxa3xx_resources_nand[] = {
839 .flags = IORESOURCE_MEM,
844 .flags = IORESOURCE_IRQ,
847 /* DRCMR for Data DMA */
850 .flags = IORESOURCE_DMA,
853 /* DRCMR for Command DMA */
856 .flags = IORESOURCE_DMA,
860 static u64 pxa3xx_nand_dma_mask = DMA_BIT_MASK(32);
862 struct platform_device pxa3xx_device_nand = {
863 .name = "pxa3xx-nand",
866 .dma_mask = &pxa3xx_nand_dma_mask,
867 .coherent_dma_mask = DMA_BIT_MASK(32),
869 .num_resources = ARRAY_SIZE(pxa3xx_resources_nand),
870 .resource = pxa3xx_resources_nand,
873 void __init pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info)
875 pxa_register_device(&pxa3xx_device_nand, info);
877 #endif /* CONFIG_PXA3xx */
879 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
880 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
881 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
883 struct platform_device *pd;
885 pd = platform_device_alloc("pxa2xx-spi", id);
887 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
892 pd->dev.platform_data = info;
893 platform_device_add(pd);