board-mop500-sdi.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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 <asm/mach-types.h>
  14. #include <plat/ste_dma40.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. static struct mmci_platform_data mop500_sdi0_data = {
  73. .ios_handler = mop500_sdi0_ios_handler,
  74. .ocr_mask = MMC_VDD_29_30,
  75. .f_max = 50000000,
  76. .capabilities = MMC_CAP_4_BIT_DATA |
  77. MMC_CAP_SD_HIGHSPEED |
  78. MMC_CAP_MMC_HIGHSPEED,
  79. .gpio_wp = -1,
  80. .sigdir = MCI_ST_FBCLKEN |
  81. MCI_ST_CMDDIREN |
  82. MCI_ST_DATA0DIREN |
  83. MCI_ST_DATA2DIREN,
  84. #ifdef CONFIG_STE_DMA40
  85. .dma_filter = stedma40_filter,
  86. .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
  87. .dma_tx_param = &mop500_sdi0_dma_cfg_tx,
  88. #endif
  89. };
  90. static void sdi0_configure(struct device *parent)
  91. {
  92. int ret;
  93. ret = gpio_request(sdi0_en, "level shifter enable");
  94. if (!ret)
  95. ret = gpio_request(sdi0_vsel,
  96. "level shifter 1v8-3v select");
  97. if (ret) {
  98. pr_warning("unable to config sdi0 gpios for level shifter.\n");
  99. return;
  100. }
  101. /* Select the default 2.9V and enable level shifter */
  102. gpio_direction_output(sdi0_vsel, 0);
  103. gpio_direction_output(sdi0_en, 1);
  104. /* Add the device, force v2 to subrevision 1 */
  105. db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
  106. }
  107. void mop500_sdi_tc35892_init(struct device *parent)
  108. {
  109. mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
  110. sdi0_en = GPIO_SDMMC_EN;
  111. sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL;
  112. sdi0_configure(parent);
  113. }
  114. /*
  115. * SDI1 (SDIO WLAN)
  116. */
  117. #ifdef CONFIG_STE_DMA40
  118. static struct stedma40_chan_cfg sdi1_dma_cfg_rx = {
  119. .mode = STEDMA40_MODE_LOGICAL,
  120. .dir = STEDMA40_PERIPH_TO_MEM,
  121. .src_dev_type = DB8500_DMA_DEV32_SD_MM1_RX,
  122. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  123. .src_info.data_width = STEDMA40_WORD_WIDTH,
  124. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  125. };
  126. static struct stedma40_chan_cfg sdi1_dma_cfg_tx = {
  127. .mode = STEDMA40_MODE_LOGICAL,
  128. .dir = STEDMA40_MEM_TO_PERIPH,
  129. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  130. .dst_dev_type = DB8500_DMA_DEV32_SD_MM1_TX,
  131. .src_info.data_width = STEDMA40_WORD_WIDTH,
  132. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  133. };
  134. #endif
  135. static struct mmci_platform_data mop500_sdi1_data = {
  136. .ocr_mask = MMC_VDD_29_30,
  137. .f_max = 50000000,
  138. .capabilities = MMC_CAP_4_BIT_DATA,
  139. .gpio_cd = -1,
  140. .gpio_wp = -1,
  141. #ifdef CONFIG_STE_DMA40
  142. .dma_filter = stedma40_filter,
  143. .dma_rx_param = &sdi1_dma_cfg_rx,
  144. .dma_tx_param = &sdi1_dma_cfg_tx,
  145. #endif
  146. };
  147. /*
  148. * SDI 2 (POP eMMC, not on DB8500ed)
  149. */
  150. #ifdef CONFIG_STE_DMA40
  151. struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
  152. .mode = STEDMA40_MODE_LOGICAL,
  153. .dir = STEDMA40_PERIPH_TO_MEM,
  154. .src_dev_type = DB8500_DMA_DEV28_SD_MM2_RX,
  155. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  156. .src_info.data_width = STEDMA40_WORD_WIDTH,
  157. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  158. };
  159. static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
  160. .mode = STEDMA40_MODE_LOGICAL,
  161. .dir = STEDMA40_MEM_TO_PERIPH,
  162. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  163. .dst_dev_type = DB8500_DMA_DEV28_SD_MM2_TX,
  164. .src_info.data_width = STEDMA40_WORD_WIDTH,
  165. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  166. };
  167. #endif
  168. static struct mmci_platform_data mop500_sdi2_data = {
  169. .ocr_mask = MMC_VDD_165_195,
  170. .f_max = 50000000,
  171. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  172. MMC_CAP_MMC_HIGHSPEED,
  173. .gpio_cd = -1,
  174. .gpio_wp = -1,
  175. #ifdef CONFIG_STE_DMA40
  176. .dma_filter = stedma40_filter,
  177. .dma_rx_param = &mop500_sdi2_dma_cfg_rx,
  178. .dma_tx_param = &mop500_sdi2_dma_cfg_tx,
  179. #endif
  180. };
  181. /*
  182. * SDI 4 (on-board eMMC)
  183. */
  184. #ifdef CONFIG_STE_DMA40
  185. struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
  186. .mode = STEDMA40_MODE_LOGICAL,
  187. .dir = STEDMA40_PERIPH_TO_MEM,
  188. .src_dev_type = DB8500_DMA_DEV42_SD_MM4_RX,
  189. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  190. .src_info.data_width = STEDMA40_WORD_WIDTH,
  191. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  192. };
  193. static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
  194. .mode = STEDMA40_MODE_LOGICAL,
  195. .dir = STEDMA40_MEM_TO_PERIPH,
  196. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  197. .dst_dev_type = DB8500_DMA_DEV42_SD_MM4_TX,
  198. .src_info.data_width = STEDMA40_WORD_WIDTH,
  199. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  200. };
  201. #endif
  202. static struct mmci_platform_data mop500_sdi4_data = {
  203. .ocr_mask = MMC_VDD_29_30,
  204. .f_max = 50000000,
  205. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  206. MMC_CAP_MMC_HIGHSPEED,
  207. .gpio_cd = -1,
  208. .gpio_wp = -1,
  209. #ifdef CONFIG_STE_DMA40
  210. .dma_filter = stedma40_filter,
  211. .dma_rx_param = &mop500_sdi4_dma_cfg_rx,
  212. .dma_tx_param = &mop500_sdi4_dma_cfg_tx,
  213. #endif
  214. };
  215. void __init mop500_sdi_init(struct device *parent)
  216. {
  217. /* PoP:ed eMMC */
  218. db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
  219. /* On-board eMMC */
  220. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  221. /*
  222. * On boards with the TC35892 GPIO expander, sdi0 will finally
  223. * be added when the TC35892 initializes and calls
  224. * mop500_sdi_tc35892_init() above.
  225. */
  226. }
  227. void __init snowball_sdi_init(struct device *parent)
  228. {
  229. /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
  230. mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
  231. /* On-board eMMC */
  232. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  233. /* External Micro SD slot */
  234. mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
  235. mop500_sdi0_data.cd_invert = true;
  236. sdi0_en = SNOWBALL_SDMMC_EN_GPIO;
  237. sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO;
  238. sdi0_configure(parent);
  239. }
  240. void __init hrefv60_sdi_init(struct device *parent)
  241. {
  242. /* PoP:ed eMMC */
  243. db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
  244. /* On-board eMMC */
  245. db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
  246. /* External Micro SD slot */
  247. mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
  248. sdi0_en = HREFV60_SDMMC_EN_GPIO;
  249. sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO;
  250. sdi0_configure(parent);
  251. /* WLAN SDIO channel */
  252. db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
  253. }