Edward O'Callaghan has uploaded this change for review.

View Change

realtek_mst_i2c_spi.c: Fix wp gpio toggle

Allow for toggling the GPIO pin 108 that is routed to the
WP pin in the reference design. This need not always apply
however is largely harmless for a better out-of-the-box
experience.

BUG=b:152558985,b:148745673
BRANCH=none
TEST=builds && A double cycle of erase+write works.

Change-Id: I825df3179cdd16f7c7ecf556b5ca29bfe6394346
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M realtek_mst_i2c_spi.c
1 file changed, 8 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/25/41125/1
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 64458dd..6cb87fe 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -34,6 +34,7 @@
#define MCU_MODE 0x6F
#define ENTER_ISP_MODE 0x80
#define START_WRITE_XFER 0xA0
+#define BUF_XFER_STATUS_MASK 0x10
#define WRITE_XFER_STATUS_MASK 0x20

#define MCU_DATA_PORT 0x70
@@ -145,7 +146,7 @@
return ret;
}

-static int realtek_mst_i2c_spi_disable_protection(int fd)
+static int realtek_mst_i2c_spi_toggle_protection(int fd, int enable)
{
int ret = 0;
uint8_t val = 0;
@@ -164,8 +165,9 @@
ret |= realtek_mst_i2c_spi_write_register(fd, 0xF5, (val & 0xF8) | 0x01);

/* Set pin value to high, 0xFFD7[0] = 1. */
+ uint8_t en = enable ? 0x00 : 0x01;
ret |= realtek_mst_i2c_spi_read_register(fd, 0xD7, &val);
- ret |= realtek_mst_i2c_spi_write_register(fd, 0xD7, (val & 0xFE) | 0x01);
+ ret |= realtek_mst_i2c_spi_write_register(fd, 0xD7, (val & 0xFE) | en);

return ret;
}
@@ -331,7 +333,7 @@
if (fd < 0)
return SPI_GENERIC_ERROR;

- ret = realtek_mst_i2c_spi_disable_protection(fd);
+ ret = realtek_mst_i2c_spi_toggle_protection(fd, 0);
if (ret)
return ret;

@@ -349,7 +351,8 @@
break;

/* Wait for empty buffer. */
- ret |= realtek_mst_i2c_spi_wait_command_done(fd, MCU_MODE, 0x10, 0x10, 1);
+ ret |= realtek_mst_i2c_spi_wait_command_done(fd, MCU_MODE,
+ BUF_XFER_STATUS_MASK, 0x10, 1);
if (ret)
break;

@@ -362,8 +365,7 @@
break;
}

-
- /* TODO: re-enable the write protection? */
+ ret |= realtek_mst_i2c_spi_toggle_protection(fd, 1);

return ret;
}

To view, visit change 41125. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I825df3179cdd16f7c7ecf556b5ca29bfe6394346
Gerrit-Change-Number: 41125
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange