devices.c 21 KB

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