devices.c 6.7 KB

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