devices.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  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/module.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 <mach/hardware.h>
  18. #include <asm/mach-types.h>
  19. #include <asm/mach/map.h>
  20. #include <plat/control.h>
  21. #include <plat/tc.h>
  22. #include <plat/board.h>
  23. #include <plat/mux.h>
  24. #include <mach/gpio.h>
  25. #include <plat/mmc.h>
  26. #include "mux.h"
  27. #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
  28. static struct resource cam_resources[] = {
  29. {
  30. .start = OMAP24XX_CAMERA_BASE,
  31. .end = OMAP24XX_CAMERA_BASE + 0xfff,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. {
  35. .start = INT_24XX_CAM_IRQ,
  36. .flags = IORESOURCE_IRQ,
  37. }
  38. };
  39. static struct platform_device omap_cam_device = {
  40. .name = "omap24xxcam",
  41. .id = -1,
  42. .num_resources = ARRAY_SIZE(cam_resources),
  43. .resource = cam_resources,
  44. };
  45. static inline void omap_init_camera(void)
  46. {
  47. platform_device_register(&omap_cam_device);
  48. }
  49. #elif defined(CONFIG_VIDEO_OMAP3) || defined(CONFIG_VIDEO_OMAP3_MODULE)
  50. static struct resource omap3isp_resources[] = {
  51. {
  52. .start = OMAP3430_ISP_BASE,
  53. .end = OMAP3430_ISP_END,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. {
  57. .start = OMAP3430_ISP_CBUFF_BASE,
  58. .end = OMAP3430_ISP_CBUFF_END,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. {
  62. .start = OMAP3430_ISP_CCP2_BASE,
  63. .end = OMAP3430_ISP_CCP2_END,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. {
  67. .start = OMAP3430_ISP_CCDC_BASE,
  68. .end = OMAP3430_ISP_CCDC_END,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. {
  72. .start = OMAP3430_ISP_HIST_BASE,
  73. .end = OMAP3430_ISP_HIST_END,
  74. .flags = IORESOURCE_MEM,
  75. },
  76. {
  77. .start = OMAP3430_ISP_H3A_BASE,
  78. .end = OMAP3430_ISP_H3A_END,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. {
  82. .start = OMAP3430_ISP_PREV_BASE,
  83. .end = OMAP3430_ISP_PREV_END,
  84. .flags = IORESOURCE_MEM,
  85. },
  86. {
  87. .start = OMAP3430_ISP_RESZ_BASE,
  88. .end = OMAP3430_ISP_RESZ_END,
  89. .flags = IORESOURCE_MEM,
  90. },
  91. {
  92. .start = OMAP3430_ISP_SBL_BASE,
  93. .end = OMAP3430_ISP_SBL_END,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. {
  97. .start = OMAP3430_ISP_CSI2A_BASE,
  98. .end = OMAP3430_ISP_CSI2A_END,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. {
  102. .start = OMAP3430_ISP_CSI2PHY_BASE,
  103. .end = OMAP3430_ISP_CSI2PHY_END,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. {
  107. .start = INT_34XX_CAM_IRQ,
  108. .flags = IORESOURCE_IRQ,
  109. }
  110. };
  111. static struct platform_device omap3isp_device = {
  112. .name = "omap3isp",
  113. .id = -1,
  114. .num_resources = ARRAY_SIZE(omap3isp_resources),
  115. .resource = omap3isp_resources,
  116. };
  117. static inline void omap_init_camera(void)
  118. {
  119. platform_device_register(&omap3isp_device);
  120. }
  121. #else
  122. static inline void omap_init_camera(void)
  123. {
  124. }
  125. #endif
  126. #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
  127. #define MBOX_REG_SIZE 0x120
  128. #ifdef CONFIG_ARCH_OMAP2
  129. static struct resource omap2_mbox_resources[] = {
  130. {
  131. .start = OMAP24XX_MAILBOX_BASE,
  132. .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. {
  136. .start = INT_24XX_MAIL_U0_MPU,
  137. .flags = IORESOURCE_IRQ,
  138. },
  139. {
  140. .start = INT_24XX_MAIL_U3_MPU,
  141. .flags = IORESOURCE_IRQ,
  142. },
  143. };
  144. static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
  145. #else
  146. #define omap2_mbox_resources NULL
  147. #define omap2_mbox_resources_sz 0
  148. #endif
  149. #ifdef CONFIG_ARCH_OMAP3
  150. static struct resource omap3_mbox_resources[] = {
  151. {
  152. .start = OMAP34XX_MAILBOX_BASE,
  153. .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
  154. .flags = IORESOURCE_MEM,
  155. },
  156. {
  157. .start = INT_24XX_MAIL_U0_MPU,
  158. .flags = IORESOURCE_IRQ,
  159. },
  160. };
  161. static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
  162. #else
  163. #define omap3_mbox_resources NULL
  164. #define omap3_mbox_resources_sz 0
  165. #endif
  166. #ifdef CONFIG_ARCH_OMAP4
  167. #define OMAP4_MBOX_REG_SIZE 0x130
  168. static struct resource omap4_mbox_resources[] = {
  169. {
  170. .start = OMAP44XX_MAILBOX_BASE,
  171. .end = OMAP44XX_MAILBOX_BASE +
  172. OMAP4_MBOX_REG_SIZE - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. {
  176. .start = OMAP44XX_IRQ_MAIL_U0,
  177. .flags = IORESOURCE_IRQ,
  178. },
  179. };
  180. static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
  181. #else
  182. #define omap4_mbox_resources NULL
  183. #define omap4_mbox_resources_sz 0
  184. #endif
  185. static struct platform_device mbox_device = {
  186. .name = "omap2-mailbox",
  187. .id = -1,
  188. };
  189. static inline void omap_init_mbox(void)
  190. {
  191. if (cpu_is_omap24xx()) {
  192. mbox_device.resource = omap2_mbox_resources;
  193. mbox_device.num_resources = omap2_mbox_resources_sz;
  194. } else if (cpu_is_omap34xx()) {
  195. mbox_device.resource = omap3_mbox_resources;
  196. mbox_device.num_resources = omap3_mbox_resources_sz;
  197. } else if (cpu_is_omap44xx()) {
  198. mbox_device.resource = omap4_mbox_resources;
  199. mbox_device.num_resources = omap4_mbox_resources_sz;
  200. } else {
  201. pr_err("%s: platform not supported\n", __func__);
  202. return;
  203. }
  204. platform_device_register(&mbox_device);
  205. }
  206. #else
  207. static inline void omap_init_mbox(void) { }
  208. #endif /* CONFIG_OMAP_MBOX_FWK */
  209. #if defined(CONFIG_OMAP_STI)
  210. #if defined(CONFIG_ARCH_OMAP2)
  211. #define OMAP2_STI_BASE 0x48068000
  212. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  213. #define OMAP2_STI_IRQ 4
  214. static struct resource sti_resources[] = {
  215. {
  216. .start = OMAP2_STI_BASE,
  217. .end = OMAP2_STI_BASE + 0x7ff,
  218. .flags = IORESOURCE_MEM,
  219. },
  220. {
  221. .start = OMAP2_STI_CHANNEL_BASE,
  222. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  223. .flags = IORESOURCE_MEM,
  224. },
  225. {
  226. .start = OMAP2_STI_IRQ,
  227. .flags = IORESOURCE_IRQ,
  228. }
  229. };
  230. #elif defined(CONFIG_ARCH_OMAP3)
  231. #define OMAP3_SDTI_BASE 0x54500000
  232. #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
  233. static struct resource sti_resources[] = {
  234. {
  235. .start = OMAP3_SDTI_BASE,
  236. .end = OMAP3_SDTI_BASE + 0xFFF,
  237. .flags = IORESOURCE_MEM,
  238. },
  239. {
  240. .start = OMAP3_SDTI_CHANNEL_BASE,
  241. .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
  242. .flags = IORESOURCE_MEM,
  243. }
  244. };
  245. #endif
  246. static struct platform_device sti_device = {
  247. .name = "sti",
  248. .id = -1,
  249. .num_resources = ARRAY_SIZE(sti_resources),
  250. .resource = sti_resources,
  251. };
  252. static inline void omap_init_sti(void)
  253. {
  254. platform_device_register(&sti_device);
  255. }
  256. #else
  257. static inline void omap_init_sti(void) {}
  258. #endif
  259. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  260. #include <plat/mcspi.h>
  261. #define OMAP2_MCSPI1_BASE 0x48098000
  262. #define OMAP2_MCSPI2_BASE 0x4809a000
  263. #define OMAP2_MCSPI3_BASE 0x480b8000
  264. #define OMAP2_MCSPI4_BASE 0x480ba000
  265. #define OMAP4_MCSPI1_BASE 0x48098100
  266. #define OMAP4_MCSPI2_BASE 0x4809a100
  267. #define OMAP4_MCSPI3_BASE 0x480b8100
  268. #define OMAP4_MCSPI4_BASE 0x480ba100
  269. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  270. .num_cs = 4,
  271. };
  272. static struct resource omap2_mcspi1_resources[] = {
  273. {
  274. .start = OMAP2_MCSPI1_BASE,
  275. .end = OMAP2_MCSPI1_BASE + 0xff,
  276. .flags = IORESOURCE_MEM,
  277. },
  278. };
  279. static struct platform_device omap2_mcspi1 = {
  280. .name = "omap2_mcspi",
  281. .id = 1,
  282. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  283. .resource = omap2_mcspi1_resources,
  284. .dev = {
  285. .platform_data = &omap2_mcspi1_config,
  286. },
  287. };
  288. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  289. .num_cs = 2,
  290. };
  291. static struct resource omap2_mcspi2_resources[] = {
  292. {
  293. .start = OMAP2_MCSPI2_BASE,
  294. .end = OMAP2_MCSPI2_BASE + 0xff,
  295. .flags = IORESOURCE_MEM,
  296. },
  297. };
  298. static struct platform_device omap2_mcspi2 = {
  299. .name = "omap2_mcspi",
  300. .id = 2,
  301. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  302. .resource = omap2_mcspi2_resources,
  303. .dev = {
  304. .platform_data = &omap2_mcspi2_config,
  305. },
  306. };
  307. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  308. defined(CONFIG_ARCH_OMAP4)
  309. static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
  310. .num_cs = 2,
  311. };
  312. static struct resource omap2_mcspi3_resources[] = {
  313. {
  314. .start = OMAP2_MCSPI3_BASE,
  315. .end = OMAP2_MCSPI3_BASE + 0xff,
  316. .flags = IORESOURCE_MEM,
  317. },
  318. };
  319. static struct platform_device omap2_mcspi3 = {
  320. .name = "omap2_mcspi",
  321. .id = 3,
  322. .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
  323. .resource = omap2_mcspi3_resources,
  324. .dev = {
  325. .platform_data = &omap2_mcspi3_config,
  326. },
  327. };
  328. #endif
  329. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  330. static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
  331. .num_cs = 1,
  332. };
  333. static struct resource omap2_mcspi4_resources[] = {
  334. {
  335. .start = OMAP2_MCSPI4_BASE,
  336. .end = OMAP2_MCSPI4_BASE + 0xff,
  337. .flags = IORESOURCE_MEM,
  338. },
  339. };
  340. static struct platform_device omap2_mcspi4 = {
  341. .name = "omap2_mcspi",
  342. .id = 4,
  343. .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
  344. .resource = omap2_mcspi4_resources,
  345. .dev = {
  346. .platform_data = &omap2_mcspi4_config,
  347. },
  348. };
  349. #endif
  350. #ifdef CONFIG_ARCH_OMAP4
  351. static inline void omap4_mcspi_fixup(void)
  352. {
  353. omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
  354. omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
  355. omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
  356. omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
  357. omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
  358. omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
  359. omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
  360. omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
  361. }
  362. #else
  363. static inline void omap4_mcspi_fixup(void)
  364. {
  365. }
  366. #endif
  367. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  368. defined(CONFIG_ARCH_OMAP4)
  369. static inline void omap2_mcspi3_init(void)
  370. {
  371. platform_device_register(&omap2_mcspi3);
  372. }
  373. #else
  374. static inline void omap2_mcspi3_init(void)
  375. {
  376. }
  377. #endif
  378. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  379. static inline void omap2_mcspi4_init(void)
  380. {
  381. platform_device_register(&omap2_mcspi4);
  382. }
  383. #else
  384. static inline void omap2_mcspi4_init(void)
  385. {
  386. }
  387. #endif
  388. static void omap_init_mcspi(void)
  389. {
  390. if (cpu_is_omap44xx())
  391. omap4_mcspi_fixup();
  392. platform_device_register(&omap2_mcspi1);
  393. platform_device_register(&omap2_mcspi2);
  394. if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
  395. omap2_mcspi3_init();
  396. if (cpu_is_omap343x() || cpu_is_omap44xx())
  397. omap2_mcspi4_init();
  398. }
  399. #else
  400. static inline void omap_init_mcspi(void) {}
  401. #endif
  402. #ifdef CONFIG_OMAP_SHA1_MD5
  403. static struct resource sha1_md5_resources[] = {
  404. {
  405. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  406. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  407. .flags = IORESOURCE_MEM,
  408. },
  409. {
  410. .start = INT_24XX_SHA1MD5,
  411. .flags = IORESOURCE_IRQ,
  412. }
  413. };
  414. static struct platform_device sha1_md5_device = {
  415. .name = "OMAP SHA1/MD5",
  416. .id = -1,
  417. .num_resources = ARRAY_SIZE(sha1_md5_resources),
  418. .resource = sha1_md5_resources,
  419. };
  420. static void omap_init_sha1_md5(void)
  421. {
  422. platform_device_register(&sha1_md5_device);
  423. }
  424. #else
  425. static inline void omap_init_sha1_md5(void) { }
  426. #endif
  427. /*-------------------------------------------------------------------------*/
  428. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  429. #define MMCHS_SYSCONFIG 0x0010
  430. #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
  431. #define MMCHS_SYSSTATUS 0x0014
  432. #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
  433. static struct platform_device dummy_pdev = {
  434. .dev = {
  435. .bus = &platform_bus_type,
  436. },
  437. };
  438. /**
  439. * omap_hsmmc_reset() - Full reset of each HS-MMC controller
  440. *
  441. * Ensure that each MMC controller is fully reset. Controllers
  442. * left in an unknown state (by bootloader) may prevent retention
  443. * or OFF-mode. This is especially important in cases where the
  444. * MMC driver is not enabled, _or_ built as a module.
  445. *
  446. * In order for reset to work, interface, functional and debounce
  447. * clocks must be enabled. The debounce clock comes from func_32k_clk
  448. * and is not under SW control, so we only enable i- and f-clocks.
  449. **/
  450. static void __init omap_hsmmc_reset(void)
  451. {
  452. u32 i, nr_controllers;
  453. if (cpu_is_omap242x())
  454. return;
  455. nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
  456. (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
  457. for (i = 0; i < nr_controllers; i++) {
  458. u32 v, base = 0;
  459. struct clk *iclk, *fclk;
  460. struct device *dev = &dummy_pdev.dev;
  461. switch (i) {
  462. case 0:
  463. base = OMAP2_MMC1_BASE;
  464. break;
  465. case 1:
  466. base = OMAP2_MMC2_BASE;
  467. break;
  468. case 2:
  469. base = OMAP3_MMC3_BASE;
  470. break;
  471. case 3:
  472. if (!cpu_is_omap44xx())
  473. return;
  474. base = OMAP4_MMC4_BASE;
  475. break;
  476. case 4:
  477. if (!cpu_is_omap44xx())
  478. return;
  479. base = OMAP4_MMC5_BASE;
  480. break;
  481. }
  482. if (cpu_is_omap44xx())
  483. base += OMAP4_MMC_REG_OFFSET;
  484. dummy_pdev.id = i;
  485. dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
  486. iclk = clk_get(dev, "ick");
  487. if (iclk && clk_enable(iclk))
  488. iclk = NULL;
  489. fclk = clk_get(dev, "fck");
  490. if (fclk && clk_enable(fclk))
  491. fclk = NULL;
  492. if (!iclk || !fclk) {
  493. printk(KERN_WARNING
  494. "%s: Unable to enable clocks for MMC%d, "
  495. "cannot reset.\n", __func__, i);
  496. break;
  497. }
  498. omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
  499. v = omap_readl(base + MMCHS_SYSSTATUS);
  500. while (!(omap_readl(base + MMCHS_SYSSTATUS) &
  501. MMCHS_SYSSTATUS_RESETDONE))
  502. cpu_relax();
  503. if (fclk) {
  504. clk_disable(fclk);
  505. clk_put(fclk);
  506. }
  507. if (iclk) {
  508. clk_disable(iclk);
  509. clk_put(iclk);
  510. }
  511. }
  512. }
  513. #else
  514. static inline void omap_hsmmc_reset(void) {}
  515. #endif
  516. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  517. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  518. static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  519. int controller_nr)
  520. {
  521. if (cpu_is_omap2420() && controller_nr == 0) {
  522. omap_cfg_reg(H18_24XX_MMC_CMD);
  523. omap_cfg_reg(H15_24XX_MMC_CLKI);
  524. omap_cfg_reg(G19_24XX_MMC_CLKO);
  525. omap_cfg_reg(F20_24XX_MMC_DAT0);
  526. omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
  527. omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
  528. if (mmc_controller->slots[0].wires == 4) {
  529. omap_cfg_reg(H14_24XX_MMC_DAT1);
  530. omap_cfg_reg(E19_24XX_MMC_DAT2);
  531. omap_cfg_reg(D19_24XX_MMC_DAT3);
  532. omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
  533. omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
  534. omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
  535. }
  536. /*
  537. * Use internal loop-back in MMC/SDIO Module Input Clock
  538. * selection
  539. */
  540. if (mmc_controller->slots[0].internal_clock) {
  541. u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  542. v |= (1 << 24);
  543. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  544. }
  545. }
  546. if (cpu_is_omap34xx()) {
  547. if (controller_nr == 0) {
  548. omap_mux_init_signal("sdmmc1_clk",
  549. OMAP_PIN_INPUT_PULLUP);
  550. omap_mux_init_signal("sdmmc1_cmd",
  551. OMAP_PIN_INPUT_PULLUP);
  552. omap_mux_init_signal("sdmmc1_dat0",
  553. OMAP_PIN_INPUT_PULLUP);
  554. if (mmc_controller->slots[0].wires == 4 ||
  555. mmc_controller->slots[0].wires == 8) {
  556. omap_mux_init_signal("sdmmc1_dat1",
  557. OMAP_PIN_INPUT_PULLUP);
  558. omap_mux_init_signal("sdmmc1_dat2",
  559. OMAP_PIN_INPUT_PULLUP);
  560. omap_mux_init_signal("sdmmc1_dat3",
  561. OMAP_PIN_INPUT_PULLUP);
  562. }
  563. if (mmc_controller->slots[0].wires == 8) {
  564. omap_mux_init_signal("sdmmc1_dat4",
  565. OMAP_PIN_INPUT_PULLUP);
  566. omap_mux_init_signal("sdmmc1_dat5",
  567. OMAP_PIN_INPUT_PULLUP);
  568. omap_mux_init_signal("sdmmc1_dat6",
  569. OMAP_PIN_INPUT_PULLUP);
  570. omap_mux_init_signal("sdmmc1_dat7",
  571. OMAP_PIN_INPUT_PULLUP);
  572. }
  573. }
  574. if (controller_nr == 1) {
  575. /* MMC2 */
  576. omap_mux_init_signal("sdmmc2_clk",
  577. OMAP_PIN_INPUT_PULLUP);
  578. omap_mux_init_signal("sdmmc2_cmd",
  579. OMAP_PIN_INPUT_PULLUP);
  580. omap_mux_init_signal("sdmmc2_dat0",
  581. OMAP_PIN_INPUT_PULLUP);
  582. /*
  583. * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
  584. * in the board-*.c files
  585. */
  586. if (mmc_controller->slots[0].wires == 4 ||
  587. mmc_controller->slots[0].wires == 8) {
  588. omap_mux_init_signal("sdmmc2_dat1",
  589. OMAP_PIN_INPUT_PULLUP);
  590. omap_mux_init_signal("sdmmc2_dat2",
  591. OMAP_PIN_INPUT_PULLUP);
  592. omap_mux_init_signal("sdmmc2_dat3",
  593. OMAP_PIN_INPUT_PULLUP);
  594. }
  595. if (mmc_controller->slots[0].wires == 8) {
  596. omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
  597. OMAP_PIN_INPUT_PULLUP);
  598. omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
  599. OMAP_PIN_INPUT_PULLUP);
  600. omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
  601. OMAP_PIN_INPUT_PULLUP);
  602. omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
  603. OMAP_PIN_INPUT_PULLUP);
  604. }
  605. }
  606. /*
  607. * For MMC3 the pins need to be muxed in the board-*.c files
  608. */
  609. }
  610. }
  611. void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  612. int nr_controllers)
  613. {
  614. int i;
  615. char *name;
  616. for (i = 0; i < nr_controllers; i++) {
  617. unsigned long base, size;
  618. unsigned int irq = 0;
  619. if (!mmc_data[i])
  620. continue;
  621. omap2_mmc_mux(mmc_data[i], i);
  622. switch (i) {
  623. case 0:
  624. base = OMAP2_MMC1_BASE;
  625. irq = INT_24XX_MMC_IRQ;
  626. break;
  627. case 1:
  628. base = OMAP2_MMC2_BASE;
  629. irq = INT_24XX_MMC2_IRQ;
  630. break;
  631. case 2:
  632. if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
  633. return;
  634. base = OMAP3_MMC3_BASE;
  635. irq = INT_34XX_MMC3_IRQ;
  636. break;
  637. case 3:
  638. if (!cpu_is_omap44xx())
  639. return;
  640. base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
  641. irq = OMAP44XX_IRQ_MMC4;
  642. break;
  643. case 4:
  644. if (!cpu_is_omap44xx())
  645. return;
  646. base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
  647. irq = OMAP44XX_IRQ_MMC5;
  648. break;
  649. default:
  650. continue;
  651. }
  652. if (cpu_is_omap2420()) {
  653. size = OMAP2420_MMC_SIZE;
  654. name = "mmci-omap";
  655. } else if (cpu_is_omap44xx()) {
  656. if (i < 3) {
  657. base += OMAP4_MMC_REG_OFFSET;
  658. irq += OMAP44XX_IRQ_GIC_START;
  659. }
  660. size = OMAP4_HSMMC_SIZE;
  661. name = "mmci-omap-hs";
  662. } else {
  663. size = OMAP3_HSMMC_SIZE;
  664. name = "mmci-omap-hs";
  665. }
  666. omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
  667. };
  668. }
  669. #endif
  670. /*-------------------------------------------------------------------------*/
  671. #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
  672. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
  673. #define OMAP_HDQ_BASE 0x480B2000
  674. #endif
  675. static struct resource omap_hdq_resources[] = {
  676. {
  677. .start = OMAP_HDQ_BASE,
  678. .end = OMAP_HDQ_BASE + 0x1C,
  679. .flags = IORESOURCE_MEM,
  680. },
  681. {
  682. .start = INT_24XX_HDQ_IRQ,
  683. .flags = IORESOURCE_IRQ,
  684. },
  685. };
  686. static struct platform_device omap_hdq_dev = {
  687. .name = "omap_hdq",
  688. .id = 0,
  689. .dev = {
  690. .platform_data = NULL,
  691. },
  692. .num_resources = ARRAY_SIZE(omap_hdq_resources),
  693. .resource = omap_hdq_resources,
  694. };
  695. static inline void omap_hdq_init(void)
  696. {
  697. (void) platform_device_register(&omap_hdq_dev);
  698. }
  699. #else
  700. static inline void omap_hdq_init(void) {}
  701. #endif
  702. /*-------------------------------------------------------------------------*/
  703. static int __init omap2_init_devices(void)
  704. {
  705. /* please keep these calls, and their implementations above,
  706. * in alphabetical order so they're easier to sort through.
  707. */
  708. omap_hsmmc_reset();
  709. omap_init_camera();
  710. omap_init_mbox();
  711. omap_init_mcspi();
  712. omap_hdq_init();
  713. omap_init_sti();
  714. omap_init_sha1_md5();
  715. return 0;
  716. }
  717. arch_initcall(omap2_init_devices);