devices.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  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/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/io.h>
  15. #include <linux/clk.h>
  16. #include <linux/err.h>
  17. #include <linux/slab.h>
  18. #include <mach/hardware.h>
  19. #include <mach/irqs.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/pmu.h>
  23. #include <plat/tc.h>
  24. #include <plat/board.h>
  25. #include <plat/mcbsp.h>
  26. #include <mach/gpio.h>
  27. #include <plat/mmc.h>
  28. #include <plat/dma.h>
  29. #include <plat/omap_hwmod.h>
  30. #include <plat/omap_device.h>
  31. #include <plat/omap4-keypad.h>
  32. #include "mux.h"
  33. #include "control.h"
  34. #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
  35. static struct resource cam_resources[] = {
  36. {
  37. .start = OMAP24XX_CAMERA_BASE,
  38. .end = OMAP24XX_CAMERA_BASE + 0xfff,
  39. .flags = IORESOURCE_MEM,
  40. },
  41. {
  42. .start = INT_24XX_CAM_IRQ,
  43. .flags = IORESOURCE_IRQ,
  44. }
  45. };
  46. static struct platform_device omap_cam_device = {
  47. .name = "omap24xxcam",
  48. .id = -1,
  49. .num_resources = ARRAY_SIZE(cam_resources),
  50. .resource = cam_resources,
  51. };
  52. static inline void omap_init_camera(void)
  53. {
  54. platform_device_register(&omap_cam_device);
  55. }
  56. #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
  57. static struct resource omap3isp_resources[] = {
  58. {
  59. .start = OMAP3430_ISP_BASE,
  60. .end = OMAP3430_ISP_END,
  61. .flags = IORESOURCE_MEM,
  62. },
  63. {
  64. .start = OMAP3430_ISP_CBUFF_BASE,
  65. .end = OMAP3430_ISP_CBUFF_END,
  66. .flags = IORESOURCE_MEM,
  67. },
  68. {
  69. .start = OMAP3430_ISP_CCP2_BASE,
  70. .end = OMAP3430_ISP_CCP2_END,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. {
  74. .start = OMAP3430_ISP_CCDC_BASE,
  75. .end = OMAP3430_ISP_CCDC_END,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. {
  79. .start = OMAP3430_ISP_HIST_BASE,
  80. .end = OMAP3430_ISP_HIST_END,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. {
  84. .start = OMAP3430_ISP_H3A_BASE,
  85. .end = OMAP3430_ISP_H3A_END,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. {
  89. .start = OMAP3430_ISP_PREV_BASE,
  90. .end = OMAP3430_ISP_PREV_END,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. {
  94. .start = OMAP3430_ISP_RESZ_BASE,
  95. .end = OMAP3430_ISP_RESZ_END,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. {
  99. .start = OMAP3430_ISP_SBL_BASE,
  100. .end = OMAP3430_ISP_SBL_END,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. {
  104. .start = OMAP3430_ISP_CSI2A_BASE,
  105. .end = OMAP3430_ISP_CSI2A_END,
  106. .flags = IORESOURCE_MEM,
  107. },
  108. {
  109. .start = OMAP3430_ISP_CSI2PHY_BASE,
  110. .end = OMAP3430_ISP_CSI2PHY_END,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. {
  114. .start = INT_34XX_CAM_IRQ,
  115. .flags = IORESOURCE_IRQ,
  116. }
  117. };
  118. static struct platform_device omap3isp_device = {
  119. .name = "omap3isp",
  120. .id = -1,
  121. .num_resources = ARRAY_SIZE(omap3isp_resources),
  122. .resource = omap3isp_resources,
  123. };
  124. static inline void omap_init_camera(void)
  125. {
  126. platform_device_register(&omap3isp_device);
  127. }
  128. #else
  129. static inline void omap_init_camera(void)
  130. {
  131. }
  132. #endif
  133. struct omap_device_pm_latency omap_keyboard_latency[] = {
  134. {
  135. .deactivate_func = omap_device_idle_hwmods,
  136. .activate_func = omap_device_enable_hwmods,
  137. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  138. },
  139. };
  140. int __init omap4_keyboard_init(struct omap4_keypad_platform_data
  141. *sdp4430_keypad_data)
  142. {
  143. struct omap_device *od;
  144. struct omap_hwmod *oh;
  145. struct omap4_keypad_platform_data *keypad_data;
  146. unsigned int id = -1;
  147. char *oh_name = "kbd";
  148. char *name = "omap4-keypad";
  149. oh = omap_hwmod_lookup(oh_name);
  150. if (!oh) {
  151. pr_err("Could not look up %s\n", oh_name);
  152. return -ENODEV;
  153. }
  154. keypad_data = sdp4430_keypad_data;
  155. od = omap_device_build(name, id, oh, keypad_data,
  156. sizeof(struct omap4_keypad_platform_data),
  157. omap_keyboard_latency,
  158. ARRAY_SIZE(omap_keyboard_latency), 0);
  159. if (IS_ERR(od)) {
  160. WARN(1, "Cant build omap_device for %s:%s.\n",
  161. name, oh->name);
  162. return PTR_ERR(od);
  163. }
  164. return 0;
  165. }
  166. #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
  167. #define MBOX_REG_SIZE 0x120
  168. #ifdef CONFIG_ARCH_OMAP2
  169. static struct resource omap2_mbox_resources[] = {
  170. {
  171. .start = OMAP24XX_MAILBOX_BASE,
  172. .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. {
  176. .start = INT_24XX_MAIL_U0_MPU,
  177. .flags = IORESOURCE_IRQ,
  178. .name = "dsp",
  179. },
  180. {
  181. .start = INT_24XX_MAIL_U3_MPU,
  182. .flags = IORESOURCE_IRQ,
  183. .name = "iva",
  184. },
  185. };
  186. static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
  187. #else
  188. #define omap2_mbox_resources NULL
  189. #define omap2_mbox_resources_sz 0
  190. #endif
  191. #ifdef CONFIG_ARCH_OMAP3
  192. static struct resource omap3_mbox_resources[] = {
  193. {
  194. .start = OMAP34XX_MAILBOX_BASE,
  195. .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
  196. .flags = IORESOURCE_MEM,
  197. },
  198. {
  199. .start = INT_24XX_MAIL_U0_MPU,
  200. .flags = IORESOURCE_IRQ,
  201. .name = "dsp",
  202. },
  203. };
  204. static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
  205. #else
  206. #define omap3_mbox_resources NULL
  207. #define omap3_mbox_resources_sz 0
  208. #endif
  209. #ifdef CONFIG_ARCH_OMAP4
  210. #define OMAP4_MBOX_REG_SIZE 0x130
  211. static struct resource omap4_mbox_resources[] = {
  212. {
  213. .start = OMAP44XX_MAILBOX_BASE,
  214. .end = OMAP44XX_MAILBOX_BASE +
  215. OMAP4_MBOX_REG_SIZE - 1,
  216. .flags = IORESOURCE_MEM,
  217. },
  218. {
  219. .start = OMAP44XX_IRQ_MAIL_U0,
  220. .flags = IORESOURCE_IRQ,
  221. .name = "mbox",
  222. },
  223. };
  224. static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
  225. #else
  226. #define omap4_mbox_resources NULL
  227. #define omap4_mbox_resources_sz 0
  228. #endif
  229. static struct platform_device mbox_device = {
  230. .name = "omap-mailbox",
  231. .id = -1,
  232. };
  233. static inline void omap_init_mbox(void)
  234. {
  235. if (cpu_is_omap24xx()) {
  236. mbox_device.resource = omap2_mbox_resources;
  237. mbox_device.num_resources = omap2_mbox_resources_sz;
  238. } else if (cpu_is_omap34xx()) {
  239. mbox_device.resource = omap3_mbox_resources;
  240. mbox_device.num_resources = omap3_mbox_resources_sz;
  241. } else if (cpu_is_omap44xx()) {
  242. mbox_device.resource = omap4_mbox_resources;
  243. mbox_device.num_resources = omap4_mbox_resources_sz;
  244. } else {
  245. pr_err("%s: platform not supported\n", __func__);
  246. return;
  247. }
  248. platform_device_register(&mbox_device);
  249. }
  250. #else
  251. static inline void omap_init_mbox(void) { }
  252. #endif /* CONFIG_OMAP_MBOX_FWK */
  253. static inline void omap_init_sti(void) {}
  254. #if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
  255. static struct platform_device omap_pcm = {
  256. .name = "omap-pcm-audio",
  257. .id = -1,
  258. };
  259. /*
  260. * OMAP2420 has 2 McBSP ports
  261. * OMAP2430 has 5 McBSP ports
  262. * OMAP3 has 5 McBSP ports
  263. * OMAP4 has 4 McBSP ports
  264. */
  265. OMAP_MCBSP_PLATFORM_DEVICE(1);
  266. OMAP_MCBSP_PLATFORM_DEVICE(2);
  267. OMAP_MCBSP_PLATFORM_DEVICE(3);
  268. OMAP_MCBSP_PLATFORM_DEVICE(4);
  269. OMAP_MCBSP_PLATFORM_DEVICE(5);
  270. static void omap_init_audio(void)
  271. {
  272. platform_device_register(&omap_mcbsp1);
  273. platform_device_register(&omap_mcbsp2);
  274. if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
  275. platform_device_register(&omap_mcbsp3);
  276. platform_device_register(&omap_mcbsp4);
  277. }
  278. if (cpu_is_omap243x() || cpu_is_omap34xx())
  279. platform_device_register(&omap_mcbsp5);
  280. platform_device_register(&omap_pcm);
  281. }
  282. #else
  283. static inline void omap_init_audio(void) {}
  284. #endif
  285. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  286. #include <plat/mcspi.h>
  287. struct omap_device_pm_latency omap_mcspi_latency[] = {
  288. [0] = {
  289. .deactivate_func = omap_device_idle_hwmods,
  290. .activate_func = omap_device_enable_hwmods,
  291. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  292. },
  293. };
  294. static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
  295. {
  296. struct omap_device *od;
  297. char *name = "omap2_mcspi";
  298. struct omap2_mcspi_platform_config *pdata;
  299. static int spi_num;
  300. struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
  301. pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
  302. if (!pdata) {
  303. pr_err("Memory allocation for McSPI device failed\n");
  304. return -ENOMEM;
  305. }
  306. pdata->num_cs = mcspi_attrib->num_chipselect;
  307. switch (oh->class->rev) {
  308. case OMAP2_MCSPI_REV:
  309. case OMAP3_MCSPI_REV:
  310. pdata->regs_offset = 0;
  311. break;
  312. case OMAP4_MCSPI_REV:
  313. pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
  314. break;
  315. default:
  316. pr_err("Invalid McSPI Revision value\n");
  317. return -EINVAL;
  318. }
  319. spi_num++;
  320. od = omap_device_build(name, spi_num, oh, pdata,
  321. sizeof(*pdata), omap_mcspi_latency,
  322. ARRAY_SIZE(omap_mcspi_latency), 0);
  323. WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n",
  324. name, oh->name);
  325. kfree(pdata);
  326. return 0;
  327. }
  328. static void omap_init_mcspi(void)
  329. {
  330. omap_hwmod_for_each_by_class("mcspi", omap_mcspi_init, NULL);
  331. }
  332. #else
  333. static inline void omap_init_mcspi(void) {}
  334. #endif
  335. static struct resource omap2_pmu_resource = {
  336. .start = 3,
  337. .end = 3,
  338. .flags = IORESOURCE_IRQ,
  339. };
  340. static struct resource omap3_pmu_resource = {
  341. .start = INT_34XX_BENCH_MPU_EMUL,
  342. .end = INT_34XX_BENCH_MPU_EMUL,
  343. .flags = IORESOURCE_IRQ,
  344. };
  345. static struct platform_device omap_pmu_device = {
  346. .name = "arm-pmu",
  347. .id = ARM_PMU_DEVICE_CPU,
  348. .num_resources = 1,
  349. };
  350. static void omap_init_pmu(void)
  351. {
  352. if (cpu_is_omap24xx())
  353. omap_pmu_device.resource = &omap2_pmu_resource;
  354. else if (cpu_is_omap34xx())
  355. omap_pmu_device.resource = &omap3_pmu_resource;
  356. else
  357. return;
  358. platform_device_register(&omap_pmu_device);
  359. }
  360. #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
  361. #ifdef CONFIG_ARCH_OMAP2
  362. static struct resource omap2_sham_resources[] = {
  363. {
  364. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  365. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  366. .flags = IORESOURCE_MEM,
  367. },
  368. {
  369. .start = INT_24XX_SHA1MD5,
  370. .flags = IORESOURCE_IRQ,
  371. }
  372. };
  373. static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
  374. #else
  375. #define omap2_sham_resources NULL
  376. #define omap2_sham_resources_sz 0
  377. #endif
  378. #ifdef CONFIG_ARCH_OMAP3
  379. static struct resource omap3_sham_resources[] = {
  380. {
  381. .start = OMAP34XX_SEC_SHA1MD5_BASE,
  382. .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. {
  386. .start = INT_34XX_SHA1MD52_IRQ,
  387. .flags = IORESOURCE_IRQ,
  388. },
  389. {
  390. .start = OMAP34XX_DMA_SHA1MD5_RX,
  391. .flags = IORESOURCE_DMA,
  392. }
  393. };
  394. static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
  395. #else
  396. #define omap3_sham_resources NULL
  397. #define omap3_sham_resources_sz 0
  398. #endif
  399. static struct platform_device sham_device = {
  400. .name = "omap-sham",
  401. .id = -1,
  402. };
  403. static void omap_init_sham(void)
  404. {
  405. if (cpu_is_omap24xx()) {
  406. sham_device.resource = omap2_sham_resources;
  407. sham_device.num_resources = omap2_sham_resources_sz;
  408. } else if (cpu_is_omap34xx()) {
  409. sham_device.resource = omap3_sham_resources;
  410. sham_device.num_resources = omap3_sham_resources_sz;
  411. } else {
  412. pr_err("%s: platform not supported\n", __func__);
  413. return;
  414. }
  415. platform_device_register(&sham_device);
  416. }
  417. #else
  418. static inline void omap_init_sham(void) { }
  419. #endif
  420. #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
  421. #ifdef CONFIG_ARCH_OMAP2
  422. static struct resource omap2_aes_resources[] = {
  423. {
  424. .start = OMAP24XX_SEC_AES_BASE,
  425. .end = OMAP24XX_SEC_AES_BASE + 0x4C,
  426. .flags = IORESOURCE_MEM,
  427. },
  428. {
  429. .start = OMAP24XX_DMA_AES_TX,
  430. .flags = IORESOURCE_DMA,
  431. },
  432. {
  433. .start = OMAP24XX_DMA_AES_RX,
  434. .flags = IORESOURCE_DMA,
  435. }
  436. };
  437. static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
  438. #else
  439. #define omap2_aes_resources NULL
  440. #define omap2_aes_resources_sz 0
  441. #endif
  442. #ifdef CONFIG_ARCH_OMAP3
  443. static struct resource omap3_aes_resources[] = {
  444. {
  445. .start = OMAP34XX_SEC_AES_BASE,
  446. .end = OMAP34XX_SEC_AES_BASE + 0x4C,
  447. .flags = IORESOURCE_MEM,
  448. },
  449. {
  450. .start = OMAP34XX_DMA_AES2_TX,
  451. .flags = IORESOURCE_DMA,
  452. },
  453. {
  454. .start = OMAP34XX_DMA_AES2_RX,
  455. .flags = IORESOURCE_DMA,
  456. }
  457. };
  458. static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
  459. #else
  460. #define omap3_aes_resources NULL
  461. #define omap3_aes_resources_sz 0
  462. #endif
  463. static struct platform_device aes_device = {
  464. .name = "omap-aes",
  465. .id = -1,
  466. };
  467. static void omap_init_aes(void)
  468. {
  469. if (cpu_is_omap24xx()) {
  470. aes_device.resource = omap2_aes_resources;
  471. aes_device.num_resources = omap2_aes_resources_sz;
  472. } else if (cpu_is_omap34xx()) {
  473. aes_device.resource = omap3_aes_resources;
  474. aes_device.num_resources = omap3_aes_resources_sz;
  475. } else {
  476. pr_err("%s: platform not supported\n", __func__);
  477. return;
  478. }
  479. platform_device_register(&aes_device);
  480. }
  481. #else
  482. static inline void omap_init_aes(void) { }
  483. #endif
  484. /*-------------------------------------------------------------------------*/
  485. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  486. #define MMCHS_SYSCONFIG 0x0010
  487. #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
  488. #define MMCHS_SYSSTATUS 0x0014
  489. #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
  490. static struct platform_device dummy_pdev = {
  491. .dev = {
  492. .bus = &platform_bus_type,
  493. },
  494. };
  495. /**
  496. * omap_hsmmc_reset() - Full reset of each HS-MMC controller
  497. *
  498. * Ensure that each MMC controller is fully reset. Controllers
  499. * left in an unknown state (by bootloader) may prevent retention
  500. * or OFF-mode. This is especially important in cases where the
  501. * MMC driver is not enabled, _or_ built as a module.
  502. *
  503. * In order for reset to work, interface, functional and debounce
  504. * clocks must be enabled. The debounce clock comes from func_32k_clk
  505. * and is not under SW control, so we only enable i- and f-clocks.
  506. **/
  507. static void __init omap_hsmmc_reset(void)
  508. {
  509. u32 i, nr_controllers;
  510. struct clk *iclk, *fclk;
  511. if (cpu_is_omap242x())
  512. return;
  513. nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
  514. (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
  515. for (i = 0; i < nr_controllers; i++) {
  516. u32 v, base = 0;
  517. struct device *dev = &dummy_pdev.dev;
  518. switch (i) {
  519. case 0:
  520. base = OMAP2_MMC1_BASE;
  521. break;
  522. case 1:
  523. base = OMAP2_MMC2_BASE;
  524. break;
  525. case 2:
  526. base = OMAP3_MMC3_BASE;
  527. break;
  528. case 3:
  529. if (!cpu_is_omap44xx())
  530. return;
  531. base = OMAP4_MMC4_BASE;
  532. break;
  533. case 4:
  534. if (!cpu_is_omap44xx())
  535. return;
  536. base = OMAP4_MMC5_BASE;
  537. break;
  538. }
  539. if (cpu_is_omap44xx())
  540. base += OMAP4_MMC_REG_OFFSET;
  541. dummy_pdev.id = i;
  542. dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
  543. iclk = clk_get(dev, "ick");
  544. if (IS_ERR(iclk))
  545. goto err1;
  546. if (clk_enable(iclk))
  547. goto err2;
  548. fclk = clk_get(dev, "fck");
  549. if (IS_ERR(fclk))
  550. goto err3;
  551. if (clk_enable(fclk))
  552. goto err4;
  553. omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
  554. v = omap_readl(base + MMCHS_SYSSTATUS);
  555. while (!(omap_readl(base + MMCHS_SYSSTATUS) &
  556. MMCHS_SYSSTATUS_RESETDONE))
  557. cpu_relax();
  558. clk_disable(fclk);
  559. clk_put(fclk);
  560. clk_disable(iclk);
  561. clk_put(iclk);
  562. }
  563. return;
  564. err4:
  565. clk_put(fclk);
  566. err3:
  567. clk_disable(iclk);
  568. err2:
  569. clk_put(iclk);
  570. err1:
  571. printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
  572. "cannot reset.\n", __func__, i);
  573. }
  574. #else
  575. static inline void omap_hsmmc_reset(void) {}
  576. #endif
  577. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  578. static inline void omap242x_mmc_mux(struct omap_mmc_platform_data
  579. *mmc_controller)
  580. {
  581. if ((mmc_controller->slots[0].switch_pin > 0) && \
  582. (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
  583. omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
  584. OMAP_PIN_INPUT_PULLUP);
  585. if ((mmc_controller->slots[0].gpio_wp > 0) && \
  586. (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
  587. omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
  588. OMAP_PIN_INPUT_PULLUP);
  589. omap_mux_init_signal("sdmmc_cmd", 0);
  590. omap_mux_init_signal("sdmmc_clki", 0);
  591. omap_mux_init_signal("sdmmc_clko", 0);
  592. omap_mux_init_signal("sdmmc_dat0", 0);
  593. omap_mux_init_signal("sdmmc_dat_dir0", 0);
  594. omap_mux_init_signal("sdmmc_cmd_dir", 0);
  595. if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
  596. omap_mux_init_signal("sdmmc_dat1", 0);
  597. omap_mux_init_signal("sdmmc_dat2", 0);
  598. omap_mux_init_signal("sdmmc_dat3", 0);
  599. omap_mux_init_signal("sdmmc_dat_dir1", 0);
  600. omap_mux_init_signal("sdmmc_dat_dir2", 0);
  601. omap_mux_init_signal("sdmmc_dat_dir3", 0);
  602. }
  603. /*
  604. * Use internal loop-back in MMC/SDIO Module Input Clock
  605. * selection
  606. */
  607. if (mmc_controller->slots[0].internal_clock) {
  608. u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  609. v |= (1 << 24);
  610. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  611. }
  612. }
  613. void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
  614. {
  615. char *name = "mmci-omap";
  616. if (!mmc_data[0]) {
  617. pr_err("%s fails: Incomplete platform data\n", __func__);
  618. return;
  619. }
  620. omap242x_mmc_mux(mmc_data[0]);
  621. omap_mmc_add(name, 0, OMAP2_MMC1_BASE, OMAP2420_MMC_SIZE,
  622. INT_24XX_MMC_IRQ, mmc_data[0]);
  623. }
  624. #endif
  625. #if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  626. void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  627. int nr_controllers)
  628. {
  629. int i;
  630. char *name;
  631. for (i = 0; i < nr_controllers; i++) {
  632. unsigned long base, size;
  633. unsigned int irq = 0;
  634. if (!mmc_data[i])
  635. continue;
  636. switch (i) {
  637. case 0:
  638. base = OMAP2_MMC1_BASE;
  639. irq = INT_24XX_MMC_IRQ;
  640. break;
  641. case 1:
  642. base = OMAP2_MMC2_BASE;
  643. irq = INT_24XX_MMC2_IRQ;
  644. break;
  645. case 2:
  646. if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
  647. return;
  648. base = OMAP3_MMC3_BASE;
  649. irq = INT_34XX_MMC3_IRQ;
  650. break;
  651. case 3:
  652. if (!cpu_is_omap44xx())
  653. return;
  654. base = OMAP4_MMC4_BASE;
  655. irq = OMAP44XX_IRQ_MMC4;
  656. break;
  657. case 4:
  658. if (!cpu_is_omap44xx())
  659. return;
  660. base = OMAP4_MMC5_BASE;
  661. irq = OMAP44XX_IRQ_MMC5;
  662. break;
  663. default:
  664. continue;
  665. }
  666. if (cpu_is_omap44xx()) {
  667. if (i < 3)
  668. irq += OMAP44XX_IRQ_GIC_START;
  669. size = OMAP4_HSMMC_SIZE;
  670. name = "mmci-omap-hs";
  671. } else {
  672. size = OMAP3_HSMMC_SIZE;
  673. name = "mmci-omap-hs";
  674. }
  675. omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
  676. };
  677. }
  678. #endif
  679. /*-------------------------------------------------------------------------*/
  680. #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
  681. #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
  682. #define OMAP_HDQ_BASE 0x480B2000
  683. #endif
  684. static struct resource omap_hdq_resources[] = {
  685. {
  686. .start = OMAP_HDQ_BASE,
  687. .end = OMAP_HDQ_BASE + 0x1C,
  688. .flags = IORESOURCE_MEM,
  689. },
  690. {
  691. .start = INT_24XX_HDQ_IRQ,
  692. .flags = IORESOURCE_IRQ,
  693. },
  694. };
  695. static struct platform_device omap_hdq_dev = {
  696. .name = "omap_hdq",
  697. .id = 0,
  698. .dev = {
  699. .platform_data = NULL,
  700. },
  701. .num_resources = ARRAY_SIZE(omap_hdq_resources),
  702. .resource = omap_hdq_resources,
  703. };
  704. static inline void omap_hdq_init(void)
  705. {
  706. (void) platform_device_register(&omap_hdq_dev);
  707. }
  708. #else
  709. static inline void omap_hdq_init(void) {}
  710. #endif
  711. /*---------------------------------------------------------------------------*/
  712. #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
  713. defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
  714. #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
  715. static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
  716. };
  717. #else
  718. static struct resource omap_vout_resource[2] = {
  719. };
  720. #endif
  721. static struct platform_device omap_vout_device = {
  722. .name = "omap_vout",
  723. .num_resources = ARRAY_SIZE(omap_vout_resource),
  724. .resource = &omap_vout_resource[0],
  725. .id = -1,
  726. };
  727. static void omap_init_vout(void)
  728. {
  729. if (platform_device_register(&omap_vout_device) < 0)
  730. printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
  731. }
  732. #else
  733. static inline void omap_init_vout(void) {}
  734. #endif
  735. /*-------------------------------------------------------------------------*/
  736. static int __init omap2_init_devices(void)
  737. {
  738. /*
  739. * please keep these calls, and their implementations above,
  740. * in alphabetical order so they're easier to sort through.
  741. */
  742. omap_hsmmc_reset();
  743. omap_init_audio();
  744. omap_init_camera();
  745. omap_init_mbox();
  746. omap_init_mcspi();
  747. omap_init_pmu();
  748. omap_hdq_init();
  749. omap_init_sti();
  750. omap_init_sham();
  751. omap_init_aes();
  752. omap_init_vout();
  753. return 0;
  754. }
  755. arch_initcall(omap2_init_devices);
  756. #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
  757. static struct omap_device_pm_latency omap_wdt_latency[] = {
  758. [0] = {
  759. .deactivate_func = omap_device_idle_hwmods,
  760. .activate_func = omap_device_enable_hwmods,
  761. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  762. },
  763. };
  764. static int __init omap_init_wdt(void)
  765. {
  766. int id = -1;
  767. struct omap_device *od;
  768. struct omap_hwmod *oh;
  769. char *oh_name = "wd_timer2";
  770. char *dev_name = "omap_wdt";
  771. if (!cpu_class_is_omap2())
  772. return 0;
  773. oh = omap_hwmod_lookup(oh_name);
  774. if (!oh) {
  775. pr_err("Could not look up wd_timer%d hwmod\n", id);
  776. return -EINVAL;
  777. }
  778. od = omap_device_build(dev_name, id, oh, NULL, 0,
  779. omap_wdt_latency,
  780. ARRAY_SIZE(omap_wdt_latency), 0);
  781. WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
  782. dev_name, oh->name);
  783. return 0;
  784. }
  785. subsys_initcall(omap_init_wdt);
  786. #endif