This patch introduces ssi_txfifo_transfer aimed to be used by SPI controllers transfering through a txfifo. When interacting with a SPI flash (m25p80), ssi_txfifo_transfer will toggle the accuracy from dummy clock cycles to dummy bytes and by doing this above mentioned SPI controllers will obtain support for the commands requiring those.
Signed-off-by: Francisco Iglesias <frasse.igles...@gmail.com> --- hw/ssi/ssi.c | 22 ++++++++++++++++++++++ include/hw/ssi/ssi.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c index e5d7ce9523..b87628ea0c 100644 --- a/hw/ssi/ssi.c +++ b/hw/ssi/ssi.c @@ -127,6 +127,28 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) return r; } +uint32_t ssi_txfifo_transfer(SSIBus *bus, uint32_t val) +{ + BusState *b = BUS(bus); + BusChild *kid; + SSIPeripheralClass *ssc; + uint32_t r = 0; + + QTAILQ_FOREACH(kid, &b->children, sibling) { + SSIPeripheral *peripheral = SSI_PERIPHERAL(kid->child); + ssc = SSI_PERIPHERAL_GET_CLASS(peripheral); + if (ssc->set_dummy_byte_accuracy) { + ssc->set_dummy_byte_accuracy(peripheral, true); + } + r |= ssc->transfer_raw(peripheral, val); + if (ssc->set_dummy_byte_accuracy) { + ssc->set_dummy_byte_accuracy(peripheral, false); + } + } + + return r; +} + const VMStateDescription vmstate_ssi_peripheral = { .name = "SSISlave", .version_id = 1, diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h index f411858ab0..39bf00ec96 100644 --- a/include/hw/ssi/ssi.h +++ b/include/hw/ssi/ssi.h @@ -54,6 +54,8 @@ struct SSIPeripheralClass { * always be called for the device for every txrx access to the parent bus */ uint32_t (*transfer_raw)(SSIPeripheral *dev, uint32_t val); + + void (*set_dummy_byte_accuracy)(SSIPeripheral *dev, bool val); }; struct SSIPeripheral { @@ -105,5 +107,6 @@ bool ssi_realize_and_unref(DeviceState *dev, SSIBus *bus, Error **errp); SSIBus *ssi_create_bus(DeviceState *parent, const char *name); uint32_t ssi_transfer(SSIBus *bus, uint32_t val); +uint32_t ssi_txfifo_transfer(SSIBus *bus, uint32_t val); #endif -- 2.20.1