mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 07:23:43 +02:00
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>
This commit is contained in:
parent
0bc0ab932e
commit
30815fc370
@ -96,6 +96,7 @@ static void bitbang_spi_write_byte(const struct bitbang_spi_master *master, uint
|
|||||||
|
|
||||||
struct bitbang_spi_master_data {
|
struct bitbang_spi_master_data {
|
||||||
const struct bitbang_spi_master *master;
|
const struct bitbang_spi_master *master;
|
||||||
|
void *spi_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bitbang_spi_send_command(const struct flashctx *flash,
|
static int bitbang_spi_send_command(const struct flashctx *flash,
|
||||||
@ -146,7 +147,7 @@ static int bitbang_spi_shutdown(void *data)
|
|||||||
return 0;
|
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;
|
struct spi_master mst = spi_master_bitbang;
|
||||||
/* If someone forgot to initialize a bitbang function, we catch it here. */
|
/* 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));
|
struct bitbang_spi_master_data *data = calloc(1, sizeof(struct bitbang_spi_master_data));
|
||||||
data->master = master;
|
data->master = master;
|
||||||
|
if (spi_data)
|
||||||
|
data->spi_data = spi_data;
|
||||||
|
|
||||||
register_spi_master(&mst, data);
|
register_spi_master(&mst, data);
|
||||||
register_shutdown(bitbang_spi_shutdown, data);
|
register_shutdown(bitbang_spi_shutdown, data);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ int developerbox_spi_init(void)
|
|||||||
if (register_shutdown(developerbox_spi_shutdown, NULL))
|
if (register_shutdown(developerbox_spi_shutdown, NULL))
|
||||||
goto err_exit;
|
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;
|
goto err_exit;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -151,7 +151,7 @@ int mcp6x_spi_init(int want_spi)
|
|||||||
(status >> MCP6X_SPI_GRANT) & 0x1);
|
(status >> MCP6X_SPI_GRANT) & 0x1);
|
||||||
mcp_gpiostate = status & 0xff;
|
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. */
|
/* This should never happen. */
|
||||||
msg_perr("MCP6X bitbang SPI master init failed!\n");
|
msg_perr("MCP6X bitbang SPI master init failed!\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -273,7 +273,7 @@ int nicintel_spi_init(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (register_spi_bitbang_master(&bitbang_spi_master_nicintel))
|
if (register_spi_bitbang_master(&bitbang_spi_master_nicintel, NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -135,7 +135,7 @@ int ogp_spi_init(void)
|
|||||||
if (ogp_spibar == ERROR_PTR)
|
if (ogp_spibar == ERROR_PTR)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (register_spi_bitbang_master(&bitbang_spi_master_ogp))
|
if (register_spi_bitbang_master(&bitbang_spi_master_ogp, NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -224,7 +224,7 @@ int pony_spi_init(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (register_spi_bitbang_master(&bitbang_spi_master_pony)) {
|
if (register_spi_bitbang_master(&bitbang_spi_master_pony, NULL)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -542,7 +542,7 @@ int pony_spi_init(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bitbang_spi.c */
|
/* 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 */
|
/* buspirate_spi.c */
|
||||||
#if CONFIG_BUSPIRATE_SPI == 1
|
#if CONFIG_BUSPIRATE_SPI == 1
|
||||||
|
@ -265,7 +265,7 @@ int rayer_spi_init(void)
|
|||||||
if (pinout->preinit)
|
if (pinout->preinit)
|
||||||
pinout->preinit(pinout);
|
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 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user