1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

Use struct pointer instead of enum to set bitbang adapter

Corresponding to flashrom svn r1091.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Michael Karcher
2010-07-17 23:27:47 +00:00
parent f7533420b4
commit 62175a094d
3 changed files with 12 additions and 28 deletions

View File

@ -29,45 +29,34 @@
/* Length of half a clock period in usecs. */
static int bitbang_spi_half_period;
static enum bitbang_spi_master bitbang_spi_master = BITBANG_SPI_INVALID;
static const struct bitbang_spi_master_entry bitbang_spi_master_table[] = {
{}, /* This entry corresponds to BITBANG_SPI_INVALID. */
};
const int bitbang_spi_master_count = ARRAY_SIZE(bitbang_spi_master_table);
static const struct bitbang_spi_master *bitbang_spi_master = NULL;
/* Note that CS# is active low, so val=0 means the chip is active. */
static void bitbang_spi_set_cs(int val)
{
bitbang_spi_master_table[bitbang_spi_master].set_cs(val);
bitbang_spi_master->set_cs(val);
}
static void bitbang_spi_set_sck(int val)
{
bitbang_spi_master_table[bitbang_spi_master].set_sck(val);
bitbang_spi_master->set_sck(val);
}
static void bitbang_spi_set_mosi(int val)
{
bitbang_spi_master_table[bitbang_spi_master].set_mosi(val);
bitbang_spi_master->set_mosi(val);
}
static int bitbang_spi_get_miso(void)
{
return bitbang_spi_master_table[bitbang_spi_master].get_miso();
return bitbang_spi_master->get_miso();
}
int bitbang_spi_init(enum bitbang_spi_master master, int halfperiod)
int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod)
{
bitbang_spi_master = master;
bitbang_spi_half_period = halfperiod;
if (bitbang_spi_master == BITBANG_SPI_INVALID) {
msg_perr("Invalid bitbang SPI master. \n"
"Please report a bug at flashrom@flashrom.org\n");
return 1;
}
bitbang_spi_set_cs(1);
bitbang_spi_set_sck(0);
bitbang_spi_set_mosi(0);