summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShiyu Sun <sshiyu@google.com>2021-01-21 16:08:11 +1100
committerPatrick Georgi <pgeorgi@google.com>2021-02-12 13:14:54 +0000
commit6cad608483924cd9c0c0c201ae69ee7e513a0f9e (patch)
treea9d4bc2da94e341b963c7766d1f2b1d67e91abc3
parent32aa933b1da48b0730dd79fbb15d864643391072 (diff)
downloadflashrom-6cad608483924cd9c0c0c201ae69ee7e513a0f9e.tar.gz
flashrom-6cad608483924cd9c0c0c201ae69ee7e513a0f9e.tar.bz2
flashrom-6cad608483924cd9c0c0c201ae69ee7e513a0f9e.zip
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>
-rw-r--r--realtek_mst_i2c_spi.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 1bbb71f42..ae79fdd3b 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -375,10 +375,6 @@ static int realtek_mst_i2c_spi_write_256(struct flashctx *flash, const uint8_t *
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 @@ static int realtek_mst_i2c_spi_write_256(struct flashctx *flash, const uint8_t *
break;
}
- ret |= realtek_mst_i2c_spi_toggle_gpio_88_strap(fd, false);
-
return ret;
}
@@ -432,6 +426,7 @@ static int realtek_mst_i2c_spi_shutdown(void *data)
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 @@ int realtek_mst_i2c_spi_init(void)
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");