* [U-Boot] generic mmc bug in reading sd card capacity
@ 2012-11-02 7:12 victor
2012-11-06 8:41 ` Romain Izard
0 siblings, 1 reply; 2+ messages in thread
From: victor @ 2012-11-02 7:12 UTC (permalink / raw)
To: u-boot
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.
================================================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
* [U-Boot] generic mmc bug in reading sd card capacity
2012-11-02 7:12 [U-Boot] generic mmc bug in reading sd card capacity victor
@ 2012-11-06 8:41 ` Romain Izard
0 siblings, 0 replies; 2+ messages in thread
From: Romain Izard @ 2012-11-06 8:41 UTC (permalink / raw)
To: u-boot
On 2012-11-02, victor <victor@keyasic.com> wrote:
> 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.
>
We should be careful about the fact that this only works for SD cards.
The size parameter is handled differently on MMC devices larger than
2 GiB. What do you think of the following patch:
(Compile tested only, I do not have a board available for testing right now)
8<----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-06 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 7:12 [U-Boot] generic mmc bug in reading sd card capacity victor
2012-11-06 8:41 ` Romain Izard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox