[PATCH] mmc: allow forward compatibility for EXT_CSD_REV
박민우 (MW Park)
mw.park at telechips.com
Thu Mar 26 08:30:54 CET 2026
[PATCH] mmc: allow forward compatibility for EXT_CSD_REV
According to the JEDEC Standard, the EXT_CSD format is meant to be
forward compatible. As long as CSD_STRUCTURE does not change, all
values for EXT_CSD_REV are authorized.
Currently, if an eMMC device with a newer EXT_CSD_REV (e.g., eMMC 5.1B
with EXT_CSD_REV=9) is used, U-Boot fails to initialize it and returns
-EINVAL because the revision is larger than the mmc_versions array size.
Fix this by falling back to the latest supported version if the
EXT_CSD_REV exceeds the known versions. This ensures forward
compatibility with future eMMC specifications.
Signed-off-by: MW Park <mw.park at telechips.com>
---
drivers/mmc/mmc.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c5705f4f215..dbec728a474 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2334,6 +2334,7 @@ static int mmc_startup_v4(struct mmc *mmc)
u64 capacity;
bool has_parts = false;
bool part_completed;
+ u8 rev;
static const u32 mmc_versions[] = {
MMC_VERSION_4,
MMC_VERSION_4_1,
@@ -2380,12 +2381,19 @@ static int mmc_startup_v4(struct mmc *mmc)
return -ENOMEM;
memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
#endif
- if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions)) {
- err = -EINVAL;
- goto error;
- }
+ rev = ext_csd[EXT_CSD_REV];
+
+ /*
+ * According to the JEDEC Standard, the EXT_CSD format is meant to be
+ * forward compatible. As long as CSD_STRUCTURE does not change, all
+ * values for EXT_CSD_REV are authorized.
+ * If the EXT_CSD_REV exceeds the known versions, fallback to the
+ * latest supported version instead of returning an error.
+ */
+ if (rev >= ARRAY_SIZE(mmc_versions))
+ rev = ARRAY_SIZE(mmc_versions) - 1;
- mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
+ mmc->version = mmc_versions[rev];
if (mmc->version >= MMC_VERSION_4_2) {
/*
--
2.34.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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mmc-allow-forward-compatibility-for-EXT_CSD_REV.patch
Type: application/octet-stream
Size: 2104 bytes
Desc: 0001-mmc-allow-forward-compatibility-for-EXT_CSD_REV.patch
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260326/9a09f81b/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JEDECJESD84-B51B-2025.pdf
Type: application/pdf
Size: 5200884 bytes
Desc: JEDECJESD84-B51B-2025.pdf
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260326/9a09f81b/attachment-0001.pdf>
More information about the U-Boot
mailing list