Changeset 2990


Ignore:
Timestamp:
May 31, 2012, 7:28:43 AM (3 years ago)
Author:
wmb
Message:

SDHCI - OLPC trac #11844 - fixed SD card detection on XO-1. The chipset's SDHCI controller requires you to turn on some enable bits before the card insertion bits become visible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dev/mmc/sdhci/sdhci.fth

    r2192 r2990  
    8989\ : led-off  ( -- )  h# 28 cb@  1 invert and  h# 28 cb!  ; 
    9090 
     91\ We leave the remove and insert interrupt enables on because the 
     92\ hardware has a bug that blocks the card detection status bits 
     93\ unless the interrupt enables are on. 
     940 instance value intstat-count 
     95: intstat-on  ( -- ) 
     96   intstat-count 0=  if 
     97      h# 00cb h# 34 cw!  \ normal interrupt status en reg 
     98      \ Enable: Remove, Insert, DMA Interrupt, Transfer Complete, CMD Complete 
     99      \ Disable: Card Interrupt, Read Ready, Write Ready, Block Gap 
     100      h# f1ff h# 36 cw!  \ error interrupt status en reg 
     101   then 
     102   intstat-count 1+ to intstat-count 
     103; 
     104: intstat-off  ( -- ) 
     105   intstat-count 1- 0 max to intstat-count 
     106   intstat-count 0=  if 
     107      h# c0 h# 34 cl!     \ Remove, Insert on, others off 
     108   then 
     109; 
     110 
    91111\ There is no need to use the debounced version (the 3.0000 bits). 
    92112\ We poll for the card when the SDMMC driver opens, rather than 
     
    96116defer card-inserted? 
    97117: sdhci-card-inserted?  ( -- flag ) 
     118   intstat-on 
    98119   get-msecs d# 500 +   begin            ( time-limit ) 
    99120      \ When the stable bit is set, we can believe the answer 
     
    101122         drop                            ( ) 
    102123         present-state@ h# 10000 and 0<> ( flag ) 
     124         intstat-off                     ( flag ) 
    103125         exit                            ( -- flag ) 
    104126      then                               ( time-limit ) 
     
    108130   ." SD Card detect unstable!" cr       ( ) 
    109131   false                                 ( flag ) 
     132   intstat-off                           ( flag ) 
    110133; 
    111134' sdhci-card-inserted? to card-inserted? 
     
    170193 
    171194: data-timeout!  ( n -- )  h# 2e cb!  ; 
    172  
    173 \ We leave the remove and insert interrupt enables on because the 
    174 \ hardware has a bug that blocks the card detection status bits 
    175 \ unless the interrupt enables are on. 
    176 : intstat-on  ( -- ) 
    177    h# 00cb h# 34 cw!  \ normal interrupt status en reg 
    178             \ Enable: Remove, Insert, DMA Interrupt, Transfer Complete, CMD Complete 
    179             \ Disable: Card Interrupt, Read Ready, Write Ready, Block Gap 
    180    h# f1ff h# 36 cw!  \ error interrupt status en reg 
    181 ; 
    182 : intstat-off  ( -- )  h# c0 h# 34 cl!  ;  \ Remove, Insert on, others off 
    183195 
    184196: setup-host  ( -- ) 
Note: See TracChangeset for help on using the changeset viewer.