/kern_oII/arch/arm/mach-davinci/devices.c

http://omnia2droid.googlecode.com/ · C · 267 lines · 188 code · 43 blank · 36 comment · 9 complexity · 2c7fe10aea35e12882a7eab72220de04 MD5 · raw file

  1. /*
  2. * mach-davinci/devices.c
  3. *
  4. * DaVinci 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/dma-mapping.h>
  16. #include <linux/io.h>
  17. #include <asm/mach/map.h>
  18. #include <mach/hardware.h>
  19. #include <mach/i2c.h>
  20. #include <mach/irqs.h>
  21. #include <mach/cputype.h>
  22. #include <mach/mux.h>
  23. #include <mach/edma.h>
  24. #include <mach/mmc.h>
  25. #include <mach/time.h>
  26. #define DAVINCI_I2C_BASE 0x01C21000
  27. #define DAVINCI_MMCSD0_BASE 0x01E10000
  28. #define DM355_MMCSD0_BASE 0x01E11000
  29. #define DM355_MMCSD1_BASE 0x01E00000
  30. static struct resource i2c_resources[] = {
  31. {
  32. .start = DAVINCI_I2C_BASE,
  33. .end = DAVINCI_I2C_BASE + 0x40,
  34. .flags = IORESOURCE_MEM,
  35. },
  36. {
  37. .start = IRQ_I2C,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. static struct platform_device davinci_i2c_device = {
  42. .name = "i2c_davinci",
  43. .id = 1,
  44. .num_resources = ARRAY_SIZE(i2c_resources),
  45. .resource = i2c_resources,
  46. };
  47. void __init davinci_init_i2c(struct davinci_i2c_platform_data *pdata)
  48. {
  49. if (cpu_is_davinci_dm644x())
  50. davinci_cfg_reg(DM644X_I2C);
  51. davinci_i2c_device.dev.platform_data = pdata;
  52. (void) platform_device_register(&davinci_i2c_device);
  53. }
  54. #if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
  55. static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32);
  56. static struct resource mmcsd0_resources[] = {
  57. {
  58. /* different on dm355 */
  59. .start = DAVINCI_MMCSD0_BASE,
  60. .end = DAVINCI_MMCSD0_BASE + SZ_4K - 1,
  61. .flags = IORESOURCE_MEM,
  62. },
  63. /* IRQs: MMC/SD, then SDIO */
  64. {
  65. .start = IRQ_MMCINT,
  66. .flags = IORESOURCE_IRQ,
  67. }, {
  68. /* different on dm355 */
  69. .start = IRQ_SDIOINT,
  70. .flags = IORESOURCE_IRQ,
  71. },
  72. /* DMA channels: RX, then TX */
  73. {
  74. .start = DAVINCI_DMA_MMCRXEVT,
  75. .flags = IORESOURCE_DMA,
  76. }, {
  77. .start = DAVINCI_DMA_MMCTXEVT,
  78. .flags = IORESOURCE_DMA,
  79. },
  80. };
  81. static struct platform_device davinci_mmcsd0_device = {
  82. .name = "davinci_mmc",
  83. .id = 0,
  84. .dev = {
  85. .dma_mask = &mmcsd0_dma_mask,
  86. .coherent_dma_mask = DMA_BIT_MASK(32),
  87. },
  88. .num_resources = ARRAY_SIZE(mmcsd0_resources),
  89. .resource = mmcsd0_resources,
  90. };
  91. static u64 mmcsd1_dma_mask = DMA_BIT_MASK(32);
  92. static struct resource mmcsd1_resources[] = {
  93. {
  94. .start = DM355_MMCSD1_BASE,
  95. .end = DM355_MMCSD1_BASE + SZ_4K - 1,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. /* IRQs: MMC/SD, then SDIO */
  99. {
  100. .start = IRQ_DM355_MMCINT1,
  101. .flags = IORESOURCE_IRQ,
  102. }, {
  103. .start = IRQ_DM355_SDIOINT1,
  104. .flags = IORESOURCE_IRQ,
  105. },
  106. /* DMA channels: RX, then TX */
  107. {
  108. .start = 30, /* rx */
  109. .flags = IORESOURCE_DMA,
  110. }, {
  111. .start = 31, /* tx */
  112. .flags = IORESOURCE_DMA,
  113. },
  114. };
  115. static struct platform_device davinci_mmcsd1_device = {
  116. .name = "davinci_mmc",
  117. .id = 1,
  118. .dev = {
  119. .dma_mask = &mmcsd1_dma_mask,
  120. .coherent_dma_mask = DMA_BIT_MASK(32),
  121. },
  122. .num_resources = ARRAY_SIZE(mmcsd1_resources),
  123. .resource = mmcsd1_resources,
  124. };
  125. void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
  126. {
  127. struct platform_device *pdev = NULL;
  128. if (WARN_ON(cpu_is_davinci_dm646x()))
  129. return;
  130. /* REVISIT: update PINMUX, ARM_IRQMUX, and EDMA_EVTMUX here too;
  131. * for example if MMCSD1 is used for SDIO, maybe DAT2 is unused.
  132. *
  133. * FIXME dm6441 (no MMC/SD), dm357 (one), and dm335 (two) are
  134. * not handled right here ...
  135. */
  136. switch (module) {
  137. case 1:
  138. if (!cpu_is_davinci_dm355())
  139. break;
  140. /* REVISIT we may not need all these pins if e.g. this
  141. * is a hard-wired SDIO device...
  142. */
  143. davinci_cfg_reg(DM355_SD1_CMD);
  144. davinci_cfg_reg(DM355_SD1_CLK);
  145. davinci_cfg_reg(DM355_SD1_DATA0);
  146. davinci_cfg_reg(DM355_SD1_DATA1);
  147. davinci_cfg_reg(DM355_SD1_DATA2);
  148. davinci_cfg_reg(DM355_SD1_DATA3);
  149. pdev = &davinci_mmcsd1_device;
  150. break;
  151. case 0:
  152. if (cpu_is_davinci_dm355()) {
  153. mmcsd0_resources[0].start = DM355_MMCSD0_BASE;
  154. mmcsd0_resources[0].end = DM355_MMCSD0_BASE + SZ_4K - 1;
  155. mmcsd0_resources[2].start = IRQ_DM355_SDIOINT0;
  156. /* expose all 6 MMC0 signals: CLK, CMD, DATA[0..3] */
  157. davinci_cfg_reg(DM355_MMCSD0);
  158. /* enable RX EDMA */
  159. davinci_cfg_reg(DM355_EVT26_MMC0_RX);
  160. }
  161. else if (cpu_is_davinci_dm644x()) {
  162. /* REVISIT: should this be in board-init code? */
  163. void __iomem *base =
  164. IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
  165. /* Power-on 3.3V IO cells */
  166. __raw_writel(0, base + DM64XX_VDD3P3V_PWDN);
  167. /*Set up the pull regiter for MMC */
  168. davinci_cfg_reg(DM644X_MSTK);
  169. }
  170. pdev = &davinci_mmcsd0_device;
  171. break;
  172. }
  173. if (WARN_ON(!pdev))
  174. return;
  175. pdev->dev.platform_data = config;
  176. platform_device_register(pdev);
  177. }
  178. #else
  179. void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
  180. {
  181. }
  182. #endif
  183. /*-------------------------------------------------------------------------*/
  184. static struct resource wdt_resources[] = {
  185. {
  186. .flags = IORESOURCE_MEM,
  187. },
  188. };
  189. struct platform_device davinci_wdt_device = {
  190. .name = "watchdog",
  191. .id = -1,
  192. .num_resources = ARRAY_SIZE(wdt_resources),
  193. .resource = wdt_resources,
  194. };
  195. static void davinci_init_wdt(void)
  196. {
  197. struct davinci_soc_info *soc_info = &davinci_soc_info;
  198. wdt_resources[0].start = (resource_size_t)soc_info->wdt_base;
  199. wdt_resources[0].end = (resource_size_t)soc_info->wdt_base + SZ_1K - 1;
  200. platform_device_register(&davinci_wdt_device);
  201. }
  202. /*-------------------------------------------------------------------------*/
  203. struct davinci_timer_instance davinci_timer_instance[2] = {
  204. {
  205. .base = IO_ADDRESS(DAVINCI_TIMER0_BASE),
  206. .bottom_irq = IRQ_TINT0_TINT12,
  207. .top_irq = IRQ_TINT0_TINT34,
  208. },
  209. {
  210. .base = IO_ADDRESS(DAVINCI_TIMER1_BASE),
  211. .bottom_irq = IRQ_TINT1_TINT12,
  212. .top_irq = IRQ_TINT1_TINT34,
  213. },
  214. };
  215. /*-------------------------------------------------------------------------*/
  216. static int __init davinci_init_devices(void)
  217. {
  218. /* please keep these calls, and their implementations above,
  219. * in alphabetical order so they're easier to sort through.
  220. */
  221. davinci_init_wdt();
  222. return 0;
  223. }
  224. arch_initcall(davinci_init_devices);