1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/module.h>
3 #include <linux/kernel.h>
4 #include <linux/init.h>
5 #include <linux/platform_device.h>
6 #include <linux/clkdev.h>
7 #include <linux/clk-provider.h>
8 #include <linux/dma-mapping.h>
9 #include <linux/dmaengine.h>
10 #include <linux/gpio-pxa.h>
11 #include <linux/platform_data/i2c-pxa.h>
12 #include <linux/soc/pxa/cpu.h>
15 #include <linux/platform_data/video-pxafb.h>
16 #include <linux/platform_data/mmc-pxamci.h>
18 #include <linux/platform_data/usb-ohci-pxa27x.h>
19 #include <linux/platform_data/mmp_dma.h>
21 #include "mfp-pxa2xx.h"
27 void __init
pxa_register_device(struct platform_device
*dev
, void *data
)
31 dev
->dev
.platform_data
= data
;
33 ret
= platform_device_register(dev
);
35 dev_err(&dev
->dev
, "unable to register device: %d\n", ret
);
38 static struct resource pxa_resource_pmu
= {
41 .flags
= IORESOURCE_IRQ
,
44 struct platform_device pxa_device_pmu
= {
47 .resource
= &pxa_resource_pmu
,
51 static const struct resource pxamci_resources
[] = {
55 .flags
= IORESOURCE_MEM
,
60 .flags
= IORESOURCE_IRQ
,
64 void __init
pxa_set_mci_info(const struct pxamci_platform_data
*info
,
65 const struct property_entry
*props
)
67 const struct platform_device_info mci_info
= {
70 .res
= pxamci_resources
,
71 .num_res
= ARRAY_SIZE(pxamci_resources
),
73 .size_data
= sizeof(*info
),
74 .dma_mask
= 0xffffffffUL
,
77 struct platform_device
*mci_dev
;
80 mci_dev
= platform_device_register_full(&mci_info
);
81 err
= PTR_ERR_OR_ZERO(mci_dev
);
83 pr_err("Unable to create mci device: %d\n", err
);
86 static struct pxa2xx_udc_mach_info pxa_udc_info
= {
90 static struct resource pxa2xx_udc_resources
[] = {
94 .flags
= IORESOURCE_MEM
,
99 .flags
= IORESOURCE_IRQ
,
103 static u64 udc_dma_mask
= ~(u32
)0;
105 struct platform_device pxa25x_device_udc
= {
106 .name
= "pxa25x-udc",
108 .resource
= pxa2xx_udc_resources
,
109 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
111 .platform_data
= &pxa_udc_info
,
112 .dma_mask
= &udc_dma_mask
,
116 struct platform_device pxa27x_device_udc
= {
117 .name
= "pxa27x-udc",
119 .resource
= pxa2xx_udc_resources
,
120 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
122 .platform_data
= &pxa_udc_info
,
123 .dma_mask
= &udc_dma_mask
,
127 static struct resource pxafb_resources
[] = {
131 .flags
= IORESOURCE_MEM
,
136 .flags
= IORESOURCE_IRQ
,
140 static u64 fb_dma_mask
= ~(u64
)0;
142 struct platform_device pxa_device_fb
= {
146 .dma_mask
= &fb_dma_mask
,
147 .coherent_dma_mask
= 0xffffffff,
149 .num_resources
= ARRAY_SIZE(pxafb_resources
),
150 .resource
= pxafb_resources
,
153 void __init
pxa_set_fb_info(struct device
*parent
, struct pxafb_mach_info
*info
)
155 pxa_device_fb
.dev
.parent
= parent
;
156 pxa_register_device(&pxa_device_fb
, info
);
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
),
303 static struct resource pxai2s_resources
[] = {
307 .flags
= IORESOURCE_MEM
,
311 .flags
= IORESOURCE_IRQ
,
315 struct platform_device pxa_device_i2s
= {
316 .name
= "pxa2xx-i2s",
318 .resource
= pxai2s_resources
,
319 .num_resources
= ARRAY_SIZE(pxai2s_resources
),
322 struct platform_device pxa_device_asoc_ssp1
= {
323 .name
= "pxa-ssp-dai",
327 struct platform_device pxa_device_asoc_ssp2
= {
328 .name
= "pxa-ssp-dai",
332 struct platform_device pxa_device_asoc_ssp3
= {
333 .name
= "pxa-ssp-dai",
337 struct platform_device pxa_device_asoc_ssp4
= {
338 .name
= "pxa-ssp-dai",
342 struct platform_device pxa_device_asoc_platform
= {
343 .name
= "pxa-pcm-audio",
347 static struct resource pxa_rtc_resources
[] = {
350 .end
= 0x40900000 + 0x3b,
351 .flags
= IORESOURCE_MEM
,
357 .flags
= IORESOURCE_IRQ
,
360 .start
= IRQ_RTCAlrm
,
363 .flags
= IORESOURCE_IRQ
,
367 struct platform_device pxa_device_rtc
= {
370 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
371 .resource
= pxa_rtc_resources
,
374 struct platform_device sa1100_device_rtc
= {
375 .name
= "sa1100-rtc",
377 .num_resources
= ARRAY_SIZE(pxa_rtc_resources
),
378 .resource
= pxa_rtc_resources
,
383 static struct resource pxa25x_resource_pwm0
[] = {
387 .flags
= IORESOURCE_MEM
,
391 struct platform_device pxa25x_device_pwm0
= {
392 .name
= "pxa25x-pwm",
394 .resource
= pxa25x_resource_pwm0
,
395 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm0
),
398 static struct resource pxa25x_resource_pwm1
[] = {
402 .flags
= IORESOURCE_MEM
,
406 struct platform_device pxa25x_device_pwm1
= {
407 .name
= "pxa25x-pwm",
409 .resource
= pxa25x_resource_pwm1
,
410 .num_resources
= ARRAY_SIZE(pxa25x_resource_pwm1
),
413 static u64 pxa25x_ssp_dma_mask
= DMA_BIT_MASK(32);
415 static struct resource pxa25x_resource_ssp
[] = {
419 .flags
= IORESOURCE_MEM
,
424 .flags
= IORESOURCE_IRQ
,
428 struct platform_device pxa25x_device_ssp
= {
429 .name
= "pxa25x-ssp",
432 .dma_mask
= &pxa25x_ssp_dma_mask
,
433 .coherent_dma_mask
= DMA_BIT_MASK(32),
435 .resource
= pxa25x_resource_ssp
,
436 .num_resources
= ARRAY_SIZE(pxa25x_resource_ssp
),
439 static u64 pxa25x_nssp_dma_mask
= DMA_BIT_MASK(32);
441 static struct resource pxa25x_resource_nssp
[] = {
445 .flags
= IORESOURCE_MEM
,
450 .flags
= IORESOURCE_IRQ
,
454 struct platform_device pxa25x_device_nssp
= {
455 .name
= "pxa25x-nssp",
458 .dma_mask
= &pxa25x_nssp_dma_mask
,
459 .coherent_dma_mask
= DMA_BIT_MASK(32),
461 .resource
= pxa25x_resource_nssp
,
462 .num_resources
= ARRAY_SIZE(pxa25x_resource_nssp
),
465 static u64 pxa25x_assp_dma_mask
= DMA_BIT_MASK(32);
467 static struct resource pxa25x_resource_assp
[] = {
471 .flags
= IORESOURCE_MEM
,
476 .flags
= IORESOURCE_IRQ
,
480 struct platform_device pxa25x_device_assp
= {
481 /* ASSP is basically equivalent to NSSP */
482 .name
= "pxa25x-nssp",
485 .dma_mask
= &pxa25x_assp_dma_mask
,
486 .coherent_dma_mask
= DMA_BIT_MASK(32),
488 .resource
= pxa25x_resource_assp
,
489 .num_resources
= ARRAY_SIZE(pxa25x_resource_assp
),
491 #endif /* CONFIG_PXA25x */
493 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
494 static u64 pxa27x_ohci_dma_mask
= DMA_BIT_MASK(32);
496 static struct resource pxa27x_resource_ohci
[] = {
500 .flags
= IORESOURCE_MEM
,
505 .flags
= IORESOURCE_IRQ
,
509 struct platform_device pxa27x_device_ohci
= {
510 .name
= "pxa27x-ohci",
513 .dma_mask
= &pxa27x_ohci_dma_mask
,
514 .coherent_dma_mask
= DMA_BIT_MASK(32),
516 .num_resources
= ARRAY_SIZE(pxa27x_resource_ohci
),
517 .resource
= pxa27x_resource_ohci
,
520 void __init
pxa_set_ohci_info(struct pxaohci_platform_data
*info
)
522 pxa_register_device(&pxa27x_device_ohci
, info
);
524 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
526 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
527 static u64 pxa27x_ssp1_dma_mask
= DMA_BIT_MASK(32);
529 static struct resource pxa27x_resource_ssp1
[] = {
533 .flags
= IORESOURCE_MEM
,
538 .flags
= IORESOURCE_IRQ
,
542 struct platform_device pxa27x_device_ssp1
= {
543 .name
= "pxa27x-ssp",
546 .dma_mask
= &pxa27x_ssp1_dma_mask
,
547 .coherent_dma_mask
= DMA_BIT_MASK(32),
549 .resource
= pxa27x_resource_ssp1
,
550 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp1
),
553 static u64 pxa27x_ssp2_dma_mask
= DMA_BIT_MASK(32);
555 static struct resource pxa27x_resource_ssp2
[] = {
559 .flags
= IORESOURCE_MEM
,
564 .flags
= IORESOURCE_IRQ
,
568 struct platform_device pxa27x_device_ssp2
= {
569 .name
= "pxa27x-ssp",
572 .dma_mask
= &pxa27x_ssp2_dma_mask
,
573 .coherent_dma_mask
= DMA_BIT_MASK(32),
575 .resource
= pxa27x_resource_ssp2
,
576 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp2
),
579 static u64 pxa27x_ssp3_dma_mask
= DMA_BIT_MASK(32);
581 static struct resource pxa27x_resource_ssp3
[] = {
585 .flags
= IORESOURCE_MEM
,
590 .flags
= IORESOURCE_IRQ
,
594 struct platform_device pxa27x_device_ssp3
= {
595 .name
= "pxa27x-ssp",
598 .dma_mask
= &pxa27x_ssp3_dma_mask
,
599 .coherent_dma_mask
= DMA_BIT_MASK(32),
601 .resource
= pxa27x_resource_ssp3
,
602 .num_resources
= ARRAY_SIZE(pxa27x_resource_ssp3
),
605 static struct resource pxa27x_resource_pwm0
[] = {
609 .flags
= IORESOURCE_MEM
,
613 struct platform_device pxa27x_device_pwm0
= {
614 .name
= "pxa27x-pwm",
616 .resource
= pxa27x_resource_pwm0
,
617 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm0
),
620 static struct resource pxa27x_resource_pwm1
[] = {
624 .flags
= IORESOURCE_MEM
,
628 struct platform_device pxa27x_device_pwm1
= {
629 .name
= "pxa27x-pwm",
631 .resource
= pxa27x_resource_pwm1
,
632 .num_resources
= ARRAY_SIZE(pxa27x_resource_pwm1
),
634 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
636 #if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
637 const struct software_node pxa2xx_gpiochip_node
= {
641 struct resource pxa_resource_gpio
[] = {
645 .flags
= IORESOURCE_MEM
,
650 .flags
= IORESOURCE_IRQ
,
655 .flags
= IORESOURCE_IRQ
,
657 .start
= IRQ_GPIO_2_x
,
660 .flags
= IORESOURCE_IRQ
,
664 static struct pxa_gpio_platform_data pxa2xx_gpio_info
= {
665 .irq_base
= PXA_GPIO_TO_IRQ(0),
666 .gpio_set_wake
= gpio_set_wake
,
669 struct platform_device pxa25x_device_gpio
= {
670 .name
= "pxa25x-gpio",
672 .num_resources
= ARRAY_SIZE(pxa_resource_gpio
),
673 .resource
= pxa_resource_gpio
,
675 .platform_data
= &pxa2xx_gpio_info
,
679 struct platform_device pxa27x_device_gpio
= {
680 .name
= "pxa27x-gpio",
682 .num_resources
= ARRAY_SIZE(pxa_resource_gpio
),
683 .resource
= pxa_resource_gpio
,
685 .platform_data
= &pxa2xx_gpio_info
,
688 #endif /* CONFIG_PXA25x || CONFIG_PXA27x */
690 static struct resource pxa_dma_resource
[] = {
694 .flags
= IORESOURCE_MEM
,
699 .flags
= IORESOURCE_IRQ
,
703 static u64 pxadma_dmamask
= 0xffffffffUL
;
705 static struct platform_device pxa2xx_pxa_dma
= {
709 .dma_mask
= &pxadma_dmamask
,
710 .coherent_dma_mask
= 0xffffffff,
712 .num_resources
= ARRAY_SIZE(pxa_dma_resource
),
713 .resource
= pxa_dma_resource
,
716 void __init
pxa2xx_set_dmac_info(struct mmp_dma_platdata
*dma_pdata
)
718 pxa_register_device(&pxa2xx_pxa_dma
, dma_pdata
);
721 void __init
pxa_register_wdt(unsigned int reset_status
)
723 struct resource res
= DEFINE_RES_MEM(OST_PHYS
, OST_LEN
);
725 reset_status
&= RESET_STATUS_WATCHDOG
;
726 platform_device_register_resndata(NULL
, "sa1100_wdt", -1, &res
, 1,
727 &reset_status
, sizeof(reset_status
));