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>
11 #include <mach/ohci.h>
12 #include <mach/pxa27x_keypad.h>
13 #include <mach/pxa2xx_spi.h>
14 #include <mach/camera.h>
15 #include <mach/audio.h>
16 #include <mach/hardware.h>
18 #include <plat/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
= {
81 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
83 memcpy(&pxa_udc_info
, info
, sizeof *info
);
86 static struct resource pxa2xx_udc_resources
[] = {
90 .flags
= IORESOURCE_MEM
,
95 .flags
= IORESOURCE_IRQ
,
99 static u64 udc_dma_mask
= ~(u32
)0;
101 struct platform_device pxa25x_device_udc
= {
102 .name
= "pxa25x-udc",
104 .resource
= pxa2xx_udc_resources
,
105 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
107 .platform_data
= &pxa_udc_info
,
108 .dma_mask
= &udc_dma_mask
,
112 struct platform_device pxa27x_device_udc
= {
113 .name
= "pxa27x-udc",
115 .resource
= pxa2xx_udc_resources
,
116 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
118 .platform_data
= &pxa_udc_info
,
119 .dma_mask
= &udc_dma_mask
,
123 static struct resource pxafb_resources
[] = {
127 .flags
= IORESOURCE_MEM
,
132 .flags
= IORESOURCE_IRQ
,
136 static u64 fb_dma_mask
= ~(u64
)0;
138 struct platform_device pxa_device_fb
= {
142 .dma_mask
= &fb_dma_mask
,
143 .coherent_dma_mask
= 0xffffffff,
145 .num_resources
= ARRAY_SIZE(pxafb_resources
),
146 .resource
= pxafb_resources
,
149 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
151 pxa_register_device(&pxa_device_fb
, info
);
154 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
156 pxa_device_fb
.dev
.parent
= parent_dev
;
159 static struct resource pxa_resource_ffuart
[] = {
163 .flags
= IORESOURCE_MEM
,
167 .flags
= IORESOURCE_IRQ
,
171 struct platform_device pxa_device_ffuart
= {
172 .name
= "pxa2xx-uart",
174 .resource
= pxa_resource_ffuart
,
175 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
178 void __init
pxa_set_ffuart_info(void *info
)
180 pxa_register_device(&pxa_device_ffuart
, info
);
183 static struct resource pxa_resource_btuart
[] = {
187 .flags
= IORESOURCE_MEM
,
191 .flags
= IORESOURCE_IRQ
,
195 struct platform_device pxa_device_btuart
= {
196 .name
= "pxa2xx-uart",
198 .resource
= pxa_resource_btuart
,
199 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
202 void __init
pxa_set_btuart_info(void *info
)
204 pxa_register_device(&pxa_device_btuart
, info
);
207 static struct resource pxa_resource_stuart
[] = {
211 .flags
= IORESOURCE_MEM
,
215 .flags
= IORESOURCE_IRQ
,
219 struct platform_device pxa_device_stuart
= {
220 .name
= "pxa2xx-uart",
222 .resource
= pxa_resource_stuart
,
223 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
226 void __init
pxa_set_stuart_info(void *info
)
228 pxa_register_device(&pxa_device_stuart
, info
);
231 static struct resource pxa_resource_hwuart
[] = {
235 .flags
= IORESOURCE_MEM
,
239 .flags
= IORESOURCE_IRQ
,
243 struct platform_device pxa_device_hwuart
= {
244 .name
= "pxa2xx-uart",
246 .resource
= pxa_resource_hwuart
,
247 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
250 void __init
pxa_set_hwuart_info(void *info
)
253 pxa_register_device(&pxa_device_hwuart
, info
);
255 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
258 static struct resource pxai2c_resources
[] = {
262 .flags
= IORESOURCE_MEM
,
266 .flags
= IORESOURCE_IRQ
,
270 struct platform_device pxa_device_i2c
= {
271 .name
= "pxa2xx-i2c",
273 .resource
= pxai2c_resources
,
274 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
277 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
279 pxa_register_device(&pxa_device_i2c
, info
);
283 static struct resource pxa27x_resources_i2c_power
[] = {
287 .flags
= IORESOURCE_MEM
,
291 .flags
= IORESOURCE_IRQ
,
295 struct platform_device pxa27x_device_i2c_power
= {
296 .name
= "pxa2xx-i2c",
298 .resource
= pxa27x_resources_i2c_power
,
299 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
304 static struct resource pxa3xx_resources_i2c_power
[] = {
308 .flags
= IORESOURCE_MEM
,
312 .flags
= IORESOURCE_IRQ
,
316 struct platform_device pxa3xx_device_i2c_power
= {
317 .name
= "pxa3xx-pwri2c",
319 .resource
= pxa3xx_resources_i2c_power
,
320 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
324 static struct resource pxai2s_resources
[] = {
328 .flags
= IORESOURCE_MEM
,
332 .flags
= IORESOURCE_IRQ
,
336 struct platform_device pxa_device_i2s
= {
337 .name
= "pxa2xx-i2s",
339 .resource
= pxai2s_resources
,
340 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
343 static u64 pxaficp_dmamask
= ~(u32
)0;
345 struct platform_device pxa_device_ficp
= {
349 .dma_mask
= &pxaficp_dmamask
,
350 .coherent_dma_mask
= 0xffffffff,
354 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
356 pxa_register_device(&pxa_device_ficp
, info
);
359 static struct resource pxa_rtc_resources
[] = {
362 .end
= 0x40900000 + 0x3b,
363 .flags
= IORESOURCE_MEM
,
368 .flags
= IORESOURCE_IRQ
,
371 .start
= IRQ_RTCAlrm
,
373 .flags
= IORESOURCE_IRQ
,
377 struct platform_device sa1100_device_rtc
= {
378 .name
= "sa1100-rtc",
382 struct platform_device pxa_device_rtc
= {
385 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
386 .resource
= pxa_rtc_resources
,
389 static struct resource pxa_ac97_resources
[] = {
392 .end
= 0x40500000 + 0xfff,
393 .flags
= IORESOURCE_MEM
,
398 .flags
= IORESOURCE_IRQ
,
402 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
404 struct platform_device pxa_device_ac97
= {
405 .name
= "pxa2xx-ac97",
408 .dma_mask
= &pxa_ac97_dmamask
,
409 .coherent_dma_mask
= 0xffffffff,
411 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
412 .resource
= pxa_ac97_resources
,
415 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
417 pxa_register_device(&pxa_device_ac97
, ops
);
422 static struct resource pxa25x_resource_pwm0
[] = {
426 .flags
= IORESOURCE_MEM
,
430 struct platform_device pxa25x_device_pwm0
= {
431 .name
= "pxa25x-pwm",
433 .resource
= pxa25x_resource_pwm0
,
434 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
437 static struct resource pxa25x_resource_pwm1
[] = {
441 .flags
= IORESOURCE_MEM
,
445 struct platform_device pxa25x_device_pwm1
= {
446 .name
= "pxa25x-pwm",
448 .resource
= pxa25x_resource_pwm1
,
449 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
452 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
454 static struct resource pxa25x_resource_ssp
[] = {
458 .flags
= IORESOURCE_MEM
,
463 .flags
= IORESOURCE_IRQ
,
469 .flags
= IORESOURCE_DMA
,
475 .flags
= IORESOURCE_DMA
,
479 struct platform_device pxa25x_device_ssp
= {
480 .name
= "pxa25x-ssp",
483 .dma_mask
= &pxa25x_ssp_dma_mask
,
484 .coherent_dma_mask
= DMA_BIT_MASK(32),
486 .resource
= pxa25x_resource_ssp
,
487 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
490 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
492 static struct resource pxa25x_resource_nssp
[] = {
496 .flags
= IORESOURCE_MEM
,
501 .flags
= IORESOURCE_IRQ
,
507 .flags
= IORESOURCE_DMA
,
513 .flags
= IORESOURCE_DMA
,
517 struct platform_device pxa25x_device_nssp
= {
518 .name
= "pxa25x-nssp",
521 .dma_mask
= &pxa25x_nssp_dma_mask
,
522 .coherent_dma_mask
= DMA_BIT_MASK(32),
524 .resource
= pxa25x_resource_nssp
,
525 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
528 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
530 static struct resource pxa25x_resource_assp
[] = {
534 .flags
= IORESOURCE_MEM
,
539 .flags
= IORESOURCE_IRQ
,
545 .flags
= IORESOURCE_DMA
,
551 .flags
= IORESOURCE_DMA
,
555 struct platform_device pxa25x_device_assp
= {
556 /* ASSP is basically equivalent to NSSP */
557 .name
= "pxa25x-nssp",
560 .dma_mask
= &pxa25x_assp_dma_mask
,
561 .coherent_dma_mask
= DMA_BIT_MASK(32),
563 .resource
= pxa25x_resource_assp
,
564 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
566 #endif /* CONFIG_PXA25x */
568 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
570 static struct resource pxa27x_resource_keypad
[] = {
574 .flags
= IORESOURCE_MEM
,
579 .flags
= IORESOURCE_IRQ
,
583 struct platform_device pxa27x_device_keypad
= {
584 .name
= "pxa27x-keypad",
586 .resource
= pxa27x_resource_keypad
,
587 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
590 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
592 pxa_register_device(&pxa27x_device_keypad
, info
);
595 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
597 static struct resource pxa27x_resource_ohci
[] = {
601 .flags
= IORESOURCE_MEM
,
606 .flags
= IORESOURCE_IRQ
,
610 struct platform_device pxa27x_device_ohci
= {
611 .name
= "pxa27x-ohci",
614 .dma_mask
= &pxa27x_ohci_dma_mask
,
615 .coherent_dma_mask
= DMA_BIT_MASK(32),
617 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
618 .resource
= pxa27x_resource_ohci
,
621 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
623 pxa_register_device(&pxa27x_device_ohci
, info
);
626 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
628 static struct resource pxa27x_resource_ssp1
[] = {
632 .flags
= IORESOURCE_MEM
,
637 .flags
= IORESOURCE_IRQ
,
643 .flags
= IORESOURCE_DMA
,
649 .flags
= IORESOURCE_DMA
,
653 struct platform_device pxa27x_device_ssp1
= {
654 .name
= "pxa27x-ssp",
657 .dma_mask
= &pxa27x_ssp1_dma_mask
,
658 .coherent_dma_mask
= DMA_BIT_MASK(32),
660 .resource
= pxa27x_resource_ssp1
,
661 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
664 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
666 static struct resource pxa27x_resource_ssp2
[] = {
670 .flags
= IORESOURCE_MEM
,
675 .flags
= IORESOURCE_IRQ
,
681 .flags
= IORESOURCE_DMA
,
687 .flags
= IORESOURCE_DMA
,
691 struct platform_device pxa27x_device_ssp2
= {
692 .name
= "pxa27x-ssp",
695 .dma_mask
= &pxa27x_ssp2_dma_mask
,
696 .coherent_dma_mask
= DMA_BIT_MASK(32),
698 .resource
= pxa27x_resource_ssp2
,
699 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
702 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
704 static struct resource pxa27x_resource_ssp3
[] = {
708 .flags
= IORESOURCE_MEM
,
713 .flags
= IORESOURCE_IRQ
,
719 .flags
= IORESOURCE_DMA
,
725 .flags
= IORESOURCE_DMA
,
729 struct platform_device pxa27x_device_ssp3
= {
730 .name
= "pxa27x-ssp",
733 .dma_mask
= &pxa27x_ssp3_dma_mask
,
734 .coherent_dma_mask
= DMA_BIT_MASK(32),
736 .resource
= pxa27x_resource_ssp3
,
737 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
740 static struct resource pxa27x_resource_pwm0
[] = {
744 .flags
= IORESOURCE_MEM
,
748 struct platform_device pxa27x_device_pwm0
= {
749 .name
= "pxa27x-pwm",
751 .resource
= pxa27x_resource_pwm0
,
752 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
755 static struct resource pxa27x_resource_pwm1
[] = {
759 .flags
= IORESOURCE_MEM
,
763 struct platform_device pxa27x_device_pwm1
= {
764 .name
= "pxa27x-pwm",
766 .resource
= pxa27x_resource_pwm1
,
767 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
770 static struct resource pxa27x_resource_camera
[] = {
774 .flags
= IORESOURCE_MEM
,
779 .flags
= IORESOURCE_IRQ
,
783 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
785 static struct platform_device pxa27x_device_camera
= {
786 .name
= "pxa27x-camera",
787 .id
= 0, /* This is used to put cameras on this interface */
789 .dma_mask
= &pxa27x_dma_mask_camera
,
790 .coherent_dma_mask
= 0xffffffff,
792 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
793 .resource
= pxa27x_resource_camera
,
796 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
798 pxa_register_device(&pxa27x_device_camera
, info
);
800 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
803 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
805 static struct resource pxa3xx_resource_ssp4
[] = {
809 .flags
= IORESOURCE_MEM
,
814 .flags
= IORESOURCE_IRQ
,
820 .flags
= IORESOURCE_DMA
,
826 .flags
= IORESOURCE_DMA
,
830 struct platform_device pxa3xx_device_ssp4
= {
831 /* PXA3xx SSP is basically equivalent to PXA27x */
832 .name
= "pxa27x-ssp",
835 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
836 .coherent_dma_mask
= DMA_BIT_MASK(32),
838 .resource
= pxa3xx_resource_ssp4
,
839 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
842 static struct resource pxa3xx_resources_mci2
[] = {
846 .flags
= IORESOURCE_MEM
,
851 .flags
= IORESOURCE_IRQ
,
856 .flags
= IORESOURCE_DMA
,
861 .flags
= IORESOURCE_DMA
,
865 struct platform_device pxa3xx_device_mci2
= {
866 .name
= "pxa2xx-mci",
869 .dma_mask
= &pxamci_dmamask
,
870 .coherent_dma_mask
= 0xffffffff,
872 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
873 .resource
= pxa3xx_resources_mci2
,
876 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
878 pxa_register_device(&pxa3xx_device_mci2
, info
);
881 static struct resource pxa3xx_resources_mci3
[] = {
885 .flags
= IORESOURCE_MEM
,
890 .flags
= IORESOURCE_IRQ
,
895 .flags
= IORESOURCE_DMA
,
900 .flags
= IORESOURCE_DMA
,
904 struct platform_device pxa3xx_device_mci3
= {
905 .name
= "pxa2xx-mci",
908 .dma_mask
= &pxamci_dmamask
,
909 .coherent_dma_mask
= 0xffffffff,
911 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
912 .resource
= pxa3xx_resources_mci3
,
915 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
917 pxa_register_device(&pxa3xx_device_mci3
, info
);
920 static struct resource pxa3xx_resources_nand
[] = {
924 .flags
= IORESOURCE_MEM
,
929 .flags
= IORESOURCE_IRQ
,
932 /* DRCMR for Data DMA */
935 .flags
= IORESOURCE_DMA
,
938 /* DRCMR for Command DMA */
941 .flags
= IORESOURCE_DMA
,
945 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
947 struct platform_device pxa3xx_device_nand
= {
948 .name
= "pxa3xx-nand",
951 .dma_mask
= &pxa3xx_nand_dma_mask
,
952 .coherent_dma_mask
= DMA_BIT_MASK(32),
954 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
955 .resource
= pxa3xx_resources_nand
,
958 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
960 pxa_register_device(&pxa3xx_device_nand
, info
);
963 static struct resource pxa3xx_resources_gcu
[] = {
967 .flags
= IORESOURCE_MEM
,
972 .flags
= IORESOURCE_IRQ
,
976 static u64 pxa3xx_gcu_dmamask
= DMA_BIT_MASK(32);
978 struct platform_device pxa3xx_device_gcu
= {
979 .name
= "pxa3xx-gcu",
981 .num_resources
= ARRAY_SIZE(pxa3xx_resources_gcu
),
982 .resource
= pxa3xx_resources_gcu
,
984 .dma_mask
= &pxa3xx_gcu_dmamask
,
985 .coherent_dma_mask
= 0xffffffff,
989 #endif /* CONFIG_PXA3xx */
991 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
992 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
993 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
995 struct platform_device
*pd
;
997 pd
= platform_device_alloc("pxa2xx-spi", id
);
999 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
1004 pd
->dev
.platform_data
= info
;
1005 platform_device_add(pd
);