[U-Boot] [PATCH 11/12] mmc: sdhci: Add support for eMMC HS200 mode
Siva Durga Prasad Paladugu
siva.durga.paladugu at xilinx.com
Wed Jan 18 10:04:30 CET 2017
Add support for eMMC HS200 mode by reading
card type from ext_csd and then by switching to
HS200 timing mode.
Signed-off-by: Siva Durga Prasad Paladugu <sivadur at xilinx.com>
---
drivers/mmc/mmc.c | 24 ++++++++++++++++++------
drivers/mmc/sdhci.c | 18 +++++++++++++-----
include/mmc.h | 8 ++++++++
3 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index d4ea0c2..7e18a38 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -619,9 +619,16 @@ static int mmc_change_freq(struct mmc *mmc)
if (err)
return err;
- cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0xf;
+ cardtype = ext_csd[EXT_CSD_CARD_TYPE] & 0x3f;
- err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1);
+ if (cardtype & EXT_CSD_CARD_TYPE_HS200)
+ err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_HS_TIMING,
+ EXT_CSD_HS_TIMING_HS200);
+ else
+ err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_HS_TIMING,
+ EXT_CSD_HS_TIMING_HIGH_SPEED);
if (err)
return err;
@@ -636,8 +643,10 @@ static int mmc_change_freq(struct mmc *mmc)
if (!ext_csd[EXT_CSD_HS_TIMING])
return 0;
- /* High Speed is set, there are two types: 52MHz and 26MHz */
- if (cardtype & EXT_CSD_CARD_TYPE_52) {
+ /* High Speed is set, there are three types: 200MHZ, 52MHz and 26MHz */
+ if (cardtype & EXT_CSD_CARD_TYPE_HS200) {
+ mmc->card_caps |= MMC_MODE_HS200;
+ } else if (cardtype & EXT_CSD_CARD_TYPE_52) {
if (cardtype & EXT_CSD_CARD_TYPE_DDR_1_8V)
mmc->card_caps |= MMC_MODE_DDR_52MHz;
mmc->card_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
@@ -1659,7 +1668,9 @@ static int mmc_startup(struct mmc *mmc)
if (err)
return err;
- if (mmc->card_caps & MMC_MODE_HS) {
+ if (mmc->card_caps & MMC_MODE_HS200) {
+ mmc->tran_speed = 200000000;
+ } else if (mmc->card_caps & MMC_MODE_HS) {
if (mmc->card_caps & MMC_MODE_HS_52MHz)
mmc->tran_speed = 52000000;
else
@@ -1670,7 +1681,8 @@ static int mmc_startup(struct mmc *mmc)
mmc_set_clock(mmc, mmc->tran_speed);
if ((mmc->card_caps & (MMC_MODE_UHS_SDR50 |
- MMC_MODE_UHS_SDR104)) &&
+ MMC_MODE_UHS_SDR104 |
+ MMC_MODE_HS200)) &&
(mmc->cfg->host_caps & MMC_MODE_NEEDS_TUNING)) {
err = mmc_execute_tuning(mmc);
if (err)
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 4f29ba1..6496bdb 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -157,7 +157,8 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
/* We shouldn't wait for data inihibit for stop commands, even
though they might use busy signaling */
if ((cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) ||
- (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK))
+ (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK) ||
+ (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200))
mask &= ~SDHCI_DATA_INHIBIT;
while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) {
@@ -179,7 +180,8 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
mask = SDHCI_INT_RESPONSE;
/* only buffer read ready interrupt whil tuning */
- if (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK)
+ if ((cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK) ||
+ (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200))
mask = SDHCI_INT_DATA_AVAIL;
if (!(cmd->resp_type & MMC_RSP_PRESENT))
@@ -197,7 +199,8 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
flags |= SDHCI_CMD_CRC;
if (cmd->resp_type & MMC_RSP_OPCODE)
flags |= SDHCI_CMD_INDEX;
- if (data || (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK))
+ if (data || (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK) ||
+ (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200))
flags |= SDHCI_CMD_DATA;
/* Set Transfer mode regarding to data flag */
@@ -407,8 +410,13 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)
if (clock == 0)
return 0;
- if (mmc->is_uhs && host->ops->set_delay)
- host->ops->set_delay(host, mmc->uhsmode);
+ if (((mmc->card_caps & MMC_MODE_HS200) || mmc->is_uhs) &&
+ host->ops->set_delay) {
+ if (mmc->is_uhs)
+ host->ops->set_delay(host, mmc->uhsmode);
+ else
+ host->ops->set_delay(host, MMC_TIMING_HS200);
+ }
if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
/*
diff --git a/include/mmc.h b/include/mmc.h
index 56395ee..e0b5510 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -223,6 +223,13 @@
#define EXT_CSD_CARD_TYPE_DDR_1_2V (1 << 3)
#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
| EXT_CSD_CARD_TYPE_DDR_1_2V)
+#define EXT_CSD_CARD_TYPE_HS200_1_8V (1 << 4)
+#define EXT_CSD_CARD_TYPE_HS200_1_2V (1 << 5)
+#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V \
+ | EXT_CSD_CARD_TYPE_HS200_1_2V)
+
+#define EXT_CSD_HS_TIMING_HIGH_SPEED 1
+#define EXT_CSD_HS_TIMING_HS200 2
#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
@@ -293,6 +300,7 @@
#define MMC_TIMING_UHS_SDR50 2
#define MMC_TIMING_UHS_SDR104 3
#define MMC_TIMING_UHS_DDR50 4
+#define MMC_TIMING_HS200 5
#define MMC_TIMING_HS 1
/* Driver model support */
--
2.7.4
More information about the U-Boot
mailing list