Author: wmb Date: Thu Jul 14 14:54:21 2011 New Revision: 2367 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2367
Log: OLPC XO-1.75 - avoid EC command timeouts in the EC-SPI protocol by draining the FIFO if the EC has timed out and sent extra packets, acking only when the FIFO is empty.
Modified: dev/olpc/kb3700/spicmd.fth
Modified: dev/olpc/kb3700/spicmd.fth ============================================================================== --- dev/olpc/kb3700/spicmd.fth Thu Jul 14 10:01:12 2011 (r2366) +++ dev/olpc/kb3700/spicmd.fth Thu Jul 14 14:54:21 2011 (r2367) @@ -261,16 +261,22 @@ ['] switched to do-state ( ) pulse-ack ; +: ?do-ack ( -- ) + \ If there is more data in the FIFO, it means that the EC + \ timed out and "inferred" an ACK, so we don't ACK until + \ the FIFO is empty. + ssp-ready? 0= if prime-fifo pulse-ack then +; : (upstream) ( -- ) ssp-ssdr rl@ ssp-ssdr rl@ ( channel# data ) debug? if ." UP: " over . dup . cr then over case ( channel# data ) - 0 of 2drop prime-fifo pulse-ack endof ( channel# data ) \ Invalid + 0 of 2drop ?do-ack endof ( channel# data ) \ Invalid 1 of 2drop handoff-command endof ( channel# data ) \ Switched ( default ) ( channel# data channel# ) - enque prime-fifo pulse-ack ( channel# ) + enque ?do-ack ( channel# ) endcase ; ' (upstream) to upstream @@ -331,6 +337,9 @@ open-count 1- 0 max to open-count ;
+: drain ( -- ) + begin ssp-ready? while poll repeat +; : data-command ( databuf datalen datain? cmdadr cmdlen more? -- ) to sticky? to cmdlen to cmdbuf to datain? to datalen to databuf @@ -338,6 +347,7 @@
set-cmd-timeout ['] do-state behavior ['] upstream = if + drain set-cmd else handoff-command
openfirmware@openfirmware.info