devices.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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 <mach/hardware.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/map.h>
  19. #include <mach/control.h>
  20. #include <mach/tc.h>
  21. #include <mach/board.h>
  22. #include <mach/mux.h>
  23. #include <mach/gpio.h>
  24. #include <mach/eac.h>
  25. #include <mach/mmc.h>
  26. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  27. #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
  28. static struct resource mbox_resources[] = {
  29. {
  30. .start = OMAP2_MBOX_BASE,
  31. .end = OMAP2_MBOX_BASE + 0x11f,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. {
  35. .start = INT_24XX_MAIL_U0_MPU,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. {
  39. .start = INT_24XX_MAIL_U3_MPU,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct platform_device mbox_device = {
  44. .name = "mailbox",
  45. .id = -1,
  46. .num_resources = ARRAY_SIZE(mbox_resources),
  47. .resource = mbox_resources,
  48. };
  49. static inline void omap_init_mbox(void)
  50. {
  51. platform_device_register(&mbox_device);
  52. }
  53. #else
  54. static inline void omap_init_mbox(void) { }
  55. #endif
  56. #if defined(CONFIG_OMAP_STI)
  57. #if defined(CONFIG_ARCH_OMAP2)
  58. #define OMAP2_STI_BASE 0x48068000
  59. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  60. #define OMAP2_STI_IRQ 4
  61. static struct resource sti_resources[] = {
  62. {
  63. .start = OMAP2_STI_BASE,
  64. .end = OMAP2_STI_BASE + 0x7ff,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. {
  68. .start = OMAP2_STI_CHANNEL_BASE,
  69. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. {
  73. .start = OMAP2_STI_IRQ,
  74. .flags = IORESOURCE_IRQ,
  75. }
  76. };
  77. #elif defined(CONFIG_ARCH_OMAP3)
  78. #define OMAP3_SDTI_BASE 0x54500000
  79. #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
  80. static struct resource sti_resources[] = {
  81. {
  82. .start = OMAP3_SDTI_BASE,
  83. .end = OMAP3_SDTI_BASE + 0xFFF,
  84. .flags = IORESOURCE_MEM,
  85. },
  86. {
  87. .start = OMAP3_SDTI_CHANNEL_BASE,
  88. .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
  89. .flags = IORESOURCE_MEM,
  90. }
  91. };
  92. #endif
  93. static struct platform_device sti_device = {
  94. .name = "sti",
  95. .id = -1,
  96. .num_resources = ARRAY_SIZE(sti_resources),
  97. .resource = sti_resources,
  98. };
  99. static inline void omap_init_sti(void)
  100. {
  101. platform_device_register(&sti_device);
  102. }
  103. #else
  104. static inline void omap_init_sti(void) {}
  105. #endif
  106. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  107. #include <mach/mcspi.h>
  108. #define OMAP2_MCSPI1_BASE 0x48098000
  109. #define OMAP2_MCSPI2_BASE 0x4809a000
  110. #define OMAP2_MCSPI3_BASE 0x480b8000
  111. #define OMAP2_MCSPI4_BASE 0x480ba000
  112. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  113. .num_cs = 4,
  114. };
  115. static struct resource omap2_mcspi1_resources[] = {
  116. {
  117. .start = OMAP2_MCSPI1_BASE,
  118. .end = OMAP2_MCSPI1_BASE + 0xff,
  119. .flags = IORESOURCE_MEM,
  120. },
  121. };
  122. static struct platform_device omap2_mcspi1 = {
  123. .name = "omap2_mcspi",
  124. .id = 1,
  125. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  126. .resource = omap2_mcspi1_resources,
  127. .dev = {
  128. .platform_data = &omap2_mcspi1_config,
  129. },
  130. };
  131. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  132. .num_cs = 2,
  133. };
  134. static struct resource omap2_mcspi2_resources[] = {
  135. {
  136. .start = OMAP2_MCSPI2_BASE,
  137. .end = OMAP2_MCSPI2_BASE + 0xff,
  138. .flags = IORESOURCE_MEM,
  139. },
  140. };
  141. static struct platform_device omap2_mcspi2 = {
  142. .name = "omap2_mcspi",
  143. .id = 2,
  144. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  145. .resource = omap2_mcspi2_resources,
  146. .dev = {
  147. .platform_data = &omap2_mcspi2_config,
  148. },
  149. };
  150. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
  151. static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
  152. .num_cs = 2,
  153. };
  154. static struct resource omap2_mcspi3_resources[] = {
  155. {
  156. .start = OMAP2_MCSPI3_BASE,
  157. .end = OMAP2_MCSPI3_BASE + 0xff,
  158. .flags = IORESOURCE_MEM,
  159. },
  160. };
  161. static struct platform_device omap2_mcspi3 = {
  162. .name = "omap2_mcspi",
  163. .id = 3,
  164. .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
  165. .resource = omap2_mcspi3_resources,
  166. .dev = {
  167. .platform_data = &omap2_mcspi3_config,
  168. },
  169. };
  170. #endif
  171. #ifdef CONFIG_ARCH_OMAP3
  172. static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
  173. .num_cs = 1,
  174. };
  175. static struct resource omap2_mcspi4_resources[] = {
  176. {
  177. .start = OMAP2_MCSPI4_BASE,
  178. .end = OMAP2_MCSPI4_BASE + 0xff,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. };
  182. static struct platform_device omap2_mcspi4 = {
  183. .name = "omap2_mcspi",
  184. .id = 4,
  185. .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
  186. .resource = omap2_mcspi4_resources,
  187. .dev = {
  188. .platform_data = &omap2_mcspi4_config,
  189. },
  190. };
  191. #endif
  192. static void omap_init_mcspi(void)
  193. {
  194. platform_device_register(&omap2_mcspi1);
  195. platform_device_register(&omap2_mcspi2);
  196. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
  197. platform_device_register(&omap2_mcspi3);
  198. #endif
  199. #ifdef CONFIG_ARCH_OMAP3
  200. platform_device_register(&omap2_mcspi4);
  201. #endif
  202. }
  203. #else
  204. static inline void omap_init_mcspi(void) {}
  205. #endif
  206. #ifdef CONFIG_SND_OMAP24XX_EAC
  207. #define OMAP2_EAC_BASE 0x48090000
  208. static struct resource omap2_eac_resources[] = {
  209. {
  210. .start = OMAP2_EAC_BASE,
  211. .end = OMAP2_EAC_BASE + 0x109,
  212. .flags = IORESOURCE_MEM,
  213. },
  214. };
  215. static struct platform_device omap2_eac_device = {
  216. .name = "omap24xx-eac",
  217. .id = -1,
  218. .num_resources = ARRAY_SIZE(omap2_eac_resources),
  219. .resource = omap2_eac_resources,
  220. .dev = {
  221. .platform_data = NULL,
  222. },
  223. };
  224. void omap_init_eac(struct eac_platform_data *pdata)
  225. {
  226. omap2_eac_device.dev.platform_data = pdata;
  227. platform_device_register(&omap2_eac_device);
  228. }
  229. #else
  230. void omap_init_eac(struct eac_platform_data *pdata) {}
  231. #endif
  232. #ifdef CONFIG_OMAP_SHA1_MD5
  233. static struct resource sha1_md5_resources[] = {
  234. {
  235. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  236. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  237. .flags = IORESOURCE_MEM,
  238. },
  239. {
  240. .start = INT_24XX_SHA1MD5,
  241. .flags = IORESOURCE_IRQ,
  242. }
  243. };
  244. static struct platform_device sha1_md5_device = {
  245. .name = "OMAP SHA1/MD5",
  246. .id = -1,
  247. .num_resources = ARRAY_SIZE(sha1_md5_resources),
  248. .resource = sha1_md5_resources,
  249. };
  250. static void omap_init_sha1_md5(void)
  251. {
  252. platform_device_register(&sha1_md5_device);
  253. }
  254. #else
  255. static inline void omap_init_sha1_md5(void) { }
  256. #endif
  257. /*-------------------------------------------------------------------------*/
  258. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) || \
  259. defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
  260. static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  261. int controller_nr)
  262. {
  263. if (cpu_is_omap2420() && controller_nr == 0) {
  264. omap_cfg_reg(H18_24XX_MMC_CMD);
  265. omap_cfg_reg(H15_24XX_MMC_CLKI);
  266. omap_cfg_reg(G19_24XX_MMC_CLKO);
  267. omap_cfg_reg(F20_24XX_MMC_DAT0);
  268. omap_cfg_reg(F19_24XX_MMC_DAT_DIR0);
  269. omap_cfg_reg(G18_24XX_MMC_CMD_DIR);
  270. if (mmc_controller->slots[0].wires == 4) {
  271. omap_cfg_reg(H14_24XX_MMC_DAT1);
  272. omap_cfg_reg(E19_24XX_MMC_DAT2);
  273. omap_cfg_reg(D19_24XX_MMC_DAT3);
  274. omap_cfg_reg(E20_24XX_MMC_DAT_DIR1);
  275. omap_cfg_reg(F18_24XX_MMC_DAT_DIR2);
  276. omap_cfg_reg(E18_24XX_MMC_DAT_DIR3);
  277. }
  278. /*
  279. * Use internal loop-back in MMC/SDIO Module Input Clock
  280. * selection
  281. */
  282. if (mmc_controller->slots[0].internal_clock) {
  283. u32 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  284. v |= (1 << 24);
  285. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  286. }
  287. }
  288. }
  289. void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
  290. int nr_controllers)
  291. {
  292. int i;
  293. for (i = 0; i < nr_controllers; i++) {
  294. unsigned long base, size;
  295. unsigned int irq = 0;
  296. if (!mmc_data[i])
  297. continue;
  298. omap2_mmc_mux(mmc_data[i], i);
  299. switch (i) {
  300. case 0:
  301. base = OMAP2_MMC1_BASE;
  302. irq = INT_24XX_MMC_IRQ;
  303. break;
  304. case 1:
  305. base = OMAP2_MMC2_BASE;
  306. irq = INT_24XX_MMC2_IRQ;
  307. break;
  308. case 2:
  309. if (!cpu_is_omap34xx())
  310. return;
  311. base = OMAP3_MMC3_BASE;
  312. irq = INT_34XX_MMC3_IRQ;
  313. break;
  314. default:
  315. continue;
  316. }
  317. if (cpu_is_omap2420())
  318. size = OMAP2420_MMC_SIZE;
  319. else
  320. size = HSMMC_SIZE;
  321. omap_mmc_add(i, base, size, irq, mmc_data[i]);
  322. };
  323. }
  324. #endif
  325. /*-------------------------------------------------------------------------*/
  326. #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
  327. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
  328. #define OMAP_HDQ_BASE 0x480B2000
  329. #endif
  330. static struct resource omap_hdq_resources[] = {
  331. {
  332. .start = OMAP_HDQ_BASE,
  333. .end = OMAP_HDQ_BASE + 0x1C,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. {
  337. .start = INT_24XX_HDQ_IRQ,
  338. .flags = IORESOURCE_IRQ,
  339. },
  340. };
  341. static struct platform_device omap_hdq_dev = {
  342. .name = "omap_hdq",
  343. .id = 0,
  344. .dev = {
  345. .platform_data = NULL,
  346. },
  347. .num_resources = ARRAY_SIZE(omap_hdq_resources),
  348. .resource = omap_hdq_resources,
  349. };
  350. static inline void omap_hdq_init(void)
  351. {
  352. (void) platform_device_register(&omap_hdq_dev);
  353. }
  354. #else
  355. static inline void omap_hdq_init(void) {}
  356. #endif
  357. /*-------------------------------------------------------------------------*/
  358. static int __init omap2_init_devices(void)
  359. {
  360. /* please keep these calls, and their implementations above,
  361. * in alphabetical order so they're easier to sort through.
  362. */
  363. omap_init_mbox();
  364. omap_init_mcspi();
  365. omap_hdq_init();
  366. omap_init_sti();
  367. omap_init_sha1_md5();
  368. return 0;
  369. }
  370. arch_initcall(omap2_init_devices);