When U-Boot hands off to the OS, mmc_deinit() renegotiates the bus
down out of HS200/HS400 by issuing CMD6 switches, then changes the
clock; see commit fceea9926804 ("mmc: Downgrade SD/MMC from
UHS/HS200/HS400 modes before boot") for the original motivation.
For eMMC this downgrade is unnecessary when the OS re-initialises
the device itself: CMD0 returns the protocol state machine to Idle,
and the OS renegotiates from scratch regardless of the mode U-Boot
left the device in.

Add a Kconfig option, MMC_SKIP_EMMC_DEINIT, to skip this downgrade
for eMMC devices.  SD cards are always deinitialized, keeping the
conservative default behaviour.

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

Signed-off-by: Minwoo Park <[email protected]>
---
Changes in v2:
- drop "retuning" from the description; the downgrade path selects a
  mode that does not require tuning
- describe CMD0 as a protocol state machine reset, not a hardware reset
- reference commit fceea9926804 for the original motivation
- drop the incorrect 1.8V/CMD0 rationale for SD; SD simply keeps the
  conservative default behaviour
- rename MMC_SKIP_DEINIT to MMC_SKIP_EMMC_DEINIT
- add MMC_HS400_ES_SUPPORT to the dependencies
- clarify in the Kconfig help when it is safe to say Y

 drivers/mmc/Kconfig | 24 ++++++++++++++++++++++++
 drivers/mmc/mmc.c   |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 6c513328de2..4697d76276f 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -226,6 +226,30 @@ 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_EMMC_DEINIT
+       bool "Skip eMMC deinit on OS handoff"
+       depends on MMC_HS200_SUPPORT || MMC_HS400_SUPPORT || 
MMC_HS400_ES_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, then changes the clock.  For eMMC this downgrade is
+         unnecessary when the OS re-initialises the device itself: CMD0
+         returns the protocol state machine to Idle, and the OS
+         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, keeping the conservative
+         default behaviour.
+
+         This removes unnecessary CMD6 switches and clock changes from
+         the OS-handoff path, which matters on fast-boot / automotive
+         platforms.
+
+         Say Y only if the OS re-initialises the eMMC from scratch and
+         can hardware-reset the device (RST_n) or power-cycle it in
+         case of trouble.  If unsure, 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..bd524c7b573 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_EMMC_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: v2-0001-mmc-add-option-to-skip-eMMC-deinit-on-OS-handoff.patch
Description: v2-0001-mmc-add-option-to-skip-eMMC-deinit-on-OS-handoff.patch

Reply via email to