summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2021-05-31 11:20:01 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2021-06-03 05:19:24 +0000
commit30815fc3706194117c633393d1ed65941a5afafd (patch)
tree0057efa0d621d30e4b511a15cbaafc8d65c2da5f
parent0bc0ab932eea6c8a60e90f9abe41c79758d2b8cb (diff)
downloadflashrom-30815fc3706194117c633393d1ed65941a5afafd.tar.gz
flashrom-30815fc3706194117c633393d1ed65941a5afafd.tar.bz2
flashrom-30815fc3706194117c633393d1ed65941a5afafd.zip
bitbang: Extend register_spi_bitbang_master() API with spi data
This allows the users of register_spi_bitbang_master() API to pass their spi data into the API, and then the data can go further, into register_spi_master() API. BUG=b:185191942 TEST=builds Change-Id: I13e83ae74dbc3a3e79c84d1463683d360ff47bc0 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/54990 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--bitbang_spi.c6
-rw-r--r--developerbox_spi.c2
-rw-r--r--mcp6x_spi.c2
-rw-r--r--nicintel_spi.c2
-rw-r--r--ogp_spi.c2
-rw-r--r--pony_spi.c2
-rw-r--r--programmer.h2
-rw-r--r--rayer_spi.c2
8 files changed, 12 insertions, 8 deletions
diff --git a/bitbang_spi.c b/bitbang_spi.c
index e70d883e9..e595b16f9 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -96,6 +96,7 @@ static void bitbang_spi_write_byte(const struct bitbang_spi_master *master, uint
struct bitbang_spi_master_data {
const struct bitbang_spi_master *master;
+ void *spi_data;
};
static int bitbang_spi_send_command(const struct flashctx *flash,
@@ -146,7 +147,7 @@ static int bitbang_spi_shutdown(void *data)
return 0;
}
-int register_spi_bitbang_master(const struct bitbang_spi_master *master)
+int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data)
{
struct spi_master mst = spi_master_bitbang;
/* If someone forgot to initialize a bitbang function, we catch it here. */
@@ -161,6 +162,9 @@ int register_spi_bitbang_master(const struct bitbang_spi_master *master)
struct bitbang_spi_master_data *data = calloc(1, sizeof(struct bitbang_spi_master_data));
data->master = master;
+ if (spi_data)
+ data->spi_data = spi_data;
+
register_spi_master(&mst, data);
register_shutdown(bitbang_spi_shutdown, data);
diff --git a/developerbox_spi.c b/developerbox_spi.c
index 4ff2fb609..4ccfaaaf2 100644
--- a/developerbox_spi.c
+++ b/developerbox_spi.c
@@ -158,7 +158,7 @@ int developerbox_spi_init(void)
if (register_shutdown(developerbox_spi_shutdown, NULL))
goto err_exit;
- if (register_spi_bitbang_master(&bitbang_spi_master_cp210x))
+ if (register_spi_bitbang_master(&bitbang_spi_master_cp210x, NULL))
goto err_exit;
return 0;
diff --git a/mcp6x_spi.c b/mcp6x_spi.c
index b53d07bd4..543142bba 100644
--- a/mcp6x_spi.c
+++ b/mcp6x_spi.c
@@ -151,7 +151,7 @@ int mcp6x_spi_init(int want_spi)
(status >> MCP6X_SPI_GRANT) & 0x1);
mcp_gpiostate = status & 0xff;
- if (register_spi_bitbang_master(&bitbang_spi_master_mcp6x)) {
+ if (register_spi_bitbang_master(&bitbang_spi_master_mcp6x, NULL)) {
/* This should never happen. */
msg_perr("MCP6X bitbang SPI master init failed!\n");
return 1;
diff --git a/nicintel_spi.c b/nicintel_spi.c
index 1173ef772..03df8efcd 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -273,7 +273,7 @@ int nicintel_spi_init(void)
return 1;
}
- if (register_spi_bitbang_master(&bitbang_spi_master_nicintel))
+ if (register_spi_bitbang_master(&bitbang_spi_master_nicintel, NULL))
return 1;
return 0;
diff --git a/ogp_spi.c b/ogp_spi.c
index e603edb8b..7a228090a 100644
--- a/ogp_spi.c
+++ b/ogp_spi.c
@@ -135,7 +135,7 @@ int ogp_spi_init(void)
if (ogp_spibar == ERROR_PTR)
return 1;
- if (register_spi_bitbang_master(&bitbang_spi_master_ogp))
+ if (register_spi_bitbang_master(&bitbang_spi_master_ogp, NULL))
return 1;
return 0;
diff --git a/pony_spi.c b/pony_spi.c
index ed9d326c5..9e00b0307 100644
--- a/pony_spi.c
+++ b/pony_spi.c
@@ -224,7 +224,7 @@ int pony_spi_init(void)
return 1;
}
- if (register_spi_bitbang_master(&bitbang_spi_master_pony)) {
+ if (register_spi_bitbang_master(&bitbang_spi_master_pony, NULL)) {
return 1;
}
return 0;
diff --git a/programmer.h b/programmer.h
index 790fcc844..1874612dd 100644
--- a/programmer.h
+++ b/programmer.h
@@ -542,7 +542,7 @@ int pony_spi_init(void);
#endif
/* bitbang_spi.c */
-int register_spi_bitbang_master(const struct bitbang_spi_master *master);
+int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data);
/* buspirate_spi.c */
#if CONFIG_BUSPIRATE_SPI == 1
diff --git a/rayer_spi.c b/rayer_spi.c
index cde008f7c..7b518c9e7 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -265,7 +265,7 @@ int rayer_spi_init(void)
if (pinout->preinit)
pinout->preinit(pinout);
- if (register_spi_bitbang_master(&bitbang_spi_master_rayer))
+ if (register_spi_bitbang_master(&bitbang_spi_master_rayer, NULL))
return 1;
return 0;