The current ICH SPI preop handling is a hack which spews lots of warnings, but still yields correct results. With the multicommand infrastructure I introduced in r645, it became possible to integrate ICH SPI preopcodes cleanly into the flashrom design.
The new code checks for every opcode in a multicommand array if it is a preopcode. If yes, it checks if the next opcode is associated with that preopcode and in that case it simply runs the opcode because the correct preopcode will be run automatically before the opcode.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-ich9_multicommand_preop/ichspi.c =================================================================== --- flashrom-ich9_multicommand_preop/ichspi.c (Revision 725) +++ flashrom-ich9_multicommand_preop/ichspi.c (Arbeitskopie) @@ -745,18 +745,25 @@ int ich_spi_send_multicommand(struct spi_command *spicommands) { int ret = 0; + int oppos, preoppos; while ((spicommands->writecnt || spicommands->readcnt) && !ret) { + /* Will the next loop iteration be taken? */ + if ((spicommands + 1)->writecnt || (spicommands + 1)->readcnt) { + preoppos = find_preop(curopcodes, spicommands->writearr[0]); + oppos = find_opcode(curopcodes, (spicommands + 1)->writearr[0]); + /* Is the current op a preop for the next op? */ + if ((oppos != -1) && (preoppos != -1) && + (curopcodes->opcode[oppos].atomic == preoppos)) { + printf_debug("opcode 0x%02x will be run as PREOP\n", + spicommands->writearr[0]); + ret = 0; + spicommands++; + continue; + } + } + 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;