board-mop500-sdi.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * Author: Hanumath Prasad <hanumath.prasad@stericsson.com>
  5. * License terms: GNU General Public License (GPL) version 2
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/gpio.h>
  9. #include <linux/amba/bus.h>
  10. #include <linux/amba/mmci.h>
  11. #include <linux/mmc/host.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/platform_data/dma-ste-dma40.h>
  14. #include <asm/mach-types.h>
  15. #include <mach/devices.h>
  16. #include <mach/hardware.h>
  17. #include "devices-db8500.h"
  18. #include "board-mop500.h"
  19. #include "ste-dma40-db8500.h"
  20. /*
  21. * v2 has a new version of this block that need to be forced, the number found
  22. * in hardware is incorrect
  23. */
  24. #define U8500_SDI_V2_PERIPHID 0x10480180
  25. /*
  26. * SDI 0 (MicroSD slot)
  27. */
  28. /* GPIO pins used by the sdi0 level shifter */
  29. static int sdi0_en = -1;
  30. static int sdi0_vsel = -1;
  31. static int mop500_sdi0_ios_handler(struct device *dev, struct mmc_ios *ios)
  32. {
  33. switch (ios->power_mode) {
  34. case MMC_POWER_UP:
  35. case MMC_POWER_ON:
  36. /*
  37. * Level shifter voltage should depend on vdd to when deciding
  38. * on either 1.8V or 2.9V. Once the decision has been made the
  39. * level shifter must be disabled and re-enabled with a changed
  40. * select signal in order to switch the voltage. Since there is
  41. * no framework support yet for indicating 1.8V in vdd, use the
  42. * default 2.9V.
  43. */
  44. gpio_direction_output(sdi0_vsel, 0);
  45. gpio_direction_output(sdi0_en, 1);
  46. break;
  47. case MMC_POWER_OFF:
  48. gpio_direction_output(sdi0_vsel, 0);
  49. gpio_direction_output(sdi0_en, 0);
  50. break;
  51. }
  52. return 0;
  53. }
  54. #ifdef CONFIG_STE_DMA40
  55. struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
  56. .mode = STEDMA40_MODE_LOGICAL,
  57. .dir = STEDMA40_PERIPH_TO_MEM,
  58. .src_dev_type = DB8500_DMA_DEV29_SD_MM0_RX,
  59. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  60. .src_info.data_width = STEDMA40_WORD_WIDTH,
  61. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  62. };
  63. static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
  64. .mode = STEDMA40_MODE_LOGICAL,
  65. .dir = STEDMA40_MEM_TO_PERIPH,
  66. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  67. .dst_dev_type = DB8500_DMA_DEV29_SD_MM0_TX,
  68. .src_info.data_width = STEDMA40_WORD_WIDTH,
  69. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  70. };
  71. #endif
  72. struct mmci_platform_data mop500_sdi0_data = {
  73. .ocr_mask = MMC_VDD_29_30,
  74. .f_max = 50000000,
  75. .capabilities = MMC_CAP_4_BIT_DATA |
  76. MMC_CAP_SD_HIGHSPEED |
  77. MMC_CAP_MMC_HIGHSPEED,
  78. .gpio_wp = -1,
  79. .sigdir = MCI_ST_FBCLKEN |
  80. MCI_ST_CMDDIREN |
  81. MCI_ST_DATA0DIREN |
  82. MCI_ST_DATA2DIREN,
  83. #ifdef CONFIG_STE_DMA40
  84. .dma_filter = stedma40_filter,
  85. .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
  86. .dma_tx_param = &mop500_sdi0_dma_cfg_tx,
  87. #endif
  88. };
  89. static void sdi0_configure(struct device *parent)
  90. {
  91. int ret;
  92. ret = gpio_request(sdi0_en, "level shifter enable");
  93. if (!ret)
  94. ret = gpio_request(sdi0_vsel,
  95. "level shifter 1v8-3v select");
  96. if (ret) {
  97. pr_warning("unable to config sdi0 gpios for level shifter.\n");
  98. return;
  99. }
  100. /* Select the default 2.9V and enable level shifter */
  101. gpio_direction_output(sdi0_vsel, 0);
  102. gpio_direction_output(sdi0_en, 1);
  103. /* Add the device, force v2 to subrevision 1 */
  104. db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
  105. }
  106. void mop500_sdi_tc35892_init(struct device *parent)
  107. {
  108. mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
  109. sdi0_en = GPIO_SDMMC_EN;
  110. sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL;
  111. sdi0_configure(parent);
  112. }
  113. /*
  114. * SDI1 (SDIO WLAN)
  115. */
  116. #ifdef CONFIG_STE_DMA40
  117. static struct stedma40_chan_cfg sdi1_dma_cfg_rx = {
  118. .mode = STEDMA40_MODE_LOGICAL,
  119. .dir = STEDMA40_PERIPH_TO_MEM,
  120. .src_dev_type = DB8500_DMA_DEV32_SD_MM1_RX,
  121. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  122. .src_info.data_width = STEDMA40_WORD_WIDTH,
  123. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  124. };
  125. static struct stedma40_chan_cfg sdi1_dma_cfg_tx = {
  126. .mode = STEDMA40_MODE_LOGICAL,
  127. .dir = STEDMA40_MEM_TO_PERIPH,
  128. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  129. .dst_dev_type = DB8500_DMA_DEV32_SD_MM1_TX,
  130. .src_info.data_width = STEDMA40_WORD_WIDTH,
  131. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  132. };
  133. #endif
  134. struct mmci_platform_data mop500_sdi1_data = {
  135. .ocr_mask = MMC_VDD_29_30,
  136. .f_max = 50000000,
  137. .capabilities = MMC_CAP_4_BIT_DATA,
  138. .gpio_cd = -1,
  139. .gpio_wp = -1,
  140. #ifdef CONFIG_STE_DMA40
  141. .dma_filter = stedma40_filter,
  142. .dma_rx_param = &sdi1_dma_cfg_rx,
  143. .dma_tx_param = &sdi1_dma_cfg_tx,
  144. #endif
  145. };
  146. /*
  147. * SDI 2 (POP eMMC, not on DB8500ed)
  148. */
  149. #ifdef CONFIG_STE_DMA40
  150. struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
  151. .mode = STEDMA40_MODE_LOGICAL,
  152. .dir = STEDMA40_PERIPH_TO_MEM,
  153. .src_dev_type = DB8500_DMA_DEV28_SD_MM2_RX,
  154. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  155. .src_info.data_width = STEDMA40_WORD_WIDTH,
  156. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  157. };
  158. static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
  159. .mode = STEDMA40_MODE_LOGICAL,
  160. .dir = STEDMA40_MEM_TO_PERIPH,
  161. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  162. .dst_dev_type = DB8500_DMA_DEV28_SD_MM2_TX,
  163. .src_info.data_width = STEDMA40_WORD_WIDTH,
  164. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  165. };
  166. #endif
  167. struct mmci_platform_data mop500_sdi2_data = {
  168. .ocr_mask = MMC_VDD_165_195,
  169. .f_max = 50000000,
  170. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  171. MMC_CAP_MMC_HIGHSPEED,
  172. .gpio_cd = -1,
  173. .gpio_wp = -1,
  174. #ifdef CONFIG_STE_DMA40
  175. .dma_filter = stedma40_filter,
  176. .dma_rx_param = &mop500_sdi2_dma_cfg_rx,
  177. .dma_tx_param = &mop500_sdi2_dma_cfg_tx,
  178. #endif
  179. };
  180. /*
  181. * SDI 4 (on-board eMMC)
  182. */
  183. #ifdef CONFIG_STE_DMA40
  184. struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
  185. .mode = STEDMA40_MODE_LOGICAL,
  186. .dir = STEDMA40_PERIPH_TO_MEM,
  187. .src_dev_type = DB8500_DMA_DEV42_SD_MM4_RX,
  188. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  189. .src_info.data_width = STEDMA40_WORD_WIDTH,
  190. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  191. };
  192. static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
  193. .mode = STEDMA40_MODE_LOGICAL,
  194. .dir = STEDMA40_MEM_TO_PERIPH,
  195. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  196. .dst_dev_type = DB8500_DMA_DEV42_SD_MM4_TX,
  197. .src_info.data_width = STEDMA40_WORD_WIDTH,
  198. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  199. };
  200. #endif
  201. struct mmci_platform_data mop500_sdi4_data = {
  202. .ocr_mask = MMC_VDD_29_30,
  203. .f_max = 50000000,
  204. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  205. MMC_CAP_MMC_HIGHSPEED,
  206. .gpio_cd = -1,
  207. .gpio_wp = -1,
  208. #ifdef CONFIG_STE_DMA40
  209. .dma_filter = stedma40_filter,
  210. .dma_rx_param = &mop500_sdi4_dma_cfg_rx,
  211. .dma_tx_param = &mop500_sdi4_dma_cfg_tx,
  212. #endif
  213. };
  214. void __init mop500_sdi_init(struct device *parent)
  215. {
  216. /* PoP:ed eMMC */
  217. db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
  218. /* On-board eMMC */
  219. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  220. /*
  221. * On boards with the TC35892 GPIO expander, sdi0 will finally
  222. * be added when the TC35892 initializes and calls
  223. * mop500_sdi_tc35892_init() above.
  224. */
  225. }
  226. void __init snowball_sdi_init(struct device *parent)
  227. {
  228. /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
  229. mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
  230. /* On-board eMMC */
  231. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  232. /* External Micro SD slot */
  233. mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
  234. mop500_sdi0_data.cd_invert = true;
  235. sdi0_en = SNOWBALL_SDMMC_EN_GPIO;
  236. sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO;
  237. sdi0_configure(parent);
  238. }
  239. void __init hrefv60_sdi_init(struct device *parent)
  240. {
  241. /* PoP:ed eMMC */
  242. db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
  243. /* On-board eMMC */
  244. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  245. /* External Micro SD slot */
  246. mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
  247. sdi0_en = HREFV60_SDMMC_EN_GPIO;
  248. sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO;
  249. sdi0_configure(parent);
  250. /* WLAN SDIO channel */
  251. db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
  252. }