From: Max Merchel <Max.Merchel@tq-group.com>
Date: Thu, 10 Feb 2022 09:16:39 +0000 (+0100)
Subject: cmd/mmc: fix output of mmc info for e-MMC
X-Git-Tag: v2025.01-rc5-pxa1908~1498^2~4
X-Git-Url: http://git.dujemihanovic.xyz/img/static/html/%7B%7B?a=commitdiff_plain;h=84191f73847c351019bb50728d28220d91b0aee4;p=u-boot.git

cmd/mmc: fix output of mmc info for e-MMC

e-MMC and SD standards differ for some CID fields:

- 6 Byte Name - assigned by Manufacturer (SD 5 Byte)
- 1 Byte OEM - assigned by Jedec  (SD 2 Byte)

See e-MMC standard (JEDEC Standard No. 84-B51), 7.2.3 (OID) and 7.2.4 (PNM)

Signed-off-by: Max Merchel <Max.Merchel@tq-group.com>
Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
---

diff --git a/cmd/mmc.c b/cmd/mmc.c
index 503dbb6199..7464f8d00c 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -22,10 +22,18 @@ static void print_mmcinfo(struct mmc *mmc)
 
 	printf("Device: %s\n", mmc->cfg->name);
 	printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
-	printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
-	printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff,
-			(mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
-			(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff);
+	if (IS_SD(mmc)) {
+		printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
+		printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff,
+		(mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
+		(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff);
+	} else {
+		printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xff);
+		printf("Name: %c%c%c%c%c%c \n", mmc->cid[0] & 0xff,
+		(mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
+		(mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff,
+		(mmc->cid[2] >> 24));
+	}
 
 	printf("Bus Speed: %d\n", mmc->clock);
 #if CONFIG_IS_ENABLED(MMC_VERBOSE)