devices.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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/tc.h>
  20. #include <mach/board.h>
  21. #include <mach/mux.h>
  22. #include <mach/gpio.h>
  23. #include <mach/eac.h>
  24. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  25. #define OMAP2_MBOX_BASE IO_ADDRESS(OMAP24XX_MAILBOX_BASE)
  26. static struct resource mbox_resources[] = {
  27. {
  28. .start = OMAP2_MBOX_BASE,
  29. .end = OMAP2_MBOX_BASE + 0x11f,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. {
  33. .start = INT_24XX_MAIL_U0_MPU,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. {
  37. .start = INT_24XX_MAIL_U3_MPU,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. static struct platform_device mbox_device = {
  42. .name = "mailbox",
  43. .id = -1,
  44. .num_resources = ARRAY_SIZE(mbox_resources),
  45. .resource = mbox_resources,
  46. };
  47. static inline void omap_init_mbox(void)
  48. {
  49. platform_device_register(&mbox_device);
  50. }
  51. #else
  52. static inline void omap_init_mbox(void) { }
  53. #endif
  54. #if defined(CONFIG_OMAP_STI)
  55. #if defined(CONFIG_ARCH_OMAP2)
  56. #define OMAP2_STI_BASE 0x48068000
  57. #define OMAP2_STI_CHANNEL_BASE 0x54000000
  58. #define OMAP2_STI_IRQ 4
  59. static struct resource sti_resources[] = {
  60. {
  61. .start = OMAP2_STI_BASE,
  62. .end = OMAP2_STI_BASE + 0x7ff,
  63. .flags = IORESOURCE_MEM,
  64. },
  65. {
  66. .start = OMAP2_STI_CHANNEL_BASE,
  67. .end = OMAP2_STI_CHANNEL_BASE + SZ_64K - 1,
  68. .flags = IORESOURCE_MEM,
  69. },
  70. {
  71. .start = OMAP2_STI_IRQ,
  72. .flags = IORESOURCE_IRQ,
  73. }
  74. };
  75. #elif defined(CONFIG_ARCH_OMAP3)
  76. #define OMAP3_SDTI_BASE 0x54500000
  77. #define OMAP3_SDTI_CHANNEL_BASE 0x54600000
  78. static struct resource sti_resources[] = {
  79. {
  80. .start = OMAP3_SDTI_BASE,
  81. .end = OMAP3_SDTI_BASE + 0xFFF,
  82. .flags = IORESOURCE_MEM,
  83. },
  84. {
  85. .start = OMAP3_SDTI_CHANNEL_BASE,
  86. .end = OMAP3_SDTI_CHANNEL_BASE + SZ_1M - 1,
  87. .flags = IORESOURCE_MEM,
  88. }
  89. };
  90. #endif
  91. static struct platform_device sti_device = {
  92. .name = "sti",
  93. .id = -1,
  94. .num_resources = ARRAY_SIZE(sti_resources),
  95. .resource = sti_resources,
  96. };
  97. static inline void omap_init_sti(void)
  98. {
  99. platform_device_register(&sti_device);
  100. }
  101. #else
  102. static inline void omap_init_sti(void) {}
  103. #endif
  104. #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
  105. #include <mach/mcspi.h>
  106. #define OMAP2_MCSPI1_BASE 0x48098000
  107. #define OMAP2_MCSPI2_BASE 0x4809a000
  108. #define OMAP2_MCSPI3_BASE 0x480b8000
  109. #define OMAP2_MCSPI4_BASE 0x480ba000
  110. static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
  111. .num_cs = 4,
  112. };
  113. static struct resource omap2_mcspi1_resources[] = {
  114. {
  115. .start = OMAP2_MCSPI1_BASE,
  116. .end = OMAP2_MCSPI1_BASE + 0xff,
  117. .flags = IORESOURCE_MEM,
  118. },
  119. };
  120. static struct platform_device omap2_mcspi1 = {
  121. .name = "omap2_mcspi",
  122. .id = 1,
  123. .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
  124. .resource = omap2_mcspi1_resources,
  125. .dev = {
  126. .platform_data = &omap2_mcspi1_config,
  127. },
  128. };
  129. static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
  130. .num_cs = 2,
  131. };
  132. static struct resource omap2_mcspi2_resources[] = {
  133. {
  134. .start = OMAP2_MCSPI2_BASE,
  135. .end = OMAP2_MCSPI2_BASE + 0xff,
  136. .flags = IORESOURCE_MEM,
  137. },
  138. };
  139. static struct platform_device omap2_mcspi2 = {
  140. .name = "omap2_mcspi",
  141. .id = 2,
  142. .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
  143. .resource = omap2_mcspi2_resources,
  144. .dev = {
  145. .platform_data = &omap2_mcspi2_config,
  146. },
  147. };
  148. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
  149. static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
  150. .num_cs = 2,
  151. };
  152. static struct resource omap2_mcspi3_resources[] = {
  153. {
  154. .start = OMAP2_MCSPI3_BASE,
  155. .end = OMAP2_MCSPI3_BASE + 0xff,
  156. .flags = IORESOURCE_MEM,
  157. },
  158. };
  159. static struct platform_device omap2_mcspi3 = {
  160. .name = "omap2_mcspi",
  161. .id = 3,
  162. .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
  163. .resource = omap2_mcspi3_resources,
  164. .dev = {
  165. .platform_data = &omap2_mcspi3_config,
  166. },
  167. };
  168. #endif
  169. #ifdef CONFIG_ARCH_OMAP3
  170. static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
  171. .num_cs = 1,
  172. };
  173. static struct resource omap2_mcspi4_resources[] = {
  174. {
  175. .start = OMAP2_MCSPI4_BASE,
  176. .end = OMAP2_MCSPI4_BASE + 0xff,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. };
  180. static struct platform_device omap2_mcspi4 = {
  181. .name = "omap2_mcspi",
  182. .id = 4,
  183. .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
  184. .resource = omap2_mcspi4_resources,
  185. .dev = {
  186. .platform_data = &omap2_mcspi4_config,
  187. },
  188. };
  189. #endif
  190. static void omap_init_mcspi(void)
  191. {
  192. platform_device_register(&omap2_mcspi1);
  193. platform_device_register(&omap2_mcspi2);
  194. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3)
  195. platform_device_register(&omap2_mcspi3);
  196. #endif
  197. #ifdef CONFIG_ARCH_OMAP3
  198. platform_device_register(&omap2_mcspi4);
  199. #endif
  200. }
  201. #else
  202. static inline void omap_init_mcspi(void) {}
  203. #endif
  204. #ifdef CONFIG_SND_OMAP24XX_EAC
  205. #define OMAP2_EAC_BASE 0x48090000
  206. static struct resource omap2_eac_resources[] = {
  207. {
  208. .start = OMAP2_EAC_BASE,
  209. .end = OMAP2_EAC_BASE + 0x109,
  210. .flags = IORESOURCE_MEM,
  211. },
  212. };
  213. static struct platform_device omap2_eac_device = {
  214. .name = "omap24xx-eac",
  215. .id = -1,
  216. .num_resources = ARRAY_SIZE(omap2_eac_resources),
  217. .resource = omap2_eac_resources,
  218. .dev = {
  219. .platform_data = NULL,
  220. },
  221. };
  222. void omap_init_eac(struct eac_platform_data *pdata)
  223. {
  224. omap2_eac_device.dev.platform_data = pdata;
  225. platform_device_register(&omap2_eac_device);
  226. }
  227. #else
  228. void omap_init_eac(struct eac_platform_data *pdata) {}
  229. #endif
  230. #ifdef CONFIG_OMAP_SHA1_MD5
  231. static struct resource sha1_md5_resources[] = {
  232. {
  233. .start = OMAP24XX_SEC_SHA1MD5_BASE,
  234. .end = OMAP24XX_SEC_SHA1MD5_BASE + 0x64,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. {
  238. .start = INT_24XX_SHA1MD5,
  239. .flags = IORESOURCE_IRQ,
  240. }
  241. };
  242. static struct platform_device sha1_md5_device = {
  243. .name = "OMAP SHA1/MD5",
  244. .id = -1,
  245. .num_resources = ARRAY_SIZE(sha1_md5_resources),
  246. .resource = sha1_md5_resources,
  247. };
  248. static void omap_init_sha1_md5(void)
  249. {
  250. platform_device_register(&sha1_md5_device);
  251. }
  252. #else
  253. static inline void omap_init_sha1_md5(void) { }
  254. #endif
  255. #if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
  256. #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
  257. #define OMAP_HDQ_BASE 0x480B2000
  258. #endif
  259. static struct resource omap_hdq_resources[] = {
  260. {
  261. .start = OMAP_HDQ_BASE,
  262. .end = OMAP_HDQ_BASE + 0x1C,
  263. .flags = IORESOURCE_MEM,
  264. },
  265. {
  266. .start = INT_24XX_HDQ_IRQ,
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. };
  270. static struct platform_device omap_hdq_dev = {
  271. .name = "omap_hdq",
  272. .id = 0,
  273. .dev = {
  274. .platform_data = NULL,
  275. },
  276. .num_resources = ARRAY_SIZE(omap_hdq_resources),
  277. .resource = omap_hdq_resources,
  278. };
  279. static inline void omap_hdq_init(void)
  280. {
  281. (void) platform_device_register(&omap_hdq_dev);
  282. }
  283. #else
  284. static inline void omap_hdq_init(void) {}
  285. #endif
  286. /*-------------------------------------------------------------------------*/
  287. static int __init omap2_init_devices(void)
  288. {
  289. /* please keep these calls, and their implementations above,
  290. * in alphabetical order so they're easier to sort through.
  291. */
  292. omap_init_mbox();
  293. omap_init_mcspi();
  294. omap_hdq_init();
  295. omap_init_sti();
  296. omap_init_sha1_md5();
  297. return 0;
  298. }
  299. arch_initcall(omap2_init_devices);