devices.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. static inline void omap_init_mbox(void) { }
  57. /*-------------------------------------------------------------------------*/
  58. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  59. static inline void omap1_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
  60. int controller_nr)
  61. {
  62. if (controller_nr == 0) {
  63. if (cpu_is_omap7xx()) {
  64. omap_cfg_reg(MMC_7XX_CMD);
  65. omap_cfg_reg(MMC_7XX_CLK);
  66. omap_cfg_reg(MMC_7XX_DAT0);
  67. } else {
  68. omap_cfg_reg(MMC_CMD);
  69. omap_cfg_reg(MMC_CLK);
  70. omap_cfg_reg(MMC_DAT0);
  71. }
  72. if (cpu_is_omap1710()) {
  73. omap_cfg_reg(M15_1710_MMC_CLKI);
  74. omap_cfg_reg(P19_1710_MMC_CMDDIR);
  75. omap_cfg_reg(P20_1710_MMC_DATDIR0);
  76. }
  77. if (mmc_controller->slots[0].wires == 4 && !cpu_is_omap7xx()) {
  78. omap_cfg_reg(MMC_DAT1);
  79. /* NOTE: DAT2 can be on W10 (here) or M15 */
  80. if (!mmc_controller->slots[0].nomux)
  81. omap_cfg_reg(MMC_DAT2);
  82. omap_cfg_reg(MMC_DAT3);
  83. }
  84. }
  85. /* Block 2 is on newer chips, and has many pinout options */
  86. if (cpu_is_omap16xx() && controller_nr == 1) {
  87. if (!mmc_controller->slots[1].nomux) {
  88. omap_cfg_reg(Y8_1610_MMC2_CMD);
  89. omap_cfg_reg(Y10_1610_MMC2_CLK);
  90. omap_cfg_reg(R18_1610_MMC2_CLKIN);
  91. omap_cfg_reg(W8_1610_MMC2_DAT0);
  92. if (mmc_controller->slots[1].wires == 4) {
  93. omap_cfg_reg(V8_1610_MMC2_DAT1);
  94. omap_cfg_reg(W15_1610_MMC2_DAT2);
  95. omap_cfg_reg(R10_1610_MMC2_DAT3);
  96. }
  97. /* These are needed for the level shifter */
  98. omap_cfg_reg(V9_1610_MMC2_CMDDIR);
  99. omap_cfg_reg(V5_1610_MMC2_DATDIR0);
  100. omap_cfg_reg(W19_1610_MMC2_DATDIR1);
  101. }
  102. /* Feedback clock must be set on OMAP-1710 MMC2 */
  103. if (cpu_is_omap1710())
  104. omap_writel(omap_readl(MOD_CONF_CTRL_1) | (1 << 24),
  105. MOD_CONF_CTRL_1);
  106. }
  107. }
  108. void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
  109. int nr_controllers)
  110. {
  111. int i;
  112. for (i = 0; i < nr_controllers; i++) {
  113. unsigned long base, size;
  114. unsigned int irq = 0;
  115. if (!mmc_data[i])
  116. continue;
  117. omap1_mmc_mux(mmc_data[i], i);
  118. switch (i) {
  119. case 0:
  120. base = OMAP1_MMC1_BASE;
  121. irq = INT_MMC;
  122. break;
  123. case 1:
  124. if (!cpu_is_omap16xx())
  125. return;
  126. base = OMAP1_MMC2_BASE;
  127. irq = INT_1610_MMC2;
  128. break;
  129. default:
  130. continue;
  131. }
  132. size = OMAP1_MMC_SIZE;
  133. omap_mmc_add("mmci-omap", i, base, size, irq, mmc_data[i]);
  134. };
  135. }
  136. #endif
  137. /*-------------------------------------------------------------------------*/
  138. /* OMAP7xx SPI support */
  139. #if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
  140. struct platform_device omap_spi1 = {
  141. .name = "omap1_spi100k",
  142. .id = 1,
  143. };
  144. struct platform_device omap_spi2 = {
  145. .name = "omap1_spi100k",
  146. .id = 2,
  147. };
  148. static void omap_init_spi100k(void)
  149. {
  150. omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
  151. if (omap_spi1.dev.platform_data)
  152. platform_device_register(&omap_spi1);
  153. omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
  154. if (omap_spi2.dev.platform_data)
  155. platform_device_register(&omap_spi2);
  156. }
  157. #else
  158. static inline void omap_init_spi100k(void)
  159. {
  160. }
  161. #endif
  162. /*-------------------------------------------------------------------------*/
  163. static inline void omap_init_sti(void) {}
  164. /*-------------------------------------------------------------------------*/
  165. /*
  166. * This gets called after board-specific INIT_MACHINE, and initializes most
  167. * on-chip peripherals accessible on this board (except for few like USB):
  168. *
  169. * (a) Does any "standard config" pin muxing needed. Board-specific
  170. * code will have muxed GPIO pins and done "nonstandard" setup;
  171. * that code could live in the boot loader.
  172. * (b) Populating board-specific platform_data with the data drivers
  173. * rely on to handle wiring variations.
  174. * (c) Creating platform devices as meaningful on this board and
  175. * with this kernel configuration.
  176. *
  177. * Claiming GPIOs, and setting their direction and initial values, is the
  178. * responsibility of the device drivers. So is responding to probe().
  179. *
  180. * Board-specific knowlege like creating devices or pin setup is to be
  181. * kept out of drivers as much as possible. In particular, pin setup
  182. * may be handled by the boot loader, and drivers should expect it will
  183. * normally have been done by the time they're probed.
  184. */
  185. static int __init omap1_init_devices(void)
  186. {
  187. /* please keep these calls, and their implementations above,
  188. * in alphabetical order so they're easier to sort through.
  189. */
  190. omap_init_mbox();
  191. omap_init_rtc();
  192. omap_init_spi100k();
  193. omap_init_sti();
  194. return 0;
  195. }
  196. arch_initcall(omap1_init_devices);