diff options
author | Edward O'Callaghan <quasisec@google.com> | 2020-09-24 15:50:21 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2020-10-02 01:02:04 +0000 |
commit | 3ba19b3148ebbf25d759bc3684bb936ff88270fb (patch) | |
tree | f57355129334e6fae6ac787e9092b6d2e6a43cb4 | |
parent | 3a49adadce560cabd0df2f4e36b17e3c2bdf61bc (diff) | |
download | flashrom-3ba19b3148ebbf25d759bc3684bb936ff88270fb.tar.gz flashrom-3ba19b3148ebbf25d759bc3684bb936ff88270fb.tar.bz2 flashrom-3ba19b3148ebbf25d759bc3684bb936ff88270fb.zip |
realtek_mst_i2c_spi.c: Introduce MCU reset param
Modify the spi master as to not automatically reset the
MCU on tear-down unless explicitly stated by a param.
Change-Id: Ib70bf7399e7541f30b6905cdb950a6fb7b74ae18
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/45674
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r-- | realtek_mst_i2c_spi.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 78675289..e975290c 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -49,6 +49,7 @@ struct realtek_mst_i2c_spi_data { int fd; + int reset; }; static int realtek_mst_i2c_spi_write_data(int fd, uint16_t addr, void *buf, uint16_t len) @@ -392,16 +393,20 @@ 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_reset_mpu(fd); + if (realtek_mst_data->reset) { + ret |= realtek_mst_i2c_spi_reset_mpu(fd); + if (ret != 0) + msg_perr("%s: MCU failed to reset on tear-down.\n", __func__); + } i2c_close(fd); free(data); return ret; } -static int get_params(int *i2c_bus) +static int get_params(int *i2c_bus, int *reset) { - char *bus_str = NULL; + char *bus_str = NULL, *reset_str = NULL; int ret = SPI_GENERIC_ERROR; bus_str = extract_programmer_param("bus"); @@ -431,6 +436,21 @@ static int get_params(int *i2c_bus) } else { msg_perr("%s: Bus number not specified.\n", __func__); } + + reset_str = extract_programmer_param("reset-mcu"); + if (reset_str) { + if (reset_str[0] == '1') + *reset = 1; + else if (reset_str[0] == '0') + *reset = 0; + else { + msg_perr("%s: Incorrect param format, reset-mcu=1 or 0.\n", __func__); + ret = SPI_GENERIC_ERROR; + } + } else + *reset = 0; /* Default behaviour is no MCU reset on tear-down. */ + free(reset_str); + get_params_done: if (bus_str) free(bus_str); @@ -441,9 +461,9 @@ get_params_done: int realtek_mst_i2c_spi_init(void) { int ret = 0; - int i2c_bus = 0; + int i2c_bus = 0, reset = 0; - if (get_params(&i2c_bus)) + if (get_params(&i2c_bus, &reset)) return SPI_GENERIC_ERROR; int fd = i2c_open(i2c_bus, REGISTER_ADDRESS, 0); @@ -461,6 +481,7 @@ int realtek_mst_i2c_spi_init(void) } data->fd = fd; + data->reset = reset; ret |= register_shutdown(realtek_mst_i2c_spi_shutdown, data); spi_master_i2c_realtek_mst.data = data; |