Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/40772 )
Change subject: realtek_mst_i2c_spi.c: Add bootloader slot param ......................................................................
realtek_mst_i2c_spi.c: Add bootloader slot param
Add spi_master parameter that allows the user to specify which firmware paritition slot to select in the bootloader upon flashing a new image.
BUG=b:155051790 BRANCH=none TEST=builds
Change-Id: I1fa6b30ea67e7feb0651dd4b4dc3d5c308fc83c8 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M realtek_mst_i2c_spi.c 1 file changed, 23 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/72/40772/1
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 6f7dd70..03c0893 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -38,6 +38,7 @@
struct realtek_mst_i2c_spi_data { int fd; + int slot; /* 0: slot A, 1: slot B, -1: undefined slot */ };
static int realtek_mst_i2c_spi_write_data(int fd, uint16_t addr, void *buf, uint16_t len) @@ -355,9 +356,9 @@ return ret; }
-static int get_params(int *i2c_bus) +static int get_params(int *i2c_bus, int *slot) { - char *bus_str = NULL; + char *bus_str = NULL, *slot_str = NULL; int ret = SPI_GENERIC_ERROR;
bus_str = extract_programmer_param("bus"); @@ -387,9 +388,26 @@ } else { msg_perr("%s: Bus number not specified.\n", __func__); } + + slot_str = extract_programmer_param("slot"); + if (slot_str) { + msg_pinfo("Using bootloader slot %s.\n", slot_str); + switch (slot_str[0]) { + case 'A': *slot = 0; break; + case 'B': *slot = 1; break; + default: + msg_perr("%s: Invalid slot specified.\n", __func__); + *slot = -1; + } + ret = 0; + goto get_params_done; + } + get_params_done: if (bus_str) free(bus_str); + if (slot_str) + free(slot_str);
return ret; } @@ -397,9 +415,9 @@ int realtek_mst_i2c_spi_init(void) { int ret = 0; - int i2c_bus = 0; + int i2c_bus = 0, bl_slot = 0;
- if (get_params(&i2c_bus)) + if (get_params(&i2c_bus, &bl_slot)) return SPI_GENERIC_ERROR;
int fd = i2c_open(i2c_bus, REGISTER_ADDRESS, 0); @@ -428,6 +446,7 @@ }
data->fd = fd; + data->slot = bl_slot; ret |= register_shutdown(realtek_mst_i2c_spi_shutdown, data);
spi_master_i2c_realtek_mst.data = data;