mmc: add a mmc_hs400_prepare_ddr() interface
authorYangbo Lu <yangbo.lu@nxp.com>
Tue, 1 Sep 2020 08:58:04 +0000 (16:58 +0800)
committerPeng Fan <peng.fan@nxp.com>
Mon, 12 Oct 2020 07:46:34 +0000 (15:46 +0800)
Add a mmc_hs400_prepare_ddr() interface for controllers
which needs preparation before switching to DDR mode for
HS400 mode.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
drivers/mmc/mmc-uclass.c
drivers/mmc/mmc.c
include/mmc.h

index b90e1ee..ec59bcd 100644 (file)
@@ -142,6 +142,21 @@ int mmc_set_enhanced_strobe(struct mmc *mmc)
 }
 #endif
 
+int dm_mmc_hs400_prepare_ddr(struct udevice *dev)
+{
+       struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+       if (ops->hs400_prepare_ddr)
+               return ops->hs400_prepare_ddr(dev);
+
+       return 0;
+}
+
+int mmc_hs400_prepare_ddr(struct mmc *mmc)
+{
+       return dm_mmc_hs400_prepare_ddr(mmc->dev);
+}
+
 int dm_mmc_host_power_cycle(struct udevice *dev)
 {
        struct dm_mmc_ops *ops = mmc_get_ops(dev);
index b75c2bc..8502503 100644 (file)
@@ -1993,6 +1993,10 @@ static int mmc_select_hs400(struct mmc *mmc)
        /* Set back to HS */
        mmc_set_card_speed(mmc, MMC_HS, true);
 
+       err = mmc_hs400_prepare_ddr(mmc);
+       if (err)
+               return err;
+
        err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
                         EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);
        if (err)
index bea1c49..ac7b54f 100644 (file)
@@ -513,6 +513,14 @@ struct dm_mmc_ops {
         * @return maximum number of blocks for this transfer
         */
        int (*get_b_max)(struct udevice *dev, void *dst, lbaint_t blkcnt);
+
+       /**
+        * hs400_prepare_ddr - prepare to switch to DDR mode
+        *
+        * @dev:        Device to check
+        * @return 0 if success, -ve on error
+        */
+       int (*hs400_prepare_ddr)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -540,7 +548,7 @@ int mmc_host_power_cycle(struct mmc *mmc);
 int mmc_deferred_probe(struct mmc *mmc);
 int mmc_reinit(struct mmc *mmc);
 int mmc_get_b_max(struct mmc *mmc, void *dst, lbaint_t blkcnt);
-
+int mmc_hs400_prepare_ddr(struct mmc *mmc);
 #else
 struct mmc_ops {
        int (*send_cmd)(struct mmc *mmc,
@@ -552,6 +560,11 @@ struct mmc_ops {
        int (*host_power_cycle)(struct mmc *mmc);
        int (*get_b_max)(struct mmc *mmc, void *dst, lbaint_t blkcnt);
 };
+
+static inline int mmc_hs400_prepare_ddr(struct mmc *mmc)
+{
+       return 0;
+}
 #endif
 
 struct mmc_config {