[media] omap3isp: Add CSI configuration registers from control block to ISP resources
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-omap2 / devices.c
1 /*
2  * linux/arch/arm/mach-omap2/devices.c
3  *
4  * OMAP2 platform device setup/initialization
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11 #include <linux/gpio.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/io.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
18 #include <linux/slab.h>
19 #include <linux/of.h>
20 #include <linux/pinctrl/machine.h>
21 #include <linux/platform_data/omap4-keypad.h>
22 #include <linux/platform_data/omap_ocp2scp.h>
23
24 #include <asm/mach-types.h>
25 #include <asm/mach/map.h>
26
27 #include "iomap.h"
28 #include <plat/dma.h>
29 #include <plat/omap_hwmod.h>
30 #include <plat/omap_device.h>
31 #include "omap4-keypad.h"
32
33 #include "soc.h"
34 #include "common.h"
35 #include "mux.h"
36 #include "control.h"
37 #include "devices.h"
38
39 #define L3_MODULES_MAX_LEN 12
40 #define L3_MODULES 3
41
42 static int __init omap3_l3_init(void)
43 {
44         struct omap_hwmod *oh;
45         struct platform_device *pdev;
46         char oh_name[L3_MODULES_MAX_LEN];
47
48         /*
49          * To avoid code running on other OMAPs in
50          * multi-omap builds
51          */
52         if (!(cpu_is_omap34xx()))
53                 return -ENODEV;
54
55         snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
56
57         oh = omap_hwmod_lookup(oh_name);
58
59         if (!oh)
60                 pr_err("could not look up %s\n", oh_name);
61
62         pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
63                                                            NULL, 0, 0);
64
65         WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
66
67         return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
68 }
69 postcore_initcall(omap3_l3_init);
70
71 static int __init omap4_l3_init(void)
72 {
73         int i;
74         struct omap_hwmod *oh[3];
75         struct platform_device *pdev;
76         char oh_name[L3_MODULES_MAX_LEN];
77
78         /* If dtb is there, the devices will be created dynamically */
79         if (of_have_populated_dt())
80                 return -ENODEV;
81
82         /*
83          * To avoid code running on other OMAPs in
84          * multi-omap builds
85          */
86         if (!cpu_is_omap44xx() && !soc_is_omap54xx())
87                 return -ENODEV;
88
89         for (i = 0; i < L3_MODULES; i++) {
90                 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
91
92                 oh[i] = omap_hwmod_lookup(oh_name);
93                 if (!(oh[i]))
94                         pr_err("could not look up %s\n", oh_name);
95         }
96
97         pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
98                                                      0, NULL, 0, 0);
99
100         WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
101
102         return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
103 }
104 postcore_initcall(omap4_l3_init);
105
106 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
107
108 static struct resource omap2cam_resources[] = {
109         {
110                 .start          = OMAP24XX_CAMERA_BASE,
111                 .end            = OMAP24XX_CAMERA_BASE + 0xfff,
112                 .flags          = IORESOURCE_MEM,
113         },
114         {
115                 .start          = 24 + OMAP_INTC_START,
116                 .flags          = IORESOURCE_IRQ,
117         }
118 };
119
120 static struct platform_device omap2cam_device = {
121         .name           = "omap24xxcam",
122         .id             = -1,
123         .num_resources  = ARRAY_SIZE(omap2cam_resources),
124         .resource       = omap2cam_resources,
125 };
126 #endif
127
128 #if defined(CONFIG_IOMMU_API)
129
130 #include <plat/iommu.h>
131
132 static struct resource omap3isp_resources[] = {
133         {
134                 .start          = OMAP3430_ISP_BASE,
135                 .end            = OMAP3430_ISP_END,
136                 .flags          = IORESOURCE_MEM,
137         },
138         {
139                 .start          = OMAP3430_ISP_CCP2_BASE,
140                 .end            = OMAP3430_ISP_CCP2_END,
141                 .flags          = IORESOURCE_MEM,
142         },
143         {
144                 .start          = OMAP3430_ISP_CCDC_BASE,
145                 .end            = OMAP3430_ISP_CCDC_END,
146                 .flags          = IORESOURCE_MEM,
147         },
148         {
149                 .start          = OMAP3430_ISP_HIST_BASE,
150                 .end            = OMAP3430_ISP_HIST_END,
151                 .flags          = IORESOURCE_MEM,
152         },
153         {
154                 .start          = OMAP3430_ISP_H3A_BASE,
155                 .end            = OMAP3430_ISP_H3A_END,
156                 .flags          = IORESOURCE_MEM,
157         },
158         {
159                 .start          = OMAP3430_ISP_PREV_BASE,
160                 .end            = OMAP3430_ISP_PREV_END,
161                 .flags          = IORESOURCE_MEM,
162         },
163         {
164                 .start          = OMAP3430_ISP_RESZ_BASE,
165                 .end            = OMAP3430_ISP_RESZ_END,
166                 .flags          = IORESOURCE_MEM,
167         },
168         {
169                 .start          = OMAP3430_ISP_SBL_BASE,
170                 .end            = OMAP3430_ISP_SBL_END,
171                 .flags          = IORESOURCE_MEM,
172         },
173         {
174                 .start          = OMAP3430_ISP_CSI2A_REGS1_BASE,
175                 .end            = OMAP3430_ISP_CSI2A_REGS1_END,
176                 .flags          = IORESOURCE_MEM,
177         },
178         {
179                 .start          = OMAP3430_ISP_CSIPHY2_BASE,
180                 .end            = OMAP3430_ISP_CSIPHY2_END,
181                 .flags          = IORESOURCE_MEM,
182         },
183         {
184                 .start          = OMAP3630_ISP_CSI2A_REGS2_BASE,
185                 .end            = OMAP3630_ISP_CSI2A_REGS2_END,
186                 .flags          = IORESOURCE_MEM,
187         },
188         {
189                 .start          = OMAP3630_ISP_CSI2C_REGS1_BASE,
190                 .end            = OMAP3630_ISP_CSI2C_REGS1_END,
191                 .flags          = IORESOURCE_MEM,
192         },
193         {
194                 .start          = OMAP3630_ISP_CSIPHY1_BASE,
195                 .end            = OMAP3630_ISP_CSIPHY1_END,
196                 .flags          = IORESOURCE_MEM,
197         },
198         {
199                 .start          = OMAP3630_ISP_CSI2C_REGS2_BASE,
200                 .end            = OMAP3630_ISP_CSI2C_REGS2_END,
201                 .flags          = IORESOURCE_MEM,
202         },
203         {
204                 .start          = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
205                 .end            = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
206                 .flags          = IORESOURCE_MEM,
207         },
208         {
209                 .start          = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
210                 .end            = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
211                 .flags          = IORESOURCE_MEM,
212         },
213         {
214                 .start          = 24 + OMAP_INTC_START,
215                 .flags          = IORESOURCE_IRQ,
216         }
217 };
218
219 static struct platform_device omap3isp_device = {
220         .name           = "omap3isp",
221         .id             = -1,
222         .num_resources  = ARRAY_SIZE(omap3isp_resources),
223         .resource       = omap3isp_resources,
224 };
225
226 static struct omap_iommu_arch_data omap3_isp_iommu = {
227         .name = "isp",
228 };
229
230 int omap3_init_camera(struct isp_platform_data *pdata)
231 {
232         omap3isp_device.dev.platform_data = pdata;
233         omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
234
235         return platform_device_register(&omap3isp_device);
236 }
237
238 #else /* !CONFIG_IOMMU_API */
239
240 int omap3_init_camera(struct isp_platform_data *pdata)
241 {
242         return 0;
243 }
244
245 #endif
246
247 static inline void omap_init_camera(void)
248 {
249 #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
250         if (cpu_is_omap24xx())
251                 platform_device_register(&omap2cam_device);
252 #endif
253 }
254
255 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
256                         *sdp4430_keypad_data, struct omap_board_data *bdata)
257 {
258         struct platform_device *pdev;
259         struct omap_hwmod *oh;
260         struct omap4_keypad_platform_data *keypad_data;
261         unsigned int id = -1;
262         char *oh_name = "kbd";
263         char *name = "omap4-keypad";
264
265         oh = omap_hwmod_lookup(oh_name);
266         if (!oh) {
267                 pr_err("Could not look up %s\n", oh_name);
268                 return -ENODEV;
269         }
270
271         keypad_data = sdp4430_keypad_data;
272
273         pdev = omap_device_build(name, id, oh, keypad_data,
274                         sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
275
276         if (IS_ERR(pdev)) {
277                 WARN(1, "Can't build omap_device for %s:%s.\n",
278                                                 name, oh->name);
279                 return PTR_ERR(pdev);
280         }
281         oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
282
283         return 0;
284 }
285
286 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
287 static inline void __init omap_init_mbox(void)
288 {
289         struct omap_hwmod *oh;
290         struct platform_device *pdev;
291
292         oh = omap_hwmod_lookup("mailbox");
293         if (!oh) {
294                 pr_err("%s: unable to find hwmod\n", __func__);
295                 return;
296         }
297
298         pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
299         WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
300                                                 __func__, PTR_ERR(pdev));
301 }
302 #else
303 static inline void omap_init_mbox(void) { }
304 #endif /* CONFIG_OMAP_MBOX_FWK */
305
306 static inline void omap_init_sti(void) {}
307
308 #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
309
310 static struct platform_device omap_pcm = {
311         .name   = "omap-pcm-audio",
312         .id     = -1,
313 };
314
315 static void omap_init_audio(void)
316 {
317         platform_device_register(&omap_pcm);
318 }
319
320 #else
321 static inline void omap_init_audio(void) {}
322 #endif
323
324 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
325                 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
326
327 static void __init omap_init_mcpdm(void)
328 {
329         struct omap_hwmod *oh;
330         struct platform_device *pdev;
331
332         oh = omap_hwmod_lookup("mcpdm");
333         if (!oh) {
334                 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
335                 return;
336         }
337
338         pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0, NULL, 0, 0);
339         WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
340 }
341 #else
342 static inline void omap_init_mcpdm(void) {}
343 #endif
344
345 #if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
346                 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
347
348 static void __init omap_init_dmic(void)
349 {
350         struct omap_hwmod *oh;
351         struct platform_device *pdev;
352
353         oh = omap_hwmod_lookup("dmic");
354         if (!oh) {
355                 pr_err("Could not look up dmic hw_mod\n");
356                 return;
357         }
358
359         pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0, NULL, 0, 0);
360         WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
361 }
362 #else
363 static inline void omap_init_dmic(void) {}
364 #endif
365
366 #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
367                 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
368
369 static struct platform_device omap_hdmi_audio = {
370         .name   = "omap-hdmi-audio",
371         .id     = -1,
372 };
373
374 static void __init omap_init_hdmi_audio(void)
375 {
376         struct omap_hwmod *oh;
377         struct platform_device *pdev;
378
379         oh = omap_hwmod_lookup("dss_hdmi");
380         if (!oh) {
381                 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
382                 return;
383         }
384
385         pdev = omap_device_build("omap-hdmi-audio-dai",
386                 -1, oh, NULL, 0, NULL, 0, 0);
387         WARN(IS_ERR(pdev),
388              "Can't build omap_device for omap-hdmi-audio-dai.\n");
389
390         platform_device_register(&omap_hdmi_audio);
391 }
392 #else
393 static inline void omap_init_hdmi_audio(void) {}
394 #endif
395
396 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
397
398 #include <linux/platform_data/spi-omap2-mcspi.h>
399
400 static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
401 {
402         struct platform_device *pdev;
403         char *name = "omap2_mcspi";
404         struct omap2_mcspi_platform_config *pdata;
405         static int spi_num;
406         struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
407
408         pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
409         if (!pdata) {
410                 pr_err("Memory allocation for McSPI device failed\n");
411                 return -ENOMEM;
412         }
413
414         pdata->num_cs = mcspi_attrib->num_chipselect;
415         switch (oh->class->rev) {
416         case OMAP2_MCSPI_REV:
417         case OMAP3_MCSPI_REV:
418                         pdata->regs_offset = 0;
419                         break;
420         case OMAP4_MCSPI_REV:
421                         pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
422                         break;
423         default:
424                         pr_err("Invalid McSPI Revision value\n");
425                         kfree(pdata);
426                         return -EINVAL;
427         }
428
429         spi_num++;
430         pdev = omap_device_build(name, spi_num, oh, pdata,
431                                 sizeof(*pdata), NULL, 0, 0);
432         WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
433                                 name, oh->name);
434         kfree(pdata);
435         return 0;
436 }
437
438 static void omap_init_mcspi(void)
439 {
440         omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
441 }
442
443 #else
444 static inline void omap_init_mcspi(void) {}
445 #endif
446
447 /**
448  * omap_init_rng - bind the RNG hwmod to the RNG omap_device
449  *
450  * Bind the RNG hwmod to the RNG omap_device.  No return value.
451  */
452 static void omap_init_rng(void)
453 {
454         struct omap_hwmod *oh;
455         struct platform_device *pdev;
456
457         oh = omap_hwmod_lookup("rng");
458         if (!oh)
459                 return;
460
461         pdev = omap_device_build("omap_rng", -1, oh, NULL, 0, NULL, 0, 0);
462         WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
463 }
464
465 #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
466
467 #ifdef CONFIG_ARCH_OMAP2
468 static struct resource omap2_sham_resources[] = {
469         {
470                 .start  = OMAP24XX_SEC_SHA1MD5_BASE,
471                 .end    = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
472                 .flags  = IORESOURCE_MEM,
473         },
474         {
475                 .start  = 51 + OMAP_INTC_START,
476                 .flags  = IORESOURCE_IRQ,
477         }
478 };
479 static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
480 #else
481 #define omap2_sham_resources            NULL
482 #define omap2_sham_resources_sz         0
483 #endif
484
485 #ifdef CONFIG_ARCH_OMAP3
486 static struct resource omap3_sham_resources[] = {
487         {
488                 .start  = OMAP34XX_SEC_SHA1MD5_BASE,
489                 .end    = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
490                 .flags  = IORESOURCE_MEM,
491         },
492         {
493                 .start  = 49 + OMAP_INTC_START,
494                 .flags  = IORESOURCE_IRQ,
495         },
496         {
497                 .start  = OMAP34XX_DMA_SHA1MD5_RX,
498                 .flags  = IORESOURCE_DMA,
499         }
500 };
501 static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
502 #else
503 #define omap3_sham_resources            NULL
504 #define omap3_sham_resources_sz         0
505 #endif
506
507 static struct platform_device sham_device = {
508         .name           = "omap-sham",
509         .id             = -1,
510 };
511
512 static void omap_init_sham(void)
513 {
514         if (cpu_is_omap24xx()) {
515                 sham_device.resource = omap2_sham_resources;
516                 sham_device.num_resources = omap2_sham_resources_sz;
517         } else if (cpu_is_omap34xx()) {
518                 sham_device.resource = omap3_sham_resources;
519                 sham_device.num_resources = omap3_sham_resources_sz;
520         } else {
521                 pr_err("%s: platform not supported\n", __func__);
522                 return;
523         }
524         platform_device_register(&sham_device);
525 }
526 #else
527 static inline void omap_init_sham(void) { }
528 #endif
529
530 #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
531
532 #ifdef CONFIG_ARCH_OMAP2
533 static struct resource omap2_aes_resources[] = {
534         {
535                 .start  = OMAP24XX_SEC_AES_BASE,
536                 .end    = OMAP24XX_SEC_AES_BASE + 0x4C,
537                 .flags  = IORESOURCE_MEM,
538         },
539         {
540                 .start  = OMAP24XX_DMA_AES_TX,
541                 .flags  = IORESOURCE_DMA,
542         },
543         {
544                 .start  = OMAP24XX_DMA_AES_RX,
545                 .flags  = IORESOURCE_DMA,
546         }
547 };
548 static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
549 #else
550 #define omap2_aes_resources             NULL
551 #define omap2_aes_resources_sz          0
552 #endif
553
554 #ifdef CONFIG_ARCH_OMAP3
555 static struct resource omap3_aes_resources[] = {
556         {
557                 .start  = OMAP34XX_SEC_AES_BASE,
558                 .end    = OMAP34XX_SEC_AES_BASE + 0x4C,
559                 .flags  = IORESOURCE_MEM,
560         },
561         {
562                 .start  = OMAP34XX_DMA_AES2_TX,
563                 .flags  = IORESOURCE_DMA,
564         },
565         {
566                 .start  = OMAP34XX_DMA_AES2_RX,
567                 .flags  = IORESOURCE_DMA,
568         }
569 };
570 static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
571 #else
572 #define omap3_aes_resources             NULL
573 #define omap3_aes_resources_sz          0
574 #endif
575
576 static struct platform_device aes_device = {
577         .name           = "omap-aes",
578         .id             = -1,
579 };
580
581 static void omap_init_aes(void)
582 {
583         if (cpu_is_omap24xx()) {
584                 aes_device.resource = omap2_aes_resources;
585                 aes_device.num_resources = omap2_aes_resources_sz;
586         } else if (cpu_is_omap34xx()) {
587                 aes_device.resource = omap3_aes_resources;
588                 aes_device.num_resources = omap3_aes_resources_sz;
589         } else {
590                 pr_err("%s: platform not supported\n", __func__);
591                 return;
592         }
593         platform_device_register(&aes_device);
594 }
595
596 #else
597 static inline void omap_init_aes(void) { }
598 #endif
599
600 /*-------------------------------------------------------------------------*/
601
602 #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
603         defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
604 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
605 static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
606 };
607 #else
608 static struct resource omap_vout_resource[2] = {
609 };
610 #endif
611
612 static struct platform_device omap_vout_device = {
613         .name           = "omap_vout",
614         .num_resources  = ARRAY_SIZE(omap_vout_resource),
615         .resource       = &omap_vout_resource[0],
616         .id             = -1,
617 };
618 static void omap_init_vout(void)
619 {
620         if (platform_device_register(&omap_vout_device) < 0)
621                 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
622 }
623 #else
624 static inline void omap_init_vout(void) {}
625 #endif
626
627 #if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
628 static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
629 {
630         int cnt = 0;
631
632         while (ocp2scp_dev->drv_name != NULL) {
633                 cnt++;
634                 ocp2scp_dev++;
635         }
636
637         return cnt;
638 }
639
640 static void omap_init_ocp2scp(void)
641 {
642         struct omap_hwmod       *oh;
643         struct platform_device  *pdev;
644         int                     bus_id = -1, dev_cnt = 0, i;
645         struct omap_ocp2scp_dev *ocp2scp_dev;
646         const char              *oh_name, *name;
647         struct omap_ocp2scp_platform_data *pdata;
648
649         if (!cpu_is_omap44xx())
650                 return;
651
652         oh_name = "ocp2scp_usb_phy";
653         name    = "omap-ocp2scp";
654
655         oh = omap_hwmod_lookup(oh_name);
656         if (!oh) {
657                 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
658                                                                 oh_name);
659                 return;
660         }
661
662         pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
663         if (!pdata) {
664                 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
665                 return;
666         }
667
668         ocp2scp_dev = oh->dev_attr;
669         dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
670
671         if (!dev_cnt) {
672                 pr_err("%s: No devices connected to ocp2scp\n", __func__);
673                 kfree(pdata);
674                 return;
675         }
676
677         pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
678                                         * dev_cnt, GFP_KERNEL);
679         if (!pdata->devices) {
680                 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
681                 kfree(pdata);
682                 return;
683         }
684
685         for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
686                 pdata->devices[i] = ocp2scp_dev;
687
688         pdata->dev_cnt  = dev_cnt;
689
690         pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL,
691                                                                 0, false);
692         if (IS_ERR(pdev)) {
693                 pr_err("Could not build omap_device for %s %s\n",
694                                                 name, oh_name);
695                 kfree(pdata->devices);
696                 kfree(pdata);
697                 return;
698         }
699 }
700 #else
701 static inline void omap_init_ocp2scp(void) { }
702 #endif
703
704 /*-------------------------------------------------------------------------*/
705
706 static int __init omap2_init_devices(void)
707 {
708         /* Enable dummy states for those platforms without pinctrl support */
709         if (!of_have_populated_dt())
710                 pinctrl_provide_dummies();
711
712         /*
713          * please keep these calls, and their implementations above,
714          * in alphabetical order so they're easier to sort through.
715          */
716         omap_init_audio();
717         omap_init_camera();
718         omap_init_hdmi_audio();
719         omap_init_mbox();
720         /* If dtb is there, the devices will be created dynamically */
721         if (!of_have_populated_dt()) {
722                 omap_init_dmic();
723                 omap_init_mcpdm();
724                 omap_init_mcspi();
725         }
726         omap_init_sti();
727         omap_init_rng();
728         omap_init_sham();
729         omap_init_aes();
730         omap_init_vout();
731         omap_init_ocp2scp();
732
733         return 0;
734 }
735 arch_initcall(omap2_init_devices);
736
737 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
738 static int __init omap_init_wdt(void)
739 {
740         int id = -1;
741         struct platform_device *pdev;
742         struct omap_hwmod *oh;
743         char *oh_name = "wd_timer2";
744         char *dev_name = "omap_wdt";
745
746         if (!cpu_class_is_omap2() || of_have_populated_dt())
747                 return 0;
748
749         oh = omap_hwmod_lookup(oh_name);
750         if (!oh) {
751                 pr_err("Could not look up wd_timer%d hwmod\n", id);
752                 return -EINVAL;
753         }
754
755         pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
756         WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
757                                 dev_name, oh->name);
758         return 0;
759 }
760 subsys_initcall(omap_init_wdt);
761 #endif