From: victor <victor@keyasic.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] generic mmc bug in reading sd card capacity
Date: Fri, 2 Nov 2012 15:12:52 +0800 [thread overview]
Message-ID: <02e101cdb8c9$7a25fe60$6e71fb20$@keyasic.com> (raw)
Hi All,
Accord to SD spec 2.0, the formula to find out sd card capacity is:
memory capacity = (C_SIZE+1) * 512K byte
and
C_SIZE is from CSD [69:48]
Thus, the code in generic mmc is wrong for the high capacity sd card. My
patch is below.
Thanks,
victor
--- mmc.c 2012-10-09 02:20:28.000000000 +0800
+++ mmc.c.victor 2012-11-02 15:07:16.949207266 +0800
@@ -1068,17 +1104,26 @@
mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf);
if (mmc->high_capacity) {
- csize = (mmc->csd[1] & 0x3f) << 16
- | (mmc->csd[2] & 0xffff0000) >> 16;
- cmult = 8;
+ //csize = (mmc->csd[1] & 0x3f) << 16
+ // | (mmc->csd[2] & 0xffff0000) >> 16;
+ //cmult = 8;
+ csize = (mmc->csd[2] & 0x3f) << 16
+ | (mmc->csd[1] & 0xffff0000) >> 16;
} else {
csize = (mmc->csd[1] & 0x3ff) << 2
| (mmc->csd[2] & 0xc0000000) >> 30;
cmult = (mmc->csd[2] & 0x00038000) >> 15;
}
- mmc->capacity = (csize + 1) << (cmult + 2);
- mmc->capacity *= mmc->read_bl_len;
+ if (mmc->high_capacity) {
+ mmc->capacity = (csize + 1) * 512 * 1024;
+ } else {
+ mmc->capacity = (csize + 1) << (cmult + 2);
+ mmc->capacity *= mmc->read_bl_len;
+ }
================================================================================================
CONFIDENTIALITY NOTE:
This e-mail and any attachments may contain confidential information and may be protected by legal privilege. If you are not the intended addressee (or authorized to receive for the addressee). be aware that any disclosure, copying, distribution or use of this e-mail or any attachment is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you for your cooperation.
KeyASIC Inc.
================================================================================================
next reply other threads:[~2012-11-02 7:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 7:12 victor [this message]
2012-11-06 8:41 ` [U-Boot] generic mmc bug in reading sd card capacity Romain Izard
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='02e101cdb8c9$7a25fe60$6e71fb20$@keyasic.com' \
--to=victor@keyasic.com \
--cc=u-boot@lists.denx.de \
/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