devices.c 20 KB

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