devices.c 7.8 KB

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