[openfirmware] r861 - dev/mmc/sdhci
svn at openfirmware.info
svn at openfirmware.info
Wed Jul 30 00:09:17 CEST 2008
Author: wmb
Date: 2008-07-30 00:09:17 +0200 (Wed, 30 Jul 2008)
New Revision: 861
Modified:
dev/mmc/sdhci/sdhci.fth
Log:
OLPC trac 7702 - Fixed random hang when reading SD cards > 4 GB.
The problem was an off-by-one error in the CSD parser, which
caused it to look at an undefined bit outside the CSD area,
sometimes causing the wrong card size to be reported.
Modified: dev/mmc/sdhci/sdhci.fth
===================================================================
--- dev/mmc/sdhci/sdhci.fth 2008-07-29 00:57:21 UTC (rev 860)
+++ dev/mmc/sdhci/sdhci.fth 2008-07-29 22:09:17 UTC (rev 861)
@@ -596,6 +596,7 @@
: dma-free ( vadr size -- ) " dma-free" $call-parent ;
: r/w-blocks ( addr block# #blocks in? -- actual )
+ over 0= if 2drop 2drop 0 exit then \ Prevents hangs
intstat-on
>r ( addr block# #blocks r: in? )
rot dma-setup ( block# r: in? )
@@ -655,7 +656,7 @@
\ The calculation below is shown on page 81 of the
\ SD Physical Layer Simplified Specification Version 2.00.
: size ( -- d.bytes )
- d# 128 d# 126 csdbits case
+ d# 127 d# 126 csdbits case
0 of
d# 49 d# 47 csdbits ( c_size_mult )
2 + 1 swap lshift ( mult )
@@ -670,7 +671,8 @@
d# 70 d# 48 csdbits d# 10 lshift h# 200 um*
endof
( default )
- h# ffffffff 0 rot
+ ." SD: Warning - invalid CSD; using default device size." cr
+ h# 8.0000.0000. rot \ 32 GB
endcase
;
external
More information about the openfirmware
mailing list