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
;
77 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
79 memcpy(&pxa_udc_info
, info
, sizeof *info
);
82 static struct resource pxa2xx_udc_resources
[] = {
86 .flags
= IORESOURCE_MEM
,
91 .flags
= IORESOURCE_IRQ
,
95 static u64 udc_dma_mask
= ~(u32
)0;
97 struct platform_device pxa25x_device_udc
= {
100 .resource
= pxa2xx_udc_resources
,
101 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
103 .platform_data
= &pxa_udc_info
,
104 .dma_mask
= &udc_dma_mask
,
108 struct platform_device pxa27x_device_udc
= {
109 .name
= "pxa27x-udc",
111 .resource
= pxa2xx_udc_resources
,
112 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
114 .platform_data
= &pxa_udc_info
,
115 .dma_mask
= &udc_dma_mask
,
119 static struct resource pxafb_resources
[] = {
123 .flags
= IORESOURCE_MEM
,
128 .flags
= IORESOURCE_IRQ
,
132 static u64 fb_dma_mask
= ~(u64
)0;
134 struct platform_device pxa_device_fb
= {
138 .dma_mask
= &fb_dma_mask
,
139 .coherent_dma_mask
= 0xffffffff,
141 .num_resources
= ARRAY_SIZE(pxafb_resources
),
142 .resource
= pxafb_resources
,
145 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
147 pxa_register_device(&pxa_device_fb
, info
);
150 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
152 pxa_device_fb
.dev
.parent
= parent_dev
;
155 static struct resource pxa_resource_ffuart
[] = {
159 .flags
= IORESOURCE_MEM
,
163 .flags
= IORESOURCE_IRQ
,
167 struct platform_device pxa_device_ffuart
= {
168 .name
= "pxa2xx-uart",
170 .resource
= pxa_resource_ffuart
,
171 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
174 static struct resource pxa_resource_btuart
[] = {
178 .flags
= IORESOURCE_MEM
,
182 .flags
= IORESOURCE_IRQ
,
186 struct platform_device pxa_device_btuart
= {
187 .name
= "pxa2xx-uart",
189 .resource
= pxa_resource_btuart
,
190 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
193 static struct resource pxa_resource_stuart
[] = {
197 .flags
= IORESOURCE_MEM
,
201 .flags
= IORESOURCE_IRQ
,
205 struct platform_device pxa_device_stuart
= {
206 .name
= "pxa2xx-uart",
208 .resource
= pxa_resource_stuart
,
209 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
212 static struct resource pxa_resource_hwuart
[] = {
216 .flags
= IORESOURCE_MEM
,
220 .flags
= IORESOURCE_IRQ
,
224 struct platform_device pxa_device_hwuart
= {
225 .name
= "pxa2xx-uart",
227 .resource
= pxa_resource_hwuart
,
228 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
231 static struct resource pxai2c_resources
[] = {
235 .flags
= IORESOURCE_MEM
,
239 .flags
= IORESOURCE_IRQ
,
243 struct platform_device pxa_device_i2c
= {
244 .name
= "pxa2xx-i2c",
246 .resource
= pxai2c_resources
,
247 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
250 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
252 pxa_register_device(&pxa_device_i2c
, info
);
256 static struct resource pxa27x_resources_i2c_power
[] = {
260 .flags
= IORESOURCE_MEM
,
264 .flags
= IORESOURCE_IRQ
,
268 struct platform_device pxa27x_device_i2c_power
= {
269 .name
= "pxa2xx-i2c",
271 .resource
= pxa27x_resources_i2c_power
,
272 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
277 static struct resource pxa3xx_resources_i2c_power
[] = {
281 .flags
= IORESOURCE_MEM
,
285 .flags
= IORESOURCE_IRQ
,
289 struct platform_device pxa3xx_device_i2c_power
= {
290 .name
= "pxa3xx-pwri2c",
292 .resource
= pxa3xx_resources_i2c_power
,
293 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
297 static struct resource pxai2s_resources
[] = {
301 .flags
= IORESOURCE_MEM
,
305 .flags
= IORESOURCE_IRQ
,
309 struct platform_device pxa_device_i2s
= {
310 .name
= "pxa2xx-i2s",
312 .resource
= pxai2s_resources
,
313 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
316 static u64 pxaficp_dmamask
= ~(u32
)0;
318 struct platform_device pxa_device_ficp
= {
322 .dma_mask
= &pxaficp_dmamask
,
323 .coherent_dma_mask
= 0xffffffff,
327 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
329 pxa_register_device(&pxa_device_ficp
, info
);
332 static struct resource pxa_rtc_resources
[] = {
335 .end
= 0x40900000 + 0x3b,
336 .flags
= IORESOURCE_MEM
,
341 .flags
= IORESOURCE_IRQ
,
344 .start
= IRQ_RTCAlrm
,
346 .flags
= IORESOURCE_IRQ
,
350 struct platform_device sa1100_device_rtc
= {
351 .name
= "sa1100-rtc",
355 struct platform_device pxa_device_rtc
= {
358 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
359 .resource
= pxa_rtc_resources
,
362 static struct resource pxa_ac97_resources
[] = {
365 .end
= 0x40500000 + 0xfff,
366 .flags
= IORESOURCE_MEM
,
371 .flags
= IORESOURCE_IRQ
,
375 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
377 struct platform_device pxa_device_ac97
= {
378 .name
= "pxa2xx-ac97",
381 .dma_mask
= &pxa_ac97_dmamask
,
382 .coherent_dma_mask
= 0xffffffff,
384 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
385 .resource
= pxa_ac97_resources
,
388 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
390 pxa_register_device(&pxa_device_ac97
, ops
);
395 static struct resource pxa25x_resource_pwm0
[] = {
399 .flags
= IORESOURCE_MEM
,
403 struct platform_device pxa25x_device_pwm0
= {
404 .name
= "pxa25x-pwm",
406 .resource
= pxa25x_resource_pwm0
,
407 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
410 static struct resource pxa25x_resource_pwm1
[] = {
414 .flags
= IORESOURCE_MEM
,
418 struct platform_device pxa25x_device_pwm1
= {
419 .name
= "pxa25x-pwm",
421 .resource
= pxa25x_resource_pwm1
,
422 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
425 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
427 static struct resource pxa25x_resource_ssp
[] = {
431 .flags
= IORESOURCE_MEM
,
436 .flags
= IORESOURCE_IRQ
,
442 .flags
= IORESOURCE_DMA
,
448 .flags
= IORESOURCE_DMA
,
452 struct platform_device pxa25x_device_ssp
= {
453 .name
= "pxa25x-ssp",
456 .dma_mask
= &pxa25x_ssp_dma_mask
,
457 .coherent_dma_mask
= DMA_BIT_MASK(32),
459 .resource
= pxa25x_resource_ssp
,
460 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
463 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
465 static struct resource pxa25x_resource_nssp
[] = {
469 .flags
= IORESOURCE_MEM
,
474 .flags
= IORESOURCE_IRQ
,
480 .flags
= IORESOURCE_DMA
,
486 .flags
= IORESOURCE_DMA
,
490 struct platform_device pxa25x_device_nssp
= {
491 .name
= "pxa25x-nssp",
494 .dma_mask
= &pxa25x_nssp_dma_mask
,
495 .coherent_dma_mask
= DMA_BIT_MASK(32),
497 .resource
= pxa25x_resource_nssp
,
498 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
501 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
503 static struct resource pxa25x_resource_assp
[] = {
507 .flags
= IORESOURCE_MEM
,
512 .flags
= IORESOURCE_IRQ
,
518 .flags
= IORESOURCE_DMA
,
524 .flags
= IORESOURCE_DMA
,
528 struct platform_device pxa25x_device_assp
= {
529 /* ASSP is basically equivalent to NSSP */
530 .name
= "pxa25x-nssp",
533 .dma_mask
= &pxa25x_assp_dma_mask
,
534 .coherent_dma_mask
= DMA_BIT_MASK(32),
536 .resource
= pxa25x_resource_assp
,
537 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
539 #endif /* CONFIG_PXA25x */
541 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
543 static struct resource pxa27x_resource_keypad
[] = {
547 .flags
= IORESOURCE_MEM
,
552 .flags
= IORESOURCE_IRQ
,
556 struct platform_device pxa27x_device_keypad
= {
557 .name
= "pxa27x-keypad",
559 .resource
= pxa27x_resource_keypad
,
560 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
563 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
565 pxa_register_device(&pxa27x_device_keypad
, info
);
568 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
570 static struct resource pxa27x_resource_ohci
[] = {
574 .flags
= IORESOURCE_MEM
,
579 .flags
= IORESOURCE_IRQ
,
583 struct platform_device pxa27x_device_ohci
= {
584 .name
= "pxa27x-ohci",
587 .dma_mask
= &pxa27x_ohci_dma_mask
,
588 .coherent_dma_mask
= DMA_BIT_MASK(32),
590 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
591 .resource
= pxa27x_resource_ohci
,
594 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
596 pxa_register_device(&pxa27x_device_ohci
, info
);
599 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
601 static struct resource pxa27x_resource_ssp1
[] = {
605 .flags
= IORESOURCE_MEM
,
610 .flags
= IORESOURCE_IRQ
,
616 .flags
= IORESOURCE_DMA
,
622 .flags
= IORESOURCE_DMA
,
626 struct platform_device pxa27x_device_ssp1
= {
627 .name
= "pxa27x-ssp",
630 .dma_mask
= &pxa27x_ssp1_dma_mask
,
631 .coherent_dma_mask
= DMA_BIT_MASK(32),
633 .resource
= pxa27x_resource_ssp1
,
634 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
637 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
639 static struct resource pxa27x_resource_ssp2
[] = {
643 .flags
= IORESOURCE_MEM
,
648 .flags
= IORESOURCE_IRQ
,
654 .flags
= IORESOURCE_DMA
,
660 .flags
= IORESOURCE_DMA
,
664 struct platform_device pxa27x_device_ssp2
= {
665 .name
= "pxa27x-ssp",
668 .dma_mask
= &pxa27x_ssp2_dma_mask
,
669 .coherent_dma_mask
= DMA_BIT_MASK(32),
671 .resource
= pxa27x_resource_ssp2
,
672 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
675 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
677 static struct resource pxa27x_resource_ssp3
[] = {
681 .flags
= IORESOURCE_MEM
,
686 .flags
= IORESOURCE_IRQ
,
692 .flags
= IORESOURCE_DMA
,
698 .flags
= IORESOURCE_DMA
,
702 struct platform_device pxa27x_device_ssp3
= {
703 .name
= "pxa27x-ssp",
706 .dma_mask
= &pxa27x_ssp3_dma_mask
,
707 .coherent_dma_mask
= DMA_BIT_MASK(32),
709 .resource
= pxa27x_resource_ssp3
,
710 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
713 static struct resource pxa27x_resource_pwm0
[] = {
717 .flags
= IORESOURCE_MEM
,
721 struct platform_device pxa27x_device_pwm0
= {
722 .name
= "pxa27x-pwm",
724 .resource
= pxa27x_resource_pwm0
,
725 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
728 static struct resource pxa27x_resource_pwm1
[] = {
732 .flags
= IORESOURCE_MEM
,
736 struct platform_device pxa27x_device_pwm1
= {
737 .name
= "pxa27x-pwm",
739 .resource
= pxa27x_resource_pwm1
,
740 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
743 static struct resource pxa27x_resource_camera
[] = {
747 .flags
= IORESOURCE_MEM
,
752 .flags
= IORESOURCE_IRQ
,
756 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
758 static struct platform_device pxa27x_device_camera
= {
759 .name
= "pxa27x-camera",
760 .id
= 0, /* This is used to put cameras on this interface */
762 .dma_mask
= &pxa27x_dma_mask_camera
,
763 .coherent_dma_mask
= 0xffffffff,
765 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
766 .resource
= pxa27x_resource_camera
,
769 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
771 pxa_register_device(&pxa27x_device_camera
, info
);
773 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
776 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
778 static struct resource pxa3xx_resource_ssp4
[] = {
782 .flags
= IORESOURCE_MEM
,
787 .flags
= IORESOURCE_IRQ
,
793 .flags
= IORESOURCE_DMA
,
799 .flags
= IORESOURCE_DMA
,
803 struct platform_device pxa3xx_device_ssp4
= {
804 /* PXA3xx SSP is basically equivalent to PXA27x */
805 .name
= "pxa27x-ssp",
808 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
809 .coherent_dma_mask
= DMA_BIT_MASK(32),
811 .resource
= pxa3xx_resource_ssp4
,
812 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
815 static struct resource pxa3xx_resources_mci2
[] = {
819 .flags
= IORESOURCE_MEM
,
824 .flags
= IORESOURCE_IRQ
,
829 .flags
= IORESOURCE_DMA
,
834 .flags
= IORESOURCE_DMA
,
838 struct platform_device pxa3xx_device_mci2
= {
839 .name
= "pxa2xx-mci",
842 .dma_mask
= &pxamci_dmamask
,
843 .coherent_dma_mask
= 0xffffffff,
845 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
846 .resource
= pxa3xx_resources_mci2
,
849 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
851 pxa_register_device(&pxa3xx_device_mci2
, info
);
854 static struct resource pxa3xx_resources_mci3
[] = {
858 .flags
= IORESOURCE_MEM
,
863 .flags
= IORESOURCE_IRQ
,
868 .flags
= IORESOURCE_DMA
,
873 .flags
= IORESOURCE_DMA
,
877 struct platform_device pxa3xx_device_mci3
= {
878 .name
= "pxa2xx-mci",
881 .dma_mask
= &pxamci_dmamask
,
882 .coherent_dma_mask
= 0xffffffff,
884 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
885 .resource
= pxa3xx_resources_mci3
,
888 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
890 pxa_register_device(&pxa3xx_device_mci3
, info
);
893 static struct resource pxa3xx_resources_nand
[] = {
897 .flags
= IORESOURCE_MEM
,
902 .flags
= IORESOURCE_IRQ
,
905 /* DRCMR for Data DMA */
908 .flags
= IORESOURCE_DMA
,
911 /* DRCMR for Command DMA */
914 .flags
= IORESOURCE_DMA
,
918 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
920 struct platform_device pxa3xx_device_nand
= {
921 .name
= "pxa3xx-nand",
924 .dma_mask
= &pxa3xx_nand_dma_mask
,
925 .coherent_dma_mask
= DMA_BIT_MASK(32),
927 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
928 .resource
= pxa3xx_resources_nand
,
931 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
933 pxa_register_device(&pxa3xx_device_nand
, info
);
935 #endif /* CONFIG_PXA3xx */
937 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
938 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
939 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
941 struct platform_device
*pd
;
943 pd
= platform_device_alloc("pxa2xx-spi", id
);
945 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
950 pd
->dev
.platform_data
= info
;
951 platform_device_add(pd
);