board-mop500-sdi.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 <plat/pincfg.h>
  14. #include <plat/ste_dma40.h>
  15. #include <mach/devices.h>
  16. #include <mach/hardware.h>
  17. #include "devices-db8500.h"
  18. #include "pins-db8500.h"
  19. #include "board-mop500.h"
  20. #include "ste-dma40-db8500.h"
  21. static pin_cfg_t mop500_sdi_pins[] = {
  22. /* SDI0 (MicroSD slot) */
  23. GPIO18_MC0_CMDDIR,
  24. GPIO19_MC0_DAT0DIR,
  25. GPIO20_MC0_DAT2DIR,
  26. GPIO21_MC0_DAT31DIR,
  27. GPIO22_MC0_FBCLK,
  28. GPIO23_MC0_CLK,
  29. GPIO24_MC0_CMD,
  30. GPIO25_MC0_DAT0,
  31. GPIO26_MC0_DAT1,
  32. GPIO27_MC0_DAT2,
  33. GPIO28_MC0_DAT3,
  34. /* SDI4 (on-board eMMC) */
  35. GPIO197_MC4_DAT3,
  36. GPIO198_MC4_DAT2,
  37. GPIO199_MC4_DAT1,
  38. GPIO200_MC4_DAT0,
  39. GPIO201_MC4_CMD,
  40. GPIO202_MC4_FBCLK,
  41. GPIO203_MC4_CLK,
  42. GPIO204_MC4_DAT7,
  43. GPIO205_MC4_DAT6,
  44. GPIO206_MC4_DAT5,
  45. GPIO207_MC4_DAT4,
  46. };
  47. static pin_cfg_t mop500_sdi2_pins[] = {
  48. /* SDI2 (POP eMMC) */
  49. GPIO128_MC2_CLK,
  50. GPIO129_MC2_CMD,
  51. GPIO130_MC2_FBCLK,
  52. GPIO131_MC2_DAT0,
  53. GPIO132_MC2_DAT1,
  54. GPIO133_MC2_DAT2,
  55. GPIO134_MC2_DAT3,
  56. GPIO135_MC2_DAT4,
  57. GPIO136_MC2_DAT5,
  58. GPIO137_MC2_DAT6,
  59. GPIO138_MC2_DAT7,
  60. };
  61. /*
  62. * SDI 0 (MicroSD slot)
  63. */
  64. /* MMCIPOWER bits */
  65. #define MCI_DATA2DIREN (1 << 2)
  66. #define MCI_CMDDIREN (1 << 3)
  67. #define MCI_DATA0DIREN (1 << 4)
  68. #define MCI_DATA31DIREN (1 << 5)
  69. #define MCI_FBCLKEN (1 << 7)
  70. static u32 mop500_sdi0_vdd_handler(struct device *dev, unsigned int vdd,
  71. unsigned char power_mode)
  72. {
  73. if (power_mode == MMC_POWER_UP)
  74. gpio_set_value_cansleep(GPIO_SDMMC_EN, 1);
  75. else if (power_mode == MMC_POWER_OFF)
  76. gpio_set_value_cansleep(GPIO_SDMMC_EN, 0);
  77. return MCI_FBCLKEN | MCI_CMDDIREN | MCI_DATA0DIREN |
  78. MCI_DATA2DIREN | MCI_DATA31DIREN;
  79. }
  80. #ifdef CONFIG_STE_DMA40
  81. struct stedma40_chan_cfg mop500_sdi0_dma_cfg_rx = {
  82. .mode = STEDMA40_MODE_LOGICAL,
  83. .dir = STEDMA40_PERIPH_TO_MEM,
  84. .src_dev_type = DB8500_DMA_DEV29_SD_MM0_RX,
  85. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  86. .src_info.data_width = STEDMA40_WORD_WIDTH,
  87. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  88. };
  89. static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
  90. .mode = STEDMA40_MODE_LOGICAL,
  91. .dir = STEDMA40_MEM_TO_PERIPH,
  92. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  93. .dst_dev_type = DB8500_DMA_DEV29_SD_MM0_TX,
  94. .src_info.data_width = STEDMA40_WORD_WIDTH,
  95. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  96. };
  97. #endif
  98. static struct mmci_platform_data mop500_sdi0_data = {
  99. .vdd_handler = mop500_sdi0_vdd_handler,
  100. .ocr_mask = MMC_VDD_29_30,
  101. .f_max = 100000000,
  102. .capabilities = MMC_CAP_4_BIT_DATA,
  103. .gpio_cd = GPIO_SDMMC_CD,
  104. .gpio_wp = -1,
  105. #ifdef CONFIG_STE_DMA40
  106. .dma_filter = stedma40_filter,
  107. .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
  108. .dma_tx_param = &mop500_sdi0_dma_cfg_tx,
  109. #endif
  110. };
  111. void mop500_sdi_tc35892_init(void)
  112. {
  113. int ret;
  114. ret = gpio_request(GPIO_SDMMC_EN, "SDMMC_EN");
  115. if (!ret)
  116. ret = gpio_request(GPIO_SDMMC_1V8_3V_SEL,
  117. "GPIO_SDMMC_1V8_3V_SEL");
  118. if (ret)
  119. return;
  120. gpio_direction_output(GPIO_SDMMC_1V8_3V_SEL, 0);
  121. gpio_direction_output(GPIO_SDMMC_EN, 1);
  122. db8500_add_sdi0(&mop500_sdi0_data);
  123. }
  124. /*
  125. * SDI 2 (POP eMMC, not on DB8500ed)
  126. */
  127. #ifdef CONFIG_STE_DMA40
  128. struct stedma40_chan_cfg mop500_sdi2_dma_cfg_rx = {
  129. .mode = STEDMA40_MODE_LOGICAL,
  130. .dir = STEDMA40_PERIPH_TO_MEM,
  131. .src_dev_type = DB8500_DMA_DEV28_SD_MM2_RX,
  132. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  133. .src_info.data_width = STEDMA40_WORD_WIDTH,
  134. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  135. };
  136. static struct stedma40_chan_cfg mop500_sdi2_dma_cfg_tx = {
  137. .mode = STEDMA40_MODE_LOGICAL,
  138. .dir = STEDMA40_MEM_TO_PERIPH,
  139. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  140. .dst_dev_type = DB8500_DMA_DEV28_SD_MM2_TX,
  141. .src_info.data_width = STEDMA40_WORD_WIDTH,
  142. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  143. };
  144. #endif
  145. static struct mmci_platform_data mop500_sdi2_data = {
  146. .ocr_mask = MMC_VDD_165_195,
  147. .f_max = 100000000,
  148. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  149. .gpio_cd = -1,
  150. .gpio_wp = -1,
  151. #ifdef CONFIG_STE_DMA40
  152. .dma_filter = stedma40_filter,
  153. .dma_rx_param = &mop500_sdi2_dma_cfg_rx,
  154. .dma_tx_param = &mop500_sdi2_dma_cfg_tx,
  155. #endif
  156. };
  157. /*
  158. * SDI 4 (on-board eMMC)
  159. */
  160. #ifdef CONFIG_STE_DMA40
  161. struct stedma40_chan_cfg mop500_sdi4_dma_cfg_rx = {
  162. .mode = STEDMA40_MODE_LOGICAL,
  163. .dir = STEDMA40_PERIPH_TO_MEM,
  164. .src_dev_type = DB8500_DMA_DEV42_SD_MM4_RX,
  165. .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
  166. .src_info.data_width = STEDMA40_WORD_WIDTH,
  167. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  168. };
  169. static struct stedma40_chan_cfg mop500_sdi4_dma_cfg_tx = {
  170. .mode = STEDMA40_MODE_LOGICAL,
  171. .dir = STEDMA40_MEM_TO_PERIPH,
  172. .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
  173. .dst_dev_type = DB8500_DMA_DEV42_SD_MM4_TX,
  174. .src_info.data_width = STEDMA40_WORD_WIDTH,
  175. .dst_info.data_width = STEDMA40_WORD_WIDTH,
  176. };
  177. #endif
  178. static struct mmci_platform_data mop500_sdi4_data = {
  179. .ocr_mask = MMC_VDD_29_30,
  180. .f_max = 100000000,
  181. .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
  182. MMC_CAP_MMC_HIGHSPEED,
  183. .gpio_cd = -1,
  184. .gpio_wp = -1,
  185. #ifdef CONFIG_STE_DMA40
  186. .dma_filter = stedma40_filter,
  187. .dma_rx_param = &mop500_sdi4_dma_cfg_rx,
  188. .dma_tx_param = &mop500_sdi4_dma_cfg_tx,
  189. #endif
  190. };
  191. void __init mop500_sdi_init(void)
  192. {
  193. nmk_config_pins(mop500_sdi_pins, ARRAY_SIZE(mop500_sdi_pins));
  194. /*
  195. * sdi0 will finally be added when the TC35892 initializes and calls
  196. * mop500_sdi_tc35892_init() above.
  197. */
  198. /* PoP:ed eMMC */
  199. if (!cpu_is_u8500ed()) {
  200. nmk_config_pins(mop500_sdi2_pins, ARRAY_SIZE(mop500_sdi2_pins));
  201. /* POP eMMC on v1.0 has problems with high speed */
  202. if (!cpu_is_u8500v10())
  203. mop500_sdi2_data.capabilities |= MMC_CAP_MMC_HIGHSPEED;
  204. db8500_add_sdi2(&mop500_sdi2_data);
  205. }
  206. /* On-board eMMC */
  207. db8500_add_sdi4(&mop500_sdi4_data);
  208. }