summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAswath Govindraju <a-govindraju@ti.com>2021-08-13 20:34:41 +0300
committerPeng Fan <peng.fan@nxp.com>2021-09-10 13:17:04 +0300
commit19f7a34a4642e25aa8b80c6d75129fe7848a158d (patch)
tree74c326eca33b00ff58048c052749f9452725fc13 /drivers
parent4a3ea75de4c5b3053eac326bf1c753ed65df8cb9 (diff)
downloadu-boot-19f7a34a4642e25aa8b80c6d75129fe7848a158d.tar.xz
mmc: Add support for enumerating MMC card in a given mode using mmc command
Add support for enumerating MMC card in a given mode using mmc rescan and mmc dev commands. The speed mode is provided as the last argument in these commands and is indicated using the index from enum bus_mode in include/mmc.h. A speed mode can be set only if it has already been enabled in the device tree. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com> Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/mmc-uclass.c5
-rw-r--r--drivers/mmc/mmc.c22
2 files changed, 25 insertions, 2 deletions
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 0e13238c7e..3ee92d03ca 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -342,6 +342,9 @@ void mmc_do_preinit(void)
if (!m)
continue;
+
+ m->user_speed_mode = MMC_MODES_END; /* Initialising user set speed mode */
+
if (m->preinit)
mmc_start_init(m);
}
@@ -414,7 +417,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
/* setup initial part type */
bdesc->part_type = cfg->part_type;
mmc->dev = dev;
-
+ mmc->user_speed_mode = MMC_MODES_END;
return 0;
}
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 8078a89f18..bd348974ae 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2862,7 +2862,25 @@ int mmc_start_init(struct mmc *mmc)
* timings.
*/
mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(MMC_LEGACY) |
- MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT;
+ MMC_MODE_1BIT;
+
+ if (IS_ENABLED(CONFIG_MMC_SPEED_MODE_SET)) {
+ if (mmc->user_speed_mode != MMC_MODES_END) {
+ int i;
+ /* set host caps */
+ if (mmc->host_caps & MMC_CAP(mmc->user_speed_mode)) {
+ /* Remove all existing speed capabilities */
+ for (i = MMC_LEGACY; i < MMC_MODES_END; i++)
+ mmc->host_caps &= ~MMC_CAP(i);
+ mmc->host_caps |= (MMC_CAP(mmc->user_speed_mode)
+ | MMC_CAP(MMC_LEGACY) |
+ MMC_MODE_1BIT);
+ } else {
+ pr_err("bus_mode requested is not supported\n");
+ return -EINVAL;
+ }
+ }
+ }
#if CONFIG_IS_ENABLED(DM_MMC)
mmc_deferred_probe(mmc);
#endif
@@ -3060,6 +3078,8 @@ int mmc_init_device(int num)
}
m = mmc_get_mmc_dev(dev);
+ m->user_speed_mode = MMC_MODES_END; /* Initialising user set speed mode */
+
if (!m)
return 0;
if (m->preinit)