devices.c 18 KB

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