devices.c 16 KB

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