[openfirmware] r1697 - cpu/x86/pc/olpc/via dev/mmc/sdhci

svn at openfirmware.info svn at openfirmware.info
Mon Jan 25 09:36:23 CET 2010


Author: wmb
Date: 2010-01-25 09:36:22 +0100 (Mon, 25 Jan 2010)
New Revision: 1697

Modified:
   cpu/x86/pc/olpc/via/fw.bth
   dev/mmc/sdhci/sdhci.fth
   dev/mmc/sdhci/sdmmc.fth
Log:
OLPC trac 9484 - NANDblaster is now working reasonably well in wired mode.


Modified: cpu/x86/pc/olpc/via/fw.bth
===================================================================
--- cpu/x86/pc/olpc/via/fw.bth	2010-01-25 08:34:05 UTC (rev 1696)
+++ cpu/x86/pc/olpc/via/fw.bth	2010-01-25 08:36:22 UTC (rev 1697)
@@ -500,6 +500,7 @@
 
 fload ${BP}/cpu/x86/pc/olpc/nandcastui.fth
 fload ${BP}/cpu/x86/pc/olpc/wifichannel.fth
+fload ${BP}/cpu/x86/pc/olpc/via/blockfifo.fth
 fload ${BP}/cpu/x86/pc/olpc/via/fsupdate.fth
 fload ${BP}/cpu/x86/pc/olpc/via/fsverify.fth
 devalias fsdisk int:0

Modified: dev/mmc/sdhci/sdhci.fth
===================================================================
--- dev/mmc/sdhci/sdhci.fth	2010-01-25 08:34:05 UTC (rev 1696)
+++ dev/mmc/sdhci/sdhci.fth	2010-01-25 08:36:22 UTC (rev 1697)
@@ -323,6 +323,27 @@
    ." Stopping" cr abort
 ;
 
+: isr-event?  ( mask -- happened? )
+   h# 8000 or                                     ( mask' )
+   isr@  2dup and  if                             ( mask' isr )
+      \ Only clear the bits we will handle this time.
+      \ If additional ISR bits are set, leave them set because
+      \ later code will be waiting for them.  In practice, the
+      \ only such additional bit is the "data transfer complete"
+      \ bit - mask 2 - which "2 wait" will handle.
+      \ But we do go ahead and clear card removal/insertion
+      \ events, because we don't handle them elsewhere.
+      swap  h# c0 or  over and  isr!              ( isr )
+
+      dup h# 8000 and  if   .sderror  else  drop  then   ( )
+      true
+   else                                           ( mask' isr )
+      \ DMA interrupt - the transfer crossed an address boundary
+      8 and  if  0 cl@ 0 cl!  8 isr!  then        ( mask )
+      drop false                                  ( false )
+   then
+;
+
 : wait  ( mask -- )
    h# 8000 or                                     ( mask' )
    begin                                          ( mask )
@@ -711,6 +732,28 @@
    drop
 ;
 
+: card-error?  ( status -- error? )
+   dup h# fdf9.8008 and  if                         ( status )
+      cr ." SD Error - status = " dup . cr
+      .card-error
+      true
+   else
+      drop
+      false
+   then
+;
+
+: write-done?  ( -- false | error? true )
+   intstat-on
+   get-status  dup  9 rshift h# f and  7  =  if  ( status )
+      drop false          ( false )
+   else                   ( status )
+      card-error?         ( error? )
+      true                ( error? true )
+   then                   ( false | error? true )
+   intstat-off            ( false | error? true )
+;
+
 \ This is the correct way to wait for programming complete.
 : wait-write-done  ( -- error? )
    writing? 0=  if  false exit  then               ( limit )
@@ -724,15 +767,7 @@
       then
    repeat                                           ( limit status )
    nip                                              ( status )
-   dup h# fdf9.8008 and  if                         ( status )
-      cr ." SD Error - status = " dup . cr
-      .card-error
-      true
-   else
-      drop
-      false
-   then
-
+   card-error?                                      ( error? )
    false to writing?
 ;
 
@@ -772,6 +807,18 @@
 
 0 instance value dma?
 
+: dma-done?  ( -- flag )
+   dma?  if
+      2 isr-event?  dup  if  ( flag )
+         dma-release         ( flag )
+         intstat-off         ( flag )
+         false to dma?       ( flag )
+      then                   ( flag )
+   else
+      true
+   then
+;
+
 : wait-dma-done  ( -- )
    dma?  if
       2 wait
@@ -865,6 +912,17 @@
 : detach-sdio-card  ( -- )
 ;
 
+\ Asynchronous poll for completion
+: r/w-blocks-end?  ( in? -- false | error? true )
+   drop
+   dma-done?  if
+      write-done?
+   else
+      false
+   then      
+;
+
+\ Wait for completion
 : r/w-blocks-end  ( in? -- error? )
    drop
    wait-dma-done

Modified: dev/mmc/sdhci/sdmmc.fth
===================================================================
--- dev/mmc/sdhci/sdmmc.fth	2010-01-25 08:34:05 UTC (rev 1696)
+++ dev/mmc/sdhci/sdmmc.fth	2010-01-25 08:36:22 UTC (rev 1697)
@@ -40,6 +40,9 @@
 : write-blocks-end  ( -- error? )
    false  " r/w-blocks-end" $call-parent
 ;
+: write-blocks-end?  ( -- false | error? true )
+   false  " r/w-blocks-end?" $call-parent
+;
 
 : dma-alloc   ( size -- vadr )  " dma-alloc"  $call-parent  ;
 : dma-free    ( vadr size -- )  " dma-free"   $call-parent  ;




More information about the openfirmware mailing list