Changeset 3206
- Timestamp:
- Aug 20, 2012 11:53:06 PM (10 months ago)
- File:
-
- 1 edited
-
dev/mmc/sdhci/sdhci.fth (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dev/mmc/sdhci/sdhci.fth
r3164 r3206 93 93 \ unless the interrupt enables are on. 94 94 0 instance value intstat-count 95 : xfer-int-on ( -- ) h# 34 cw@ 2 or h# 34 cw! ; 96 : xfer-int-off ( -- ) h# 34 cw@ 2 invert and h# 34 cw! ; 97 95 98 : intstat-on ( -- ) 96 99 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 100 \ Enable: Remove, Insert, DMA Interrupt, CMD Complete 101 \ Transfer complete is handled separately because some host controllers 102 \ (e.g. Marvell MMP3) set it spuriously during commands that shouldn't set it. 103 h# 00c9 h# 34 cw! \ normal interrupt status en reg 104 99 105 \ Disable: Card Interrupt, Read Ready, Write Ready, Block Gap 100 106 h# f1ff h# 36 cw! \ error interrupt status en reg … … 219 225 dup to dma-padr ( padr ) \ Remember for later 220 226 0 cl! \ Set address 227 xfer-int-on 221 228 ; 222 229 … … 375 382 : cmd ( arg cmd mode -- ) 376 383 debug? if ." CMD: " over 4 u.r space then 384 385 \ R1B-class commands have an implied data transfer phase 386 over h# ff and h# 1b = if xfer-int-on then 387 377 388 over add-cmd 378 389 wait-ready … … 452 463 h# 061b 0 cmd response h# 80 and if ." MMC SWITCH_ERROR" cr then 453 464 2 wait \ This command appears to have a transfer-complete 465 xfer-int-off 454 466 ; 455 467 … … 462 474 d# 16 ms \ Give the operation time to complete 463 475 isr@ isr! 476 xfer-int-off 464 477 ; 465 478 … … 1064 1077 ; 1065 1078 1066 : wait-dat ( -- ) d# 10 ms begin 2 ms present-state@ 4 and 0= until ;1067 1068 1079 \ Wait for completion 1069 1080 : r/w-blocks-end ( in? -- error? ) 1070 1081 drop 1071 wait-dat1072 1082 wait-dma-done 1073 1083 intstat-on wait-write-done intstat-off … … 1081 1091 : r/w-blocks-start ( addr block# #blocks in? fresh? -- error? ) 1082 1092 wait-dma-done ( addr block# #blocks fresh? in? ) 1093 1094 \ wait-write-done used to be after dma-setup in an attempt to overlap 1095 \ work with waiting time, but that doesn't work now that dma-setup 1096 \ enables transfer interrupts, which can happen spuriously during 1097 \ wait-write-done on some host controllers. 1098 wait-write-done if 3drop 2drop true exit then ( addr block# #blocks fresh? in? ) 1099 1083 1100 2 pick 0= if 3drop 2drop false exit then \ Prevents hangs 1084 1101 intstat-on ( addr block# #blocks fresh? in? ) 1085 1102 2 pick >r >r >r ( addr block# #blocks r: #blocks fresh? in? ) 1086 1103 rot dma-setup ( block# r: #blocks fresh? in? ) 1087 wait-write-done if drop r> r> r> 3drop true exit then ( block# ) 1104 1088 1105 address-shift lshift r> if ( block# r: #blocks fresh? ) 1089 1106 r> drop ( block# r: #blocks ) … … 1098 1115 ; 1099 1116 : fresh-write-blocks-start ( addr block# #blocks -- error? ) 1100 intstat-on1101 wait-dat1102 1117 false true r/w-blocks-start 1103 1118 ;
Note: See TracChangeset
for help on using the changeset viewer.
