devices.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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/mux.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 = "omap2-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. #if defined(CONFIG_OMAP_STI)
  217. #if defined(CONFIG_ARCH_OMAP2)
  218. #define OMAP2_STI_BASE 0x48068000
  219. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  220. #define OMAP2_STI_IRQ 4
  221. static struct resource sti_resources[] = {
  222. {
  223. .start = OMAP2_STI_BASE,
  224. .end = OMAP2_STI_BASE + 0x7ff,
  225. .flags = IORESOURCE_MEM,
  226. },
  227. {
  228. .start = OMAP2_STI_CHANNEL_BASE,
  229. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. {
  233. .start = OMAP2_STI_IRQ,
  234. .flags = IORESOURCE_IRQ,
  235. }
  236. };
  237. #elif defined(CONFIG_ARCH_OMAP3)
  238. #define OMAP3_SDTI_BASE 0x54500000
  239. #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
  240. static struct resource sti_resources[] = {
  241. {
  242. .start = OMAP3_SDTI_BASE,
  243. .end = OMAP3_SDTI_BASE + 0xFFF,
  244. .flags = IORESOURCE_MEM,
  245. },
  246. {
  247. .start = OMAP3_SDTI_CHANNEL_BASE,
  248. .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
  249. .flags = IORESOURCE_MEM,
  250. }
  251. };
  252. #endif
  253. static struct platform_device sti_device = {
  254. .name = "sti",
  255. .id = -1,
  256. .num_resources = ARRAY_SIZE(sti_resources),
  257. .resource = sti_resources,
  258. };
  259. static inline void omap_init_sti(void)
  260. {
  261. platform_device_register(&sti_device);
  262. }
  263. #else
  264. static inline void omap_init_sti(void) {}
  265. #endif
  266. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  267. #include <plat/mcspi.h>
  268. #define OMAP2_MCSPI1_BASE 0x48098000
  269. #define OMAP2_MCSPI2_BASE 0x4809a000
  270. #define OMAP2_MCSPI3_BASE 0x480b8000
  271. #define OMAP2_MCSPI4_BASE 0x480ba000
  272. #define OMAP4_MCSPI1_BASE 0x48098100
  273. #define OMAP4_MCSPI2_BASE 0x4809a100
  274. #define OMAP4_MCSPI3_BASE 0x480b8100
  275. #define OMAP4_MCSPI4_BASE 0x480ba100
  276. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  277. .num_cs = 4,
  278. };
  279. static struct resource omap2_mcspi1_resources[] = {
  280. {
  281. .start = OMAP2_MCSPI1_BASE,
  282. .end = OMAP2_MCSPI1_BASE + 0xff,
  283. .flags = IORESOURCE_MEM,
  284. },
  285. };
  286. static struct platform_device omap2_mcspi1 = {
  287. .name = "omap2_mcspi",
  288. .id = 1,
  289. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  290. .resource = omap2_mcspi1_resources,
  291. .dev = {
  292. .platform_data = &omap2_mcspi1_config,
  293. },
  294. };
  295. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  296. .num_cs = 2,
  297. };
  298. static struct resource omap2_mcspi2_resources[] = {
  299. {
  300. .start = OMAP2_MCSPI2_BASE,
  301. .end = OMAP2_MCSPI2_BASE + 0xff,
  302. .flags = IORESOURCE_MEM,
  303. },
  304. };
  305. static struct platform_device omap2_mcspi2 = {
  306. .name = "omap2_mcspi",
  307. .id = 2,
  308. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  309. .resource = omap2_mcspi2_resources,
  310. .dev = {
  311. .platform_data = &omap2_mcspi2_config,
  312. },
  313. };
  314. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  315. defined(CONFIG_ARCH_OMAP4)
  316. static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
  317. .num_cs = 2,
  318. };
  319. static struct resource omap2_mcspi3_resources[] = {
  320. {
  321. .start = OMAP2_MCSPI3_BASE,
  322. .end = OMAP2_MCSPI3_BASE + 0xff,
  323. .flags = IORESOURCE_MEM,
  324. },
  325. };
  326. static struct platform_device omap2_mcspi3 = {
  327. .name = "omap2_mcspi",
  328. .id = 3,
  329. .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
  330. .resource = omap2_mcspi3_resources,
  331. .dev = {
  332. .platform_data = &omap2_mcspi3_config,
  333. },
  334. };
  335. #endif
  336. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  337. static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
  338. .num_cs = 1,
  339. };
  340. static struct resource omap2_mcspi4_resources[] = {
  341. {
  342. .start = OMAP2_MCSPI4_BASE,
  343. .end = OMAP2_MCSPI4_BASE + 0xff,
  344. .flags = IORESOURCE_MEM,
  345. },
  346. };
  347. static struct platform_device omap2_mcspi4 = {
  348. .name = "omap2_mcspi",
  349. .id = 4,
  350. .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
  351. .resource = omap2_mcspi4_resources,
  352. .dev = {
  353. .platform_data = &omap2_mcspi4_config,
  354. },
  355. };
  356. #endif
  357. #ifdef CONFIG_ARCH_OMAP4
  358. static inline void omap4_mcspi_fixup(void)
  359. {
  360. omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
  361. omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
  362. omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
  363. omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
  364. omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
  365. omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
  366. omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
  367. omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
  368. }
  369. #else
  370. static inline void omap4_mcspi_fixup(void)
  371. {
  372. }
  373. #endif
  374. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  375. defined(CONFIG_ARCH_OMAP4)
  376. static inline void omap2_mcspi3_init(void)
  377. {
  378. platform_device_register(&omap2_mcspi3);
  379. }
  380. #else
  381. static inline void omap2_mcspi3_init(void)
  382. {
  383. }
  384. #endif
  385. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  386. static inline void omap2_mcspi4_init(void)
  387. {
  388. platform_device_register(&omap2_mcspi4);
  389. }
  390. #else
  391. static inline void omap2_mcspi4_init(void)
  392. {
  393. }
  394. #endif
  395. static void omap_init_mcspi(void)
  396. {
  397. if (cpu_is_omap44xx())
  398. omap4_mcspi_fixup();
  399. platform_device_register(&omap2_mcspi1);
  400. platform_device_register(&omap2_mcspi2);
  401. if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
  402. omap2_mcspi3_init();
  403. if (cpu_is_omap343x() || cpu_is_omap44xx())
  404. omap2_mcspi4_init();
  405. }
  406. #else
  407. static inline void omap_init_mcspi(void) {}
  408. #endif
  409. static struct resource omap2_pmu_resource = {
  410. .start = 3,
  411. .end = 3,
  412. .flags = IORESOURCE_IRQ,
  413. };
  414. static struct resource omap3_pmu_resource = {
  415. .start = INT_34XX_BENCH_MPU_EMUL,
  416. .end = INT_34XX_BENCH_MPU_EMUL,
  417. .flags = IORESOURCE_IRQ,
  418. };
  419. static struct platform_device omap_pmu_device = {
  420. .name = "arm-pmu",
  421. .id = ARM_PMU_DEVICE_CPU,
  422. .num_resources = 1,
  423. };
  424. static void omap_init_pmu(void)
  425. {
  426. if (cpu_is_omap24xx())
  427. omap_pmu_device.resource = &omap2_pmu_resource;
  428. else if (cpu_is_omap34xx())
  429. omap_pmu_device.resource = &omap3_pmu_resource;
  430. else
  431. return;
  432. platform_device_register(&omap_pmu_device);
  433. }
  434. #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
  435. #ifdef CONFIG_ARCH_OMAP2
  436. static struct resource omap2_sham_resources[] = {
  437. {
  438. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  439. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  440. .flags = IORESOURCE_MEM,
  441. },
  442. {
  443. .start = INT_24XX_SHA1MD5,
  444. .flags = IORESOURCE_IRQ,
  445. }
  446. };
  447. static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
  448. #else
  449. #define omap2_sham_resources NULL
  450. #define omap2_sham_resources_sz 0
  451. #endif
  452. #ifdef CONFIG_ARCH_OMAP3
  453. static struct resource omap3_sham_resources[] = {
  454. {
  455. .start = OMAP34XX_SEC_SHA1MD5_BASE,
  456. .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
  457. .flags = IORESOURCE_MEM,
  458. },
  459. {
  460. .start = INT_34XX_SHA1MD52_IRQ,
  461. .flags = IORESOURCE_IRQ,
  462. },
  463. {
  464. .start = OMAP34XX_DMA_SHA1MD5_RX,
  465. .flags = IORESOURCE_DMA,
  466. }
  467. };
  468. static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
  469. #else
  470. #define omap3_sham_resources NULL
  471. #define omap3_sham_resources_sz 0
  472. #endif
  473. static struct platform_device sham_device = {
  474. .name = "omap-sham",
  475. .id = -1,
  476. };
  477. static void omap_init_sham(void)
  478. {
  479. if (cpu_is_omap24xx()) {
  480. sham_device.resource = omap2_sham_resources;
  481. sham_device.num_resources = omap2_sham_resources_sz;
  482. } else if (cpu_is_omap34xx()) {
  483. sham_device.resource = omap3_sham_resources;
  484. sham_device.num_resources = omap3_sham_resources_sz;
  485. } else {
  486. pr_err("%s: platform not supported\n", __func__);
  487. return;
  488. }
  489. platform_device_register(&sham_device);
  490. }
  491. #else
  492. static inline void omap_init_sham(void) { }
  493. #endif
  494. /*-------------------------------------------------------------------------*/
  495. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  496. #define MMCHS_SYSCONFIG 0x0010
  497. #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
  498. #define MMCHS_SYSSTATUS 0x0014
  499. #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
  500. static struct platform_device dummy_pdev = {
  501. .dev = {
  502. .bus = &platform_bus_type,
  503. },
  504. };
  505. /**
  506. * omap_hsmmc_reset() - Full reset of each HS-MMC controller
  507. *
  508. * Ensure that each MMC controller is fully reset. Controllers
  509. * left in an unknown state (by bootloader) may prevent retention
  510. * or OFF-mode. This is especially important in cases where the
  511. * MMC driver is not enabled, _or_ built as a module.
  512. *
  513. * In order for reset to work, interface, functional and debounce
  514. * clocks must be enabled. The debounce clock comes from func_32k_clk
  515. * and is not under SW control, so we only enable i- and f-clocks.
  516. **/
  517. static void __init omap_hsmmc_reset(void)
  518. {
  519. u32 i, nr_controllers;
  520. if (cpu_is_omap242x())
  521. return;
  522. nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
  523. (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
  524. for (i = 0; i < nr_controllers; i++) {
  525. u32 v, base = 0;
  526. struct clk *iclk, *fclk;
  527. struct device *dev = &dummy_pdev.dev;
  528. switch (i) {
  529. case 0:
  530. base = OMAP2_MMC1_BASE;
  531. break;
  532. case 1:
  533. base = OMAP2_MMC2_BASE;
  534. break;
  535. case 2:
  536. base = OMAP3_MMC3_BASE;
  537. break;
  538. case 3:
  539. if (!cpu_is_omap44xx())
  540. return;
  541. base = OMAP4_MMC4_BASE;
  542. break;
  543. case 4:
  544. if (!cpu_is_omap44xx())
  545. return;
  546. base = OMAP4_MMC5_BASE;
  547. break;
  548. }
  549. if (cpu_is_omap44xx())
  550. base += OMAP4_MMC_REG_OFFSET;
  551. dummy_pdev.id = i;
  552. dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
  553. iclk = clk_get(dev, "ick");
  554. if (iclk && clk_enable(iclk))
  555. iclk = NULL;
  556. fclk = clk_get(dev, "fck");
  557. if (fclk && clk_enable(fclk))
  558. fclk = NULL;
  559. if (!iclk || !fclk) {
  560. printk(KERN_WARNING
  561. "%s: Unable to enable clocks for MMC%d, "
  562. "cannot reset.\n", __func__, i);
  563. break;
  564. }
  565. omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
  566. v = omap_readl(base + MMCHS_SYSSTATUS);
  567. while (!(omap_readl(base + MMCHS_SYSSTATUS) &
  568. MMCHS_SYSSTATUS_RESETDONE))
  569. cpu_relax();
  570. if (fclk) {
  571. clk_disable(fclk);
  572. clk_put(fclk);
  573. }
  574. if (iclk) {
  575. clk_disable(iclk);
  576. clk_put(iclk);
  577. }
  578. }
  579. }
  580. #else
  581. static inline void omap_hsmmc_reset(void) {}
  582. #endif
  583. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  584. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  585. static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  586. int controller_nr)
  587. {
  588. if ((mmc_controller->slots[0].switch_pin > 0) && \
  589. (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
  590. omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
  591. OMAP_PIN_INPUT_PULLUP);
  592. if ((mmc_controller->slots[0].gpio_wp > 0) && \
  593. (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
  594. omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
  595. OMAP_PIN_INPUT_PULLUP);
  596. if (cpu_is_omap2420() && controller_nr == 0) {
  597. omap_cfg_reg(H18_24XX_MMC_CMD);
  598. omap_cfg_reg(H15_24XX_MMC_CLKI);
  599. omap_cfg_reg(G19_24XX_MMC_CLKO);
  600. omap_cfg_reg(F20_24XX_MMC_DAT0);
  601. omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
  602. omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
  603. if (mmc_controller->slots[0].wires == 4) {
  604. omap_cfg_reg(H14_24XX_MMC_DAT1);
  605. omap_cfg_reg(E19_24XX_MMC_DAT2);
  606. omap_cfg_reg(D19_24XX_MMC_DAT3);
  607. omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
  608. omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
  609. omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
  610. }
  611. /*
  612. * Use internal loop-back in MMC/SDIO Module Input Clock
  613. * selection
  614. */
  615. if (mmc_controller->slots[0].internal_clock) {
  616. u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  617. v |= (1 << 24);
  618. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  619. }
  620. }
  621. if (cpu_is_omap34xx()) {
  622. if (controller_nr == 0) {
  623. omap_mux_init_signal("sdmmc1_clk",
  624. OMAP_PIN_INPUT_PULLUP);
  625. omap_mux_init_signal("sdmmc1_cmd",
  626. OMAP_PIN_INPUT_PULLUP);
  627. omap_mux_init_signal("sdmmc1_dat0",
  628. OMAP_PIN_INPUT_PULLUP);
  629. if (mmc_controller->slots[0].wires == 4 ||
  630. mmc_controller->slots[0].wires == 8) {
  631. omap_mux_init_signal("sdmmc1_dat1",
  632. OMAP_PIN_INPUT_PULLUP);
  633. omap_mux_init_signal("sdmmc1_dat2",
  634. OMAP_PIN_INPUT_PULLUP);
  635. omap_mux_init_signal("sdmmc1_dat3",
  636. OMAP_PIN_INPUT_PULLUP);
  637. }
  638. if (mmc_controller->slots[0].wires == 8) {
  639. omap_mux_init_signal("sdmmc1_dat4",
  640. OMAP_PIN_INPUT_PULLUP);
  641. omap_mux_init_signal("sdmmc1_dat5",
  642. OMAP_PIN_INPUT_PULLUP);
  643. omap_mux_init_signal("sdmmc1_dat6",
  644. OMAP_PIN_INPUT_PULLUP);
  645. omap_mux_init_signal("sdmmc1_dat7",
  646. OMAP_PIN_INPUT_PULLUP);
  647. }
  648. }
  649. if (controller_nr == 1) {
  650. /* MMC2 */
  651. omap_mux_init_signal("sdmmc2_clk",
  652. OMAP_PIN_INPUT_PULLUP);
  653. omap_mux_init_signal("sdmmc2_cmd",
  654. OMAP_PIN_INPUT_PULLUP);
  655. omap_mux_init_signal("sdmmc2_dat0",
  656. OMAP_PIN_INPUT_PULLUP);
  657. /*
  658. * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
  659. * in the board-*.c files
  660. */
  661. if (mmc_controller->slots[0].wires == 4 ||
  662. mmc_controller->slots[0].wires == 8) {
  663. omap_mux_init_signal("sdmmc2_dat1",
  664. OMAP_PIN_INPUT_PULLUP);
  665. omap_mux_init_signal("sdmmc2_dat2",
  666. OMAP_PIN_INPUT_PULLUP);
  667. omap_mux_init_signal("sdmmc2_dat3",
  668. OMAP_PIN_INPUT_PULLUP);
  669. }
  670. if (mmc_controller->slots[0].wires == 8) {
  671. omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
  672. OMAP_PIN_INPUT_PULLUP);
  673. omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
  674. OMAP_PIN_INPUT_PULLUP);
  675. omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
  676. OMAP_PIN_INPUT_PULLUP);
  677. omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
  678. OMAP_PIN_INPUT_PULLUP);
  679. }
  680. }
  681. /*
  682. * For MMC3 the pins need to be muxed in the board-*.c files
  683. */
  684. }
  685. }
  686. void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  687. int nr_controllers)
  688. {
  689. int i;
  690. char *name;
  691. for (i = 0; i < nr_controllers; i++) {
  692. unsigned long base, size;
  693. unsigned int irq = 0;
  694. if (!mmc_data[i])
  695. continue;
  696. omap2_mmc_mux(mmc_data[i], i);
  697. switch (i) {
  698. case 0:
  699. base = OMAP2_MMC1_BASE;
  700. irq = INT_24XX_MMC_IRQ;
  701. break;
  702. case 1:
  703. base = OMAP2_MMC2_BASE;
  704. irq = INT_24XX_MMC2_IRQ;
  705. break;
  706. case 2:
  707. if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
  708. return;
  709. base = OMAP3_MMC3_BASE;
  710. irq = INT_34XX_MMC3_IRQ;
  711. break;
  712. case 3:
  713. if (!cpu_is_omap44xx())
  714. return;
  715. base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET;
  716. irq = OMAP44XX_IRQ_MMC4;
  717. break;
  718. case 4:
  719. if (!cpu_is_omap44xx())
  720. return;
  721. base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET;
  722. irq = OMAP44XX_IRQ_MMC5;
  723. break;
  724. default:
  725. continue;
  726. }
  727. if (cpu_is_omap2420()) {
  728. size = OMAP2420_MMC_SIZE;
  729. name = "mmci-omap";
  730. } else if (cpu_is_omap44xx()) {
  731. if (i < 3) {
  732. base += OMAP4_MMC_REG_OFFSET;
  733. irq += OMAP44XX_IRQ_GIC_START;
  734. }
  735. size = OMAP4_HSMMC_SIZE;
  736. name = "mmci-omap-hs";
  737. } else {
  738. size = OMAP3_HSMMC_SIZE;
  739. name = "mmci-omap-hs";
  740. }
  741. omap_mmc_add(name, i, base, size, irq, mmc_data[i]);
  742. };
  743. }
  744. #endif
  745. /*-------------------------------------------------------------------------*/
  746. #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
  747. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
  748. #define OMAP_HDQ_BASE 0x480B2000
  749. #endif
  750. static struct resource omap_hdq_resources[] = {
  751. {
  752. .start = OMAP_HDQ_BASE,
  753. .end = OMAP_HDQ_BASE + 0x1C,
  754. .flags = IORESOURCE_MEM,
  755. },
  756. {
  757. .start = INT_24XX_HDQ_IRQ,
  758. .flags = IORESOURCE_IRQ,
  759. },
  760. };
  761. static struct platform_device omap_hdq_dev = {
  762. .name = "omap_hdq",
  763. .id = 0,
  764. .dev = {
  765. .platform_data = NULL,
  766. },
  767. .num_resources = ARRAY_SIZE(omap_hdq_resources),
  768. .resource = omap_hdq_resources,
  769. };
  770. static inline void omap_hdq_init(void)
  771. {
  772. (void) platform_device_register(&omap_hdq_dev);
  773. }
  774. #else
  775. static inline void omap_hdq_init(void) {}
  776. #endif
  777. /*---------------------------------------------------------------------------*/
  778. #if defined(CONFIG_VIDEO_OMAP2_VOUT) || \
  779. defined(CONFIG_VIDEO_OMAP2_VOUT_MODULE)
  780. #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
  781. static struct resource omap_vout_resource[3 - CONFIG_FB_OMAP2_NUM_FBS] = {
  782. };
  783. #else
  784. static struct resource omap_vout_resource[2] = {
  785. };
  786. #endif
  787. static struct platform_device omap_vout_device = {
  788. .name = "omap_vout",
  789. .num_resources = ARRAY_SIZE(omap_vout_resource),
  790. .resource = &omap_vout_resource[0],
  791. .id = -1,
  792. };
  793. static void omap_init_vout(void)
  794. {
  795. if (platform_device_register(&omap_vout_device) < 0)
  796. printk(KERN_ERR "Unable to register OMAP-VOUT device\n");
  797. }
  798. #else
  799. static inline void omap_init_vout(void) {}
  800. #endif
  801. /*-------------------------------------------------------------------------*/
  802. static int __init omap2_init_devices(void)
  803. {
  804. /* please keep these calls, and their implementations above,
  805. * in alphabetical order so they're easier to sort through.
  806. */
  807. omap_hsmmc_reset();
  808. omap_init_camera();
  809. omap_init_mbox();
  810. omap_init_mcspi();
  811. omap_init_pmu();
  812. omap_hdq_init();
  813. omap_init_sti();
  814. omap_init_sham();
  815. omap_init_vout();
  816. return 0;
  817. }
  818. arch_initcall(omap2_init_devices);