devices.c 22 KB

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