devices.c 22 KB

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