Author: wmb
Date: Sat Feb 13 20:27:16 2010
New Revision: 1744
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1744
Log:
OLPC trac 10024 - Improved SD card detection procedure so it works well for both the CaFe SDHCI controller and the Via SDHCI controller.
Modified:
dev/mmc/sdhci/sdhci.fth
Modified: dev/mmc/sdhci/sdhci.fth
==============================================================================
--- dev/mmc/sdhci/sdhci.fth Sat Feb 13 08:06:38 2010 (r1743)
+++ dev/mmc/sdhci/sdhci.fth Sat Feb 13 20:27:16 2010 (r1744)
@@ -153,7 +153,18 @@
\ The debouncer takes about 300 ms to stabilize.
: card-inserted? ( -- flag )
- present-state@ h# 30000 and h# 30000 =
+ get-msecs d# 500 + begin ( time-limit )
+ \ When the stable bit is set, we can believe the answer
+ present-state@ h# 20000 and if ( time-limit )
+ drop ( )
+ present-state@ h# 10000 and 0<> ( flag )
+ exit ( -- flag )
+ then ( time-limit )
+ dup get-msecs - 0< ( time-limit timeout? )
+ until ( time-limit )
+ drop ( )
+ ." SD Card detect unstable!" cr ( )
+ false ( flag )
;
: write-protected? ( -- flag )
present-state@ h# 80000 and 0=
Author: wmb
Date: Sat Feb 13 06:59:35 2010
New Revision: 1741
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1741
Log:
USB mass storage driver - fixed a potential coherence problem that could result from having multiple deblocker instances open on the same device.
Modified:
dev/usb2/device/storage/scsicom.fth
dev/usb2/device/storage/scsidisk.fth
Modified: dev/usb2/device/storage/scsicom.fth
==============================================================================
--- dev/usb2/device/storage/scsicom.fth Sat Feb 13 06:58:02 2010 (r1740)
+++ dev/usb2/device/storage/scsicom.fth Sat Feb 13 06:59:35 2010 (r1741)
@@ -73,7 +73,7 @@
\ block or record oriented, but the OBP external interface is byte-oriented,
\ in order to be independent of particular device block sizes.
-0 instance value deblocker
+0 value deblocker
: init-deblocker ( -- okay? )
" " " deblocker" $open-package to deblocker
deblocker if
Modified: dev/usb2/device/storage/scsidisk.fth
==============================================================================
--- dev/usb2/device/storage/scsidisk.fth Sat Feb 13 06:58:02 2010 (r1740)
+++ dev/usb2/device/storage/scsidisk.fth Sat Feb 13 06:59:35 2010 (r1741)
@@ -139,8 +139,8 @@
\ This method is called by the deblocker
-0 instance value #blocks
-0 instance value block-size
+0 value #blocks
+0 value block-size
headers
@@ -193,40 +193,54 @@
\ Methods used by external clients
+0 value open-count
+
: open ( -- flag )
my-unit parent-set-address
- \ Set timeout to 45 sec: some large (>1GB) drives take
- \ up to 30 secs to spin up.
- d# 45 d# 1000 * set-timeout
+ open-count if
+ d# 2000 set-timeout
+ else
- unit-ready? 0= if false exit then
+ \ Set timeout to 45 sec: some large (>1GB) drives take
+ \ up to 30 secs to spin up.
+ d# 45 d# 1000 * set-timeout
- \ It might be a good idea to do an inquiry here to determine the
- \ device configuration, checking the result to see if the device
- \ really is a disk.
+ unit-ready? 0= if false exit then
- \ Make sure the disk is spinning
+ \ It might be a good idea to do an inquiry here to determine the
+ \ device configuration, checking the result to see if the device
+ \ really is a disk.
- timed-spin if false exit then
+ \ Make sure the disk is spinning
- read-block-extent if false exit then ( block-size #blocks )
- to #blocks to block-size
+ timed-spin if false exit then
- d# 2000 set-timeout
+ read-block-extent if false exit then ( block-size #blocks )
+ to #blocks to block-size
- init-deblocker 0= if false exit then
+ d# 2000 set-timeout
+ init-deblocker 0= if false exit then
+ then
init-label-package 0= if
- deblocker close-package false exit
+ open-count 0= if
+ deblocker close-package
+ then
+ false exit
then
+ open-count 1+ to open-count
+
true
;
: close ( -- )
- label-package close-package
- deblocker close-package
+ open-count dup 1- 0 max to open-count ( old-open-count )
+ label-package close-package ( old-open-count )
+ 1 = if
+ deblocker close-package
+ then
;
: seek ( offset.low offset.high -- okay? )