devices.c 17 KB

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