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>
12 #include <mach/ohci.h>
13 #include <mach/pxa27x_keypad.h>
14 #include <mach/pxa2xx_spi.h>
15 #include <mach/camera.h>
16 #include <mach/audio.h>
17 #include <mach/pxa3xx_nand.h>
22 void __init
pxa_register_device(struct platform_device
*dev
, void *data
)
26 dev
->dev
.platform_data
= data
;
28 ret
= platform_device_register(dev
);
30 dev_err(&dev
->dev
, "unable to register device: %d\n", ret
);
33 static struct resource pxamci_resources
[] = {
37 .flags
= IORESOURCE_MEM
,
42 .flags
= IORESOURCE_IRQ
,
47 .flags
= IORESOURCE_DMA
,
52 .flags
= IORESOURCE_DMA
,
56 static u64 pxamci_dmamask
= 0xffffffffUL
;
58 struct platform_device pxa_device_mci
= {
62 .dma_mask
= &pxamci_dmamask
,
63 .coherent_dma_mask
= 0xffffffff,
65 .num_resources
= ARRAY_SIZE(pxamci_resources
),
66 .resource
= pxamci_resources
,
69 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
71 pxa_register_device(&pxa_device_mci
, info
);
75 static struct pxa2xx_udc_mach_info pxa_udc_info
= {
80 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
82 memcpy(&pxa_udc_info
, info
, sizeof *info
);
85 static struct resource pxa2xx_udc_resources
[] = {
89 .flags
= IORESOURCE_MEM
,
94 .flags
= IORESOURCE_IRQ
,
98 static u64 udc_dma_mask
= ~(u32
)0;
100 struct platform_device pxa25x_device_udc
= {
101 .name
= "pxa25x-udc",
103 .resource
= pxa2xx_udc_resources
,
104 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
106 .platform_data
= &pxa_udc_info
,
107 .dma_mask
= &udc_dma_mask
,
111 struct platform_device pxa27x_device_udc
= {
112 .name
= "pxa27x-udc",
114 .resource
= pxa2xx_udc_resources
,
115 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
117 .platform_data
= &pxa_udc_info
,
118 .dma_mask
= &udc_dma_mask
,
122 static struct resource pxafb_resources
[] = {
126 .flags
= IORESOURCE_MEM
,
131 .flags
= IORESOURCE_IRQ
,
135 static u64 fb_dma_mask
= ~(u64
)0;
137 struct platform_device pxa_device_fb
= {
141 .dma_mask
= &fb_dma_mask
,
142 .coherent_dma_mask
= 0xffffffff,
144 .num_resources
= ARRAY_SIZE(pxafb_resources
),
145 .resource
= pxafb_resources
,
148 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
150 pxa_register_device(&pxa_device_fb
, info
);
153 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
155 pxa_device_fb
.dev
.parent
= parent_dev
;
158 static struct resource pxa_resource_ffuart
[] = {
162 .flags
= IORESOURCE_MEM
,
166 .flags
= IORESOURCE_IRQ
,
170 struct platform_device pxa_device_ffuart
= {
171 .name
= "pxa2xx-uart",
173 .resource
= pxa_resource_ffuart
,
174 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
177 static struct resource pxa_resource_btuart
[] = {
181 .flags
= IORESOURCE_MEM
,
185 .flags
= IORESOURCE_IRQ
,
189 struct platform_device pxa_device_btuart
= {
190 .name
= "pxa2xx-uart",
192 .resource
= pxa_resource_btuart
,
193 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
196 static struct resource pxa_resource_stuart
[] = {
200 .flags
= IORESOURCE_MEM
,
204 .flags
= IORESOURCE_IRQ
,
208 struct platform_device pxa_device_stuart
= {
209 .name
= "pxa2xx-uart",
211 .resource
= pxa_resource_stuart
,
212 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
215 static struct resource pxa_resource_hwuart
[] = {
219 .flags
= IORESOURCE_MEM
,
223 .flags
= IORESOURCE_IRQ
,
227 struct platform_device pxa_device_hwuart
= {
228 .name
= "pxa2xx-uart",
230 .resource
= pxa_resource_hwuart
,
231 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
234 static struct resource pxai2c_resources
[] = {
238 .flags
= IORESOURCE_MEM
,
242 .flags
= IORESOURCE_IRQ
,
246 struct platform_device pxa_device_i2c
= {
247 .name
= "pxa2xx-i2c",
249 .resource
= pxai2c_resources
,
250 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
253 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
255 pxa_register_device(&pxa_device_i2c
, info
);
259 static struct resource pxa27x_resources_i2c_power
[] = {
263 .flags
= IORESOURCE_MEM
,
267 .flags
= IORESOURCE_IRQ
,
271 struct platform_device pxa27x_device_i2c_power
= {
272 .name
= "pxa2xx-i2c",
274 .resource
= pxa27x_resources_i2c_power
,
275 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
280 static struct resource pxa3xx_resources_i2c_power
[] = {
284 .flags
= IORESOURCE_MEM
,
288 .flags
= IORESOURCE_IRQ
,
292 struct platform_device pxa3xx_device_i2c_power
= {
293 .name
= "pxa3xx-pwri2c",
295 .resource
= pxa3xx_resources_i2c_power
,
296 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
300 static struct resource pxai2s_resources
[] = {
304 .flags
= IORESOURCE_MEM
,
308 .flags
= IORESOURCE_IRQ
,
312 struct platform_device pxa_device_i2s
= {
313 .name
= "pxa2xx-i2s",
315 .resource
= pxai2s_resources
,
316 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
319 static u64 pxaficp_dmamask
= ~(u32
)0;
321 struct platform_device pxa_device_ficp
= {
325 .dma_mask
= &pxaficp_dmamask
,
326 .coherent_dma_mask
= 0xffffffff,
330 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
332 pxa_register_device(&pxa_device_ficp
, info
);
335 static struct resource pxa_rtc_resources
[] = {
338 .end
= 0x40900000 + 0x3b,
339 .flags
= IORESOURCE_MEM
,
344 .flags
= IORESOURCE_IRQ
,
347 .start
= IRQ_RTCAlrm
,
349 .flags
= IORESOURCE_IRQ
,
353 struct platform_device sa1100_device_rtc
= {
354 .name
= "sa1100-rtc",
358 struct platform_device pxa_device_rtc
= {
361 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
362 .resource
= pxa_rtc_resources
,
365 static struct resource pxa_ac97_resources
[] = {
368 .end
= 0x40500000 + 0xfff,
369 .flags
= IORESOURCE_MEM
,
374 .flags
= IORESOURCE_IRQ
,
378 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
380 struct platform_device pxa_device_ac97
= {
381 .name
= "pxa2xx-ac97",
384 .dma_mask
= &pxa_ac97_dmamask
,
385 .coherent_dma_mask
= 0xffffffff,
387 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
388 .resource
= pxa_ac97_resources
,
391 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
393 pxa_register_device(&pxa_device_ac97
, ops
);
398 static struct resource pxa25x_resource_pwm0
[] = {
402 .flags
= IORESOURCE_MEM
,
406 struct platform_device pxa25x_device_pwm0
= {
407 .name
= "pxa25x-pwm",
409 .resource
= pxa25x_resource_pwm0
,
410 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
413 static struct resource pxa25x_resource_pwm1
[] = {
417 .flags
= IORESOURCE_MEM
,
421 struct platform_device pxa25x_device_pwm1
= {
422 .name
= "pxa25x-pwm",
424 .resource
= pxa25x_resource_pwm1
,
425 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
428 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
430 static struct resource pxa25x_resource_ssp
[] = {
434 .flags
= IORESOURCE_MEM
,
439 .flags
= IORESOURCE_IRQ
,
445 .flags
= IORESOURCE_DMA
,
451 .flags
= IORESOURCE_DMA
,
455 struct platform_device pxa25x_device_ssp
= {
456 .name
= "pxa25x-ssp",
459 .dma_mask
= &pxa25x_ssp_dma_mask
,
460 .coherent_dma_mask
= DMA_BIT_MASK(32),
462 .resource
= pxa25x_resource_ssp
,
463 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
466 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
468 static struct resource pxa25x_resource_nssp
[] = {
472 .flags
= IORESOURCE_MEM
,
477 .flags
= IORESOURCE_IRQ
,
483 .flags
= IORESOURCE_DMA
,
489 .flags
= IORESOURCE_DMA
,
493 struct platform_device pxa25x_device_nssp
= {
494 .name
= "pxa25x-nssp",
497 .dma_mask
= &pxa25x_nssp_dma_mask
,
498 .coherent_dma_mask
= DMA_BIT_MASK(32),
500 .resource
= pxa25x_resource_nssp
,
501 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
504 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
506 static struct resource pxa25x_resource_assp
[] = {
510 .flags
= IORESOURCE_MEM
,
515 .flags
= IORESOURCE_IRQ
,
521 .flags
= IORESOURCE_DMA
,
527 .flags
= IORESOURCE_DMA
,
531 struct platform_device pxa25x_device_assp
= {
532 /* ASSP is basically equivalent to NSSP */
533 .name
= "pxa25x-nssp",
536 .dma_mask
= &pxa25x_assp_dma_mask
,
537 .coherent_dma_mask
= DMA_BIT_MASK(32),
539 .resource
= pxa25x_resource_assp
,
540 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
542 #endif /* CONFIG_PXA25x */
544 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
546 static struct resource pxa27x_resource_keypad
[] = {
550 .flags
= IORESOURCE_MEM
,
555 .flags
= IORESOURCE_IRQ
,
559 struct platform_device pxa27x_device_keypad
= {
560 .name
= "pxa27x-keypad",
562 .resource
= pxa27x_resource_keypad
,
563 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
566 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
568 pxa_register_device(&pxa27x_device_keypad
, info
);
571 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
573 static struct resource pxa27x_resource_ohci
[] = {
577 .flags
= IORESOURCE_MEM
,
582 .flags
= IORESOURCE_IRQ
,
586 struct platform_device pxa27x_device_ohci
= {
587 .name
= "pxa27x-ohci",
590 .dma_mask
= &pxa27x_ohci_dma_mask
,
591 .coherent_dma_mask
= DMA_BIT_MASK(32),
593 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
594 .resource
= pxa27x_resource_ohci
,
597 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
599 pxa_register_device(&pxa27x_device_ohci
, info
);
602 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
604 static struct resource pxa27x_resource_ssp1
[] = {
608 .flags
= IORESOURCE_MEM
,
613 .flags
= IORESOURCE_IRQ
,
619 .flags
= IORESOURCE_DMA
,
625 .flags
= IORESOURCE_DMA
,
629 struct platform_device pxa27x_device_ssp1
= {
630 .name
= "pxa27x-ssp",
633 .dma_mask
= &pxa27x_ssp1_dma_mask
,
634 .coherent_dma_mask
= DMA_BIT_MASK(32),
636 .resource
= pxa27x_resource_ssp1
,
637 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
640 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
642 static struct resource pxa27x_resource_ssp2
[] = {
646 .flags
= IORESOURCE_MEM
,
651 .flags
= IORESOURCE_IRQ
,
657 .flags
= IORESOURCE_DMA
,
663 .flags
= IORESOURCE_DMA
,
667 struct platform_device pxa27x_device_ssp2
= {
668 .name
= "pxa27x-ssp",
671 .dma_mask
= &pxa27x_ssp2_dma_mask
,
672 .coherent_dma_mask
= DMA_BIT_MASK(32),
674 .resource
= pxa27x_resource_ssp2
,
675 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
678 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
680 static struct resource pxa27x_resource_ssp3
[] = {
684 .flags
= IORESOURCE_MEM
,
689 .flags
= IORESOURCE_IRQ
,
695 .flags
= IORESOURCE_DMA
,
701 .flags
= IORESOURCE_DMA
,
705 struct platform_device pxa27x_device_ssp3
= {
706 .name
= "pxa27x-ssp",
709 .dma_mask
= &pxa27x_ssp3_dma_mask
,
710 .coherent_dma_mask
= DMA_BIT_MASK(32),
712 .resource
= pxa27x_resource_ssp3
,
713 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
716 static struct resource pxa27x_resource_pwm0
[] = {
720 .flags
= IORESOURCE_MEM
,
724 struct platform_device pxa27x_device_pwm0
= {
725 .name
= "pxa27x-pwm",
727 .resource
= pxa27x_resource_pwm0
,
728 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
731 static struct resource pxa27x_resource_pwm1
[] = {
735 .flags
= IORESOURCE_MEM
,
739 struct platform_device pxa27x_device_pwm1
= {
740 .name
= "pxa27x-pwm",
742 .resource
= pxa27x_resource_pwm1
,
743 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
746 static struct resource pxa27x_resource_camera
[] = {
750 .flags
= IORESOURCE_MEM
,
755 .flags
= IORESOURCE_IRQ
,
759 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
761 static struct platform_device pxa27x_device_camera
= {
762 .name
= "pxa27x-camera",
763 .id
= 0, /* This is used to put cameras on this interface */
765 .dma_mask
= &pxa27x_dma_mask_camera
,
766 .coherent_dma_mask
= 0xffffffff,
768 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
769 .resource
= pxa27x_resource_camera
,
772 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
774 pxa_register_device(&pxa27x_device_camera
, info
);
776 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
779 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
781 static struct resource pxa3xx_resource_ssp4
[] = {
785 .flags
= IORESOURCE_MEM
,
790 .flags
= IORESOURCE_IRQ
,
796 .flags
= IORESOURCE_DMA
,
802 .flags
= IORESOURCE_DMA
,
806 struct platform_device pxa3xx_device_ssp4
= {
807 /* PXA3xx SSP is basically equivalent to PXA27x */
808 .name
= "pxa27x-ssp",
811 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
812 .coherent_dma_mask
= DMA_BIT_MASK(32),
814 .resource
= pxa3xx_resource_ssp4
,
815 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
818 static struct resource pxa3xx_resources_mci2
[] = {
822 .flags
= IORESOURCE_MEM
,
827 .flags
= IORESOURCE_IRQ
,
832 .flags
= IORESOURCE_DMA
,
837 .flags
= IORESOURCE_DMA
,
841 struct platform_device pxa3xx_device_mci2
= {
842 .name
= "pxa2xx-mci",
845 .dma_mask
= &pxamci_dmamask
,
846 .coherent_dma_mask
= 0xffffffff,
848 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
849 .resource
= pxa3xx_resources_mci2
,
852 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
854 pxa_register_device(&pxa3xx_device_mci2
, info
);
857 static struct resource pxa3xx_resources_mci3
[] = {
861 .flags
= IORESOURCE_MEM
,
866 .flags
= IORESOURCE_IRQ
,
871 .flags
= IORESOURCE_DMA
,
876 .flags
= IORESOURCE_DMA
,
880 struct platform_device pxa3xx_device_mci3
= {
881 .name
= "pxa2xx-mci",
884 .dma_mask
= &pxamci_dmamask
,
885 .coherent_dma_mask
= 0xffffffff,
887 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
888 .resource
= pxa3xx_resources_mci3
,
891 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
893 pxa_register_device(&pxa3xx_device_mci3
, info
);
896 static struct resource pxa3xx_resources_nand
[] = {
900 .flags
= IORESOURCE_MEM
,
905 .flags
= IORESOURCE_IRQ
,
908 /* DRCMR for Data DMA */
911 .flags
= IORESOURCE_DMA
,
914 /* DRCMR for Command DMA */
917 .flags
= IORESOURCE_DMA
,
921 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
923 struct platform_device pxa3xx_device_nand
= {
924 .name
= "pxa3xx-nand",
927 .dma_mask
= &pxa3xx_nand_dma_mask
,
928 .coherent_dma_mask
= DMA_BIT_MASK(32),
930 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
931 .resource
= pxa3xx_resources_nand
,
934 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
936 pxa_register_device(&pxa3xx_device_nand
, info
);
938 #endif /* CONFIG_PXA3xx */
940 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
941 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
942 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
944 struct platform_device
*pd
;
946 pd
= platform_device_alloc("pxa2xx-spi", id
);
948 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
953 pd
->dev
.platform_data
= info
;
954 platform_device_add(pd
);