[U-Boot] [PATCH 04/33] mmc: rework high speed mode selection

2017-05-15 Thread Ziyuan Xu
Select timing parameter for the host since HS mode switch is completed.

Signed-off-by: Ziyuan Xu 
---

 drivers/mmc/mmc.c | 16 ++--
 include/mmc.h |  6 ++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1b3652a..0b30172 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -552,6 +552,19 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 }
 
+static int mmc_select_hs(struct mmc *mmc)
+{
+   int ret;
+
+   ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS);
+
+   if (!ret)
+   mmc_set_timing(mmc, MMC_TIMING_MMC_HS);
+
+   return ret;
+}
+
 static u32 mmc_select_card_type(struct mmc *mmc, u8 *ext_csd)
 {
u8 card_type;
@@ -630,8 +643,7 @@ static int mmc_change_freq(struct mmc *mmc)
avail_type = mmc_select_card_type(mmc, ext_csd);
 
if (avail_type & EXT_CSD_CARD_TYPE_HS)
-   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
-EXT_CSD_HS_TIMING, 1);
+   err = mmc_select_hs(mmc);
else
err = -EINVAL;
 
diff --git a/include/mmc.h b/include/mmc.h
index 68b6790..060c1f8 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -228,6 +228,12 @@
 #define EXT_CSD_DDR_BUS_WIDTH_45   /* Card is in 4 bit DDR mode */
 #define EXT_CSD_DDR_BUS_WIDTH_86   /* Card is in 8 bit DDR mode */
 
+#define EXT_CSD_TIMING_BC  0   /* Backwards compatility */
+#define EXT_CSD_TIMING_HS  1   /* High speed */
+#define EXT_CSD_TIMING_HS200   2   /* HS200 */
+#define EXT_CSD_TIMING_HS400   3   /* HS400 */
+#define EXT_CSD_DRV_STR_SHIFT  4   /* Driver Strength shift */
+
 #define EXT_CSD_BOOT_ACK_ENABLE(1 << 6)
 #define EXT_CSD_BOOT_PARTITION_ENABLE  (1 << 3)
 #define EXT_CSD_PARTITION_ACCESS_ENABLE(1 << 0)
-- 
2.7.4


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 04/33] mmc: rework high speed mode selection

2017-05-14 Thread Ziyuan Xu
Select timing parameter for the host since HS mode switch is completed.

Signed-off-by: Ziyuan Xu 
---

 drivers/mmc/mmc.c | 16 ++--
 include/mmc.h |  6 ++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1b3652a..0b30172 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -552,6 +552,19 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 }
 
+static int mmc_select_hs(struct mmc *mmc)
+{
+   int ret;
+
+   ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS);
+
+   if (!ret)
+   mmc_set_timing(mmc, MMC_TIMING_MMC_HS);
+
+   return ret;
+}
+
 static u32 mmc_select_card_type(struct mmc *mmc, u8 *ext_csd)
 {
u8 card_type;
@@ -630,8 +643,7 @@ static int mmc_change_freq(struct mmc *mmc)
avail_type = mmc_select_card_type(mmc, ext_csd);
 
if (avail_type & EXT_CSD_CARD_TYPE_HS)
-   err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
-EXT_CSD_HS_TIMING, 1);
+   err = mmc_select_hs(mmc);
else
err = -EINVAL;
 
diff --git a/include/mmc.h b/include/mmc.h
index 68b6790..060c1f8 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -228,6 +228,12 @@
 #define EXT_CSD_DDR_BUS_WIDTH_45   /* Card is in 4 bit DDR mode */
 #define EXT_CSD_DDR_BUS_WIDTH_86   /* Card is in 8 bit DDR mode */
 
+#define EXT_CSD_TIMING_BC  0   /* Backwards compatility */
+#define EXT_CSD_TIMING_HS  1   /* High speed */
+#define EXT_CSD_TIMING_HS200   2   /* HS200 */
+#define EXT_CSD_TIMING_HS400   3   /* HS400 */
+#define EXT_CSD_DRV_STR_SHIFT  4   /* Driver Strength shift */
+
 #define EXT_CSD_BOOT_ACK_ENABLE(1 << 6)
 #define EXT_CSD_BOOT_PARTITION_ENABLE  (1 << 3)
 #define EXT_CSD_PARTITION_ACCESS_ENABLE(1 << 0)
-- 
2.7.4


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot