aboutsummaryrefslogtreecommitdiffstats
path: root/parade_lspcon.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-06-30 19:54:44 +1000
committerThomas Heijligen <src@posteo.de>2022-07-30 07:22:55 +0000
commitc59cf52e2aa389e4efbc81ef62cc5f7c5ea14286 (patch)
treee25cb11897f078af1469755940d9af8ce20344c4 /parade_lspcon.c
parentb8c16e042962d73cb5cd9ee5f7d9526ad8166f71 (diff)
downloadflashrom-c59cf52e2aa389e4efbc81ef62cc5f7c5ea14286.tar.gz
flashrom-c59cf52e2aa389e4efbc81ef62cc5f7c5ea14286.tar.bz2
flashrom-c59cf52e2aa389e4efbc81ef62cc5f7c5ea14286.zip
parade_lspcon.c: Add allow_brick=yes programmer param
Currently i2c programmers do not have a safe allow listing mechanism via board_enable to facilitate fully qualified chip detection. Since i2c addresses alone can overlap a user may make the mistake of using the wrong programmer. Although unlikely, it is within the realm of possibility that a user could accidently somehow program another chip on their board. Change-Id: I819f9a5e0f3102bec8d01dd52a0025a0fbe46970 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/65555 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'parade_lspcon.c')
-rw-r--r--parade_lspcon.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/parade_lspcon.c b/parade_lspcon.c
index ceb1f029..11c7bf3c 100644
--- a/parade_lspcon.c
+++ b/parade_lspcon.c
@@ -439,8 +439,45 @@ static const struct spi_master spi_master_parade_lspcon = {
.probe_opcode = default_spi_probe_opcode,
};
+static int get_params(bool *allow_brick)
+{
+ char *brick_str = NULL;
+ int ret = 0;
+
+ *allow_brick = false; /* Default behaviour is to bail. */
+ brick_str = extract_programmer_param_str("allow_brick");
+ if (brick_str) {
+ if (!strcmp(brick_str, "yes")) {
+ *allow_brick = true;
+ } else {
+ msg_perr("%s: Incorrect param format, allow_brick=yes.\n", __func__);
+ ret = SPI_GENERIC_ERROR;
+ }
+ }
+ free(brick_str);
+
+ return ret;
+}
+
static int parade_lspcon_init(void)
{
+ bool allow_brick;
+
+ if (get_params(&allow_brick))
+ return SPI_GENERIC_ERROR;
+
+ /*
+ * TODO: Once board_enable can facilitate safe i2c allow listing
+ * then this can be removed.
+ */
+ if (!allow_brick) {
+ msg_perr("%s: For i2c drivers you must explicitly 'allow_brick=yes'. ", __func__);
+ msg_perr("There is currently no way to determine if the programmer works on a board "
+ "as i2c device address space can be overloaded. Set 'allow_brick=yes' if "
+ "you are sure you know what you are doing.\n");
+ return SPI_GENERIC_ERROR;
+ }
+
int fd = i2c_open_from_programmer_params(REGISTER_ADDRESS, 0);
if (fd < 0)
return fd;