[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
- [PATCH v47 00/19] hw/sd/sdcard: Add eMMC support, Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 01/19] hw/sd/sdcard: Basis for eMMC support, Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 02/19] hw/sd/sdcard: Register generic command handlers, Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 03/19] hw/sd/sdcard: Register unimplemented command handlers, Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 04/19] hw/sd/sdcard: Implement emmc_set_cid(),
Philippe Mathieu-Daudé <=
- [PATCH v47 05/19] hw/sd/sdcard: Implement emmc_set_csd(), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 06/19] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR handler (CMD3), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 07/19] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 08/19] hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 09/19] hw/sd/sdcard: Implement eMMC sleep state (CMD5), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 10/19] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8), Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 11/19] hw/sd/sdcard: Add eMMC 'boot-size' property, Philippe Mathieu-Daudé, 2024/07/09
- [PATCH v47 12/19] hw/sd/sdcard: Simplify EXT_CSD values for spec v4.3, Philippe Mathieu-Daudé, 2024/07/09