[flashrom] [PATCH] Fix another SB600 SPI corner case

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Mon Aug 10 02:56:21 CEST 2009


SB600 SPI has an off-by-one error during read, and that hardware issue
is not documented anywhere yet. r661 tried to work around this, but the
fix had unpleasant side effects. The new workaround only triggers if
readcnt is nonzero, eliminating all possible interactions with
write-only commands.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: flashrom-spi_sb600_offbyone_fixfix/sb600spi.c
===================================================================
--- flashrom-spi_sb600_offbyone_fixfix/sb600spi.c	(revision 672)
+++ flashrom-spi_sb600_offbyone_fixfix/sb600spi.c	(working copy)
@@ -118,9 +118,13 @@
 	 * an opcode and no additional data/address, the SPI controller will
 	 * read one byte too few from the chip. Basically, the last byte of
 	 * the chip response is discarded and will not end up in the FIFO.
-	 * It is unclear if the CS# line is set high too early as well.
+	 * It is unclear if the CS# line is set high too early as well, but
+	 * it seems CS# line timing matches the bytecounts we specify, so there
+	 * is a mismatch between FIFO content count and CS# timing.
+	 * Only trigger this if readcnt is nonzero on the assumption that
+	 * reading more doesn't hurt if we already read soemthing.
 	 */
-	readoffby1 = (writecnt) ? 0 : 1;
+	readoffby1 = (!writecnt && readcnt) ? 1 : 0;
 	mmio_writeb((readcnt + readoffby1) << 4 | (writecnt), sb600_spibar + 1);
 	mmio_writeb(cmd, sb600_spibar + 0);
 


-- 
http://www.hailfinger.org/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: flashrom_spi_sb600_offbyone_fixfix.diff
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20090810/34a15d17/attachment.diff>


More information about the flashrom mailing list