From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH 26/28] hw/sd.c: Fix erase for high capacity cards
Date: Tue, 30 Oct 2012 08:44:22 +0000 [thread overview]
Message-ID: <1351586664-20525-27-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1351586664-20525-1-git-send-email-peter.maydell@linaro.org>
From: Igor Mitsyanko <i.mitsyanko@gmail.com>
Standard capacity cards SDSC use byte unit address while SDHC and SDXC cards use
block unit address (512 bytes) when setting ERASE_START and ERASE_END with CMD32
and CMD33, we have to account for this.
Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/sd.c | 17 +++++++++++++----
hw/sd.h | 1 +
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/sd.c b/hw/sd.c
index 297580a..b2f211c 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -476,19 +476,28 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)
static void sd_erase(SDState *sd)
{
- int i, start, end;
+ int i;
+ uint64_t erase_start = sd->erase_start;
+ uint64_t erase_end = sd->erase_end;
+
if (!sd->erase_start || !sd->erase_end) {
sd->card_status |= ERASE_SEQ_ERROR;
return;
}
- start = sd_addr_to_wpnum(sd->erase_start);
- end = sd_addr_to_wpnum(sd->erase_end);
+ if (extract32(sd->ocr, OCR_CCS_BITN, 1)) {
+ /* High capacity memory card: erase units are 512 byte blocks */
+ erase_start *= 512;
+ erase_end *= 512;
+ }
+
+ erase_start = sd_addr_to_wpnum(erase_start);
+ erase_end = sd_addr_to_wpnum(erase_end);
sd->erase_start = 0;
sd->erase_end = 0;
sd->csd[14] |= 0x40;
- for (i = start; i <= end; i++) {
+ for (i = erase_start; i <= erase_end; i++) {
if (test_bit(i, sd->wp_groups)) {
sd->card_status |= WP_ERASE_SKIP;
}
diff --git a/hw/sd.h b/hw/sd.h
index 4eb9679..d9b97e4 100644
--- a/hw/sd.h
+++ b/hw/sd.h
@@ -50,6 +50,7 @@
#define READY_FOR_DATA (1 << 8)
#define APP_CMD (1 << 5)
#define AKE_SEQ_ERROR (1 << 3)
+#define OCR_CCS_BITN 30
typedef enum {
sd_none = -1,
--
1.7.9.5
next prev parent reply other threads:[~2012-10-30 8:55 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-30 8:43 [Qemu-devel] [PULL 00/28] arm-devs queue Peter Maydell
2012-10-30 8:43 ` [Qemu-devel] [PATCH 01/28] hw/armv7m_nvic: Implement byte/halfword access for NVIC SCB_SHPRx registers Peter Maydell
2012-10-30 8:43 ` [Qemu-devel] [PATCH 02/28] hw/vexpress.c: Don't prematurely explode QEMUMachineInitArgs Peter Maydell
2012-10-30 8:43 ` [Qemu-devel] [PATCH 03/28] hw/realview.c: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 04/28] hw/versatilepb: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 05/28] hw/spitz: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 06/28] hw/omap_sx1: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 07/28] hw/nseries: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 08/28] hw/mainstone: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 09/28] hw/exynos4_boards: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 10/28] hw/pl050: Use LOG_GUEST_ERROR Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 11/28] hw/pl061: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 12/28] hw/pl080: Use LOG_GUEST_ERROR and LOG_UNIMP Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 13/28] hw/pl110: Use LOG_GUEST_ERROR rather than hw_error() Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 14/28] hw/pl190: Use LOG_UNIMP " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 15/28] hw/arm11mpcore: Use LOG_GUEST_ERROR " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 16/28] hw/arm_gic: Use LOG_GUEST_ERROR Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 17/28] hw/arm_timer: Use LOG_GUEST_ERROR and LOG_UNIMP Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 18/28] hw/armv7m_nvic: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 19/28] hw/arm_sysctl: Use LOG_GUEST_ERROR Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 20/28] hw/arm_l2x0: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 21/28] hw/versatile_i2c: " Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 22/28] pflash_cfi0x: remove unused base field Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 23/28] pflash_cfi01: remove unused total_len field Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 24/28] pflash_cfi0x: QOMified Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 25/28] pflash_cfi01: Fix debug mode printfery Peter Maydell
2012-10-30 8:44 ` Peter Maydell [this message]
2012-10-30 8:44 ` [Qemu-devel] [PATCH 27/28] vmstate: Add support for saving/loading bitmaps Peter Maydell
2012-10-30 8:44 ` [Qemu-devel] [PATCH 28/28] hw/sd.c: add SD card save/load support Peter Maydell
2013-03-06 18:31 ` Michael Walle
2013-03-06 18:52 ` Peter Maydell
2013-03-07 12:35 ` Igor Mitsyanko
2012-11-01 16:02 ` [Qemu-devel] [PULL 00/28] arm-devs queue Aurelien Jarno
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=1351586664-20525-27-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=anthony@codemonkey.ws \
--cc=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/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).