Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved
realtek_mst_i2c_spi.c: Move gpio 88 toggle outside write function

Gpio 88 toggle is used as write protection disable/enable now
and we need that to happen at the initialization of programmer.

Background:
The RTD devices has an interesting implementation where the
flag we need to flash is `aa aa aa ff ff`. However, after reset,
the boot firmware of RTD device will overwrite this flag value to
`aa aa aa ff aa`. Given this evidence, the root cause would be
that the boot firmware is doing something with protection enable
by itself. This explains why the message
'Block protection cannot be disabled' is shown since the block
protection is called before write operation.

BUG=b:147402710,b:152558985,b:178766553
BRANCH=none
TEST=flashrom -p realtek_mst_i2c_spi:bus=x,reset-mcu=1,enter-isp=1 -w
image.bin

Signed-off-by: Shiyu Sun <sshiyu@chromium.org>
Change-Id: I237bf9f8aa0fcbb904e7f0c09c74fd179e8c70c1
Reviewed-on: https://review.coreboot.org/c/flashrom/+/49785
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M realtek_mst_i2c_spi.c
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 1bbb71f..ae79fdd 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -375,10 +375,6 @@
if (fd < 0)
return SPI_GENERIC_ERROR;

- ret = realtek_mst_i2c_spi_toggle_gpio_88_strap(fd, true);
- if (ret)
- return ret;
-
ret |= realtek_mst_i2c_spi_write_register(fd, 0x6D, 0x02); /* write opcode */
ret |= realtek_mst_i2c_spi_write_register(fd, 0x71, (PAGE_SIZE - 1)); /* fit len=256 */

@@ -404,8 +400,6 @@
break;
}

- ret |= realtek_mst_i2c_spi_toggle_gpio_88_strap(fd, false);
-
return ret;
}

@@ -432,6 +426,7 @@
struct realtek_mst_i2c_spi_data *realtek_mst_data =
(struct realtek_mst_i2c_spi_data *)data;
int fd = realtek_mst_data->fd;
+ ret |= realtek_mst_i2c_spi_toggle_gpio_88_strap(fd, false);
if (realtek_mst_data->reset) {
/*
* Return value for reset mpu is not checked since
@@ -532,6 +527,12 @@
return ret;
}

+ ret |= realtek_mst_i2c_spi_toggle_gpio_88_strap(fd, true);
+ if (ret) {
+ msg_perr("Unable to toggle gpio 88 strap to True.\n");
+ return ret;
+ }
+
struct realtek_mst_i2c_spi_data *data = calloc(1, sizeof(struct realtek_mst_i2c_spi_data));
if (!data) {
msg_perr("Unable to allocate space for extra SPI master data.\n");

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I237bf9f8aa0fcbb904e7f0c09c74fd179e8c70c1
Gerrit-Change-Number: 49785
Gerrit-PatchSet: 5
Gerrit-Owner: Shiyu Sun <sshiyu@google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-CC: Sam McNally <sammc@google.com>
Gerrit-MessageType: merged