devices.c 25 KB

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