devices.c 17 KB

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