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>
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
;
78 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
80 memcpy(&pxa_udc_info
, info
, sizeof *info
);
83 static struct resource pxa2xx_udc_resources
[] = {
87 .flags
= IORESOURCE_MEM
,
92 .flags
= IORESOURCE_IRQ
,
96 static u64 udc_dma_mask
= ~(u32
)0;
98 struct platform_device pxa25x_device_udc
= {
101 .resource
= pxa2xx_udc_resources
,
102 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
104 .platform_data
= &pxa_udc_info
,
105 .dma_mask
= &udc_dma_mask
,
109 struct platform_device pxa27x_device_udc
= {
110 .name
= "pxa27x-udc",
112 .resource
= pxa2xx_udc_resources
,
113 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
115 .platform_data
= &pxa_udc_info
,
116 .dma_mask
= &udc_dma_mask
,
120 static struct resource pxafb_resources
[] = {
124 .flags
= IORESOURCE_MEM
,
129 .flags
= IORESOURCE_IRQ
,
133 static u64 fb_dma_mask
= ~(u64
)0;
135 struct platform_device pxa_device_fb
= {
139 .dma_mask
= &fb_dma_mask
,
140 .coherent_dma_mask
= 0xffffffff,
142 .num_resources
= ARRAY_SIZE(pxafb_resources
),
143 .resource
= pxafb_resources
,
146 void __init
set_pxa_fb_info(struct pxafb_mach_info
*info
)
148 pxa_register_device(&pxa_device_fb
, info
);
151 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
153 pxa_device_fb
.dev
.parent
= parent_dev
;
156 static struct resource pxa_resource_ffuart
[] = {
158 .start
= __PREG(FFUART
),
159 .end
= __PREG(FFUART
) + 35,
160 .flags
= IORESOURCE_MEM
,
164 .flags
= IORESOURCE_IRQ
,
168 struct platform_device pxa_device_ffuart
= {
169 .name
= "pxa2xx-uart",
171 .resource
= pxa_resource_ffuart
,
172 .num_resources
= ARRAY_SIZE(pxa_resource_ffuart
),
175 static struct resource pxa_resource_btuart
[] = {
177 .start
= __PREG(BTUART
),
178 .end
= __PREG(BTUART
) + 35,
179 .flags
= IORESOURCE_MEM
,
183 .flags
= IORESOURCE_IRQ
,
187 struct platform_device pxa_device_btuart
= {
188 .name
= "pxa2xx-uart",
190 .resource
= pxa_resource_btuart
,
191 .num_resources
= ARRAY_SIZE(pxa_resource_btuart
),
194 static struct resource pxa_resource_stuart
[] = {
196 .start
= __PREG(STUART
),
197 .end
= __PREG(STUART
) + 35,
198 .flags
= IORESOURCE_MEM
,
202 .flags
= IORESOURCE_IRQ
,
206 struct platform_device pxa_device_stuart
= {
207 .name
= "pxa2xx-uart",
209 .resource
= pxa_resource_stuart
,
210 .num_resources
= ARRAY_SIZE(pxa_resource_stuart
),
213 static struct resource pxa_resource_hwuart
[] = {
215 .start
= __PREG(HWUART
),
216 .end
= __PREG(HWUART
) + 47,
217 .flags
= IORESOURCE_MEM
,
221 .flags
= IORESOURCE_IRQ
,
225 struct platform_device pxa_device_hwuart
= {
226 .name
= "pxa2xx-uart",
228 .resource
= pxa_resource_hwuart
,
229 .num_resources
= ARRAY_SIZE(pxa_resource_hwuart
),
232 static struct resource pxai2c_resources
[] = {
236 .flags
= IORESOURCE_MEM
,
240 .flags
= IORESOURCE_IRQ
,
244 struct platform_device pxa_device_i2c
= {
245 .name
= "pxa2xx-i2c",
247 .resource
= pxai2c_resources
,
248 .num_resources
= ARRAY_SIZE(pxai2c_resources
),
251 static unsigned long pxa27x_i2c_mfp_cfg
[] = {
256 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
259 pxa2xx_mfp_config(ARRAY_AND_SIZE(pxa27x_i2c_mfp_cfg
));
260 pxa_register_device(&pxa_device_i2c
, info
);
263 static struct resource pxai2s_resources
[] = {
267 .flags
= IORESOURCE_MEM
,
271 .flags
= IORESOURCE_IRQ
,
275 struct platform_device pxa_device_i2s
= {
276 .name
= "pxa2xx-i2s",
278 .resource
= pxai2s_resources
,
279 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
282 static u64 pxaficp_dmamask
= ~(u32
)0;
284 struct platform_device pxa_device_ficp
= {
288 .dma_mask
= &pxaficp_dmamask
,
289 .coherent_dma_mask
= 0xffffffff,
293 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
295 pxa_register_device(&pxa_device_ficp
, info
);
298 struct platform_device pxa_device_rtc
= {
299 .name
= "sa1100-rtc",
303 static struct resource pxa_ac97_resources
[] = {
306 .end
= 0x40500000 + 0xfff,
307 .flags
= IORESOURCE_MEM
,
312 .flags
= IORESOURCE_IRQ
,
316 static u64 pxa_ac97_dmamask
= 0xffffffffUL
;
318 struct platform_device pxa_device_ac97
= {
319 .name
= "pxa2xx-ac97",
322 .dma_mask
= &pxa_ac97_dmamask
,
323 .coherent_dma_mask
= 0xffffffff,
325 .num_resources
= ARRAY_SIZE(pxa_ac97_resources
),
326 .resource
= pxa_ac97_resources
,
329 void __init
pxa_set_ac97_info(pxa2xx_audio_ops_t
*ops
)
331 pxa_register_device(&pxa_device_ac97
, ops
);
336 static struct resource pxa25x_resource_pwm0
[] = {
340 .flags
= IORESOURCE_MEM
,
344 struct platform_device pxa25x_device_pwm0
= {
345 .name
= "pxa25x-pwm",
347 .resource
= pxa25x_resource_pwm0
,
348 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
351 static struct resource pxa25x_resource_pwm1
[] = {
355 .flags
= IORESOURCE_MEM
,
359 struct platform_device pxa25x_device_pwm1
= {
360 .name
= "pxa25x-pwm",
362 .resource
= pxa25x_resource_pwm1
,
363 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
366 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
368 static struct resource pxa25x_resource_ssp
[] = {
372 .flags
= IORESOURCE_MEM
,
377 .flags
= IORESOURCE_IRQ
,
383 .flags
= IORESOURCE_DMA
,
389 .flags
= IORESOURCE_DMA
,
393 struct platform_device pxa25x_device_ssp
= {
394 .name
= "pxa25x-ssp",
397 .dma_mask
= &pxa25x_ssp_dma_mask
,
398 .coherent_dma_mask
= DMA_BIT_MASK(32),
400 .resource
= pxa25x_resource_ssp
,
401 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
404 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
406 static struct resource pxa25x_resource_nssp
[] = {
410 .flags
= IORESOURCE_MEM
,
415 .flags
= IORESOURCE_IRQ
,
421 .flags
= IORESOURCE_DMA
,
427 .flags
= IORESOURCE_DMA
,
431 struct platform_device pxa25x_device_nssp
= {
432 .name
= "pxa25x-nssp",
435 .dma_mask
= &pxa25x_nssp_dma_mask
,
436 .coherent_dma_mask
= DMA_BIT_MASK(32),
438 .resource
= pxa25x_resource_nssp
,
439 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
442 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
444 static struct resource pxa25x_resource_assp
[] = {
448 .flags
= IORESOURCE_MEM
,
453 .flags
= IORESOURCE_IRQ
,
459 .flags
= IORESOURCE_DMA
,
465 .flags
= IORESOURCE_DMA
,
469 struct platform_device pxa25x_device_assp
= {
470 /* ASSP is basically equivalent to NSSP */
471 .name
= "pxa25x-nssp",
474 .dma_mask
= &pxa25x_assp_dma_mask
,
475 .coherent_dma_mask
= DMA_BIT_MASK(32),
477 .resource
= pxa25x_resource_assp
,
478 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
480 #endif /* CONFIG_PXA25x */
482 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
484 static struct resource pxa27x_resource_keypad
[] = {
488 .flags
= IORESOURCE_MEM
,
493 .flags
= IORESOURCE_IRQ
,
497 struct platform_device pxa27x_device_keypad
= {
498 .name
= "pxa27x-keypad",
500 .resource
= pxa27x_resource_keypad
,
501 .num_resources
= ARRAY_SIZE(pxa27x_resource_keypad
),
504 void __init
pxa_set_keypad_info(struct pxa27x_keypad_platform_data
*info
)
506 pxa_register_device(&pxa27x_device_keypad
, info
);
509 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
511 static struct resource pxa27x_resource_ohci
[] = {
515 .flags
= IORESOURCE_MEM
,
520 .flags
= IORESOURCE_IRQ
,
524 struct platform_device pxa27x_device_ohci
= {
525 .name
= "pxa27x-ohci",
528 .dma_mask
= &pxa27x_ohci_dma_mask
,
529 .coherent_dma_mask
= DMA_BIT_MASK(32),
531 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
532 .resource
= pxa27x_resource_ohci
,
535 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
537 pxa_register_device(&pxa27x_device_ohci
, info
);
540 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
542 static struct resource pxa27x_resource_ssp1
[] = {
546 .flags
= IORESOURCE_MEM
,
551 .flags
= IORESOURCE_IRQ
,
557 .flags
= IORESOURCE_DMA
,
563 .flags
= IORESOURCE_DMA
,
567 struct platform_device pxa27x_device_ssp1
= {
568 .name
= "pxa27x-ssp",
571 .dma_mask
= &pxa27x_ssp1_dma_mask
,
572 .coherent_dma_mask
= DMA_BIT_MASK(32),
574 .resource
= pxa27x_resource_ssp1
,
575 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
578 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
580 static struct resource pxa27x_resource_ssp2
[] = {
584 .flags
= IORESOURCE_MEM
,
589 .flags
= IORESOURCE_IRQ
,
595 .flags
= IORESOURCE_DMA
,
601 .flags
= IORESOURCE_DMA
,
605 struct platform_device pxa27x_device_ssp2
= {
606 .name
= "pxa27x-ssp",
609 .dma_mask
= &pxa27x_ssp2_dma_mask
,
610 .coherent_dma_mask
= DMA_BIT_MASK(32),
612 .resource
= pxa27x_resource_ssp2
,
613 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
616 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
618 static struct resource pxa27x_resource_ssp3
[] = {
622 .flags
= IORESOURCE_MEM
,
627 .flags
= IORESOURCE_IRQ
,
633 .flags
= IORESOURCE_DMA
,
639 .flags
= IORESOURCE_DMA
,
643 struct platform_device pxa27x_device_ssp3
= {
644 .name
= "pxa27x-ssp",
647 .dma_mask
= &pxa27x_ssp3_dma_mask
,
648 .coherent_dma_mask
= DMA_BIT_MASK(32),
650 .resource
= pxa27x_resource_ssp3
,
651 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
654 static struct resource pxa27x_resource_pwm0
[] = {
658 .flags
= IORESOURCE_MEM
,
662 struct platform_device pxa27x_device_pwm0
= {
663 .name
= "pxa27x-pwm",
665 .resource
= pxa27x_resource_pwm0
,
666 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
669 static struct resource pxa27x_resource_pwm1
[] = {
673 .flags
= IORESOURCE_MEM
,
677 struct platform_device pxa27x_device_pwm1
= {
678 .name
= "pxa27x-pwm",
680 .resource
= pxa27x_resource_pwm1
,
681 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
684 static struct resource pxa27x_resource_camera
[] = {
688 .flags
= IORESOURCE_MEM
,
693 .flags
= IORESOURCE_IRQ
,
697 static u64 pxa27x_dma_mask_camera
= DMA_BIT_MASK(32);
699 static struct platform_device pxa27x_device_camera
= {
700 .name
= "pxa27x-camera",
701 .id
= 0, /* This is used to put cameras on this interface */
703 .dma_mask
= &pxa27x_dma_mask_camera
,
704 .coherent_dma_mask
= 0xffffffff,
706 .num_resources
= ARRAY_SIZE(pxa27x_resource_camera
),
707 .resource
= pxa27x_resource_camera
,
710 void __init
pxa_set_camera_info(struct pxacamera_platform_data
*info
)
712 pxa_register_device(&pxa27x_device_camera
, info
);
714 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
717 static u64 pxa3xx_ssp4_dma_mask
= DMA_BIT_MASK(32);
719 static struct resource pxa3xx_resource_ssp4
[] = {
723 .flags
= IORESOURCE_MEM
,
728 .flags
= IORESOURCE_IRQ
,
734 .flags
= IORESOURCE_DMA
,
740 .flags
= IORESOURCE_DMA
,
744 struct platform_device pxa3xx_device_ssp4
= {
745 /* PXA3xx SSP is basically equivalent to PXA27x */
746 .name
= "pxa27x-ssp",
749 .dma_mask
= &pxa3xx_ssp4_dma_mask
,
750 .coherent_dma_mask
= DMA_BIT_MASK(32),
752 .resource
= pxa3xx_resource_ssp4
,
753 .num_resources
= ARRAY_SIZE(pxa3xx_resource_ssp4
),
756 static struct resource pxa3xx_resources_mci2
[] = {
760 .flags
= IORESOURCE_MEM
,
765 .flags
= IORESOURCE_IRQ
,
770 .flags
= IORESOURCE_DMA
,
775 .flags
= IORESOURCE_DMA
,
779 struct platform_device pxa3xx_device_mci2
= {
780 .name
= "pxa2xx-mci",
783 .dma_mask
= &pxamci_dmamask
,
784 .coherent_dma_mask
= 0xffffffff,
786 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci2
),
787 .resource
= pxa3xx_resources_mci2
,
790 void __init
pxa3xx_set_mci2_info(struct pxamci_platform_data
*info
)
792 pxa_register_device(&pxa3xx_device_mci2
, info
);
795 static struct resource pxa3xx_resources_mci3
[] = {
799 .flags
= IORESOURCE_MEM
,
804 .flags
= IORESOURCE_IRQ
,
809 .flags
= IORESOURCE_DMA
,
814 .flags
= IORESOURCE_DMA
,
818 struct platform_device pxa3xx_device_mci3
= {
819 .name
= "pxa2xx-mci",
822 .dma_mask
= &pxamci_dmamask
,
823 .coherent_dma_mask
= 0xffffffff,
825 .num_resources
= ARRAY_SIZE(pxa3xx_resources_mci3
),
826 .resource
= pxa3xx_resources_mci3
,
829 void __init
pxa3xx_set_mci3_info(struct pxamci_platform_data
*info
)
831 pxa_register_device(&pxa3xx_device_mci3
, info
);
834 #endif /* CONFIG_PXA3xx */
836 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
837 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
838 void __init
pxa2xx_set_spi_info(unsigned id
, struct pxa2xx_spi_master
*info
)
840 struct platform_device
*pd
;
842 pd
= platform_device_alloc("pxa2xx-spi", id
);
844 printk(KERN_ERR
"pxa2xx-spi: failed to allocate device id %d\n",
849 pd
->dev
.platform_data
= info
;
850 platform_device_add(pd
);