qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v47 04/19] hw/sd/sdcard: Implement emmc_set_cid()


From: Philippe Mathieu-Daudé
Subject: [PATCH v47 04/19] hw/sd/sdcard: Implement emmc_set_cid()
Date: Tue, 9 Jul 2024 17:25:41 +0200

eMMC CID register is slightly different from SD:
- One extra PNM (5 -> 6)
- MDT is only 1 byte (2 -> 1).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sd/sd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 097c9cc61f..2d737a836f 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -446,6 +446,23 @@ static void sd_set_cid(SDState *sd)
     sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1;
 }
 
+static void emmc_set_cid(SDState *sd)
+{
+    sd->cid[0] = MID;       /* Fake card manufacturer ID (MID) */
+    sd->cid[1] = 0b01;      /* CBX: BGA */
+    sd->cid[2] = OID[0];    /* OEM/Application ID (OID) */
+    sd->cid[3] = PNM[0];    /* Fake product name (PNM) */
+    sd->cid[4] = PNM[1];
+    sd->cid[5] = PNM[2];
+    sd->cid[6] = PNM[3];
+    sd->cid[7] = PNM[4];
+    sd->cid[8] = PNM[4];
+    sd->cid[9] = PRV;       /* Fake product revision (PRV) */
+    stl_be_p(&sd->cid[10], 0xdeadbeef); /* Fake serial number (PSN) */
+    sd->cid[14] = (MDT_MON << 4) | (MDT_YR - 1997); /* Manufacture date (MDT) 
*/
+    sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1;
+}
+
 /* Card-Specific Data register */
 
 #define HWBLOCK_SHIFT   9        /* 512 bytes */
@@ -2581,6 +2598,8 @@ static void emmc_class_init(ObjectClass *klass, void 
*data)
     dc->user_creatable = false;
 
     sc->proto = &sd_proto_emmc;
+
+    sc->set_cid = emmc_set_cid;
 }
 
 static const TypeInfo sd_types[] = {
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]