[coreboot] [flashrom] r514 - trunk

svn at coreboot.org svn at coreboot.org
Fri May 15 02:56:22 CEST 2009


Author: hailfinger
Date: 2009-05-15 02:56:22 +0200 (Fri, 15 May 2009)
New Revision: 514

Modified:
   trunk/spi.c
Log:
Until the ICH SPI driver can handle preopcodes as standalone opcodes, we
should handle such special opcode failure gracefully on ICH and
compatible chipsets.

This fixes status register writes on almost all ICH+VIA SPI masters.

The fix is almost identical to r484, but this time it affects the EWSR
(Enable Write Status Register) opcode instead of the WREN (Write Enable)
opcode.

With the differentiated return codes introduced in r500, the workaround
is more precise this time. The old WREN workaround was updated as well.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Acked-by: FENG Yu Ning <fengyuning1984 at gmail.com>
Acked-by: Cristi Magherusan <cristi.magherusan at net.utcluj.ro>


Modified: trunk/spi.c
===================================================================
--- trunk/spi.c	2009-05-14 22:58:21 UTC (rev 513)
+++ trunk/spi.c	2009-05-15 00:56:22 UTC (rev 514)
@@ -121,8 +121,10 @@
 
 	/* Send WREN (Write Enable) */
 	result = spi_command(sizeof(cmd), 0, cmd, NULL);
-	if (result) {
-		printf_debug("spi_write_enable failed");
+
+	if (result)
+		printf_debug("%s failed", __func__);
+	if (result == SPI_INVALID_OPCODE) {
 		switch (flashbus) {
 		case BUS_TYPE_ICH7_SPI:
 		case BUS_TYPE_ICH9_SPI:
@@ -131,9 +133,12 @@
 				     " and hoping it will be run as PREOP\n");
 			return 0;
 		default:
-			printf_debug("\n");
+			break;
 		}
 	}
+	if (result)
+		printf_debug("\n");
+
 	return result;
 }
 
@@ -561,9 +566,29 @@
 int spi_write_status_enable(void)
 {
 	const unsigned char cmd[JEDEC_EWSR_OUTSIZE] = { JEDEC_EWSR };
+	int result;
 
 	/* Send EWSR (Enable Write Status Register). */
-	return spi_command(JEDEC_EWSR_OUTSIZE, JEDEC_EWSR_INSIZE, cmd, NULL);
+	result = spi_command(sizeof(cmd), JEDEC_EWSR_INSIZE, cmd, NULL);
+
+	if (result)
+		printf_debug("%s failed", __func__);
+	if (result == SPI_INVALID_OPCODE) {
+		switch (flashbus) {
+		case BUS_TYPE_ICH7_SPI:
+		case BUS_TYPE_ICH9_SPI:
+		case BUS_TYPE_VIA_SPI:
+			printf_debug(" due to SPI master limitation, ignoring"
+				     " and hoping it will be run as PREOP\n");
+			return 0;
+		default:
+			break;
+		}
+	}
+	if (result)
+		printf_debug("\n");
+
+	return result;
 }
 
 /*





More information about the coreboot mailing list