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/platform_data/i2c-pxa.h>
11 #include <linux/soc/pxa/cpu.h>
14 #include <linux/platform_data/video-pxafb.h>
15 #include <linux/platform_data/mmc-pxamci.h>
17 #include <linux/platform_data/usb-ohci-pxa27x.h>
18 #include <linux/platform_data/mmp_dma.h>
25 void __init pxa_register_device(struct platform_device *dev, void *data)
29 dev->dev.platform_data = data;
31 ret = platform_device_register(dev);
33 dev_err(&dev->dev, "unable to register device: %d\n", ret);
36 static struct resource pxa_resource_pmu = {
39 .flags = IORESOURCE_IRQ,
42 struct platform_device pxa_device_pmu = {
45 .resource = &pxa_resource_pmu,
49 static struct resource pxamci_resources[] = {
53 .flags = IORESOURCE_MEM,
58 .flags = IORESOURCE_IRQ,
62 static u64 pxamci_dmamask = 0xffffffffUL;
64 struct platform_device pxa_device_mci = {
68 .dma_mask = &pxamci_dmamask,
69 .coherent_dma_mask = 0xffffffff,
71 .num_resources = ARRAY_SIZE(pxamci_resources),
72 .resource = pxamci_resources,
75 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
77 pxa_register_device(&pxa_device_mci, info);
80 static struct pxa2xx_udc_mach_info pxa_udc_info = {
84 static struct resource pxa2xx_udc_resources[] = {
88 .flags = IORESOURCE_MEM,
93 .flags = IORESOURCE_IRQ,
97 static u64 udc_dma_mask = ~(u32)0;
99 struct platform_device pxa25x_device_udc = {
100 .name = "pxa25x-udc",
102 .resource = pxa2xx_udc_resources,
103 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
105 .platform_data = &pxa_udc_info,
106 .dma_mask = &udc_dma_mask,
110 struct platform_device pxa27x_device_udc = {
111 .name = "pxa27x-udc",
113 .resource = pxa2xx_udc_resources,
114 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
116 .platform_data = &pxa_udc_info,
117 .dma_mask = &udc_dma_mask,
121 static struct resource pxafb_resources[] = {
125 .flags = IORESOURCE_MEM,
130 .flags = IORESOURCE_IRQ,
134 static u64 fb_dma_mask = ~(u64)0;
136 struct platform_device pxa_device_fb = {
140 .dma_mask = &fb_dma_mask,
141 .coherent_dma_mask = 0xffffffff,
143 .num_resources = ARRAY_SIZE(pxafb_resources),
144 .resource = pxafb_resources,
147 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info)
149 pxa_device_fb.dev.parent = parent;
150 pxa_register_device(&pxa_device_fb, info);
153 static struct resource pxa_resource_ffuart[] = {
157 .flags = IORESOURCE_MEM,
161 .flags = IORESOURCE_IRQ,
165 struct platform_device pxa_device_ffuart = {
166 .name = "pxa2xx-uart",
168 .resource = pxa_resource_ffuart,
169 .num_resources = ARRAY_SIZE(pxa_resource_ffuart),
172 void __init pxa_set_ffuart_info(void *info)
174 pxa_register_device(&pxa_device_ffuart, info);
177 static struct resource pxa_resource_btuart[] = {
181 .flags = IORESOURCE_MEM,
185 .flags = IORESOURCE_IRQ,
189 struct platform_device pxa_device_btuart = {
190 .name = "pxa2xx-uart",
192 .resource = pxa_resource_btuart,
193 .num_resources = ARRAY_SIZE(pxa_resource_btuart),
196 void __init pxa_set_btuart_info(void *info)
198 pxa_register_device(&pxa_device_btuart, info);
201 static struct resource pxa_resource_stuart[] = {
205 .flags = IORESOURCE_MEM,
209 .flags = IORESOURCE_IRQ,
213 struct platform_device pxa_device_stuart = {
214 .name = "pxa2xx-uart",
216 .resource = pxa_resource_stuart,
217 .num_resources = ARRAY_SIZE(pxa_resource_stuart),
220 void __init pxa_set_stuart_info(void *info)
222 pxa_register_device(&pxa_device_stuart, info);
225 static struct resource pxa_resource_hwuart[] = {
229 .flags = IORESOURCE_MEM,
233 .flags = IORESOURCE_IRQ,
237 struct platform_device pxa_device_hwuart = {
238 .name = "pxa2xx-uart",
240 .resource = pxa_resource_hwuart,
241 .num_resources = ARRAY_SIZE(pxa_resource_hwuart),
244 void __init pxa_set_hwuart_info(void *info)
247 pxa_register_device(&pxa_device_hwuart, info);
249 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
252 static struct resource pxai2c_resources[] = {
256 .flags = IORESOURCE_MEM,
260 .flags = IORESOURCE_IRQ,
264 struct platform_device pxa_device_i2c = {
265 .name = "pxa2xx-i2c",
267 .resource = pxai2c_resources,
268 .num_resources = ARRAY_SIZE(pxai2c_resources),
271 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
273 pxa_register_device(&pxa_device_i2c, info);
277 static struct resource pxa27x_resources_i2c_power[] = {
281 .flags = IORESOURCE_MEM,
285 .flags = IORESOURCE_IRQ,
289 struct platform_device pxa27x_device_i2c_power = {
290 .name = "pxa2xx-i2c",
292 .resource = pxa27x_resources_i2c_power,
293 .num_resources = ARRAY_SIZE(pxa27x_resources_i2c_power),
297 static struct resource pxai2s_resources[] = {
301 .flags = IORESOURCE_MEM,
305 .flags = IORESOURCE_IRQ,
309 struct platform_device pxa_device_i2s = {
310 .name = "pxa2xx-i2s",
312 .resource = pxai2s_resources,
313 .num_resources = ARRAY_SIZE(pxai2s_resources),
316 struct platform_device pxa_device_asoc_ssp1 = {
317 .name = "pxa-ssp-dai",
321 struct platform_device pxa_device_asoc_ssp2= {
322 .name = "pxa-ssp-dai",
326 struct platform_device pxa_device_asoc_ssp3 = {
327 .name = "pxa-ssp-dai",
331 struct platform_device pxa_device_asoc_ssp4 = {
332 .name = "pxa-ssp-dai",
336 struct platform_device pxa_device_asoc_platform = {
337 .name = "pxa-pcm-audio",
341 static struct resource pxa_rtc_resources[] = {
344 .end = 0x40900000 + 0x3b,
345 .flags = IORESOURCE_MEM,
351 .flags = IORESOURCE_IRQ,
354 .start = IRQ_RTCAlrm,
357 .flags = IORESOURCE_IRQ,
361 struct platform_device pxa_device_rtc = {
364 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
365 .resource = pxa_rtc_resources,
368 struct platform_device sa1100_device_rtc = {
369 .name = "sa1100-rtc",
371 .num_resources = ARRAY_SIZE(pxa_rtc_resources),
372 .resource = pxa_rtc_resources,
377 static struct resource pxa25x_resource_pwm0[] = {
381 .flags = IORESOURCE_MEM,
385 struct platform_device pxa25x_device_pwm0 = {
386 .name = "pxa25x-pwm",
388 .resource = pxa25x_resource_pwm0,
389 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm0),
392 static struct resource pxa25x_resource_pwm1[] = {
396 .flags = IORESOURCE_MEM,
400 struct platform_device pxa25x_device_pwm1 = {
401 .name = "pxa25x-pwm",
403 .resource = pxa25x_resource_pwm1,
404 .num_resources = ARRAY_SIZE(pxa25x_resource_pwm1),
407 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
409 static struct resource pxa25x_resource_ssp[] = {
413 .flags = IORESOURCE_MEM,
418 .flags = IORESOURCE_IRQ,
422 struct platform_device pxa25x_device_ssp = {
423 .name = "pxa25x-ssp",
426 .dma_mask = &pxa25x_ssp_dma_mask,
427 .coherent_dma_mask = DMA_BIT_MASK(32),
429 .resource = pxa25x_resource_ssp,
430 .num_resources = ARRAY_SIZE(pxa25x_resource_ssp),
433 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
435 static struct resource pxa25x_resource_nssp[] = {
439 .flags = IORESOURCE_MEM,
444 .flags = IORESOURCE_IRQ,
448 struct platform_device pxa25x_device_nssp = {
449 .name = "pxa25x-nssp",
452 .dma_mask = &pxa25x_nssp_dma_mask,
453 .coherent_dma_mask = DMA_BIT_MASK(32),
455 .resource = pxa25x_resource_nssp,
456 .num_resources = ARRAY_SIZE(pxa25x_resource_nssp),
459 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
461 static struct resource pxa25x_resource_assp[] = {
465 .flags = IORESOURCE_MEM,
470 .flags = IORESOURCE_IRQ,
474 struct platform_device pxa25x_device_assp = {
475 /* ASSP is basically equivalent to NSSP */
476 .name = "pxa25x-nssp",
479 .dma_mask = &pxa25x_assp_dma_mask,
480 .coherent_dma_mask = DMA_BIT_MASK(32),
482 .resource = pxa25x_resource_assp,
483 .num_resources = ARRAY_SIZE(pxa25x_resource_assp),
485 #endif /* CONFIG_PXA25x */
487 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
488 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
490 static struct resource pxa27x_resource_ohci[] = {
494 .flags = IORESOURCE_MEM,
499 .flags = IORESOURCE_IRQ,
503 struct platform_device pxa27x_device_ohci = {
504 .name = "pxa27x-ohci",
507 .dma_mask = &pxa27x_ohci_dma_mask,
508 .coherent_dma_mask = DMA_BIT_MASK(32),
510 .num_resources = ARRAY_SIZE(pxa27x_resource_ohci),
511 .resource = pxa27x_resource_ohci,
514 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
516 pxa_register_device(&pxa27x_device_ohci, info);
518 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
520 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
521 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
523 static struct resource pxa27x_resource_ssp1[] = {
527 .flags = IORESOURCE_MEM,
532 .flags = IORESOURCE_IRQ,
536 struct platform_device pxa27x_device_ssp1 = {
537 .name = "pxa27x-ssp",
540 .dma_mask = &pxa27x_ssp1_dma_mask,
541 .coherent_dma_mask = DMA_BIT_MASK(32),
543 .resource = pxa27x_resource_ssp1,
544 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp1),
547 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
549 static struct resource pxa27x_resource_ssp2[] = {
553 .flags = IORESOURCE_MEM,
558 .flags = IORESOURCE_IRQ,
562 struct platform_device pxa27x_device_ssp2 = {
563 .name = "pxa27x-ssp",
566 .dma_mask = &pxa27x_ssp2_dma_mask,
567 .coherent_dma_mask = DMA_BIT_MASK(32),
569 .resource = pxa27x_resource_ssp2,
570 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp2),
573 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
575 static struct resource pxa27x_resource_ssp3[] = {
579 .flags = IORESOURCE_MEM,
584 .flags = IORESOURCE_IRQ,
588 struct platform_device pxa27x_device_ssp3 = {
589 .name = "pxa27x-ssp",
592 .dma_mask = &pxa27x_ssp3_dma_mask,
593 .coherent_dma_mask = DMA_BIT_MASK(32),
595 .resource = pxa27x_resource_ssp3,
596 .num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
599 static struct resource pxa27x_resource_pwm0[] = {
603 .flags = IORESOURCE_MEM,
607 struct platform_device pxa27x_device_pwm0 = {
608 .name = "pxa27x-pwm",
610 .resource = pxa27x_resource_pwm0,
611 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm0),
614 static struct resource pxa27x_resource_pwm1[] = {
618 .flags = IORESOURCE_MEM,
622 struct platform_device pxa27x_device_pwm1 = {
623 .name = "pxa27x-pwm",
625 .resource = pxa27x_resource_pwm1,
626 .num_resources = ARRAY_SIZE(pxa27x_resource_pwm1),
628 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
630 struct resource pxa_resource_gpio[] = {
634 .flags = IORESOURCE_MEM,
639 .flags = IORESOURCE_IRQ,
644 .flags = IORESOURCE_IRQ,
646 .start = IRQ_GPIO_2_x,
649 .flags = IORESOURCE_IRQ,
653 struct platform_device pxa25x_device_gpio = {
654 .name = "pxa25x-gpio",
656 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
657 .resource = pxa_resource_gpio,
660 struct platform_device pxa27x_device_gpio = {
661 .name = "pxa27x-gpio",
663 .num_resources = ARRAY_SIZE(pxa_resource_gpio),
664 .resource = pxa_resource_gpio,
667 static struct resource pxa_dma_resource[] = {
671 .flags = IORESOURCE_MEM,
676 .flags = IORESOURCE_IRQ,
680 static u64 pxadma_dmamask = 0xffffffffUL;
682 static struct platform_device pxa2xx_pxa_dma = {
686 .dma_mask = &pxadma_dmamask,
687 .coherent_dma_mask = 0xffffffff,
689 .num_resources = ARRAY_SIZE(pxa_dma_resource),
690 .resource = pxa_dma_resource,
693 void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
695 pxa_register_device(&pxa2xx_pxa_dma, dma_pdata);
698 void __init pxa_register_wdt(unsigned int reset_status)
700 struct resource res = DEFINE_RES_MEM(OST_PHYS, OST_LEN);
702 reset_status &= RESET_STATUS_WATCHDOG;
703 platform_device_register_resndata(NULL, "sa1100_wdt", -1, &res, 1,
704 &reset_status, sizeof(reset_status));