Igor Mitsyanko <i.mitsya...@samsung.com> writes:

> 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.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;

Is this a bug fix?

If yes, I recommend to state that clearly in the subject, say "hw/sd.c:
Fix erase for high capacity cards".

Reply via email to