Parse the new binding and store it in the mmc config struct after doing some sanity checks. The code is designed to support fixed mmc driver type if we ever need that.
Signed-off-by: Shunsuke Tokumoto <s-tokum...@fujitsu.com> Signed-off-by: Yasushi Iida <yasushi.i...@fujitsu.com> --- drivers/mmc/mmc-uclass.c | 30 ++++++++++++++++++++++++++++++ drivers/mmc/mmc.c | 8 ++++++++ include/mmc.h | 3 +++ 3 files changed, 41 insertions(+) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index c5b7872900..e67aae451f 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -162,6 +162,36 @@ int dm_mmc_deferred_probe(struct udevice *dev) if (ops->deferred_probe) return ops->deferred_probe(dev); + /* Check eMMC driver type selection */ + val = dev_read_u32_default(dev, "fixed-emmc-driver-type", 0); + if (val > 4) { + puts("\"fixed-emmc-driver-type\" is illegal. force to 0.\n"); + val = 0; + } + cfg->driver_type = val; + + val = dev_read_u32_default(dev, + "fixed-emmc-driver-type-hs200", + -ENOENT); + if (val != -ENOENT) { + if (val > 4) { + puts("\"fixed-emmc-driver-type-hs200\" is illegal.\n"); + val = 0; + } + } + cfg->driver_type_hs200 = val; + + val = dev_read_u32_default(dev, + "fixed-emmc-driver-type-hs400", + -ENOENT); + if (val != -ENOENT) { + if (val > 4) { + puts("\"fixed-emmc-driver-type-hs400\" is illegal.\n"); + val = 0; + } + } + cfg->driver_type_hs400 = val; + return 0; } diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 620bb93064..8241be9996 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -849,11 +849,19 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode, #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) case MMC_HS_200: speed_bits = EXT_CSD_TIMING_HS200; + if (mmc->cfg->driver_type_hs200 != -ENOENT) + speed_bits |= (mmc->cfg->driver_type_hs200 << 4); + else + speed_bits |= (mmc->cfg->driver_type << 4); break; #endif #if CONFIG_IS_ENABLED(MMC_HS400_SUPPORT) case MMC_HS_400: speed_bits = EXT_CSD_TIMING_HS400; + if (mmc->cfg->driver_type_hs400 != -ENOENT) + speed_bits |= (mmc->cfg->driver_type_hs400 << 4); + else + speed_bits |= (mmc->cfg->driver_type << 4); break; #endif #if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT) diff --git a/include/mmc.h b/include/mmc.h index 82562193cc..8d79ff5cbe 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -555,6 +555,9 @@ struct mmc_config { uint f_max; uint b_max; unsigned char part_type; + uint driver_type; + uint driver_type_hs200; + uint driver_type_hs400; }; struct sd_ssr { -- 2.25.4