devices.c 21 KB

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