Message ID | 1614540807-30686-16-git-send-email-sai.pavan.boddu@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | eMMC support | expand |
On 2/28/21 8:33 PM, Sai Pavan Boddu wrote: > CID structure is little different for eMMC, w.r.t to product name and > manufacturing date. > > Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> > --- > hw/sd/sd.c | 47 ++++++++++++++++++++++++++++++----------------- > 1 file changed, 30 insertions(+), 17 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index bba0446..08b77ad 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -365,23 +365,36 @@ static void sd_set_scr(SDState *sd) > > static void sd_set_cid(SDState *sd) > { > - sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ > - sd->cid[1] = OID[0]; /* OEM/Application ID (OID) */ > - sd->cid[2] = OID[1]; > - 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] = PRV; /* Fake product revision (PRV) */ > - sd->cid[9] = 0xde; /* Fake serial number (PSN) */ > - sd->cid[10] = 0xad; > - sd->cid[11] = 0xbe; > - sd->cid[12] = 0xef; > - sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ > - ((MDT_YR - 2000) / 10); > - sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; > - sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; > + if (sd->emmc) { > + sd->cid[0] = MID; > + sd->cid[1] = 0x1; /* CBX */ > + sd->cid[2] = OID[0]; /* OEM/Application ID (OID) */ > + sd->cid[8] = 0x0; > + sd->cid[9] = PRV; /* Fake product revision (PRV) */ > + sd->cid[10] = 0xde; /* Fake serial number (PSN) */ > + sd->cid[11] = 0xad; > + sd->cid[12] = 0xbe; > + sd->cid[13] = 0xef; > + sd->cid[14] = ((MDT_YR - 1997) % 0x10); /* MDT */ > + } else { > + sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ > + sd->cid[1] = OID[0]; /* OEM/Application ID (OID) */ > + sd->cid[2] = OID[1]; > + sd->cid[8] = PRV; /* Fake product revision (PRV) */ > + sd->cid[9] = 0xde; /* Fake serial number (PSN) */ > + sd->cid[10] = 0xad; > + sd->cid[11] = 0xbe; > + sd->cid[12] = 0xef; > + sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ > + ((MDT_YR - 2000) / 10); > + sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; > + } > + sd->cid[3] = PNM[0]; /* Fake product name (PNM) 48bit */ > + sd->cid[4] = PNM[1]; > + sd->cid[5] = PNM[2]; > + sd->cid[6] = PNM[3]; > + sd->cid[7] = PNM[4]; > + sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; > } These are constant values and could be kept in SDCardClass. C. > #define HWBLOCK_SHIFT 9 /* 512 bytes */ >
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bba0446..08b77ad 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -365,23 +365,36 @@ static void sd_set_scr(SDState *sd) static void sd_set_cid(SDState *sd) { - sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ - sd->cid[1] = OID[0]; /* OEM/Application ID (OID) */ - sd->cid[2] = OID[1]; - 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] = PRV; /* Fake product revision (PRV) */ - sd->cid[9] = 0xde; /* Fake serial number (PSN) */ - sd->cid[10] = 0xad; - sd->cid[11] = 0xbe; - sd->cid[12] = 0xef; - sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ - ((MDT_YR - 2000) / 10); - sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; - sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; + if (sd->emmc) { + sd->cid[0] = MID; + sd->cid[1] = 0x1; /* CBX */ + sd->cid[2] = OID[0]; /* OEM/Application ID (OID) */ + sd->cid[8] = 0x0; + sd->cid[9] = PRV; /* Fake product revision (PRV) */ + sd->cid[10] = 0xde; /* Fake serial number (PSN) */ + sd->cid[11] = 0xad; + sd->cid[12] = 0xbe; + sd->cid[13] = 0xef; + sd->cid[14] = ((MDT_YR - 1997) % 0x10); /* MDT */ + } else { + sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ + sd->cid[1] = OID[0]; /* OEM/Application ID (OID) */ + sd->cid[2] = OID[1]; + sd->cid[8] = PRV; /* Fake product revision (PRV) */ + sd->cid[9] = 0xde; /* Fake serial number (PSN) */ + sd->cid[10] = 0xad; + sd->cid[11] = 0xbe; + sd->cid[12] = 0xef; + sd->cid[13] = 0x00 | /* Manufacture date (MDT) */ + ((MDT_YR - 2000) / 10); + sd->cid[14] = ((MDT_YR % 10) << 4) | MDT_MON; + } + sd->cid[3] = PNM[0]; /* Fake product name (PNM) 48bit */ + sd->cid[4] = PNM[1]; + sd->cid[5] = PNM[2]; + sd->cid[6] = PNM[3]; + sd->cid[7] = PNM[4]; + sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; } #define HWBLOCK_SHIFT 9 /* 512 bytes */