qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH v1 1/3] hw: ssi: Introduce ssi_txfifo_transfer


From: Francisco Iglesias
Subject: [RFC PATCH v1 1/3] hw: ssi: Introduce ssi_txfifo_transfer
Date: Tue, 19 Jan 2021 14:01:53 +0100

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.iglesias@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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]