devices.c 7.6 KB

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