devices.c 16 KB

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