devices.c 8.1 KB

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