SDSC cards use byte unit address and SDHC and SDXC Cards use block unit address
(512 bytes) when setting ERASE_START and ERASE_END with CMD32 and CMD33, we need
to account for this.

Signed-off-by: Igor Mitsyanko <i.mitsya...@samsung.com>
---
 hw/sd.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/sd.c b/hw/sd.c
index d0674d5..f7aa580 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -482,8 +482,10 @@ static void sd_erase(SDState *sd)
         return;
     }
 
-    start = sd_addr_to_wpnum(sd->erase_start);
-    end = sd_addr_to_wpnum(sd->erase_end);
+    start = sd_addr_to_wpnum(sd->ocr & (1 << 30) ?
+            (uint64_t)sd->erase_start * 512 : sd->erase_start);
+    end = sd_addr_to_wpnum(sd->ocr & (1 << 30) ?
+            (uint64_t)sd->erase_end * 512 : sd->erase_end);
     sd->erase_start = 0;
     sd->erase_end = 0;
     sd->csd[14] |= 0x40;
-- 
1.7.4.1


Reply via email to