summaryrefslogtreecommitdiffstats
path: root/ch341a_spi.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-09-07 12:51:16 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2022-12-12 00:01:10 +0000
commit78e421bdf73d5739daa25a9f71b2c323dc98e840 (patch)
tree293a63c17096eb667bea701e332d6ed911e8d7d0 /ch341a_spi.c
parent048aab6d66c45423386d0216fd7bf445fbd1dc7f (diff)
downloadflashrom-78e421bdf73d5739daa25a9f71b2c323dc98e840.tar.gz
flashrom-78e421bdf73d5739daa25a9f71b2c323dc98e840.tar.bz2
flashrom-78e421bdf73d5739daa25a9f71b2c323dc98e840.zip
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>
Diffstat (limited to 'ch341a_spi.c')
-rw-r--r--ch341a_spi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ch341a_spi.c b/ch341a_spi.c
index 294a6a655..2dc983ffd 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -322,7 +322,7 @@ static void pluck_cs(uint8_t *ptr)
*ptr++ = CH341A_CMD_UIO_STM_END;
}
-static void ch341a_spi_delay(unsigned int usecs)
+static void ch341a_spi_delay(const struct flashctx *flash, unsigned int usecs)
{
/* There is space for 28 bytes instructions of 750 ns each in the CS packet (32 - 4 for the actual CS
* instructions), thus max 21 us, but we avoid getting too near to this boundary and use
@@ -419,6 +419,7 @@ static const struct spi_master spi_master_ch341a_spi = {
.write_aai = default_spi_write_aai,
.shutdown = ch341a_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
+ .delay = ch341a_spi_delay,
};
static int ch341a_spi_init(const struct programmer_cfg *cfg)
@@ -525,5 +526,4 @@ const struct programmer_entry programmer_ch341a_spi = {
.type = USB,
.devs.dev = devs_ch341a_spi,
.init = ch341a_spi_init,
- .delay = ch341a_spi_delay,
};