From: Marek Vasut Date: Wed, 6 Feb 2019 14:10:52 +0100 Subject: [U-Boot] [PATCH 2/2] mmc: tmio: renesas: Downgrade SD/MMC from UHS/HS200/HS400 modes before boot In-Reply-To: <20190206131052.24334-1-marek.vasut+renesas@gmail.com> References: <20190206131052.24334-1-marek.vasut+renesas@gmail.com> Message-ID: <20190206131052.24334-2-marek.vasut+renesas@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Older kernel versions cannot handle situation where either the eMMC is left in HS200/HS400 mode or SD in UHS modes by the bootloader and can misbehave. Downgrade the eMMC to HS/HS52 mode and/or SD to non-UHS mode before boot to allow such older kernels to work with modern U-Boot. Signed-off-by: Marek Vasut Cc: Masahiro Yamada --- drivers/mmc/renesas-sdhi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c index a556acd5cb..d78f91f937 100644 --- a/drivers/mmc/renesas-sdhi.c +++ b/drivers/mmc/renesas-sdhi.c @@ -15,6 +15,7 @@ #include #include +#include "mmc_private.h" #include "tmio-common.h" #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \ @@ -530,13 +531,38 @@ static int renesas_sdhi_probe(struct udevice *dev) return ret; } +int renesas_sdhi_remove(struct udevice *dev) +{ + struct mmc *mmc = mmc_get_mmc_dev(dev); + u32 caps_filtered; + + if (!mmc->has_init) + return 0; + + if (IS_SD(mmc)) { + caps_filtered = mmc->card_caps & + ~(MMC_CAP(UHS_SDR12) | MMC_CAP(UHS_SDR25) | + MMC_CAP(UHS_SDR50) | MMC_CAP(UHS_DDR50) | + MMC_CAP(UHS_SDR104)); + + return sd_select_mode_and_width(mmc, caps_filtered); + } else { + caps_filtered = mmc->card_caps & + ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400)); + + return mmc_select_mode_and_width(mmc, caps_filtered); + } +} + U_BOOT_DRIVER(renesas_sdhi) = { .name = "renesas-sdhi", .id = UCLASS_MMC, .of_match = renesas_sdhi_match, .bind = tmio_sd_bind, .probe = renesas_sdhi_probe, + .remove = renesas_sdhi_remove, .priv_auto_alloc_size = sizeof(struct tmio_sd_priv), .platdata_auto_alloc_size = sizeof(struct tmio_sd_plat), .ops = &renesas_sdhi_ops, + .flags = DM_FLAG_OS_PREPARE, }; -- 2.19.2