From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Sai Pavan Boddu <saipava@xilinx.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
"Vincent Palatin" <vpalatin@chromium.org>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Max Reitz" <mreitz@redhat.com>,
"Edgar Iglesias" <edgari@xilinx.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Joel Stanley" <joel@jms.id.au>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Luc Michel" <luc.michel@greensocs.com>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [PATCH v3 12/21] sd: emmc: add CMD21 tuning sequence
Date: Wed, 3 Mar 2021 09:15:38 +0000 [thread overview]
Message-ID: <YD9TukdPgVH4coHs@work-vm> (raw)
In-Reply-To: <BY5PR02MB6772300E84C0553278094EBDCA989@BY5PR02MB6772.namprd02.prod.outlook.com>
* Sai Pavan Boddu (saipava@xilinx.com) wrote:
> Hi David,
>
> > -----Original Message-----
> > From: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > Sent: Monday, March 1, 2021 4:12 PM
> > 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>; 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>; qemu-block@nongnu.org; qemu-devel@nongnu.org;
> > Sai Pavan Boddu <saipava@xilinx.com>
> > Subject: Re: [PATCH v3 12/21] sd: emmc: add CMD21 tuning sequence
> >
> > * Sai Pavan Boddu (sai.pavan.boddu@xilinx.com) wrote:
> > > eMMC cards support tuning sequence for entering HS200 mode.
> > >
> > > 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, 47 insertions(+)
> > >
> > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> > > index bf963ec..174c28e 100644
> > > --- a/hw/sd/sd.c
> > > +++ b/hw/sd/sd.c
> > > @@ -1386,6 +1386,14 @@ static sd_rsp_type_t
> > sd_normal_command(SDState *sd, SDRequest req)
> > > }
> > > break;
> > >
> > > + case 21: /* CMD21: mmc SEND TUNING_BLOCK */
> > > + if (sd->emmc && (sd->state == sd_transfer_state)) {
> > > + sd->state = sd_sendingdata_state;
> > > + sd->data_offset = 0;
> > > + return sd_r1;
> > > + }
> > > + break;
> > > +
> > > case 23: /* CMD23: SET_BLOCK_COUNT */
> > > if (sd->spec_version < SD_PHY_SPECv3_01_VERS) {
> > > break;
> > > @@ -2120,6 +2128,30 @@ static const uint8_t
> > sd_tuning_block_pattern[SD_TUNING_BLOCK_SIZE] = {
> > > 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
> > > };
> > >
> > > +#define EXCSD_BUS_WIDTH_OFFSET 183
> > > +#define BUS_WIDTH_8_MASK 0x4
> > > +#define BUS_WIDTH_4_MASK 0x2
> > > +#define MMC_TUNING_BLOCK_SIZE 128
> > > +
> > > +static const uint8_t mmc_tunning_block_pattern[128] = {
> > > + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
> > > + 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
> > > + 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
> > > + 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
> > > + 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
> > > + 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
> > > + 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
> > > + 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
> > > + 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
> > > + 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
> > > + 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
> > > + 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
> > > + 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
> > > + 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
> > > + 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
> > > + 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
> >
> > Where does this magic pattern come from? Is it part of some spec?
> [Sai Pavan Boddu] Yes its part of JEDEC eMMC spec. It's the tuning sequence for HS200 mode.
OK, if you have to repost it, then please add a comment saying that.
DAve
> Regards,
> Sai Pavan
> >
> > Dave
> >
> > > +};
> > > +
> > > uint8_t sd_read_byte(SDState *sd)
> > > {
> > > /* TODO: Append CRCs */
> > > @@ -2213,6 +2245,21 @@ uint8_t sd_read_byte(SDState *sd)
> > > ret = sd_tuning_block_pattern[sd->data_offset++];
> > > break;
> > >
> > > + case 21: /* CMD21: SEND_TUNNING_BLOCK (MMC) */
> > > + if (sd->data_offset >= MMC_TUNING_BLOCK_SIZE - 1) {
> > > + sd->state = sd_transfer_state;
> > > + }
> > > + if (sd->ext_csd[EXCSD_BUS_WIDTH_OFFSET] & BUS_WIDTH_8_MASK) {
> > > + ret = mmc_tunning_block_pattern[sd->data_offset++];
> > > + } else {
> > > + /* Return LSB Nibbles of two byte from the 8bit tuning block
> > > + * for 4bit mode
> > > + */
> > > + ret = mmc_tunning_block_pattern[sd->data_offset++] & 0x0F;
> > > + ret |= (mmc_tunning_block_pattern[sd->data_offset++] & 0x0F) << 4;
> > > + }
> > > + break;
> > > +
> > > case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */
> > > ret = sd->data[sd->data_offset ++];
> > >
> > > --
> > > 2.7.4
> > >
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2021-03-03 9:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-28 19:33 [PATCH v3 00/21] eMMC support Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 01/21] sd: sd: Remove usage of tabs in the file Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 02/21] sd: emmc: Add support for eMMC cards Sai Pavan Boddu
2021-03-01 11:02 ` Cédric Le Goater
2021-03-03 3:57 ` Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 03/21] sd: emmc: Update SET_RELATIVE_ADDR command Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 04/21] sd: emmc: update OCR fields for eMMC Sai Pavan Boddu
2021-03-01 11:04 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 05/21] sd: emmc: Add support for EXT_CSD & CSD " Sai Pavan Boddu
2021-03-01 11:08 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 06/21] sd: emmc: Update CMD8 to send EXT_CSD register Sai Pavan Boddu
2021-03-01 12:02 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 07/21] sd: sdmmc-internal: Add command string for SEND_OP_CMD Sai Pavan Boddu
2021-03-01 12:03 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 08/21] sd: emmc: Dont not update CARD_CAPACITY for eMMC cards Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 09/21] sd: emmc: Update CMD1 definition for eMMC Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 10/21] sd: emmc: support idle state in CMD2 Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 11/21] sd: emmc: Add mmc switch function support Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 12/21] sd: emmc: add CMD21 tuning sequence Sai Pavan Boddu
2021-03-01 10:42 ` Dr. David Alan Gilbert
2021-03-03 3:53 ` Sai Pavan Boddu
2021-03-03 9:15 ` Dr. David Alan Gilbert [this message]
2021-02-28 19:33 ` [PATCH v3 13/21] sd: emmc: Make ACMD41 illegal for mmc Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 14/21] sd: emmc: Add support for emmc erase Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 15/21] sd: emmc: Update CID structure for eMMC Sai Pavan Boddu
2021-03-01 12:09 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 16/21] sd: emmc: Support boot area in emmc image Sai Pavan Boddu
2021-03-01 12:07 ` Cédric Le Goater
2021-02-28 19:33 ` [PATCH v3 17/21] sd: emmc: Subtract bootarea size from blk Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 18/21] sd: sdhci: Support eMMC devices Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 19/21] arm: xlnx-versal: Add emmc to versal Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 20/21] docs: devel: emmc: Add a doc for emmc card emulation Sai Pavan Boddu
2021-02-28 19:33 ` [PATCH v3 21/21] docs: arm: xlnx-versal-virt: Add eMMC support documentation Sai Pavan Boddu
2021-03-02 9:52 ` [PATCH v3 00/21] eMMC support Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YD9TukdPgVH4coHs@work-vm \
--to=dgilbert@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=armbru@redhat.com \
--cc=clg@kaod.org \
--cc=edgari@xilinx.com \
--cc=joel@jms.id.au \
--cc=kwolf@redhat.com \
--cc=luc.michel@greensocs.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=saipava@xilinx.com \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=vpalatin@chromium.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).