From 02487aa4edfc832b27afcd850cbfbe499fa09c35 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 22 Jul 2009 15:36:50 +0000 Subject: Replace most of the switch cases in the spi code with lookup on a struct instead This brings the SPI code in line with the generic programmer infrastructure. This patch is a reworked version of a patch by Jakob Bornecrantz. Corresponding to flashrom svn r657. Signed-off-by: Carl-Daniel Hailfinger Signed-off-by: Jakob Bornecrantz Acked-by: Stefan Reinauer Acked-by: Jakob Bornecrantz Acked-by: Carl-Daniel Hailfinger --- ichspi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ichspi.c') diff --git a/ichspi.c b/ichspi.c index 73dc249..5d2e40f 100644 --- a/ichspi.c +++ b/ichspi.c @@ -742,3 +742,23 @@ int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, return result; } + +int ich_spi_send_multicommand(struct spi_command *spicommands) +{ + int ret = 0; + while ((spicommands->writecnt || spicommands->readcnt) && !ret) { + ret = ich_spi_send_command(spicommands->writecnt, spicommands->readcnt, + spicommands->writearr, spicommands->readarr); + /* This awful hack needs to be smarter. + */ + if ((ret == SPI_INVALID_OPCODE) && + ((spicommands->writearr[0] == JEDEC_WREN) || + (spicommands->writearr[0] == JEDEC_EWSR))) { + printf_debug(" due to SPI master limitation, ignoring" + " and hoping it will be run as PREOP\n"); + ret = 0; + } + spicommands++; + } + return ret; +} -- cgit v1.1