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/spi/pxa2xx_spi.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>
26 void __init pxa_register_device(struct platform_device *dev, void *data)
30 dev->dev.platform_data = data;
32 ret = platform_device_register(dev);
34 dev_err(&dev->dev, "unable to register device: %d\n", ret);
37 static struct resource pxa_resource_pmu = {
40 .flags = IORESOURCE_IRQ,
43 struct platform_device pxa_device_pmu = {
46 .resource = &pxa_resource_pmu,
50 static struct resource pxamci_resources[] = {
54 .flags = IORESOURCE_MEM,
59 .flags = IORESOURCE_IRQ,
63 static u64 pxamci_dmamask = 0xffffffffUL;
65 struct platform_device pxa_device_mci = {
69 .dma_mask = &pxamci_dmamask,
70 .coherent_dma_mask = 0xffffffff,
72 .num_resources = ARRAY_SIZE(pxamci_resources),
73 .resource = pxamci_resources,
76 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
78 pxa_register_device(&pxa_device_mci, info);
81 static struct pxa2xx_udc_mach_info pxa_udc_info = {
85 static struct resource pxa2xx_udc_resources[] = {
89 .flags = IORESOURCE_MEM,
94 .flags = IORESOURCE_IRQ,
98 static u64 udc_dma_mask = ~(u32)0;
100 struct platform_device pxa25x_device_udc = {
101 .name = "pxa25x-udc",
103 .resource = pxa2xx_udc_resources,
104 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
106 .platform_data = &pxa_udc_info,
107 .dma_mask = &udc_dma_mask,
111 struct platform_device pxa27x_device_udc = {
112 .name = "pxa27x-udc",
114 .resource = pxa2xx_udc_resources,
115 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
117 .platform_data = &pxa_udc_info,
118 .dma_mask = &udc_dma_mask,
122 static struct resource pxafb_resources[] = {
126 .flags = IORESOURCE_MEM,
131 .flags = IORESOURCE_IRQ,
135 static u64 fb_dma_mask = ~(u64)0;
137 struct platform_device pxa_device_fb = {
141 .dma_mask = &fb_dma_mask,
142 .coherent_dma_mask = 0xffffffff,
144 .num_resources = ARRAY_SIZE(pxafb_resources),
145 .resource = pxafb_resources,
148 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info)
150 pxa_device_fb.dev.parent = parent;
151 pxa_register_device(&pxa_device_fb, info);
154 static struct resource pxa_resource_ffuart[] = {
158 .flags = IORESOURCE_MEM,
162 .flags = IORESOURCE_IRQ,
166 struct platform_device pxa_device_ffuart = {
167 .name = "pxa2xx-uart",
169 .resource = pxa_resource_ffuart,
170 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
173 void __init pxa_set_ffuart_info(void *info)
175 pxa_register_device(&pxa_device_ffuart, info);
178 static struct resource pxa_resource_btuart[] = {
182 .flags = IORESOURCE_MEM,
186 .flags = IORESOURCE_IRQ,
190 struct platform_device pxa_device_btuart = {
191 .name = "pxa2xx-uart",
193 .resource = pxa_resource_btuart,
194 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
197 void __init pxa_set_btuart_info(void *info)
199 pxa_register_device(&pxa_device_btuart, info);
202 static struct resource pxa_resource_stuart[] = {
206 .flags = IORESOURCE_MEM,
210 .flags = IORESOURCE_IRQ,
214 struct platform_device pxa_device_stuart = {
215 .name = "pxa2xx-uart",
217 .resource = pxa_resource_stuart,
218 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
221 void __init pxa_set_stuart_info(void *info)
223 pxa_register_device(&pxa_device_stuart, info);
226 static struct resource pxa_resource_hwuart[] = {
230 .flags = IORESOURCE_MEM,
234 .flags = IORESOURCE_IRQ,
238 struct platform_device pxa_device_hwuart = {
239 .name = "pxa2xx-uart",
241 .resource = pxa_resource_hwuart,
242 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
245 void __init pxa_set_hwuart_info(void *info)
248 pxa_register_device(&pxa_device_hwuart, info);
250 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
253 static struct resource pxai2c_resources[] = {
257 .flags = IORESOURCE_MEM,
261 .flags = IORESOURCE_IRQ,
265 struct platform_device pxa_device_i2c = {
266 .name = "pxa2xx-i2c",
268 .resource = pxai2c_resources,
269 .num_resources = ARRAY_SIZE(pxai2c_resources),
272 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
274 pxa_register_device(&pxa_device_i2c, info);
278 static struct resource pxa27x_resources_i2c_power[] = {
282 .flags = IORESOURCE_MEM,
286 .flags = IORESOURCE_IRQ,
290 struct platform_device pxa27x_device_i2c_power = {
291 .name = "pxa2xx-i2c",
293 .resource = pxa27x_resources_i2c_power,
294 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
298 static struct resource pxai2s_resources[] = {
302 .flags = IORESOURCE_MEM,
306 .flags = IORESOURCE_IRQ,
310 struct platform_device pxa_device_i2s = {
311 .name = "pxa2xx-i2s",
313 .resource = pxai2s_resources,
314 .num_resources = ARRAY_SIZE(pxai2s_resources),
317 struct platform_device pxa_device_asoc_ssp1 = {
318 .name = "pxa-ssp-dai",
322 struct platform_device pxa_device_asoc_ssp2= {
323 .name = "pxa-ssp-dai",
327 struct platform_device pxa_device_asoc_ssp3 = {
328 .name = "pxa-ssp-dai",
332 struct platform_device pxa_device_asoc_ssp4 = {
333 .name = "pxa-ssp-dai",
337 struct platform_device pxa_device_asoc_platform = {
338 .name = "pxa-pcm-audio",
342 static struct resource pxa_rtc_resources[] = {
345 .end = 0x40900000 + 0x3b,
346 .flags = IORESOURCE_MEM,
352 .flags = IORESOURCE_IRQ,
355 .start = IRQ_RTCAlrm,
358 .flags = IORESOURCE_IRQ,
362 struct platform_device pxa_device_rtc = {
365 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
366 .resource = pxa_rtc_resources,
369 struct platform_device sa1100_device_rtc = {
370 .name = "sa1100-rtc",
372 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
373 .resource = pxa_rtc_resources,
378 static struct resource pxa25x_resource_pwm0[] = {
382 .flags = IORESOURCE_MEM,
386 struct platform_device pxa25x_device_pwm0 = {
387 .name = "pxa25x-pwm",
389 .resource = pxa25x_resource_pwm0,
390 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
393 static struct resource pxa25x_resource_pwm1[] = {
397 .flags = IORESOURCE_MEM,
401 struct platform_device pxa25x_device_pwm1 = {
402 .name = "pxa25x-pwm",
404 .resource = pxa25x_resource_pwm1,
405 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
408 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
410 static struct resource pxa25x_resource_ssp[] = {
414 .flags = IORESOURCE_MEM,
419 .flags = IORESOURCE_IRQ,
423 struct platform_device pxa25x_device_ssp = {
424 .name = "pxa25x-ssp",
427 .dma_mask = &pxa25x_ssp_dma_mask,
428 .coherent_dma_mask = DMA_BIT_MASK(32),
430 .resource = pxa25x_resource_ssp,
431 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
434 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
436 static struct resource pxa25x_resource_nssp[] = {
440 .flags = IORESOURCE_MEM,
445 .flags = IORESOURCE_IRQ,
449 struct platform_device pxa25x_device_nssp = {
450 .name = "pxa25x-nssp",
453 .dma_mask = &pxa25x_nssp_dma_mask,
454 .coherent_dma_mask = DMA_BIT_MASK(32),
456 .resource = pxa25x_resource_nssp,
457 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
460 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
462 static struct resource pxa25x_resource_assp[] = {
466 .flags = IORESOURCE_MEM,
471 .flags = IORESOURCE_IRQ,
475 struct platform_device pxa25x_device_assp = {
476 /* ASSP is basically equivalent to NSSP */
477 .name = "pxa25x-nssp",
480 .dma_mask = &pxa25x_assp_dma_mask,
481 .coherent_dma_mask = DMA_BIT_MASK(32),
483 .resource = pxa25x_resource_assp,
484 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
486 #endif /* CONFIG_PXA25x */
488 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
489 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
491 static struct resource pxa27x_resource_ohci[] = {
495 .flags = IORESOURCE_MEM,
500 .flags = IORESOURCE_IRQ,
504 struct platform_device pxa27x_device_ohci = {
505 .name = "pxa27x-ohci",
508 .dma_mask = &pxa27x_ohci_dma_mask,
509 .coherent_dma_mask = DMA_BIT_MASK(32),
511 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
512 .resource = pxa27x_resource_ohci,
515 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
517 pxa_register_device(&pxa27x_device_ohci, info);
519 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
521 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
522 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
524 static struct resource pxa27x_resource_ssp1[] = {
528 .flags = IORESOURCE_MEM,
533 .flags = IORESOURCE_IRQ,
537 struct platform_device pxa27x_device_ssp1 = {
538 .name = "pxa27x-ssp",
541 .dma_mask = &pxa27x_ssp1_dma_mask,
542 .coherent_dma_mask = DMA_BIT_MASK(32),
544 .resource = pxa27x_resource_ssp1,
545 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
548 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
550 static struct resource pxa27x_resource_ssp2[] = {
554 .flags = IORESOURCE_MEM,
559 .flags = IORESOURCE_IRQ,
563 struct platform_device pxa27x_device_ssp2 = {
564 .name = "pxa27x-ssp",
567 .dma_mask = &pxa27x_ssp2_dma_mask,
568 .coherent_dma_mask = DMA_BIT_MASK(32),
570 .resource = pxa27x_resource_ssp2,
571 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
574 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
576 static struct resource pxa27x_resource_ssp3[] = {
580 .flags = IORESOURCE_MEM,
585 .flags = IORESOURCE_IRQ,
589 struct platform_device pxa27x_device_ssp3 = {
590 .name = "pxa27x-ssp",
593 .dma_mask = &pxa27x_ssp3_dma_mask,
594 .coherent_dma_mask = DMA_BIT_MASK(32),
596 .resource = pxa27x_resource_ssp3,
597 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
600 static struct resource pxa27x_resource_pwm0[] = {
604 .flags = IORESOURCE_MEM,
608 struct platform_device pxa27x_device_pwm0 = {
609 .name = "pxa27x-pwm",
611 .resource = pxa27x_resource_pwm0,
612 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
615 static struct resource pxa27x_resource_pwm1[] = {
619 .flags = IORESOURCE_MEM,
623 struct platform_device pxa27x_device_pwm1 = {
624 .name = "pxa27x-pwm",
626 .resource = pxa27x_resource_pwm1,
627 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
629 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
631 struct resource pxa_resource_gpio[] = {
635 .flags = IORESOURCE_MEM,
640 .flags = IORESOURCE_IRQ,
645 .flags = IORESOURCE_IRQ,
647 .start = IRQ_GPIO_2_x,
650 .flags = IORESOURCE_IRQ,
654 struct platform_device pxa25x_device_gpio = {
655 .name = "pxa25x-gpio",
657 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
658 .resource = pxa_resource_gpio,
661 struct platform_device pxa27x_device_gpio = {
662 .name = "pxa27x-gpio",
664 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
665 .resource = pxa_resource_gpio,
668 /* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
669 * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
670 void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_controller *info)
672 struct platform_device *pd;
674 pd = platform_device_alloc("pxa2xx-spi", id);
676 printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
681 pd->dev.platform_data = info;
682 platform_device_add(pd);
685 static struct resource pxa_dma_resource[] = {
689 .flags = IORESOURCE_MEM,
694 .flags = IORESOURCE_IRQ,
698 static u64 pxadma_dmamask = 0xffffffffUL;
700 static struct platform_device pxa2xx_pxa_dma = {
704 .dma_mask = &pxadma_dmamask,
705 .coherent_dma_mask = 0xffffffff,
707 .num_resources = ARRAY_SIZE(pxa_dma_resource),
708 .resource = pxa_dma_resource,
711 void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
713 pxa_register_device(&pxa2xx_pxa_dma, dma_pdata);
716 void __init pxa_register_wdt(unsigned int reset_status)
718 struct resource res = DEFINE_RES_MEM(OST_PHYS, OST_LEN);
720 reset_status &= RESET_STATUS_WATCHDOG;
721 platform_device_register_resndata(NULL, "sa1100_wdt", -1, &res, 1,
722 &reset_status, sizeof(reset_status));