devices.c 17 KB

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