devices.c 17 KB

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