]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm/mach-omap2/devices.c
mailbox/omap: move the OMAP mailbox framework to drivers
[mirror_ubuntu-artful-kernel.git] / arch / arm / mach-omap2 / devices.c
CommitLineData
1dbae815
TL
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 */
2f8163ba 11#include <linux/gpio.h>
1dbae815
TL
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
fced80c7 15#include <linux/io.h>
917fa280 16#include <linux/clk.h>
f2ce6231 17#include <linux/err.h>
1a5d8190 18#include <linux/slab.h>
ad8dfac6 19#include <linux/of.h>
484202f4 20#include <linux/pinctrl/machine.h>
0f1142a5 21#include <linux/platform_data/omap4-keypad.h>
459bc971 22#include <linux/platform_data/omap_ocp2scp.h>
b8a7cf8e 23#include <linux/platform_data/mailbox-omap.h>
36273356 24#include <linux/usb/omap_control_usb.h>
1dbae815 25
1dbae815
TL
26#include <asm/mach-types.h>
27#include <asm/mach/map.h>
28
45c3eb7d 29#include <linux/omap-dma.h>
2a296c8f 30
ee0839c2 31#include "iomap.h"
2a296c8f 32#include "omap_hwmod.h"
25c7d49e 33#include "omap_device.h"
0e70156d 34#include "omap4-keypad.h"
1dbae815 35
7d7e1eba
TL
36#include "soc.h"
37#include "common.h"
4896e394 38#include "mux.h"
4814ced5 39#include "control.h"
a11f6706 40#include "devices.h"
d5e7c864 41#include "dma.h"
4896e394 42
0abcf618 43#define L3_MODULES_MAX_LEN 12
a4dc616a 44#define L3_MODULES 3
0abcf618 45
46static int __init omap3_l3_init(void)
47{
0abcf618 48 struct omap_hwmod *oh;
3528c58e 49 struct platform_device *pdev;
0abcf618 50 char oh_name[L3_MODULES_MAX_LEN];
51
52 /*
53 * To avoid code running on other OMAPs in
54 * multi-omap builds
55 */
56 if (!(cpu_is_omap34xx()))
57 return -ENODEV;
58
eeb3711b 59 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
0abcf618 60
61 oh = omap_hwmod_lookup(oh_name);
62
63 if (!oh)
64 pr_err("could not look up %s\n", oh_name);
65
c1d1cd59 66 pdev = omap_device_build("omap_l3_smx", 0, oh, NULL, 0);
0abcf618 67
3528c58e 68 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
0abcf618 69
3528c58e 70 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
0abcf618 71}
b76c8b19 72omap_postcore_initcall(omap3_l3_init);
0abcf618 73
a4dc616a 74static int __init omap4_l3_init(void)
75{
eeb3711b 76 int i;
a4dc616a 77 struct omap_hwmod *oh[3];
3528c58e 78 struct platform_device *pdev;
a4dc616a 79 char oh_name[L3_MODULES_MAX_LEN];
80
ad8dfac6
BC
81 /* If dtb is there, the devices will be created dynamically */
82 if (of_have_populated_dt())
83 return -ENODEV;
84
a4dc616a 85 /*
86 * To avoid code running on other OMAPs in
87 * multi-omap builds
88 */
e17933c2 89 if (!cpu_is_omap44xx() && !soc_is_omap54xx())
a4dc616a 90 return -ENODEV;
91
92 for (i = 0; i < L3_MODULES; i++) {
eeb3711b 93 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
a4dc616a 94
95 oh[i] = omap_hwmod_lookup(oh_name);
96 if (!(oh[i]))
97 pr_err("could not look up %s\n", oh_name);
98 }
99
c1d1cd59 100 pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL, 0);
a4dc616a 101
3528c58e 102 WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);
a4dc616a 103
3528c58e 104 return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
a4dc616a 105}
b76c8b19 106omap_postcore_initcall(omap4_l3_init);
a4dc616a 107
828c707e 108#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
c40fae95 109
cfe2cde6 110static struct resource omap2cam_resources[] = {
c40fae95 111 {
828c707e
TL
112 .start = OMAP24XX_CAMERA_BASE,
113 .end = OMAP24XX_CAMERA_BASE + 0xfff,
114 .flags = IORESOURCE_MEM,
115 },
116 {
7d7e1eba 117 .start = 24 + OMAP_INTC_START,
828c707e
TL
118 .flags = IORESOURCE_IRQ,
119 }
120};
121
cfe2cde6 122static struct platform_device omap2cam_device = {
828c707e
TL
123 .name = "omap24xxcam",
124 .id = -1,
cfe2cde6
SA
125 .num_resources = ARRAY_SIZE(omap2cam_resources),
126 .resource = omap2cam_resources,
828c707e 127};
a11f6706 128#endif
828c707e 129
1a51a0ce
OBC
130#if defined(CONFIG_IOMMU_API)
131
2ab7c848 132#include <linux/platform_data/iommu-omap.h>
1a51a0ce 133
828c707e
TL
134static struct resource omap3isp_resources[] = {
135 {
136 .start = OMAP3430_ISP_BASE,
137 .end = OMAP3430_ISP_END,
138 .flags = IORESOURCE_MEM,
139 },
828c707e
TL
140 {
141 .start = OMAP3430_ISP_CCP2_BASE,
142 .end = OMAP3430_ISP_CCP2_END,
143 .flags = IORESOURCE_MEM,
144 },
145 {
146 .start = OMAP3430_ISP_CCDC_BASE,
147 .end = OMAP3430_ISP_CCDC_END,
148 .flags = IORESOURCE_MEM,
149 },
150 {
151 .start = OMAP3430_ISP_HIST_BASE,
152 .end = OMAP3430_ISP_HIST_END,
153 .flags = IORESOURCE_MEM,
154 },
155 {
156 .start = OMAP3430_ISP_H3A_BASE,
157 .end = OMAP3430_ISP_H3A_END,
158 .flags = IORESOURCE_MEM,
159 },
160 {
161 .start = OMAP3430_ISP_PREV_BASE,
162 .end = OMAP3430_ISP_PREV_END,
163 .flags = IORESOURCE_MEM,
164 },
165 {
166 .start = OMAP3430_ISP_RESZ_BASE,
167 .end = OMAP3430_ISP_RESZ_END,
168 .flags = IORESOURCE_MEM,
169 },
170 {
171 .start = OMAP3430_ISP_SBL_BASE,
172 .end = OMAP3430_ISP_SBL_END,
173 .flags = IORESOURCE_MEM,
174 },
175 {
6817a69a
TT
176 .start = OMAP3430_ISP_CSI2A_REGS1_BASE,
177 .end = OMAP3430_ISP_CSI2A_REGS1_END,
828c707e
TL
178 .flags = IORESOURCE_MEM,
179 },
180 {
6817a69a
TT
181 .start = OMAP3430_ISP_CSIPHY2_BASE,
182 .end = OMAP3430_ISP_CSIPHY2_END,
183 .flags = IORESOURCE_MEM,
184 },
185 {
186 .start = OMAP3630_ISP_CSI2A_REGS2_BASE,
187 .end = OMAP3630_ISP_CSI2A_REGS2_END,
828c707e
TL
188 .flags = IORESOURCE_MEM,
189 },
190 {
6817a69a
TT
191 .start = OMAP3630_ISP_CSI2C_REGS1_BASE,
192 .end = OMAP3630_ISP_CSI2C_REGS1_END,
193 .flags = IORESOURCE_MEM,
194 },
195 {
196 .start = OMAP3630_ISP_CSIPHY1_BASE,
197 .end = OMAP3630_ISP_CSIPHY1_END,
198 .flags = IORESOURCE_MEM,
199 },
200 {
201 .start = OMAP3630_ISP_CSI2C_REGS2_BASE,
202 .end = OMAP3630_ISP_CSI2C_REGS2_END,
828c707e
TL
203 .flags = IORESOURCE_MEM,
204 },
c19d19eb
SA
205 {
206 .start = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
207 .end = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
208 .flags = IORESOURCE_MEM,
209 },
210 {
211 .start = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
212 .end = OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
213 .flags = IORESOURCE_MEM,
214 },
828c707e 215 {
7d7e1eba 216 .start = 24 + OMAP_INTC_START,
828c707e
TL
217 .flags = IORESOURCE_IRQ,
218 }
219};
220
221static struct platform_device omap3isp_device = {
222 .name = "omap3isp",
223 .id = -1,
224 .num_resources = ARRAY_SIZE(omap3isp_resources),
225 .resource = omap3isp_resources,
226};
227
c8eaab3b 228static struct omap_iommu_arch_data omap3_isp_iommu = {
72b15b6a 229 .name = "mmu_isp",
c8eaab3b
OBC
230};
231
a11f6706 232int omap3_init_camera(struct isp_platform_data *pdata)
828c707e 233{
a11f6706 234 omap3isp_device.dev.platform_data = pdata;
c8eaab3b
OBC
235 omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
236
a11f6706 237 return platform_device_register(&omap3isp_device);
828c707e 238}
828c707e 239
1a51a0ce
OBC
240#else /* !CONFIG_IOMMU_API */
241
242int omap3_init_camera(struct isp_platform_data *pdata)
243{
244 return 0;
245}
246
247#endif
248
828c707e
TL
249static inline void omap_init_camera(void)
250{
cfe2cde6
SA
251#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
252 if (cpu_is_omap24xx())
253 platform_device_register(&omap2cam_device);
828c707e 254#endif
cfe2cde6 255}
828c707e 256
36273356
KVA
257#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)
258static struct omap_control_usb_platform_data omap4_control_usb_pdata = {
259 .type = 1,
260};
261
262struct resource omap4_control_usb_res[] = {
263 {
264 .name = "control_dev_conf",
265 .start = 0x4a002300,
266 .end = 0x4a002303,
267 .flags = IORESOURCE_MEM,
268 },
269 {
270 .name = "otghs_control",
271 .start = 0x4a00233c,
272 .end = 0x4a00233f,
273 .flags = IORESOURCE_MEM,
274 },
275};
276
277static struct platform_device omap4_control_usb = {
278 .name = "omap-control-usb",
279 .id = -1,
280 .dev = {
281 .platform_data = &omap4_control_usb_pdata,
282 },
283 .num_resources = 2,
284 .resource = omap4_control_usb_res,
285};
286
287static inline void __init omap_init_control_usb(void)
288{
289 if (!cpu_is_omap44xx())
290 return;
291
292 if (platform_device_register(&omap4_control_usb))
293 pr_err("Error registering omap_control_usb device\n");
294}
295
296#else
297static inline void omap_init_control_usb(void) { }
298#endif /* CONFIG_OMAP_CONTROL_USB */
299
59556765 300int __init omap4_keyboard_init(struct omap4_keypad_platform_data
f67df6c6 301 *sdp4430_keypad_data, struct omap_board_data *bdata)
59556765 302{
3528c58e 303 struct platform_device *pdev;
59556765
SR
304 struct omap_hwmod *oh;
305 struct omap4_keypad_platform_data *keypad_data;
306 unsigned int id = -1;
307 char *oh_name = "kbd";
308 char *name = "omap4-keypad";
309
310 oh = omap_hwmod_lookup(oh_name);
311 if (!oh) {
312 pr_err("Could not look up %s\n", oh_name);
313 return -ENODEV;
314 }
315
316 keypad_data = sdp4430_keypad_data;
317
3528c58e 318 pdev = omap_device_build(name, id, oh, keypad_data,
c1d1cd59 319 sizeof(struct omap4_keypad_platform_data));
59556765 320
3528c58e 321 if (IS_ERR(pdev)) {
25985edc 322 WARN(1, "Can't build omap_device for %s:%s.\n",
59556765 323 name, oh->name);
3528c58e 324 return PTR_ERR(pdev);
59556765 325 }
f67df6c6 326 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
59556765
SR
327
328 return 0;
329}
330
c869c75c 331#if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
9cf793f9 332static inline void __init omap_init_mbox(void)
c40fae95 333{
69dbf857 334 struct omap_hwmod *oh;
3528c58e 335 struct platform_device *pdev;
b8a7cf8e 336 struct omap_mbox_pdata *pdata;
69dbf857
FC
337
338 oh = omap_hwmod_lookup("mailbox");
339 if (!oh) {
340 pr_err("%s: unable to find hwmod\n", __func__);
6c20a683
HD
341 return;
342 }
b8a7cf8e
SA
343 if (!oh->dev_attr) {
344 pr_err("%s: hwmod doesn't have valid attrs\n", __func__);
345 return;
346 }
69dbf857 347
b8a7cf8e
SA
348 pdata = (struct omap_mbox_pdata *)oh->dev_attr;
349 pdev = omap_device_build("omap-mailbox", -1, oh, pdata, sizeof(*pdata));
3528c58e
KH
350 WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
351 __func__, PTR_ERR(pdev));
c40fae95
TL
352}
353#else
354static inline void omap_init_mbox(void) { }
c869c75c 355#endif /* CONFIG_OMAP2PLUS_MBOX */
c40fae95 356
9b6553cd 357static inline void omap_init_sti(void) {}
9b6553cd 358
f0fba2ad
LG
359#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
360
361static struct platform_device omap_pcm = {
362 .name = "omap-pcm-audio",
363 .id = -1,
364};
365
f0fba2ad
LG
366static void omap_init_audio(void)
367{
f0fba2ad
LG
368 platform_device_register(&omap_pcm);
369}
370
371#else
372static inline void omap_init_audio(void) {}
373#endif
374
d231f5cb
PU
375#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
376 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
377
9cf793f9 378static void __init omap_init_mcpdm(void)
d231f5cb
PU
379{
380 struct omap_hwmod *oh;
927dbbb2 381 struct platform_device *pdev;
d231f5cb
PU
382
383 oh = omap_hwmod_lookup("mcpdm");
384 if (!oh) {
385 printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
386 return;
387 }
388
c1d1cd59 389 pdev = omap_device_build("omap-mcpdm", -1, oh, NULL, 0);
927dbbb2 390 WARN(IS_ERR(pdev), "Can't build omap_device for omap-mcpdm.\n");
d231f5cb
PU
391}
392#else
393static inline void omap_init_mcpdm(void) {}
394#endif
395
de9eb097
PU
396#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
397 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
398
9cf793f9 399static void __init omap_init_dmic(void)
de9eb097
PU
400{
401 struct omap_hwmod *oh;
402 struct platform_device *pdev;
403
404 oh = omap_hwmod_lookup("dmic");
405 if (!oh) {
49c58e82 406 pr_err("Could not look up dmic hw_mod\n");
de9eb097
PU
407 return;
408 }
409
c1d1cd59 410 pdev = omap_device_build("omap-dmic", -1, oh, NULL, 0);
de9eb097
PU
411 WARN(IS_ERR(pdev), "Can't build omap_device for omap-dmic.\n");
412}
413#else
414static inline void omap_init_dmic(void) {}
415#endif
416
5eeec215
RN
417#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
418 defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
419
420static struct platform_device omap_hdmi_audio = {
421 .name = "omap-hdmi-audio",
422 .id = -1,
423};
424
425static void __init omap_init_hdmi_audio(void)
426{
427 struct omap_hwmod *oh;
428 struct platform_device *pdev;
429
430 oh = omap_hwmod_lookup("dss_hdmi");
431 if (!oh) {
432 printk(KERN_ERR "Could not look up dss_hdmi hw_mod\n");
433 return;
434 }
435
6efc3fe0 436 pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
5eeec215
RN
437 WARN(IS_ERR(pdev),
438 "Can't build omap_device for omap-hdmi-audio-dai.\n");
439
440 platform_device_register(&omap_hdmi_audio);
441}
442#else
443static inline void omap_init_hdmi_audio(void) {}
444#endif
445
646e3ed1 446#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
ed7eb9d9 447
2203747c 448#include <linux/platform_data/spi-omap2-mcspi.h>
ed7eb9d9 449
9cf793f9 450static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
af41a12f 451{
3528c58e 452 struct platform_device *pdev;
1a5d8190
C
453 char *name = "omap2_mcspi";
454 struct omap2_mcspi_platform_config *pdata;
455 static int spi_num;
456 struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
457
458 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
459 if (!pdata) {
460 pr_err("Memory allocation for McSPI device failed\n");
461 return -ENOMEM;
462 }
af41a12f 463
1a5d8190
C
464 pdata->num_cs = mcspi_attrib->num_chipselect;
465 switch (oh->class->rev) {
466 case OMAP2_MCSPI_REV:
467 case OMAP3_MCSPI_REV:
468 pdata->regs_offset = 0;
469 break;
470 case OMAP4_MCSPI_REV:
471 pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
472 break;
473 default:
474 pr_err("Invalid McSPI Revision value\n");
e0feca89 475 kfree(pdata);
1a5d8190
C
476 return -EINVAL;
477 }
af41a12f 478
1a5d8190 479 spi_num++;
c1d1cd59 480 pdev = omap_device_build(name, spi_num, oh, pdata, sizeof(*pdata));
3528c58e 481 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
1a5d8190
C
482 name, oh->name);
483 kfree(pdata);
484 return 0;
af41a12f 485}
af41a12f
TL
486
487static void omap_init_mcspi(void)
488{
1a5d8190 489 omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
ed7eb9d9
JY
490}
491
492#else
493static inline void omap_init_mcspi(void) {}
494#endif
495
4848d460
PW
496/**
497 * omap_init_rng - bind the RNG hwmod to the RNG omap_device
498 *
499 * Bind the RNG hwmod to the RNG omap_device. No return value.
500 */
501static void omap_init_rng(void)
502{
503 struct omap_hwmod *oh;
504 struct platform_device *pdev;
505
506 oh = omap_hwmod_lookup("rng");
507 if (!oh)
508 return;
509
c1d1cd59 510 pdev = omap_device_build("omap_rng", -1, oh, NULL, 0);
4848d460
PW
511 WARN(IS_ERR(pdev), "Can't build omap_device for omap_rng\n");
512}
88341334 513
26f88e6e 514static void __init omap_init_sham(void)
646e3ed1 515{
8c7bb573
MG
516 struct omap_hwmod *oh;
517 struct platform_device *pdev;
518
519 oh = omap_hwmod_lookup("sham");
520 if (!oh)
521 return;
522
523 pdev = omap_device_build("omap-sham", -1, oh, NULL, 0);
524 WARN(IS_ERR(pdev), "Can't build omap_device for omap-sham\n");
646e3ed1 525}
646e3ed1 526
14ae5564 527static void __init omap_init_aes(void)
b744c679 528{
77e2fd84
MG
529 struct omap_hwmod *oh;
530 struct platform_device *pdev;
531
532 oh = omap_hwmod_lookup("aes");
533 if (!oh)
534 return;
535
536 pdev = omap_device_build("omap-aes", -1, oh, NULL, 0);
537 WARN(IS_ERR(pdev), "Can't build omap_device for omap-aes\n");
b744c679
DK
538}
539
d8874665
TL
540/*-------------------------------------------------------------------------*/
541
b227358d
VH
542#if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
543 defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
544#if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
545static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
546};
547#else
548static struct resource omap_vout_resource[2] = {
549};
550#endif
551
552static struct platform_device omap_vout_device = {
553 .name = "omap_vout",
554 .num_resources = ARRAY_SIZE(omap_vout_resource),
555 .resource = &omap_vout_resource[0],
556 .id = -1,
557};
558static void omap_init_vout(void)
559{
560 if (platform_device_register(&omap_vout_device) < 0)
561 printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
562}
563#else
564static inline void omap_init_vout(void) {}
565#endif
566
459bc971
KVA
567#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
568static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
569{
570 int cnt = 0;
571
572 while (ocp2scp_dev->drv_name != NULL) {
573 cnt++;
574 ocp2scp_dev++;
575 }
576
577 return cnt;
578}
579
e407ee09 580static void __init omap_init_ocp2scp(void)
459bc971
KVA
581{
582 struct omap_hwmod *oh;
583 struct platform_device *pdev;
584 int bus_id = -1, dev_cnt = 0, i;
585 struct omap_ocp2scp_dev *ocp2scp_dev;
586 const char *oh_name, *name;
587 struct omap_ocp2scp_platform_data *pdata;
588
589 if (!cpu_is_omap44xx())
590 return;
591
592 oh_name = "ocp2scp_usb_phy";
593 name = "omap-ocp2scp";
594
595 oh = omap_hwmod_lookup(oh_name);
596 if (!oh) {
597 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
598 oh_name);
599 return;
600 }
601
602 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
603 if (!pdata) {
604 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
605 return;
606 }
607
608 ocp2scp_dev = oh->dev_attr;
609 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
610
611 if (!dev_cnt) {
612 pr_err("%s: No devices connected to ocp2scp\n", __func__);
613 kfree(pdata);
614 return;
615 }
616
617 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
618 * dev_cnt, GFP_KERNEL);
619 if (!pdata->devices) {
620 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
621 kfree(pdata);
622 return;
623 }
624
625 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
626 pdata->devices[i] = ocp2scp_dev;
627
628 pdata->dev_cnt = dev_cnt;
629
c1d1cd59 630 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata));
459bc971
KVA
631 if (IS_ERR(pdev)) {
632 pr_err("Could not build omap_device for %s %s\n",
633 name, oh_name);
634 kfree(pdata->devices);
635 kfree(pdata);
636 return;
637 }
638}
639#else
640static inline void omap_init_ocp2scp(void) { }
641#endif
642
1dbae815
TL
643/*-------------------------------------------------------------------------*/
644
645static int __init omap2_init_devices(void)
646{
484202f4
MP
647 /* Enable dummy states for those platforms without pinctrl support */
648 if (!of_have_populated_dt())
649 pinctrl_provide_dummies();
650
81fbc5ef
PW
651 /*
652 * please keep these calls, and their implementations above,
1dbae815
TL
653 * in alphabetical order so they're easier to sort through.
654 */
f0fba2ad 655 omap_init_audio();
828c707e 656 omap_init_camera();
5eeec215 657 omap_init_hdmi_audio();
c40fae95 658 omap_init_mbox();
efcf1e50 659 /* If dtb is there, the devices will be created dynamically */
259bd6ce 660 if (!of_have_populated_dt()) {
36273356 661 omap_init_control_usb();
259bd6ce 662 omap_init_dmic();
4b21ffcf 663 omap_init_mcpdm();
efcf1e50 664 omap_init_mcspi();
114d7a8b 665 omap_init_sham();
53335acc 666 omap_init_aes();
259bd6ce 667 }
9b6553cd 668 omap_init_sti();
4848d460 669 omap_init_rng();
b227358d 670 omap_init_vout();
459bc971 671 omap_init_ocp2scp();
1dbae815
TL
672
673 return 0;
674}
b76c8b19 675omap_arch_initcall(omap2_init_devices);