]> Git Repo - J-linux.git/blob - arch/arm/mach-pxa/devices.c
Merge patch series "riscv: Extension parsing fixes"
[J-linux.git] / arch / arm / mach-pxa / devices.c
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>
12
13 #include "udc.h"
14 #include <linux/platform_data/video-pxafb.h>
15 #include <linux/platform_data/mmc-pxamci.h>
16 #include "irqs.h"
17 #include <linux/platform_data/usb-ohci-pxa27x.h>
18 #include <linux/platform_data/mmp_dma.h>
19
20 #include "regs-ost.h"
21 #include "reset.h"
22 #include "devices.h"
23 #include "generic.h"
24
25 void __init pxa_register_device(struct platform_device *dev, void *data)
26 {
27         int ret;
28
29         dev->dev.platform_data = data;
30
31         ret = platform_device_register(dev);
32         if (ret)
33                 dev_err(&dev->dev, "unable to register device: %d\n", ret);
34 }
35
36 static struct resource pxa_resource_pmu = {
37         .start  = IRQ_PMU,
38         .end    = IRQ_PMU,
39         .flags  = IORESOURCE_IRQ,
40 };
41
42 struct platform_device pxa_device_pmu = {
43         .name           = "xscale-pmu",
44         .id             = -1,
45         .resource       = &pxa_resource_pmu,
46         .num_resources  = 1,
47 };
48
49 static struct resource pxamci_resources[] = {
50         [0] = {
51                 .start  = 0x41100000,
52                 .end    = 0x41100fff,
53                 .flags  = IORESOURCE_MEM,
54         },
55         [1] = {
56                 .start  = IRQ_MMC,
57                 .end    = IRQ_MMC,
58                 .flags  = IORESOURCE_IRQ,
59         },
60 };
61
62 static u64 pxamci_dmamask = 0xffffffffUL;
63
64 struct platform_device pxa_device_mci = {
65         .name           = "pxa2xx-mci",
66         .id             = 0,
67         .dev            = {
68                 .dma_mask = &pxamci_dmamask,
69                 .coherent_dma_mask = 0xffffffff,
70         },
71         .num_resources  = ARRAY_SIZE(pxamci_resources),
72         .resource       = pxamci_resources,
73 };
74
75 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
76 {
77         pxa_register_device(&pxa_device_mci, info);
78 }
79
80 static struct pxa2xx_udc_mach_info pxa_udc_info = {
81         .gpio_pullup = -1,
82 };
83
84 static struct resource pxa2xx_udc_resources[] = {
85         [0] = {
86                 .start  = 0x40600000,
87                 .end    = 0x4060ffff,
88                 .flags  = IORESOURCE_MEM,
89         },
90         [1] = {
91                 .start  = IRQ_USB,
92                 .end    = IRQ_USB,
93                 .flags  = IORESOURCE_IRQ,
94         },
95 };
96
97 static u64 udc_dma_mask = ~(u32)0;
98
99 struct platform_device pxa25x_device_udc = {
100         .name           = "pxa25x-udc",
101         .id             = -1,
102         .resource       = pxa2xx_udc_resources,
103         .num_resources  = ARRAY_SIZE(pxa2xx_udc_resources),
104         .dev            =  {
105                 .platform_data  = &pxa_udc_info,
106                 .dma_mask       = &udc_dma_mask,
107         }
108 };
109
110 struct platform_device pxa27x_device_udc = {
111         .name           = "pxa27x-udc",
112         .id             = -1,
113         .resource       = pxa2xx_udc_resources,
114         .num_resources  = ARRAY_SIZE(pxa2xx_udc_resources),
115         .dev            =  {
116                 .platform_data  = &pxa_udc_info,
117                 .dma_mask       = &udc_dma_mask,
118         }
119 };
120
121 static struct resource pxafb_resources[] = {
122         [0] = {
123                 .start  = 0x44000000,
124                 .end    = 0x4400ffff,
125                 .flags  = IORESOURCE_MEM,
126         },
127         [1] = {
128                 .start  = IRQ_LCD,
129                 .end    = IRQ_LCD,
130                 .flags  = IORESOURCE_IRQ,
131         },
132 };
133
134 static u64 fb_dma_mask = ~(u64)0;
135
136 struct platform_device pxa_device_fb = {
137         .name           = "pxa2xx-fb",
138         .id             = -1,
139         .dev            = {
140                 .dma_mask       = &fb_dma_mask,
141                 .coherent_dma_mask = 0xffffffff,
142         },
143         .num_resources  = ARRAY_SIZE(pxafb_resources),
144         .resource       = pxafb_resources,
145 };
146
147 void __init pxa_set_fb_info(struct device *parent, struct pxafb_mach_info *info)
148 {
149         pxa_device_fb.dev.parent = parent;
150         pxa_register_device(&pxa_device_fb, info);
151 }
152
153 static struct resource pxa_resource_ffuart[] = {
154         {
155                 .start  = 0x40100000,
156                 .end    = 0x40100023,
157                 .flags  = IORESOURCE_MEM,
158         }, {
159                 .start  = IRQ_FFUART,
160                 .end    = IRQ_FFUART,
161                 .flags  = IORESOURCE_IRQ,
162         }
163 };
164
165 struct platform_device pxa_device_ffuart = {
166         .name           = "pxa2xx-uart",
167         .id             = 0,
168         .resource       = pxa_resource_ffuart,
169         .num_resources  = ARRAY_SIZE(pxa_resource_ffuart),
170 };
171
172 void __init pxa_set_ffuart_info(void *info)
173 {
174         pxa_register_device(&pxa_device_ffuart, info);
175 }
176
177 static struct resource pxa_resource_btuart[] = {
178         {
179                 .start  = 0x40200000,
180                 .end    = 0x40200023,
181                 .flags  = IORESOURCE_MEM,
182         }, {
183                 .start  = IRQ_BTUART,
184                 .end    = IRQ_BTUART,
185                 .flags  = IORESOURCE_IRQ,
186         }
187 };
188
189 struct platform_device pxa_device_btuart = {
190         .name           = "pxa2xx-uart",
191         .id             = 1,
192         .resource       = pxa_resource_btuart,
193         .num_resources  = ARRAY_SIZE(pxa_resource_btuart),
194 };
195
196 void __init pxa_set_btuart_info(void *info)
197 {
198         pxa_register_device(&pxa_device_btuart, info);
199 }
200
201 static struct resource pxa_resource_stuart[] = {
202         {
203                 .start  = 0x40700000,
204                 .end    = 0x40700023,
205                 .flags  = IORESOURCE_MEM,
206         }, {
207                 .start  = IRQ_STUART,
208                 .end    = IRQ_STUART,
209                 .flags  = IORESOURCE_IRQ,
210         }
211 };
212
213 struct platform_device pxa_device_stuart = {
214         .name           = "pxa2xx-uart",
215         .id             = 2,
216         .resource       = pxa_resource_stuart,
217         .num_resources  = ARRAY_SIZE(pxa_resource_stuart),
218 };
219
220 void __init pxa_set_stuart_info(void *info)
221 {
222         pxa_register_device(&pxa_device_stuart, info);
223 }
224
225 static struct resource pxa_resource_hwuart[] = {
226         {
227                 .start  = 0x41600000,
228                 .end    = 0x4160002F,
229                 .flags  = IORESOURCE_MEM,
230         }, {
231                 .start  = IRQ_HWUART,
232                 .end    = IRQ_HWUART,
233                 .flags  = IORESOURCE_IRQ,
234         }
235 };
236
237 struct platform_device pxa_device_hwuart = {
238         .name           = "pxa2xx-uart",
239         .id             = 3,
240         .resource       = pxa_resource_hwuart,
241         .num_resources  = ARRAY_SIZE(pxa_resource_hwuart),
242 };
243
244 void __init pxa_set_hwuart_info(void *info)
245 {
246         if (cpu_is_pxa255())
247                 pxa_register_device(&pxa_device_hwuart, info);
248         else
249                 pr_info("UART: Ignoring attempt to register HWUART on non-PXA255 hardware");
250 }
251
252 static struct resource pxai2c_resources[] = {
253         {
254                 .start  = 0x40301680,
255                 .end    = 0x403016a3,
256                 .flags  = IORESOURCE_MEM,
257         }, {
258                 .start  = IRQ_I2C,
259                 .end    = IRQ_I2C,
260                 .flags  = IORESOURCE_IRQ,
261         },
262 };
263
264 struct platform_device pxa_device_i2c = {
265         .name           = "pxa2xx-i2c",
266         .id             = 0,
267         .resource       = pxai2c_resources,
268         .num_resources  = ARRAY_SIZE(pxai2c_resources),
269 };
270
271 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
272 {
273         pxa_register_device(&pxa_device_i2c, info);
274 }
275
276 #ifdef CONFIG_PXA27x
277 static struct resource pxa27x_resources_i2c_power[] = {
278         {
279                 .start  = 0x40f00180,
280                 .end    = 0x40f001a3,
281                 .flags  = IORESOURCE_MEM,
282         }, {
283                 .start  = IRQ_PWRI2C,
284                 .end    = IRQ_PWRI2C,
285                 .flags  = IORESOURCE_IRQ,
286         },
287 };
288
289 struct platform_device pxa27x_device_i2c_power = {
290         .name           = "pxa2xx-i2c",
291         .id             = 1,
292         .resource       = pxa27x_resources_i2c_power,
293         .num_resources  = ARRAY_SIZE(pxa27x_resources_i2c_power),
294 };
295 #endif
296
297 static struct resource pxai2s_resources[] = {
298         {
299                 .start  = 0x40400000,
300                 .end    = 0x40400083,
301                 .flags  = IORESOURCE_MEM,
302         }, {
303                 .start  = IRQ_I2S,
304                 .end    = IRQ_I2S,
305                 .flags  = IORESOURCE_IRQ,
306         },
307 };
308
309 struct platform_device pxa_device_i2s = {
310         .name           = "pxa2xx-i2s",
311         .id             = -1,
312         .resource       = pxai2s_resources,
313         .num_resources  = ARRAY_SIZE(pxai2s_resources),
314 };
315
316 struct platform_device pxa_device_asoc_ssp1 = {
317         .name           = "pxa-ssp-dai",
318         .id             = 0,
319 };
320
321 struct platform_device pxa_device_asoc_ssp2= {
322         .name           = "pxa-ssp-dai",
323         .id             = 1,
324 };
325
326 struct platform_device pxa_device_asoc_ssp3 = {
327         .name           = "pxa-ssp-dai",
328         .id             = 2,
329 };
330
331 struct platform_device pxa_device_asoc_ssp4 = {
332         .name           = "pxa-ssp-dai",
333         .id             = 3,
334 };
335
336 struct platform_device pxa_device_asoc_platform = {
337         .name           = "pxa-pcm-audio",
338         .id             = -1,
339 };
340
341 static struct resource pxa_rtc_resources[] = {
342         [0] = {
343                 .start  = 0x40900000,
344                 .end    = 0x40900000 + 0x3b,
345                 .flags  = IORESOURCE_MEM,
346         },
347         [1] = {
348                 .start  = IRQ_RTC1Hz,
349                 .end    = IRQ_RTC1Hz,
350                 .name   = "rtc 1Hz",
351                 .flags  = IORESOURCE_IRQ,
352         },
353         [2] = {
354                 .start  = IRQ_RTCAlrm,
355                 .end    = IRQ_RTCAlrm,
356                 .name   = "rtc alarm",
357                 .flags  = IORESOURCE_IRQ,
358         },
359 };
360
361 struct platform_device pxa_device_rtc = {
362         .name           = "pxa-rtc",
363         .id             = -1,
364         .num_resources  = ARRAY_SIZE(pxa_rtc_resources),
365         .resource       = pxa_rtc_resources,
366 };
367
368 struct platform_device sa1100_device_rtc = {
369         .name           = "sa1100-rtc",
370         .id             = -1,
371         .num_resources  = ARRAY_SIZE(pxa_rtc_resources),
372         .resource       = pxa_rtc_resources,
373 };
374
375 #ifdef CONFIG_PXA25x
376
377 static struct resource pxa25x_resource_pwm0[] = {
378         [0] = {
379                 .start  = 0x40b00000,
380                 .end    = 0x40b0000f,
381                 .flags  = IORESOURCE_MEM,
382         },
383 };
384
385 struct platform_device pxa25x_device_pwm0 = {
386         .name           = "pxa25x-pwm",
387         .id             = 0,
388         .resource       = pxa25x_resource_pwm0,
389         .num_resources  = ARRAY_SIZE(pxa25x_resource_pwm0),
390 };
391
392 static struct resource pxa25x_resource_pwm1[] = {
393         [0] = {
394                 .start  = 0x40c00000,
395                 .end    = 0x40c0000f,
396                 .flags  = IORESOURCE_MEM,
397         },
398 };
399
400 struct platform_device pxa25x_device_pwm1 = {
401         .name           = "pxa25x-pwm",
402         .id             = 1,
403         .resource       = pxa25x_resource_pwm1,
404         .num_resources  = ARRAY_SIZE(pxa25x_resource_pwm1),
405 };
406
407 static u64 pxa25x_ssp_dma_mask = DMA_BIT_MASK(32);
408
409 static struct resource pxa25x_resource_ssp[] = {
410         [0] = {
411                 .start  = 0x41000000,
412                 .end    = 0x4100001f,
413                 .flags  = IORESOURCE_MEM,
414         },
415         [1] = {
416                 .start  = IRQ_SSP,
417                 .end    = IRQ_SSP,
418                 .flags  = IORESOURCE_IRQ,
419         },
420 };
421
422 struct platform_device pxa25x_device_ssp = {
423         .name           = "pxa25x-ssp",
424         .id             = 0,
425         .dev            = {
426                 .dma_mask = &pxa25x_ssp_dma_mask,
427                 .coherent_dma_mask = DMA_BIT_MASK(32),
428         },
429         .resource       = pxa25x_resource_ssp,
430         .num_resources  = ARRAY_SIZE(pxa25x_resource_ssp),
431 };
432
433 static u64 pxa25x_nssp_dma_mask = DMA_BIT_MASK(32);
434
435 static struct resource pxa25x_resource_nssp[] = {
436         [0] = {
437                 .start  = 0x41400000,
438                 .end    = 0x4140002f,
439                 .flags  = IORESOURCE_MEM,
440         },
441         [1] = {
442                 .start  = IRQ_NSSP,
443                 .end    = IRQ_NSSP,
444                 .flags  = IORESOURCE_IRQ,
445         },
446 };
447
448 struct platform_device pxa25x_device_nssp = {
449         .name           = "pxa25x-nssp",
450         .id             = 1,
451         .dev            = {
452                 .dma_mask = &pxa25x_nssp_dma_mask,
453                 .coherent_dma_mask = DMA_BIT_MASK(32),
454         },
455         .resource       = pxa25x_resource_nssp,
456         .num_resources  = ARRAY_SIZE(pxa25x_resource_nssp),
457 };
458
459 static u64 pxa25x_assp_dma_mask = DMA_BIT_MASK(32);
460
461 static struct resource pxa25x_resource_assp[] = {
462         [0] = {
463                 .start  = 0x41500000,
464                 .end    = 0x4150002f,
465                 .flags  = IORESOURCE_MEM,
466         },
467         [1] = {
468                 .start  = IRQ_ASSP,
469                 .end    = IRQ_ASSP,
470                 .flags  = IORESOURCE_IRQ,
471         },
472 };
473
474 struct platform_device pxa25x_device_assp = {
475         /* ASSP is basically equivalent to NSSP */
476         .name           = "pxa25x-nssp",
477         .id             = 2,
478         .dev            = {
479                 .dma_mask = &pxa25x_assp_dma_mask,
480                 .coherent_dma_mask = DMA_BIT_MASK(32),
481         },
482         .resource       = pxa25x_resource_assp,
483         .num_resources  = ARRAY_SIZE(pxa25x_resource_assp),
484 };
485 #endif /* CONFIG_PXA25x */
486
487 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
488 static u64 pxa27x_ohci_dma_mask = DMA_BIT_MASK(32);
489
490 static struct resource pxa27x_resource_ohci[] = {
491         [0] = {
492                 .start  = 0x4C000000,
493                 .end    = 0x4C00ff6f,
494                 .flags  = IORESOURCE_MEM,
495         },
496         [1] = {
497                 .start  = IRQ_USBH1,
498                 .end    = IRQ_USBH1,
499                 .flags  = IORESOURCE_IRQ,
500         },
501 };
502
503 struct platform_device pxa27x_device_ohci = {
504         .name           = "pxa27x-ohci",
505         .id             = -1,
506         .dev            = {
507                 .dma_mask = &pxa27x_ohci_dma_mask,
508                 .coherent_dma_mask = DMA_BIT_MASK(32),
509         },
510         .num_resources  = ARRAY_SIZE(pxa27x_resource_ohci),
511         .resource       = pxa27x_resource_ohci,
512 };
513
514 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
515 {
516         pxa_register_device(&pxa27x_device_ohci, info);
517 }
518 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
519
520 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
521 static u64 pxa27x_ssp1_dma_mask = DMA_BIT_MASK(32);
522
523 static struct resource pxa27x_resource_ssp1[] = {
524         [0] = {
525                 .start  = 0x41000000,
526                 .end    = 0x4100003f,
527                 .flags  = IORESOURCE_MEM,
528         },
529         [1] = {
530                 .start  = IRQ_SSP,
531                 .end    = IRQ_SSP,
532                 .flags  = IORESOURCE_IRQ,
533         },
534 };
535
536 struct platform_device pxa27x_device_ssp1 = {
537         .name           = "pxa27x-ssp",
538         .id             = 0,
539         .dev            = {
540                 .dma_mask = &pxa27x_ssp1_dma_mask,
541                 .coherent_dma_mask = DMA_BIT_MASK(32),
542         },
543         .resource       = pxa27x_resource_ssp1,
544         .num_resources  = ARRAY_SIZE(pxa27x_resource_ssp1),
545 };
546
547 static u64 pxa27x_ssp2_dma_mask = DMA_BIT_MASK(32);
548
549 static struct resource pxa27x_resource_ssp2[] = {
550         [0] = {
551                 .start  = 0x41700000,
552                 .end    = 0x4170003f,
553                 .flags  = IORESOURCE_MEM,
554         },
555         [1] = {
556                 .start  = IRQ_SSP2,
557                 .end    = IRQ_SSP2,
558                 .flags  = IORESOURCE_IRQ,
559         },
560 };
561
562 struct platform_device pxa27x_device_ssp2 = {
563         .name           = "pxa27x-ssp",
564         .id             = 1,
565         .dev            = {
566                 .dma_mask = &pxa27x_ssp2_dma_mask,
567                 .coherent_dma_mask = DMA_BIT_MASK(32),
568         },
569         .resource       = pxa27x_resource_ssp2,
570         .num_resources  = ARRAY_SIZE(pxa27x_resource_ssp2),
571 };
572
573 static u64 pxa27x_ssp3_dma_mask = DMA_BIT_MASK(32);
574
575 static struct resource pxa27x_resource_ssp3[] = {
576         [0] = {
577                 .start  = 0x41900000,
578                 .end    = 0x4190003f,
579                 .flags  = IORESOURCE_MEM,
580         },
581         [1] = {
582                 .start  = IRQ_SSP3,
583                 .end    = IRQ_SSP3,
584                 .flags  = IORESOURCE_IRQ,
585         },
586 };
587
588 struct platform_device pxa27x_device_ssp3 = {
589         .name           = "pxa27x-ssp",
590         .id             = 2,
591         .dev            = {
592                 .dma_mask = &pxa27x_ssp3_dma_mask,
593                 .coherent_dma_mask = DMA_BIT_MASK(32),
594         },
595         .resource       = pxa27x_resource_ssp3,
596         .num_resources  = ARRAY_SIZE(pxa27x_resource_ssp3),
597 };
598
599 static struct resource pxa27x_resource_pwm0[] = {
600         [0] = {
601                 .start  = 0x40b00000,
602                 .end    = 0x40b0001f,
603                 .flags  = IORESOURCE_MEM,
604         },
605 };
606
607 struct platform_device pxa27x_device_pwm0 = {
608         .name           = "pxa27x-pwm",
609         .id             = 0,
610         .resource       = pxa27x_resource_pwm0,
611         .num_resources  = ARRAY_SIZE(pxa27x_resource_pwm0),
612 };
613
614 static struct resource pxa27x_resource_pwm1[] = {
615         [0] = {
616                 .start  = 0x40c00000,
617                 .end    = 0x40c0001f,
618                 .flags  = IORESOURCE_MEM,
619         },
620 };
621
622 struct platform_device pxa27x_device_pwm1 = {
623         .name           = "pxa27x-pwm",
624         .id             = 1,
625         .resource       = pxa27x_resource_pwm1,
626         .num_resources  = ARRAY_SIZE(pxa27x_resource_pwm1),
627 };
628 #endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
629
630 struct resource pxa_resource_gpio[] = {
631         {
632                 .start  = 0x40e00000,
633                 .end    = 0x40e0ffff,
634                 .flags  = IORESOURCE_MEM,
635         }, {
636                 .start  = IRQ_GPIO0,
637                 .end    = IRQ_GPIO0,
638                 .name   = "gpio0",
639                 .flags  = IORESOURCE_IRQ,
640         }, {
641                 .start  = IRQ_GPIO1,
642                 .end    = IRQ_GPIO1,
643                 .name   = "gpio1",
644                 .flags  = IORESOURCE_IRQ,
645         }, {
646                 .start  = IRQ_GPIO_2_x,
647                 .end    = IRQ_GPIO_2_x,
648                 .name   = "gpio_mux",
649                 .flags  = IORESOURCE_IRQ,
650         },
651 };
652
653 struct platform_device pxa25x_device_gpio = {
654         .name           = "pxa25x-gpio",
655         .id             = -1,
656         .num_resources  = ARRAY_SIZE(pxa_resource_gpio),
657         .resource       = pxa_resource_gpio,
658 };
659
660 struct platform_device pxa27x_device_gpio = {
661         .name           = "pxa27x-gpio",
662         .id             = -1,
663         .num_resources  = ARRAY_SIZE(pxa_resource_gpio),
664         .resource       = pxa_resource_gpio,
665 };
666
667 static struct resource pxa_dma_resource[] = {
668         [0] = {
669                 .start  = 0x40000000,
670                 .end    = 0x4000ffff,
671                 .flags  = IORESOURCE_MEM,
672         },
673         [1] = {
674                 .start  = IRQ_DMA,
675                 .end    = IRQ_DMA,
676                 .flags  = IORESOURCE_IRQ,
677         },
678 };
679
680 static u64 pxadma_dmamask = 0xffffffffUL;
681
682 static struct platform_device pxa2xx_pxa_dma = {
683         .name           = "pxa-dma",
684         .id             = 0,
685         .dev            = {
686                 .dma_mask = &pxadma_dmamask,
687                 .coherent_dma_mask = 0xffffffff,
688         },
689         .num_resources  = ARRAY_SIZE(pxa_dma_resource),
690         .resource       = pxa_dma_resource,
691 };
692
693 void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
694 {
695         pxa_register_device(&pxa2xx_pxa_dma, dma_pdata);
696 }
697
698 void __init pxa_register_wdt(unsigned int reset_status)
699 {
700         struct resource res = DEFINE_RES_MEM(OST_PHYS, OST_LEN);
701
702         reset_status &= RESET_STATUS_WATCHDOG;
703         platform_device_register_resndata(NULL, "sa1100_wdt", -1, &res, 1,
704                                           &reset_status, sizeof(reset_status));
705 }
This page took 0.075774 seconds and 4 git commands to generate.