board-mop500-sdi.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. * SDI 0 (MicroSD slot)
  22. */
  23. /* MMCIPOWER bits */
  24. #define MCI_DATA2DIREN (1 << 2)
  25. #define MCI_CMDDIREN (1 << 3)
  26. #define MCI_DATA0DIREN (1 << 4)
  27. #define MCI_DATA31DIREN (1 << 5)
  28. #define MCI_FBCLKEN (1 << 7)
  29. /* GPIO pins used by the sdi0 level shifter */
  30. static int sdi0_en = -1;
  31. static int sdi0_vsel = -1;
  32. static u32 mop500_sdi0_vdd_handler(struct device *dev, unsigned int vdd,
  33. unsigned char power_mode)
  34. {
  35. switch (power_mode) {
  36. case MMC_POWER_UP:
  37. case MMC_POWER_ON:
  38. /*
  39. * Level shifter voltage should depend on vdd to when deciding
  40. * on either 1.8V or 2.9V. Once the decision has been made the
  41. * level shifter must be disabled and re-enabled with a changed
  42. * select signal in order to switch the voltage. Since there is
  43. * no framework support yet for indicating 1.8V in vdd, use the
  44. * default 2.9V.
  45. */
  46. gpio_direction_output(sdi0_vsel, 0);
  47. gpio_direction_output(sdi0_en, 1);
  48. break;
  49. case MMC_POWER_OFF:
  50. gpio_direction_output(sdi0_vsel, 0);
  51. gpio_direction_output(sdi0_en, 0);
  52. break;
  53. }
  54. return MCI_FBCLKEN | MCI_CMDDIREN | MCI_DATA0DIREN |
  55. MCI_DATA2DIREN | MCI_DATA31DIREN;
  56. }
  57. #ifdef CONFIG_STE_DMA40
  58. struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
  59. .mode = STEDMA40_MODE_LOGICAL,
  60. .dir = STEDMA40_PERIPH_TO_MEM,
  61. .src_dev_type = DB8500_DMA_DEV29_SD_MM0_RX,
  62. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  63. .src_info.data_width = STEDMA40_WORD_WIDTH,
  64. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  65. };
  66. static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
  67. .mode = STEDMA40_MODE_LOGICAL,
  68. .dir = STEDMA40_MEM_TO_PERIPH,
  69. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  70. .dst_dev_type = DB8500_DMA_DEV29_SD_MM0_TX,
  71. .src_info.data_width = STEDMA40_WORD_WIDTH,
  72. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  73. };
  74. #endif
  75. static struct mmci_platform_data mop500_sdi0_data = {
  76. .vdd_handler = mop500_sdi0_vdd_handler,
  77. .ocr_mask = MMC_VDD_29_30,
  78. .f_max = 50000000,
  79. .capabilities = MMC_CAP_4_BIT_DATA |
  80. MMC_CAP_SD_HIGHSPEED |
  81. MMC_CAP_MMC_HIGHSPEED,
  82. .gpio_wp = -1,
  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(void)
  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. if (cpu_is_u8500v2())
  105. db8500_add_sdi0(&mop500_sdi0_data, 0x10480180);
  106. else
  107. db8500_add_sdi0(&mop500_sdi0_data, 0);
  108. }
  109. void mop500_sdi_tc35892_init(void)
  110. {
  111. mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
  112. sdi0_en = GPIO_SDMMC_EN;
  113. sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL;
  114. sdi0_configure();
  115. }
  116. /*
  117. * SDI 2 (POP eMMC, not on DB8500ed)
  118. */
  119. #ifdef CONFIG_STE_DMA40
  120. struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
  121. .mode = STEDMA40_MODE_LOGICAL,
  122. .dir = STEDMA40_PERIPH_TO_MEM,
  123. .src_dev_type = DB8500_DMA_DEV28_SD_MM2_RX,
  124. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  125. .src_info.data_width = STEDMA40_WORD_WIDTH,
  126. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  127. };
  128. static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
  129. .mode = STEDMA40_MODE_LOGICAL,
  130. .dir = STEDMA40_MEM_TO_PERIPH,
  131. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  132. .dst_dev_type = DB8500_DMA_DEV28_SD_MM2_TX,
  133. .src_info.data_width = STEDMA40_WORD_WIDTH,
  134. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  135. };
  136. #endif
  137. static struct mmci_platform_data mop500_sdi2_data = {
  138. .ocr_mask = MMC_VDD_165_195,
  139. .f_max = 50000000,
  140. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  141. .gpio_cd = -1,
  142. .gpio_wp = -1,
  143. #ifdef CONFIG_STE_DMA40
  144. .dma_filter = stedma40_filter,
  145. .dma_rx_param = &mop500_sdi2_dma_cfg_rx,
  146. .dma_tx_param = &mop500_sdi2_dma_cfg_tx,
  147. #endif
  148. };
  149. /*
  150. * SDI 4 (on-board eMMC)
  151. */
  152. #ifdef CONFIG_STE_DMA40
  153. struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
  154. .mode = STEDMA40_MODE_LOGICAL,
  155. .dir = STEDMA40_PERIPH_TO_MEM,
  156. .src_dev_type = DB8500_DMA_DEV42_SD_MM4_RX,
  157. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  158. .src_info.data_width = STEDMA40_WORD_WIDTH,
  159. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  160. };
  161. static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
  162. .mode = STEDMA40_MODE_LOGICAL,
  163. .dir = STEDMA40_MEM_TO_PERIPH,
  164. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  165. .dst_dev_type = DB8500_DMA_DEV42_SD_MM4_TX,
  166. .src_info.data_width = STEDMA40_WORD_WIDTH,
  167. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  168. };
  169. #endif
  170. static struct mmci_platform_data mop500_sdi4_data = {
  171. .ocr_mask = MMC_VDD_29_30,
  172. .f_max = 50000000,
  173. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  174. MMC_CAP_MMC_HIGHSPEED,
  175. .gpio_cd = -1,
  176. .gpio_wp = -1,
  177. #ifdef CONFIG_STE_DMA40
  178. .dma_filter = stedma40_filter,
  179. .dma_rx_param = &mop500_sdi4_dma_cfg_rx,
  180. .dma_tx_param = &mop500_sdi4_dma_cfg_tx,
  181. #endif
  182. };
  183. void __init mop500_sdi_init(void)
  184. {
  185. u32 periphid = 0;
  186. /* v2 has a new version of this block that need to be forced */
  187. if (cpu_is_u8500v2())
  188. periphid = 0x10480180;
  189. /* PoP:ed eMMC on top of DB8500 v1.0 has problems with high speed */
  190. if (!cpu_is_u8500v10())
  191. mop500_sdi2_data.capabilities |= MMC_CAP_MMC_HIGHSPEED;
  192. /* sdi2 on snowball is in ATL_B mode for FSMC (LAN) */
  193. if (!machine_is_snowball())
  194. db8500_add_sdi2(&mop500_sdi2_data, periphid);
  195. /* On-board eMMC */
  196. db8500_add_sdi4(&mop500_sdi4_data, periphid);
  197. if (machine_is_hrefv60() || machine_is_snowball()) {
  198. if (machine_is_hrefv60()) {
  199. mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
  200. sdi0_en = HREFV60_SDMMC_EN_GPIO;
  201. sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO;
  202. } else if (machine_is_snowball()) {
  203. mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
  204. mop500_sdi0_data.cd_invert = true;
  205. sdi0_en = SNOWBALL_SDMMC_EN_GPIO;
  206. sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO;
  207. }
  208. sdi0_configure();
  209. }
  210. /*
  211. * On boards with the TC35892 GPIO expander, sdi0 will finally
  212. * be added when the TC35892 initializes and calls
  213. * mop500_sdi_tc35892_init() above.
  214. */
  215. }