devices.c 6.6 KB

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