Message ID | 1613031446-22154-11-git-send-email-sai.pavan.boddu@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | eMMC support | expand |
On Thu, Feb 11, 2021 at 12:30 AM Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> 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 | 52 +++++++++++++++++++++++++++++++++++----------------- > 1 file changed, 35 insertions(+), 17 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 7aab647..45311fa 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -345,23 +345,41 @@ 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[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]; Aren't the majority of these the same between the two cases? It's probably cleaner to split them out then. Alistair > + 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[3] = PNM[0]; /* Fake product name (PNM) 40bit */ > + 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; > } > > #define HWBLOCK_SHIFT 9 /* 512 bytes */ > -- > 2.7.4 > >
Hi Alistair > -----Original Message----- > From: Alistair Francis <alistair23@gmail.com> > Sent: Saturday, February 13, 2021 3:41 AM > To: Sai Pavan Boddu <saipava@xilinx.com> > Cc: Markus Armbruster <armbru@redhat.com>; Kevin Wolf > <kwolf@redhat.com>; Max Reitz <mreitz@redhat.com>; Vladimir Sementsov- > Ogievskiy <vsementsov@virtuozzo.com>; Eric Blake <eblake@redhat.com>; > Joel Stanley <joel@jms.id.au>; Cédric Le Goater <clg@kaod.org>; Vincent > Palatin <vpalatin@chromium.org>; Dr. David Alan Gilbert > <dgilbert@redhat.com>; Thomas Huth <thuth@redhat.com>; Stefan Hajnoczi > <stefanha@redhat.com>; Peter Maydell <peter.maydell@linaro.org>; Alistair > Francis <alistair.francis@wdc.com>; Edgar Iglesias <edgari@xilinx.com>; Luc > Michel <luc.michel@greensocs.com>; Paolo Bonzini <pbonzini@redhat.com>; > Sai Pavan Boddu <saipava@xilinx.com>; qemu-devel@nongnu.org Developers > <qemu-devel@nongnu.org>; Qemu-block <qemu-block@nongnu.org> > Subject: Re: [RFC PATCH 10/15] sd: emmc: Update CID structure for eMMC > > On Thu, Feb 11, 2021 at 12:30 AM Sai Pavan Boddu > <sai.pavan.boddu@xilinx.com> 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 | 52 +++++++++++++++++++++++++++++++++++----------------- > > 1 file changed, 35 insertions(+), 17 deletions(-) > > > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > > index 7aab647..45311fa 100644 > > --- a/hw/sd/sd.c > > +++ b/hw/sd/sd.c > > @@ -345,23 +345,41 @@ 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[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]; > > Aren't the majority of these the same between the two cases? It's probably > cleaner to split them out then. [Sai Pavan Boddu] Yes, I would try to re-order. If I see only the PNM fields are same, rest all fields kind of moved a byte below. Regards, Sai Pavan > > Alistair > > > + 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[3] = PNM[0]; /* Fake product name (PNM) 40bit */ > > + 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; > > } > > > > #define HWBLOCK_SHIFT 9 /* 512 bytes */ > > -- > > 2.7.4 > > > >
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7aab647..45311fa 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -345,23 +345,41 @@ 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[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[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[3] = PNM[0]; /* Fake product name (PNM) 40bit */ + 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; } #define HWBLOCK_SHIFT 9 /* 512 bytes */