From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
To: "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 E. Iglesias" <edgar.iglesias@xilinx.com>,
"Luc Michel" <luc.michel@greensocs.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Cc: saipava@xilinx.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: [PATCH v2 05/22] sd: emmc: Add support for EXT_CSD & CSD for eMMC
Date: Mon, 22 Feb 2021 13:50:22 +0530 [thread overview]
Message-ID: <1613982039-13861-6-git-send-email-sai.pavan.boddu@xilinx.com> (raw)
In-Reply-To: <1613982039-13861-1-git-send-email-sai.pavan.boddu@xilinx.com>
From: Vincent Palatin <vpalatin@chromium.org>
eMMC CSD is similar to SD with an option to refer EXT_CSD for larger
devices.
Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
hw/sd/sd.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 55 insertions(+), 2 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 430bea5..4c211ba 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -135,6 +135,7 @@ struct SDState {
uint64_t data_start;
uint32_t data_offset;
uint8_t data[512];
+ uint8_t ext_csd[512];
qemu_irq readonly_cb;
qemu_irq inserted_cb;
QEMUTimer *ocr_power_timer;
@@ -389,6 +390,51 @@ static const uint8_t sd_csd_rw_mask[16] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe,
};
+static void mmc_set_ext_csd(SDState *sd, uint64_t size)
+{
+ uint32_t sectcount = size >> HWBLOCK_SHIFT;
+
+ memset(sd->ext_csd, 0, sizeof(sd->ext_csd));
+ sd->ext_csd[504] = 0x1; /* supported command sets */
+ sd->ext_csd[503] = 0x1; /* HPI features */
+ sd->ext_csd[502] = 0x1; /* Background operations support */
+ sd->ext_csd[241] = 0xA; /* 1st initialization time after partitioning */
+ sd->ext_csd[232] = 0x1; /* Trim multiplier */
+ sd->ext_csd[231] = 0x15; /* Secure feature support */
+ sd->ext_csd[230] = 0x96; /* Secure erase support */
+ sd->ext_csd[229] = 0x96; /* Secure TRIM multiplier */
+ sd->ext_csd[228] = 0x7; /* Boot information */
+ sd->ext_csd[226] = 0x8; /* Boot partition size */
+ sd->ext_csd[225] = 0x6; /* Access size */
+ sd->ext_csd[224] = 0x4; /* HC Erase unit size */
+ sd->ext_csd[223] = 0x1; /* HC erase timeout */
+ sd->ext_csd[222] = 0x1; /* Reliable write sector count */
+ sd->ext_csd[221] = 0x4; /* HC write protect group size */
+ sd->ext_csd[220] = 0x8; /* Sleep current VCC */
+ sd->ext_csd[219] = 0x7; /* Sleep current VCCQ */
+ sd->ext_csd[217] = 0x11; /* Sleep/Awake timeout */
+ sd->ext_csd[215] = (sectcount >> 24) & 0xff; /* Sector count */
+ sd->ext_csd[214] = (sectcount >> 16) & 0xff; /* ... */
+ sd->ext_csd[213] = (sectcount >> 8) & 0xff; /* ... */
+ sd->ext_csd[212] = (sectcount & 0xff); /* ... */
+ sd->ext_csd[210] = 0xa; /* Min write perf for 8bit@52Mhz */
+ sd->ext_csd[209] = 0xa; /* Min read perf for 8bit@52Mhz */
+ sd->ext_csd[208] = 0xa; /* Min write perf for 4bit@52Mhz */
+ sd->ext_csd[207] = 0xa; /* Min read perf for 4bit@52Mhz */
+ sd->ext_csd[206] = 0xa; /* Min write perf for 4bit@26Mhz */
+ sd->ext_csd[205] = 0xa; /* Min read perf for 4bit@26Mhz */
+ sd->ext_csd[199] = 0x1; /* Partition switching timing */
+ sd->ext_csd[198] = 0x1; /* Out-of-interrupt busy timing */
+ sd->ext_csd[196] = 0xFF; /* Card type */
+ sd->ext_csd[194] = 0x2; /* CSD Structure version */
+ sd->ext_csd[192] = 0x5; /* Extended CSD revision */
+ sd->ext_csd[168] = 0x1; /* RPMB size */
+ sd->ext_csd[160] = 0x3; /* Partinioning support */
+ sd->ext_csd[159] = 0x00; /* Max enhanced area size */
+ sd->ext_csd[158] = 0x00; /* ... */
+ sd->ext_csd[157] = 0xEC; /* ... */
+}
+
static void sd_set_csd(SDState *sd, uint64_t size)
{
int hwblock_shift = HWBLOCK_SHIFT;
@@ -402,8 +448,11 @@ static void sd_set_csd(SDState *sd, uint64_t size)
}
csize = (size >> (CMULT_SHIFT + hwblock_shift)) - 1;
- if (size <= SDSC_MAX_CAPACITY) { /* Standard Capacity SD */
- sd->csd[0] = 0x00; /* CSD structure */
+ if (size <= SDSC_MAX_CAPACITY || sd->emmc) { /* Standard Capacity SD */
+ if (sd->emmc && size >= SDSC_MAX_CAPACITY) {
+ csize = 0xfff;
+ }
+ sd->csd[0] = sd->emmc ? 0xd0 : 0x00; /* CSD structure */
sd->csd[1] = 0x26; /* Data read access-time-1 */
sd->csd[2] = 0x00; /* Data read access-time-2 */
sd->csd[3] = 0x32; /* Max. data transfer rate: 25 MHz */
@@ -447,6 +496,10 @@ static void sd_set_csd(SDState *sd, uint64_t size)
sd->csd[14] = 0x00;
}
sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1;
+
+ if (sd->emmc) {
+ mmc_set_ext_csd(sd, size);
+ }
}
static void sd_set_rca(SDState *sd, uint16_t value)
--
2.7.4
next prev parent reply other threads:[~2021-02-22 8:27 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 8:20 [PATCH v2 00/22] eMMC support Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 01/22] block: add eMMC block device type Sai Pavan Boddu
2021-02-22 12:04 ` Philippe Mathieu-Daudé
2021-02-22 12:19 ` Markus Armbruster
2021-02-22 13:16 ` Dr. David Alan Gilbert
2021-02-22 13:23 ` Philippe Mathieu-Daudé
2021-02-22 16:17 ` Sai Pavan Boddu
2021-02-22 16:26 ` Dr. David Alan Gilbert
2021-02-23 17:35 ` Sai Pavan Boddu
2021-02-24 11:40 ` Stefan Hajnoczi
2021-02-24 13:55 ` Cédric Le Goater
2021-02-24 19:13 ` Sai Pavan Boddu
2021-02-25 14:43 ` Cédric Le Goater
2021-02-24 19:06 ` Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 02/22] sd: sd: Remove usage of tabs in the file Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 03/22] sd: emmc: Add support for eMMC cards Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 04/22] sd: emmc: update OCR fields for eMMC Sai Pavan Boddu
2021-02-22 9:51 ` Cédric Le Goater
2021-02-22 9:55 ` Sai Pavan Boddu
2021-02-22 11:59 ` Philippe Mathieu-Daudé
2021-02-22 8:20 ` Sai Pavan Boddu [this message]
2021-02-22 8:20 ` [PATCH v2 06/22] sd: emmc: Update CMD8 to send EXT_CSD register Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 07/22] sd: sdmmc-internal: Add command string for SEND_OP_CMD Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 08/22] sd: emmc: Dont not update CARD_CAPACITY for eMMC cards Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 09/22] sd: emmc: Update CMD1 definition for eMMC Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 10/22] sd: emmc: support idle state in CMD2 Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 11/22] sd: emmc: Add mmc switch function support Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 12/22] sd: emmc: add CMD21 tuning sequence Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 13/22] sd: emmc: Make ACMD41 illegal for mmc Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 14/22] sd: emmc: Add support for emmc erase Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 15/22] sd: emmc: Update CID structure for eMMC Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 16/22] sd: emmc: Add Extended CSD register definitions Sai Pavan Boddu
2021-02-22 9:54 ` Cédric Le Goater
2021-02-22 8:20 ` [PATCH v2 17/22] sd: emmc: Support boot area in emmc image Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 18/22] sd: emmc: Subtract bootarea size from blk Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 19/22] sd: sdhci: Support eMMC devices Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 20/22] arm: xlnx-versal: Add emmc to versal Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 21/22] docs: devel: emmc: Add a doc for emmc card emulation Sai Pavan Boddu
2021-02-22 8:20 ` [PATCH v2 22/22] docs: arm: xlnx-versal-virt: Add eMMC support documentation Sai Pavan Boddu
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=1613982039-13861-6-git-send-email-sai.pavan.boddu@xilinx.com \
--to=sai.pavan.boddu@xilinx.com \
--cc=alistair.francis@wdc.com \
--cc=armbru@redhat.com \
--cc=clg@kaod.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=edgar.iglesias@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).