devices.c 6.7 KB

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