When U-Boot hands off to the OS, mmc_deinit() renegotiates the bus
down out of HS200/HS400 by issuing CMD6 switches and retuning, then
changes the clock.  For eMMC this is unnecessary: the OS issues CMD0
(card reset), which returns the device to backward-compatible mode,
and renegotiates from scratch regardless of the mode U-Boot left the
device in.

Add a Kconfig option, MMC_SKIP_DEINIT, to skip this downgrade for
eMMC devices.  SD cards are always deinitialized: a UHS card switched
to 1.8V signaling cannot be reset by CMD0 and needs a power cycle,
which not every board can perform.

This removes unnecessary CMD6 switches, retuning and clock changes
from the OS-handoff path, which matters on fast-boot / automotive
platforms.

Signed-off-by: Minwoo Park <[email protected]>
---
 drivers/mmc/Kconfig | 23 +++++++++++++++++++++++
 drivers/mmc/mmc.c   |  3 +++
 2 files changed, 26 insertions(+)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 6c513328de2..8b516bf359f 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -226,6 +226,29 @@ config SPL_MMC_HS200_SUPPORT
          The HS200 mode is support by some eMMC. The bus frequency is up to
          200MHz. This mode requires tuning the IO.

+config MMC_SKIP_DEINIT
+       bool "Skip eMMC deinit on OS handoff"
+       depends on MMC_HS200_SUPPORT || MMC_HS400_SUPPORT
+       help
+         When U-Boot hands off to the OS, the MMC subsystem normally
+         renegotiates the bus down out of HS200/HS400 by issuing CMD6
+         switches and retuning, then changes the clock.  For eMMC this is
+         unnecessary: the OS issues CMD0 (card reset), which returns the
+         device to backward-compatible mode, and renegotiates from scratch
+         regardless of the mode U-Boot left the device in.
+
+         Enabling this option skips the deinit for eMMC devices only.  SD
+         cards are always deinitialized: a UHS card switched to 1.8V
+         signaling cannot be reset by CMD0 and needs a power cycle, which
+         not every board can perform.
+
+         This removes unnecessary CMD6 switches, retuning and clock
+         changes from the OS-handoff path, which matters on fast-boot /
+         automotive platforms.
+
+         If unsure, say N.  If your eMMC device or controller cannot be
+         re-initialised by the OS out of HS200/HS400, say N.
+
 config MMC_VERBOSE
        bool "Output more information about the MMC"
        default y
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2e565560656..121739a0a33 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -3184,6 +3184,9 @@ int mmc_deinit(struct mmc *mmc)

                return sd_select_mode_and_width(mmc, caps_filtered);
        } else {
+               if (CONFIG_IS_ENABLED(MMC_SKIP_DEINIT))
+                       return 0;
+
                caps_filtered = mmc->card_caps &
                        ~(MMC_CAP(MMC_HS_200) | MMC_CAP(MMC_HS_400) | 
MMC_CAP(MMC_HS_400_ES));


base-commit: ece349ade2973e220f524ce59e59711cc919263f
--
2.25.1
This email and any attachments to it may be confidential and are intended 
solely for the use of the individual to whom it is addressed. Any views or 
opinions expressed are solely those of the author and do not necessarily 
represent those of Telechips Inc. If you are not the intended recipient of this 
email, you must neither take any action based upon its contents nor copy or 
show it to anyone. Please notify the sender immediately by email if you have 
received this email by mistake and delete this email from your system. Please 
consider the environment before printing this email.

Attachment: 0001-mmc-add-option-to-skip-eMMC-deinit-on-OS-handoff.patch
Description: 0001-mmc-add-option-to-skip-eMMC-deinit-on-OS-handoff.patch

Reply via email to