Edward O'Callaghan has uploaded this change for review.

View Change

realtek_mst_i2c_spi.c: Introduce MCU reset param

Modify the spi master as to not automatically reset the
MCU unless explicitly stated by a param.

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

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/74/45674/1
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 6158524..6ac57d5 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,14 +393,15 @@
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 (data->reset)
+ ret |= realtek_mst_i2c_spi_reset_mpu(fd);
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;
int ret = SPI_GENERIC_ERROR;
@@ -431,6 +433,12 @@
} else {
msg_perr("%s: Bus number not specified.\n", __func__);
}
+
+ reset_str = extract_programmer_param("reset-mcu");
+ if (reset_str && reset_str[0] == '1')
+ reset = 1;
+ free(reset_str);
+
get_params_done:
if (bus_str)
free(bus_str);
@@ -441,9 +449,9 @@
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);
@@ -451,7 +459,8 @@
return fd;

/* Ensure we are in a known state before entering ISP mode */
- ret |= realtek_mst_i2c_spi_reset_mpu(fd);
+ if (reset)
+ ret |= realtek_mst_i2c_spi_reset_mpu(fd);
if (ret)
return ret;

@@ -466,6 +475,7 @@
}

data->fd = fd;
+ data->reset = reset;
ret |= register_shutdown(realtek_mst_i2c_spi_shutdown, data);

spi_master_i2c_realtek_mst.data = data;

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

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