devices.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * linux/arch/arm/mach-omap1/devices.c
  3. *
  4. * OMAP1 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/spi/spi.h>
  17. #include <mach/hardware.h>
  18. #include <asm/mach/map.h>
  19. #include <plat/tc.h>
  20. #include <plat/board.h>
  21. #include <plat/mux.h>
  22. #include <mach/gpio.h>
  23. #include <plat/mmc.h>
  24. #include <plat/omap7xx.h>
  25. /*-------------------------------------------------------------------------*/
  26. #if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
  27. #define OMAP_RTC_BASE 0xfffb4800
  28. static struct resource rtc_resources[] = {
  29. {
  30. .start = OMAP_RTC_BASE,
  31. .end = OMAP_RTC_BASE + 0x5f,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. {
  35. .start = INT_RTC_TIMER,
  36. .flags = IORESOURCE_IRQ,
  37. },
  38. {
  39. .start = INT_RTC_ALARM,
  40. .flags = IORESOURCE_IRQ,
  41. },
  42. };
  43. static struct platform_device omap_rtc_device = {
  44. .name = "omap_rtc",
  45. .id = -1,
  46. .num_resources = ARRAY_SIZE(rtc_resources),
  47. .resource = rtc_resources,
  48. };
  49. static void omap_init_rtc(void)
  50. {
  51. (void) platform_device_register(&omap_rtc_device);
  52. }
  53. #else
  54. static inline void omap_init_rtc(void) {}
  55. #endif
  56. #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
  57. #if defined(CONFIG_ARCH_OMAP15XX)
  58. # define OMAP1_MBOX_SIZE 0x23
  59. # define INT_DSP_MAILBOX1 INT_1510_DSP_MAILBOX1
  60. #elif defined(CONFIG_ARCH_OMAP16XX)
  61. # define OMAP1_MBOX_SIZE 0x2f
  62. # define INT_DSP_MAILBOX1 INT_1610_DSP_MAILBOX1
  63. #endif
  64. #define OMAP1_MBOX_BASE OMAP16XX_MAILBOX_BASE
  65. static struct resource mbox_resources[] = {
  66. {
  67. .start = OMAP1_MBOX_BASE,
  68. .end = OMAP1_MBOX_BASE + OMAP1_MBOX_SIZE,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. {
  72. .start = INT_DSP_MAILBOX1,
  73. .flags = IORESOURCE_IRQ,
  74. },
  75. };
  76. static struct platform_device mbox_device = {
  77. .name = "omap1-mailbox",
  78. .id = -1,
  79. .num_resources = ARRAY_SIZE(mbox_resources),
  80. .resource = mbox_resources,
  81. };
  82. static inline void omap_init_mbox(void)
  83. {
  84. platform_device_register(&mbox_device);
  85. }
  86. #else
  87. static inline void omap_init_mbox(void) { }
  88. #endif
  89. /*-------------------------------------------------------------------------*/
  90. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  91. static inline void omap1_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  92. int controller_nr)
  93. {
  94. if (controller_nr == 0) {
  95. if (cpu_is_omap7xx()) {
  96. omap_cfg_reg(MMC_7XX_CMD);
  97. omap_cfg_reg(MMC_7XX_CLK);
  98. omap_cfg_reg(MMC_7XX_DAT0);
  99. } else {
  100. omap_cfg_reg(MMC_CMD);
  101. omap_cfg_reg(MMC_CLK);
  102. omap_cfg_reg(MMC_DAT0);
  103. }
  104. if (cpu_is_omap1710()) {
  105. omap_cfg_reg(M15_1710_MMC_CLKI);
  106. omap_cfg_reg(P19_1710_MMC_CMDDIR);
  107. omap_cfg_reg(P20_1710_MMC_DATDIR0);
  108. }
  109. if (mmc_controller->slots[0].wires == 4 && !cpu_is_omap7xx()) {
  110. omap_cfg_reg(MMC_DAT1);
  111. /* NOTE: DAT2 can be on W10 (here) or M15 */
  112. if (!mmc_controller->slots[0].nomux)
  113. omap_cfg_reg(MMC_DAT2);
  114. omap_cfg_reg(MMC_DAT3);
  115. }
  116. }
  117. /* Block 2 is on newer chips, and has many pinout options */
  118. if (cpu_is_omap16xx() && controller_nr == 1) {
  119. if (!mmc_controller->slots[1].nomux) {
  120. omap_cfg_reg(Y8_1610_MMC2_CMD);
  121. omap_cfg_reg(Y10_1610_MMC2_CLK);
  122. omap_cfg_reg(R18_1610_MMC2_CLKIN);
  123. omap_cfg_reg(W8_1610_MMC2_DAT0);
  124. if (mmc_controller->slots[1].wires == 4) {
  125. omap_cfg_reg(V8_1610_MMC2_DAT1);
  126. omap_cfg_reg(W15_1610_MMC2_DAT2);
  127. omap_cfg_reg(R10_1610_MMC2_DAT3);
  128. }
  129. /* These are needed for the level shifter */
  130. omap_cfg_reg(V9_1610_MMC2_CMDDIR);
  131. omap_cfg_reg(V5_1610_MMC2_DATDIR0);
  132. omap_cfg_reg(W19_1610_MMC2_DATDIR1);
  133. }
  134. /* Feedback clock must be set on OMAP-1710 MMC2 */
  135. if (cpu_is_omap1710())
  136. omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24),
  137. MOD_CONF_CTRL_1);
  138. }
  139. }
  140. void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  141. int nr_controllers)
  142. {
  143. int i;
  144. for (i = 0; i < nr_controllers; i++) {
  145. unsigned long base, size;
  146. unsigned int irq = 0;
  147. if (!mmc_data[i])
  148. continue;
  149. omap1_mmc_mux(mmc_data[i], i);
  150. switch (i) {
  151. case 0:
  152. base = OMAP1_MMC1_BASE;
  153. irq = INT_MMC;
  154. break;
  155. case 1:
  156. if (!cpu_is_omap16xx())
  157. return;
  158. base = OMAP1_MMC2_BASE;
  159. irq = INT_1610_MMC2;
  160. break;
  161. default:
  162. continue;
  163. }
  164. size = OMAP1_MMC_SIZE;
  165. omap_mmc_add("mmci-omap", i, base, size, irq, mmc_data[i]);
  166. };
  167. }
  168. #endif
  169. /*-------------------------------------------------------------------------*/
  170. /* OMAP7xx SPI support */
  171. #if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
  172. struct platform_device omap_spi1 = {
  173. .name = "omap1_spi100k",
  174. .id = 1,
  175. };
  176. struct platform_device omap_spi2 = {
  177. .name = "omap1_spi100k",
  178. .id = 2,
  179. };
  180. static void omap_init_spi100k(void)
  181. {
  182. omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
  183. if (omap_spi1.dev.platform_data)
  184. platform_device_register(&omap_spi1);
  185. omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
  186. if (omap_spi2.dev.platform_data)
  187. platform_device_register(&omap_spi2);
  188. }
  189. #else
  190. static inline void omap_init_spi100k(void)
  191. {
  192. }
  193. #endif
  194. /*-------------------------------------------------------------------------*/
  195. #if defined(CONFIG_OMAP_STI)
  196. #define OMAP1_STI_BASE 0xfffea000
  197. #define OMAP1_STI_CHANNEL_BASE (OMAP1_STI_BASE + 0x400)
  198. static struct resource sti_resources[] = {
  199. {
  200. .start = OMAP1_STI_BASE,
  201. .end = OMAP1_STI_BASE + SZ_1K - 1,
  202. .flags = IORESOURCE_MEM,
  203. },
  204. {
  205. .start = OMAP1_STI_CHANNEL_BASE,
  206. .end = OMAP1_STI_CHANNEL_BASE + SZ_1K - 1,
  207. .flags = IORESOURCE_MEM,
  208. },
  209. {
  210. .start = INT_1610_STI,
  211. .flags = IORESOURCE_IRQ,
  212. }
  213. };
  214. static struct platform_device sti_device = {
  215. .name = "sti",
  216. .id = -1,
  217. .num_resources = ARRAY_SIZE(sti_resources),
  218. .resource = sti_resources,
  219. };
  220. static inline void omap_init_sti(void)
  221. {
  222. platform_device_register(&sti_device);
  223. }
  224. #else
  225. static inline void omap_init_sti(void) {}
  226. #endif
  227. /*-------------------------------------------------------------------------*/
  228. /*
  229. * This gets called after board-specific INIT_MACHINE, and initializes most
  230. * on-chip peripherals accessible on this board (except for few like USB):
  231. *
  232. * (a) Does any "standard config" pin muxing needed. Board-specific
  233. * code will have muxed GPIO pins and done "nonstandard" setup;
  234. * that code could live in the boot loader.
  235. * (b) Populating board-specific platform_data with the data drivers
  236. * rely on to handle wiring variations.
  237. * (c) Creating platform devices as meaningful on this board and
  238. * with this kernel configuration.
  239. *
  240. * Claiming GPIOs, and setting their direction and initial values, is the
  241. * responsibility of the device drivers. So is responding to probe().
  242. *
  243. * Board-specific knowlege like creating devices or pin setup is to be
  244. * kept out of drivers as much as possible. In particular, pin setup
  245. * may be handled by the boot loader, and drivers should expect it will
  246. * normally have been done by the time they're probed.
  247. */
  248. static int __init omap1_init_devices(void)
  249. {
  250. /* please keep these calls, and their implementations above,
  251. * in alphabetical order so they're easier to sort through.
  252. */
  253. omap_init_mbox();
  254. omap_init_rtc();
  255. omap_init_spi100k();
  256. omap_init_sti();
  257. return 0;
  258. }
  259. arch_initcall(omap1_init_devices);