[coreboot] [PATCH] flashrom: Handle WREN and EWSR failure gracefully on ICH/VIA SPI

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Thu May 14 03:04:10 CEST 2009


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>

Index: flashrom-spi_wren_ewsr_error_checking_ichspi_workaround/spi.c
===================================================================
--- flashrom-spi_wren_ewsr_error_checking_ichspi_workaround/spi.c	(Revision 505)
+++ flashrom-spi_wren_ewsr_error_checking_ichspi_workaround/spi.c	(Arbeitskopie)
@@ -116,8 +116,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:
@@ -126,9 +128,12 @@
 				     " and hoping it will be run as PREOP\n");
 			return 0;
 		default:
-			printf_debug("\n");
+			break;
 		}
 	}
+	if (result)
+		printf_debug("\n");
+
 	return result;
 }
 
@@ -555,9 +560,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;
 }
 
 /*


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

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flashrom_spi_wren_ewsr_error_checking_ichspi_workaround.diff
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090514/2ff02584/attachment.ksh>


More information about the coreboot mailing list