devices.c 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/io.h>
  15. #include <linux/clk.h>
  16. #include <linux/err.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/tc.h>
  23. #include <plat/board.h>
  24. #include <mach/gpio.h>
  25. #include <plat/mmc.h>
  26. #include <plat/dma.h>
  27. #include <plat/omap_hwmod.h>
  28. #include <plat/omap_device.h>
  29. #include "mux.h"
  30. #include "control.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. .name = "dsp",
  143. },
  144. {
  145. .start = INT_24XX_MAIL_U3_MPU,
  146. .flags = IORESOURCE_IRQ,
  147. .name = "iva",
  148. },
  149. };
  150. static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources);
  151. #else
  152. #define omap2_mbox_resources NULL
  153. #define omap2_mbox_resources_sz 0
  154. #endif
  155. #ifdef CONFIG_ARCH_OMAP3
  156. static struct resource omap3_mbox_resources[] = {
  157. {
  158. .start = OMAP34XX_MAILBOX_BASE,
  159. .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1,
  160. .flags = IORESOURCE_MEM,
  161. },
  162. {
  163. .start = INT_24XX_MAIL_U0_MPU,
  164. .flags = IORESOURCE_IRQ,
  165. .name = "dsp",
  166. },
  167. };
  168. static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources);
  169. #else
  170. #define omap3_mbox_resources NULL
  171. #define omap3_mbox_resources_sz 0
  172. #endif
  173. #ifdef CONFIG_ARCH_OMAP4
  174. #define OMAP4_MBOX_REG_SIZE 0x130
  175. static struct resource omap4_mbox_resources[] = {
  176. {
  177. .start = OMAP44XX_MAILBOX_BASE,
  178. .end = OMAP44XX_MAILBOX_BASE +
  179. OMAP4_MBOX_REG_SIZE - 1,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. {
  183. .start = OMAP44XX_IRQ_MAIL_U0,
  184. .flags = IORESOURCE_IRQ,
  185. .name = "mbox",
  186. },
  187. };
  188. static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources);
  189. #else
  190. #define omap4_mbox_resources NULL
  191. #define omap4_mbox_resources_sz 0
  192. #endif
  193. static struct platform_device mbox_device = {
  194. .name = "omap-mailbox",
  195. .id = -1,
  196. };
  197. static inline void omap_init_mbox(void)
  198. {
  199. if (cpu_is_omap24xx()) {
  200. mbox_device.resource = omap2_mbox_resources;
  201. mbox_device.num_resources = omap2_mbox_resources_sz;
  202. } else if (cpu_is_omap34xx()) {
  203. mbox_device.resource = omap3_mbox_resources;
  204. mbox_device.num_resources = omap3_mbox_resources_sz;
  205. } else if (cpu_is_omap44xx()) {
  206. mbox_device.resource = omap4_mbox_resources;
  207. mbox_device.num_resources = omap4_mbox_resources_sz;
  208. } else {
  209. pr_err("%s: platform not supported\n", __func__);
  210. return;
  211. }
  212. platform_device_register(&mbox_device);
  213. }
  214. #else
  215. static inline void omap_init_mbox(void) { }
  216. #endif /* CONFIG_OMAP_MBOX_FWK */
  217. static inline void omap_init_sti(void) {}
  218. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  219. #include <plat/mcspi.h>
  220. #define OMAP2_MCSPI1_BASE 0x48098000
  221. #define OMAP2_MCSPI2_BASE 0x4809a000
  222. #define OMAP2_MCSPI3_BASE 0x480b8000
  223. #define OMAP2_MCSPI4_BASE 0x480ba000
  224. #define OMAP4_MCSPI1_BASE 0x48098100
  225. #define OMAP4_MCSPI2_BASE 0x4809a100
  226. #define OMAP4_MCSPI3_BASE 0x480b8100
  227. #define OMAP4_MCSPI4_BASE 0x480ba100
  228. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  229. .num_cs = 4,
  230. };
  231. static struct resource omap2_mcspi1_resources[] = {
  232. {
  233. .start = OMAP2_MCSPI1_BASE,
  234. .end = OMAP2_MCSPI1_BASE + 0xff,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. };
  238. static struct platform_device omap2_mcspi1 = {
  239. .name = "omap2_mcspi",
  240. .id = 1,
  241. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  242. .resource = omap2_mcspi1_resources,
  243. .dev = {
  244. .platform_data = &omap2_mcspi1_config,
  245. },
  246. };
  247. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  248. .num_cs = 2,
  249. };
  250. static struct resource omap2_mcspi2_resources[] = {
  251. {
  252. .start = OMAP2_MCSPI2_BASE,
  253. .end = OMAP2_MCSPI2_BASE + 0xff,
  254. .flags = IORESOURCE_MEM,
  255. },
  256. };
  257. static struct platform_device omap2_mcspi2 = {
  258. .name = "omap2_mcspi",
  259. .id = 2,
  260. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  261. .resource = omap2_mcspi2_resources,
  262. .dev = {
  263. .platform_data = &omap2_mcspi2_config,
  264. },
  265. };
  266. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  267. defined(CONFIG_ARCH_OMAP4)
  268. static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
  269. .num_cs = 2,
  270. };
  271. static struct resource omap2_mcspi3_resources[] = {
  272. {
  273. .start = OMAP2_MCSPI3_BASE,
  274. .end = OMAP2_MCSPI3_BASE + 0xff,
  275. .flags = IORESOURCE_MEM,
  276. },
  277. };
  278. static struct platform_device omap2_mcspi3 = {
  279. .name = "omap2_mcspi",
  280. .id = 3,
  281. .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
  282. .resource = omap2_mcspi3_resources,
  283. .dev = {
  284. .platform_data = &omap2_mcspi3_config,
  285. },
  286. };
  287. #endif
  288. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  289. static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
  290. .num_cs = 1,
  291. };
  292. static struct resource omap2_mcspi4_resources[] = {
  293. {
  294. .start = OMAP2_MCSPI4_BASE,
  295. .end = OMAP2_MCSPI4_BASE + 0xff,
  296. .flags = IORESOURCE_MEM,
  297. },
  298. };
  299. static struct platform_device omap2_mcspi4 = {
  300. .name = "omap2_mcspi",
  301. .id = 4,
  302. .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
  303. .resource = omap2_mcspi4_resources,
  304. .dev = {
  305. .platform_data = &omap2_mcspi4_config,
  306. },
  307. };
  308. #endif
  309. #ifdef CONFIG_ARCH_OMAP4
  310. static inline void omap4_mcspi_fixup(void)
  311. {
  312. omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
  313. omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
  314. omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
  315. omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
  316. omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
  317. omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
  318. omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
  319. omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
  320. }
  321. #else
  322. static inline void omap4_mcspi_fixup(void)
  323. {
  324. }
  325. #endif
  326. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
  327. defined(CONFIG_ARCH_OMAP4)
  328. static inline void omap2_mcspi3_init(void)
  329. {
  330. platform_device_register(&omap2_mcspi3);
  331. }
  332. #else
  333. static inline void omap2_mcspi3_init(void)
  334. {
  335. }
  336. #endif
  337. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  338. static inline void omap2_mcspi4_init(void)
  339. {
  340. platform_device_register(&omap2_mcspi4);
  341. }
  342. #else
  343. static inline void omap2_mcspi4_init(void)
  344. {
  345. }
  346. #endif
  347. static void omap_init_mcspi(void)
  348. {
  349. if (cpu_is_omap44xx())
  350. omap4_mcspi_fixup();
  351. platform_device_register(&omap2_mcspi1);
  352. platform_device_register(&omap2_mcspi2);
  353. if (cpu_is_omap2430() || cpu_is_omap343x() || cpu_is_omap44xx())
  354. omap2_mcspi3_init();
  355. if (cpu_is_omap343x() || cpu_is_omap44xx())
  356. omap2_mcspi4_init();
  357. }
  358. #else
  359. static inline void omap_init_mcspi(void) {}
  360. #endif
  361. static struct resource omap2_pmu_resource = {
  362. .start = 3,
  363. .end = 3,
  364. .flags = IORESOURCE_IRQ,
  365. };
  366. static struct resource omap3_pmu_resource = {
  367. .start = INT_34XX_BENCH_MPU_EMUL,
  368. .end = INT_34XX_BENCH_MPU_EMUL,
  369. .flags = IORESOURCE_IRQ,
  370. };
  371. static struct platform_device omap_pmu_device = {
  372. .name = "arm-pmu",
  373. .id = ARM_PMU_DEVICE_CPU,
  374. .num_resources = 1,
  375. };
  376. static void omap_init_pmu(void)
  377. {
  378. if (cpu_is_omap24xx())
  379. omap_pmu_device.resource = &omap2_pmu_resource;
  380. else if (cpu_is_omap34xx())
  381. omap_pmu_device.resource = &omap3_pmu_resource;
  382. else
  383. return;
  384. platform_device_register(&omap_pmu_device);
  385. }
  386. #if defined(CONFIG_CRYPTO_DEV_OMAP_SHAM) || defined(CONFIG_CRYPTO_DEV_OMAP_SHAM_MODULE)
  387. #ifdef CONFIG_ARCH_OMAP2
  388. static struct resource omap2_sham_resources[] = {
  389. {
  390. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  391. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  392. .flags = IORESOURCE_MEM,
  393. },
  394. {
  395. .start = INT_24XX_SHA1MD5,
  396. .flags = IORESOURCE_IRQ,
  397. }
  398. };
  399. static int omap2_sham_resources_sz = ARRAY_SIZE(omap2_sham_resources);
  400. #else
  401. #define omap2_sham_resources NULL
  402. #define omap2_sham_resources_sz 0
  403. #endif
  404. #ifdef CONFIG_ARCH_OMAP3
  405. static struct resource omap3_sham_resources[] = {
  406. {
  407. .start = OMAP34XX_SEC_SHA1MD5_BASE,
  408. .end = OMAP34XX_SEC_SHA1MD5_BASE + 0x64,
  409. .flags = IORESOURCE_MEM,
  410. },
  411. {
  412. .start = INT_34XX_SHA1MD52_IRQ,
  413. .flags = IORESOURCE_IRQ,
  414. },
  415. {
  416. .start = OMAP34XX_DMA_SHA1MD5_RX,
  417. .flags = IORESOURCE_DMA,
  418. }
  419. };
  420. static int omap3_sham_resources_sz = ARRAY_SIZE(omap3_sham_resources);
  421. #else
  422. #define omap3_sham_resources NULL
  423. #define omap3_sham_resources_sz 0
  424. #endif
  425. static struct platform_device sham_device = {
  426. .name = "omap-sham",
  427. .id = -1,
  428. };
  429. static void omap_init_sham(void)
  430. {
  431. if (cpu_is_omap24xx()) {
  432. sham_device.resource = omap2_sham_resources;
  433. sham_device.num_resources = omap2_sham_resources_sz;
  434. } else if (cpu_is_omap34xx()) {
  435. sham_device.resource = omap3_sham_resources;
  436. sham_device.num_resources = omap3_sham_resources_sz;
  437. } else {
  438. pr_err("%s: platform not supported\n", __func__);
  439. return;
  440. }
  441. platform_device_register(&sham_device);
  442. }
  443. #else
  444. static inline void omap_init_sham(void) { }
  445. #endif
  446. #if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
  447. #ifdef CONFIG_ARCH_OMAP2
  448. static struct resource omap2_aes_resources[] = {
  449. {
  450. .start = OMAP24XX_SEC_AES_BASE,
  451. .end = OMAP24XX_SEC_AES_BASE + 0x4C,
  452. .flags = IORESOURCE_MEM,
  453. },
  454. {
  455. .start = OMAP24XX_DMA_AES_TX,
  456. .flags = IORESOURCE_DMA,
  457. },
  458. {
  459. .start = OMAP24XX_DMA_AES_RX,
  460. .flags = IORESOURCE_DMA,
  461. }
  462. };
  463. static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
  464. #else
  465. #define omap2_aes_resources NULL
  466. #define omap2_aes_resources_sz 0
  467. #endif
  468. #ifdef CONFIG_ARCH_OMAP3
  469. static struct resource omap3_aes_resources[] = {
  470. {
  471. .start = OMAP34XX_SEC_AES_BASE,
  472. .end = OMAP34XX_SEC_AES_BASE + 0x4C,
  473. .flags = IORESOURCE_MEM,
  474. },
  475. {
  476. .start = OMAP34XX_DMA_AES2_TX,
  477. .flags = IORESOURCE_DMA,
  478. },
  479. {
  480. .start = OMAP34XX_DMA_AES2_RX,
  481. .flags = IORESOURCE_DMA,
  482. }
  483. };
  484. static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
  485. #else
  486. #define omap3_aes_resources NULL
  487. #define omap3_aes_resources_sz 0
  488. #endif
  489. static struct platform_device aes_device = {
  490. .name = "omap-aes",
  491. .id = -1,
  492. };
  493. static void omap_init_aes(void)
  494. {
  495. if (cpu_is_omap24xx()) {
  496. aes_device.resource = omap2_aes_resources;
  497. aes_device.num_resources = omap2_aes_resources_sz;
  498. } else if (cpu_is_omap34xx()) {
  499. aes_device.resource = omap3_aes_resources;
  500. aes_device.num_resources = omap3_aes_resources_sz;
  501. } else {
  502. pr_err("%s: platform not supported\n", __func__);
  503. return;
  504. }
  505. platform_device_register(&aes_device);
  506. }
  507. #else
  508. static inline void omap_init_aes(void) { }
  509. #endif
  510. /*-------------------------------------------------------------------------*/
  511. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
  512. #define MMCHS_SYSCONFIG 0x0010
  513. #define MMCHS_SYSCONFIG_SWRESET (1 << 1)
  514. #define MMCHS_SYSSTATUS 0x0014
  515. #define MMCHS_SYSSTATUS_RESETDONE (1 << 0)
  516. static struct platform_device dummy_pdev = {
  517. .dev = {
  518. .bus = &platform_bus_type,
  519. },
  520. };
  521. /**
  522. * omap_hsmmc_reset() - Full reset of each HS-MMC controller
  523. *
  524. * Ensure that each MMC controller is fully reset. Controllers
  525. * left in an unknown state (by bootloader) may prevent retention
  526. * or OFF-mode. This is especially important in cases where the
  527. * MMC driver is not enabled, _or_ built as a module.
  528. *
  529. * In order for reset to work, interface, functional and debounce
  530. * clocks must be enabled. The debounce clock comes from func_32k_clk
  531. * and is not under SW control, so we only enable i- and f-clocks.
  532. **/
  533. static void __init omap_hsmmc_reset(void)
  534. {
  535. u32 i, nr_controllers;
  536. if (cpu_is_omap242x())
  537. return;
  538. nr_controllers = cpu_is_omap44xx() ? OMAP44XX_NR_MMC :
  539. (cpu_is_omap34xx() ? OMAP34XX_NR_MMC : OMAP24XX_NR_MMC);
  540. for (i = 0; i < nr_controllers; i++) {
  541. u32 v, base = 0;
  542. struct clk *iclk, *fclk;
  543. struct device *dev = &dummy_pdev.dev;
  544. switch (i) {
  545. case 0:
  546. base = OMAP2_MMC1_BASE;
  547. break;
  548. case 1:
  549. base = OMAP2_MMC2_BASE;
  550. break;
  551. case 2:
  552. base = OMAP3_MMC3_BASE;
  553. break;
  554. case 3:
  555. if (!cpu_is_omap44xx())
  556. return;
  557. base = OMAP4_MMC4_BASE;
  558. break;
  559. case 4:
  560. if (!cpu_is_omap44xx())
  561. return;
  562. base = OMAP4_MMC5_BASE;
  563. break;
  564. }
  565. if (cpu_is_omap44xx())
  566. base += OMAP4_MMC_REG_OFFSET;
  567. dummy_pdev.id = i;
  568. dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
  569. iclk = clk_get(dev, "ick");
  570. if (iclk && clk_enable(iclk))
  571. iclk = NULL;
  572. fclk = clk_get(dev, "fck");
  573. if (fclk && clk_enable(fclk))
  574. fclk = NULL;
  575. if (!iclk || !fclk) {
  576. printk(KERN_WARNING
  577. "%s: Unable to enable clocks for MMC%d, "
  578. "cannot reset.\n", __func__, i);
  579. break;
  580. }
  581. omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
  582. v = omap_readl(base + MMCHS_SYSSTATUS);
  583. while (!(omap_readl(base + MMCHS_SYSSTATUS) &
  584. MMCHS_SYSSTATUS_RESETDONE))
  585. cpu_relax();
  586. if (fclk) {
  587. clk_disable(fclk);
  588. clk_put(fclk);
  589. }
  590. if (iclk) {
  591. clk_disable(iclk);
  592. clk_put(iclk);
  593. }
  594. }
  595. }
  596. #else
  597. static inline void omap_hsmmc_reset(void) {}
  598. #endif
  599. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  600. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  601. static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  602. int controller_nr)
  603. {
  604. if ((mmc_controller->slots[0].switch_pin > 0) && \
  605. (mmc_controller->slots[0].switch_pin < OMAP_MAX_GPIO_LINES))
  606. omap_mux_init_gpio(mmc_controller->slots[0].switch_pin,
  607. OMAP_PIN_INPUT_PULLUP);
  608. if ((mmc_controller->slots[0].gpio_wp > 0) && \
  609. (mmc_controller->slots[0].gpio_wp < OMAP_MAX_GPIO_LINES))
  610. omap_mux_init_gpio(mmc_controller->slots[0].gpio_wp,
  611. OMAP_PIN_INPUT_PULLUP);
  612. if (cpu_is_omap2420() && controller_nr == 0) {
  613. omap_mux_init_signal("sdmmc_cmd", 0);
  614. omap_mux_init_signal("sdmmc_clki", 0);
  615. omap_mux_init_signal("sdmmc_clko", 0);
  616. omap_mux_init_signal("sdmmc_dat0", 0);
  617. omap_mux_init_signal("sdmmc_dat_dir0", 0);
  618. omap_mux_init_signal("sdmmc_cmd_dir", 0);
  619. if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
  620. omap_mux_init_signal("sdmmc_dat1", 0);
  621. omap_mux_init_signal("sdmmc_dat2", 0);
  622. omap_mux_init_signal("sdmmc_dat3", 0);
  623. omap_mux_init_signal("sdmmc_dat_dir1", 0);
  624. omap_mux_init_signal("sdmmc_dat_dir2", 0);
  625. omap_mux_init_signal("sdmmc_dat_dir3", 0);
  626. }
  627. /*
  628. * Use internal loop-back in MMC/SDIO Module Input Clock
  629. * selection
  630. */
  631. if (mmc_controller->slots[0].internal_clock) {
  632. u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  633. v |= (1 << 24);
  634. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  635. }
  636. }
  637. if (cpu_is_omap34xx()) {
  638. if (controller_nr == 0) {
  639. omap_mux_init_signal("sdmmc1_clk",
  640. OMAP_PIN_INPUT_PULLUP);
  641. omap_mux_init_signal("sdmmc1_cmd",
  642. OMAP_PIN_INPUT_PULLUP);
  643. omap_mux_init_signal("sdmmc1_dat0",
  644. OMAP_PIN_INPUT_PULLUP);
  645. if (mmc_controller->slots[0].caps &
  646. (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
  647. omap_mux_init_signal("sdmmc1_dat1",
  648. OMAP_PIN_INPUT_PULLUP);
  649. omap_mux_init_signal("sdmmc1_dat2",
  650. OMAP_PIN_INPUT_PULLUP);
  651. omap_mux_init_signal("sdmmc1_dat3",
  652. OMAP_PIN_INPUT_PULLUP);
  653. }
  654. if (mmc_controller->slots[0].caps &
  655. MMC_CAP_8_BIT_DATA) {
  656. omap_mux_init_signal("sdmmc1_dat4",
  657. OMAP_PIN_INPUT_PULLUP);
  658. omap_mux_init_signal("sdmmc1_dat5",
  659. OMAP_PIN_INPUT_PULLUP);
  660. omap_mux_init_signal("sdmmc1_dat6",
  661. OMAP_PIN_INPUT_PULLUP);
  662. omap_mux_init_signal("sdmmc1_dat7",
  663. OMAP_PIN_INPUT_PULLUP);
  664. }
  665. }
  666. if (controller_nr == 1) {
  667. /* MMC2 */
  668. omap_mux_init_signal("sdmmc2_clk",
  669. OMAP_PIN_INPUT_PULLUP);
  670. omap_mux_init_signal("sdmmc2_cmd",
  671. OMAP_PIN_INPUT_PULLUP);
  672. omap_mux_init_signal("sdmmc2_dat0",
  673. OMAP_PIN_INPUT_PULLUP);
  674. /*
  675. * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
  676. * in the board-*.c files
  677. */
  678. if (mmc_controller->slots[0].caps &
  679. (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
  680. omap_mux_init_signal("sdmmc2_dat1",
  681. OMAP_PIN_INPUT_PULLUP);
  682. omap_mux_init_signal("sdmmc2_dat2",
  683. OMAP_PIN_INPUT_PULLUP);
  684. omap_mux_init_signal("sdmmc2_dat3",
  685. OMAP_PIN_INPUT_PULLUP);
  686. }
  687. if (mmc_controller->slots[0].caps &
  688. MMC_CAP_8_BIT_DATA) {
  689. omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
  690. OMAP_PIN_INPUT_PULLUP);
  691. omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
  692. OMAP_PIN_INPUT_PULLUP);
  693. omap_mux_init_signal("sdmmc2_dat6.sdmmc2_dat6",
  694. OMAP_PIN_INPUT_PULLUP);
  695. omap_mux_init_signal("sdmmc2_dat7.sdmmc2_dat7",
  696. OMAP_PIN_INPUT_PULLUP);
  697. }
  698. }
  699. /*
  700. * For MMC3 the pins need to be muxed in the board-*.c files
  701. */
  702. }
  703. }
  704. void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  705. int nr_controllers)
  706. {
  707. int i;
  708. char *name;
  709. for (i = 0; i < nr_controllers; i++) {
  710. unsigned long base, size;
  711. unsigned int irq = 0;
  712. if (!mmc_data[i])
  713. continue;
  714. omap2_mmc_mux(mmc_data[i], i);
  715. switch (i) {
  716. case 0:
  717. base = OMAP2_MMC1_BASE;
  718. irq = INT_24XX_MMC_IRQ;
  719. break;
  720. case 1:
  721. base = OMAP2_MMC2_BASE;
  722. irq = INT_24XX_MMC2_IRQ;
  723. break;
  724. case 2:
  725. if (!cpu_is_omap44xx() && !cpu_is_omap34xx())
  726. return;
  727. base = OMAP3_MMC3_BASE;
  728. irq = INT_34XX_MMC3_IRQ;
  729. break;
  730. case 3:
  731. if (!cpu_is_omap44xx())
  732. return;
  733. base = OMAP4_MMC4_BASE;
  734. irq = OMAP44XX_IRQ_MMC4;
  735. break;
  736. case 4:
  737. if (!cpu_is_omap44xx())
  738. return;
  739. base = OMAP4_MMC5_BASE;
  740. irq = OMAP44XX_IRQ_MMC5;
  741. break;
  742. default:
  743. continue;
  744. }
  745. if (cpu_is_omap2420()) {
  746. size = OMAP2420_MMC_SIZE;
  747. name = "mmci-omap";
  748. } else if (cpu_is_omap44xx()) {
  749. if (i < 3)
  750. irq += OMAP44XX_IRQ_GIC_START;
  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. /*
  819. * Inorder to avoid any assumptions from bootloader regarding WDT
  820. * settings, WDT module is reset during init. This enables the watchdog
  821. * timer. Hence it is required to disable the watchdog after the WDT reset
  822. * during init. Otherwise the system would reboot as per the default
  823. * watchdog timer registers settings.
  824. */
  825. #define OMAP_WDT_WPS (0x34)
  826. #define OMAP_WDT_SPR (0x48)
  827. static int omap2_disable_wdt(struct omap_hwmod *oh, void *unused)
  828. {
  829. void __iomem *base;
  830. int ret;
  831. if (!oh) {
  832. pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
  833. return -EINVAL;
  834. }
  835. base = omap_hwmod_get_mpu_rt_va(oh);
  836. if (!base) {
  837. pr_err("%s: Could not get the base address for %s\n",
  838. oh->name, __func__);
  839. return -EINVAL;
  840. }
  841. /* Enable the clocks before accessing the WDT registers */
  842. ret = omap_hwmod_enable(oh);
  843. if (ret) {
  844. pr_err("%s: Could not enable clocks for %s\n",
  845. oh->name, __func__);
  846. return ret;
  847. }
  848. /* sequence required to disable watchdog */
  849. __raw_writel(0xAAAA, base + OMAP_WDT_SPR);
  850. while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
  851. cpu_relax();
  852. __raw_writel(0x5555, base + OMAP_WDT_SPR);
  853. while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
  854. cpu_relax();
  855. ret = omap_hwmod_idle(oh);
  856. if (ret)
  857. pr_err("%s: Could not disable clocks for %s\n",
  858. oh->name, __func__);
  859. return ret;
  860. }
  861. static void __init omap_disable_wdt(void)
  862. {
  863. if (cpu_class_is_omap2())
  864. omap_hwmod_for_each_by_class("wd_timer",
  865. omap2_disable_wdt, NULL);
  866. return;
  867. }
  868. static int __init omap2_init_devices(void)
  869. {
  870. /* please keep these calls, and their implementations above,
  871. * in alphabetical order so they're easier to sort through.
  872. */
  873. omap_disable_wdt();
  874. omap_hsmmc_reset();
  875. omap_init_camera();
  876. omap_init_mbox();
  877. omap_init_mcspi();
  878. omap_init_pmu();
  879. omap_hdq_init();
  880. omap_init_sti();
  881. omap_init_sham();
  882. omap_init_aes();
  883. omap_init_vout();
  884. return 0;
  885. }
  886. arch_initcall(omap2_init_devices);
  887. #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
  888. struct omap_device_pm_latency omap_wdt_latency[] = {
  889. [0] = {
  890. .deactivate_func = omap_device_idle_hwmods,
  891. .activate_func = omap_device_enable_hwmods,
  892. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  893. },
  894. };
  895. static int __init omap_init_wdt(void)
  896. {
  897. int id = -1;
  898. struct omap_device *od;
  899. struct omap_hwmod *oh;
  900. char *oh_name = "wd_timer2";
  901. char *dev_name = "omap_wdt";
  902. if (!cpu_class_is_omap2())
  903. return 0;
  904. oh = omap_hwmod_lookup(oh_name);
  905. if (!oh) {
  906. pr_err("Could not look up wd_timer%d hwmod\n", id);
  907. return -EINVAL;
  908. }
  909. od = omap_device_build(dev_name, id, oh, NULL, 0,
  910. omap_wdt_latency,
  911. ARRAY_SIZE(omap_wdt_latency), 0);
  912. WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
  913. dev_name, oh->name);
  914. return 0;
  915. }
  916. subsys_initcall(omap_init_wdt);
  917. #endif