1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-06-30 21:52:36 +02:00

tree/: Move programmer_delay() out of programmer state machine

Handle the special cases of both serprog and ch341a_spi.
Also rewrite programmer_delay() to handle the two base
cases of zero time and no valid flashctx yet before
handling per master branching.

Additionally, modify the custom delay function pointer
signature to allow closure over the flashctx. This allows
driver specific delay implementations to recover programmer
specific opaque data within their delay implementations.
Therefore programmer specific delay functions can avoid
programmer specific globals.

Change-Id: Id059abb58b31a066a408009073912da2b224d40c
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67393
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Edward O'Callaghan
2022-09-07 12:51:16 +10:00
committed by Edward O'Callaghan
parent 048aab6d66
commit 78e421bdf7
4 changed files with 43 additions and 31 deletions

View File

@ -256,12 +256,21 @@ static bool master_uses_physmap(const struct registered_master *mst)
void programmer_delay(const struct flashctx *flash, unsigned int usecs)
{
if (usecs > 0) {
if (programmer->delay)
programmer->delay(usecs);
else
internal_delay(usecs);
if (usecs == 0)
return;
if (!flash)
return internal_delay(usecs);
if (flash->mst->buses_supported & BUS_SPI) {
if (flash->mst->spi.delay)
return flash->mst->spi.delay(flash, usecs);
} else if (flash->mst->buses_supported & BUS_PARALLEL) {
if (flash->mst->par.delay)
return flash->mst->par.delay(flash, usecs);
}
return internal_delay(usecs);
}
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start,