devices.c 19 KB

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