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>
9 #include <mach/pxafb.h>
11 #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/hardware.h>
19 #include <plat/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 pxa_resource_pmu
= {
38 .flags
= IORESOURCE_IRQ
,
41 struct platform_device pxa_device_pmu
= {
43 .id
= ARM_PMU_DEVICE_CPU
,
44 .resource
= &pxa_resource_pmu
,
48 static struct resource pxamci_resources
[] = {
52 .flags
= IORESOURCE_MEM
,
57 .flags
= IORESOURCE_IRQ
,
62 .flags
= IORESOURCE_DMA
,
67 .flags
= IORESOURCE_DMA
,
71 static u64 pxamci_dmamask
= 0xffffffffUL
;
73 struct platform_device pxa_device_mci
= {
77 .dma_mask
= &pxamci_dmamask
,
78 .coherent_dma_mask
= 0xffffffff,
80 .num_resources
= ARRAY_SIZE(pxamci_resources
),
81 .resource
= pxamci_resources
,
84 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
86 pxa_register_device(&pxa_device_mci
, info
);
90 static struct pxa2xx_udc_mach_info pxa_udc_info
= {
95 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
97 memcpy(&pxa_udc_info
, info
, sizeof *info
);
100 static struct resource pxa2xx_udc_resources
[] = {
104 .flags
= IORESOURCE_MEM
,
109 .flags
= IORESOURCE_IRQ
,
113 static u64 udc_dma_mask
= ~(u32
)0;
115 struct platform_device pxa25x_device_udc
= {
116 .name
= "pxa25x-udc",
118 .resource
= pxa2xx_udc_resources
,
119 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
121 .platform_data
= &pxa_udc_info
,
122 .dma_mask
= &udc_dma_mask
,
126 struct platform_device pxa27x_device_udc
= {
127 .name
= "pxa27x-udc",
129 .resource
= pxa2xx_udc_resources
,
130 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
132 .platform_data
= &pxa_udc_info
,
133 .dma_mask
= &udc_dma_mask
,
137 static struct resource pxafb_resources
[] = {
141 .flags
= IORESOURCE_MEM
,
146 .flags
= IORESOURCE_IRQ
,
150 static u64 fb_dma_mask
= ~(u64
)0;
152 struct platform_device pxa_device_fb
= {
156 .dma_mask
= &fb_dma_mask
,
157 .coherent_dma_mask
= 0xffffffff,
159 .num_resources
= ARRAY_SIZE(pxafb_resources
),
160 .resource
= pxafb_resources
,
163 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
165 pxa_register_device(&pxa_device_fb
, info
);
168 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
170 pxa_device_fb
.dev
.parent
= parent_dev
;
173 static struct resource pxa_resource_ffuart
[] = {
177 .flags
= IORESOURCE_MEM
,
181 .flags
= IORESOURCE_IRQ
,
185 struct platform_device pxa_device_ffuart
= {
186 .name
= "pxa2xx-uart",
188 .resource
= pxa_resource_ffuart
,
189 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
192 void __init
pxa_set_ffuart_info(void *info
)
194 pxa_register_device(&pxa_device_ffuart
, info
);
197 static struct resource pxa_resource_btuart
[] = {
201 .flags
= IORESOURCE_MEM
,
205 .flags
= IORESOURCE_IRQ
,
209 struct platform_device pxa_device_btuart
= {
210 .name
= "pxa2xx-uart",
212 .resource
= pxa_resource_btuart
,
213 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
216 void __init
pxa_set_btuart_info(void *info
)
218 pxa_register_device(&pxa_device_btuart
, info
);
221 static struct resource pxa_resource_stuart
[] = {
225 .flags
= IORESOURCE_MEM
,
229 .flags
= IORESOURCE_IRQ
,
233 struct platform_device pxa_device_stuart
= {
234 .name
= "pxa2xx-uart",
236 .resource
= pxa_resource_stuart
,
237 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
240 void __init
pxa_set_stuart_info(void *info
)
242 pxa_register_device(&pxa_device_stuart
, info
);
245 static struct resource pxa_resource_hwuart
[] = {
249 .flags
= IORESOURCE_MEM
,
253 .flags
= IORESOURCE_IRQ
,
257 struct platform_device pxa_device_hwuart
= {
258 .name
= "pxa2xx-uart",
260 .resource
= pxa_resource_hwuart
,
261 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
264 void __init
pxa_set_hwuart_info(void *info
)
267 pxa_register_device(&pxa_device_hwuart
, info
);
269 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
272 static struct resource pxai2c_resources
[] = {
276 .flags
= IORESOURCE_MEM
,
280 .flags
= IORESOURCE_IRQ
,
284 struct platform_device pxa_device_i2c
= {
285 .name
= "pxa2xx-i2c",
287 .resource
= pxai2c_resources
,
288 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
291 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
293 pxa_register_device(&pxa_device_i2c
, info
);
297 static struct resource pxa27x_resources_i2c_power
[] = {
301 .flags
= IORESOURCE_MEM
,
305 .flags
= IORESOURCE_IRQ
,
309 struct platform_device pxa27x_device_i2c_power
= {
310 .name
= "pxa2xx-i2c",
312 .resource
= pxa27x_resources_i2c_power
,
313 .num_resources
= ARRAY_SIZE(pxa27x_resources_i2c_power
),
318 static struct resource pxa3xx_resources_i2c_power
[] = {
322 .flags
= IORESOURCE_MEM
,
326 .flags
= IORESOURCE_IRQ
,
330 struct platform_device pxa3xx_device_i2c_power
= {
331 .name
= "pxa3xx-pwri2c",
333 .resource
= pxa3xx_resources_i2c_power
,
334 .num_resources
= ARRAY_SIZE(pxa3xx_resources_i2c_power
),
338 static struct resource pxai2s_resources
[] = {
342 .flags
= IORESOURCE_MEM
,
346 .flags
= IORESOURCE_IRQ
,
350 struct platform_device pxa_device_i2s
= {
351 .name
= "pxa2xx-i2s",
353 .resource
= pxai2s_resources
,
354 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
357 static u64 pxaficp_dmamask
= ~(u32
)0;
359 struct platform_device pxa_device_ficp
= {
363 .dma_mask
= &pxaficp_dmamask
,
364 .coherent_dma_mask
= 0xffffffff,
368 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
370 pxa_register_device(&pxa_device_ficp
, info
);
373 static struct resource pxa_rtc_resources
[] = {
376 .end
= 0x40900000 + 0x3b,
377 .flags
= IORESOURCE_MEM
,
382 .flags
= IORESOURCE_IRQ
,
385 .start
= IRQ_RTCAlrm
,
387 .flags
= IORESOURCE_IRQ
,
391 struct platform_device sa1100_device_rtc
= {
392 .name
= "sa1100-rtc",
396 struct platform_device pxa_device_rtc
= {
399 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
400 .resource
= pxa_rtc_resources
,
403 static struct resource pxa_ac97_resources
[] = {
406 .end
= 0x40500000 + 0xfff,
407 .flags
= IORESOURCE_MEM
,
412 .flags
= IORESOURCE_IRQ
,
416 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
418 struct platform_device pxa_device_ac97
= {
419 .name
= "pxa2xx-ac97",
422 .dma_mask
= &pxa_ac97_dmamask
,
423 .coherent_dma_mask
= 0xffffffff,
425 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
426 .resource
= pxa_ac97_resources
,
429 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
431 pxa_register_device(&pxa_device_ac97
, ops
);
436 static struct resource pxa25x_resource_pwm0
[] = {
440 .flags
= IORESOURCE_MEM
,
444 struct platform_device pxa25x_device_pwm0
= {
445 .name
= "pxa25x-pwm",
447 .resource
= pxa25x_resource_pwm0
,
448 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
451 static struct resource pxa25x_resource_pwm1
[] = {
455 .flags
= IORESOURCE_MEM
,
459 struct platform_device pxa25x_device_pwm1
= {
460 .name
= "pxa25x-pwm",
462 .resource
= pxa25x_resource_pwm1
,
463 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
466 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
468 static struct resource pxa25x_resource_ssp
[] = {
472 .flags
= IORESOURCE_MEM
,
477 .flags
= IORESOURCE_IRQ
,
483 .flags
= IORESOURCE_DMA
,
489 .flags
= IORESOURCE_DMA
,
493 struct platform_device pxa25x_device_ssp
= {
494 .name
= "pxa25x-ssp",
497 .dma_mask
= &pxa25x_ssp_dma_mask
,
498 .coherent_dma_mask
= DMA_BIT_MASK(32),
500 .resource
= pxa25x_resource_ssp
,
501 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
504 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
506 static struct resource pxa25x_resource_nssp
[] = {
510 .flags
= IORESOURCE_MEM
,
515 .flags
= IORESOURCE_IRQ
,
521 .flags
= IORESOURCE_DMA
,
527 .flags
= IORESOURCE_DMA
,
531 struct platform_device pxa25x_device_nssp
= {
532 .name
= "pxa25x-nssp",
535 .dma_mask
= &pxa25x_nssp_dma_mask
,
536 .coherent_dma_mask
= DMA_BIT_MASK(32),
538 .resource
= pxa25x_resource_nssp
,
539 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
542 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
544 static struct resource pxa25x_resource_assp
[] = {
548 .flags
= IORESOURCE_MEM
,
553 .flags
= IORESOURCE_IRQ
,
559 .flags
= IORESOURCE_DMA
,
565 .flags
= IORESOURCE_DMA
,
569 struct platform_device pxa25x_device_assp
= {
570 /* ASSP is basically equivalent to NSSP */
571 .name
= "pxa25x-nssp",
574 .dma_mask
= &pxa25x_assp_dma_mask
,
575 .coherent_dma_mask
= DMA_BIT_MASK(32),
577 .resource
= pxa25x_resource_assp
,
578 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
580 #endif /* CONFIG_PXA25x */
582 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
584 static struct resource pxa27x_resource_keypad
[] = {
588 .flags
= IORESOURCE_MEM
,
593 .flags
= IORESOURCE_IRQ
,
597 struct platform_device pxa27x_device_keypad
= {
598 .name
= "pxa27x-keypad",
600 .resource
= pxa27x_resource_keypad
,
601 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
604 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
606 pxa_register_device(&pxa27x_device_keypad
, info
);
609 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
611 static struct resource pxa27x_resource_ohci
[] = {
615 .flags
= IORESOURCE_MEM
,
620 .flags
= IORESOURCE_IRQ
,
624 struct platform_device pxa27x_device_ohci
= {
625 .name
= "pxa27x-ohci",
628 .dma_mask
= &pxa27x_ohci_dma_mask
,
629 .coherent_dma_mask
= DMA_BIT_MASK(32),
631 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
632 .resource
= pxa27x_resource_ohci
,
635 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
637 pxa_register_device(&pxa27x_device_ohci
, info
);
640 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
642 static struct resource pxa27x_resource_ssp1
[] = {
646 .flags
= IORESOURCE_MEM
,
651 .flags
= IORESOURCE_IRQ
,
657 .flags
= IORESOURCE_DMA
,
663 .flags
= IORESOURCE_DMA
,
667 struct platform_device pxa27x_device_ssp1
= {
668 .name
= "pxa27x-ssp",
671 .dma_mask
= &pxa27x_ssp1_dma_mask
,
672 .coherent_dma_mask
= DMA_BIT_MASK(32),
674 .resource
= pxa27x_resource_ssp1
,
675 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
678 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
680 static struct resource pxa27x_resource_ssp2
[] = {
684 .flags
= IORESOURCE_MEM
,
689 .flags
= IORESOURCE_IRQ
,
695 .flags
= IORESOURCE_DMA
,
701 .flags
= IORESOURCE_DMA
,
705 struct platform_device pxa27x_device_ssp2
= {
706 .name
= "pxa27x-ssp",
709 .dma_mask
= &pxa27x_ssp2_dma_mask
,
710 .coherent_dma_mask
= DMA_BIT_MASK(32),
712 .resource
= pxa27x_resource_ssp2
,
713 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
716 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
718 static struct resource pxa27x_resource_ssp3
[] = {
722 .flags
= IORESOURCE_MEM
,
727 .flags
= IORESOURCE_IRQ
,
733 .flags
= IORESOURCE_DMA
,
739 .flags
= IORESOURCE_DMA
,
743 struct platform_device pxa27x_device_ssp3
= {
744 .name
= "pxa27x-ssp",
747 .dma_mask
= &pxa27x_ssp3_dma_mask
,
748 .coherent_dma_mask
= DMA_BIT_MASK(32),
750 .resource
= pxa27x_resource_ssp3
,
751 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
754 static struct resource pxa27x_resource_pwm0
[] = {
758 .flags
= IORESOURCE_MEM
,
762 struct platform_device pxa27x_device_pwm0
= {
763 .name
= "pxa27x-pwm",
765 .resource
= pxa27x_resource_pwm0
,
766 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
769 static struct resource pxa27x_resource_pwm1
[] = {
773 .flags
= IORESOURCE_MEM
,
777 struct platform_device pxa27x_device_pwm1
= {
778 .name
= "pxa27x-pwm",
780 .resource
= pxa27x_resource_pwm1
,
781 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
784 static struct resource pxa27x_resource_camera
[] = {
788 .flags
= IORESOURCE_MEM
,
793 .flags
= IORESOURCE_IRQ
,
797 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
799 static struct platform_device pxa27x_device_camera
= {
800 .name
= "pxa27x-camera",
801 .id
= 0, /* This is used to put cameras on this interface */
803 .dma_mask
= &pxa27x_dma_mask_camera
,
804 .coherent_dma_mask
= 0xffffffff,
806 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
807 .resource
= pxa27x_resource_camera
,
810 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
812 pxa_register_device(&pxa27x_device_camera
, info
);
814 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
817 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
819 static struct resource pxa3xx_resource_ssp4
[] = {
823 .flags
= IORESOURCE_MEM
,
828 .flags
= IORESOURCE_IRQ
,
834 .flags
= IORESOURCE_DMA
,
840 .flags
= IORESOURCE_DMA
,
844 struct platform_device pxa3xx_device_ssp4
= {
845 /* PXA3xx SSP is basically equivalent to PXA27x */
846 .name
= "pxa27x-ssp",
849 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
850 .coherent_dma_mask
= DMA_BIT_MASK(32),
852 .resource
= pxa3xx_resource_ssp4
,
853 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
856 static struct resource pxa3xx_resources_mci2
[] = {
860 .flags
= IORESOURCE_MEM
,
865 .flags
= IORESOURCE_IRQ
,
870 .flags
= IORESOURCE_DMA
,
875 .flags
= IORESOURCE_DMA
,
879 struct platform_device pxa3xx_device_mci2
= {
880 .name
= "pxa2xx-mci",
883 .dma_mask
= &pxamci_dmamask
,
884 .coherent_dma_mask
= 0xffffffff,
886 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
887 .resource
= pxa3xx_resources_mci2
,
890 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
892 pxa_register_device(&pxa3xx_device_mci2
, info
);
895 static struct resource pxa3xx_resources_mci3
[] = {
899 .flags
= IORESOURCE_MEM
,
904 .flags
= IORESOURCE_IRQ
,
909 .flags
= IORESOURCE_DMA
,
914 .flags
= IORESOURCE_DMA
,
918 struct platform_device pxa3xx_device_mci3
= {
919 .name
= "pxa2xx-mci",
922 .dma_mask
= &pxamci_dmamask
,
923 .coherent_dma_mask
= 0xffffffff,
925 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
926 .resource
= pxa3xx_resources_mci3
,
929 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
931 pxa_register_device(&pxa3xx_device_mci3
, info
);
934 static struct resource pxa3xx_resources_nand
[] = {
938 .flags
= IORESOURCE_MEM
,
943 .flags
= IORESOURCE_IRQ
,
946 /* DRCMR for Data DMA */
949 .flags
= IORESOURCE_DMA
,
952 /* DRCMR for Command DMA */
955 .flags
= IORESOURCE_DMA
,
959 static u64 pxa3xx_nand_dma_mask
= DMA_BIT_MASK(32);
961 struct platform_device pxa3xx_device_nand
= {
962 .name
= "pxa3xx-nand",
965 .dma_mask
= &pxa3xx_nand_dma_mask
,
966 .coherent_dma_mask
= DMA_BIT_MASK(32),
968 .num_resources
= ARRAY_SIZE(pxa3xx_resources_nand
),
969 .resource
= pxa3xx_resources_nand
,
972 void __init
pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data
*info
)
974 pxa_register_device(&pxa3xx_device_nand
, info
);
977 static struct resource pxa3xx_resources_gcu
[] = {
981 .flags
= IORESOURCE_MEM
,
986 .flags
= IORESOURCE_IRQ
,
990 static u64 pxa3xx_gcu_dmamask
= DMA_BIT_MASK(32);
992 struct platform_device pxa3xx_device_gcu
= {
993 .name
= "pxa3xx-gcu",
995 .num_resources
= ARRAY_SIZE(pxa3xx_resources_gcu
),
996 .resource
= pxa3xx_resources_gcu
,
998 .dma_mask
= &pxa3xx_gcu_dmamask
,
999 .coherent_dma_mask
= 0xffffffff,
1003 #endif /* CONFIG_PXA3xx */
1005 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
1006 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
1007 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
1009 struct platform_device
*pd
;
1011 pd
= platform_device_alloc("pxa2xx-spi", id
);
1013 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
1018 pd
->dev
.platform_data
= info
;
1019 platform_device_add(pd
);