Skip to contentSkip to conversation

hw/misc: Add code to emulate Xilinx Slave Serial port

PATCH In review Andrey Smirnov 4 participants 5 messages Dec 14, 2017 – Jan 16, 2018 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/misc: Add code to emulate Xilinx Slave Serial port

Add code to emulate Xilinx Slave Serial FPGA configuration port.

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

Thanks,
Andrey Smirnov

 hw/misc/Makefile.objs                 |   1 +
 hw/misc/xilinx_slave_serial.c         | 105 ++++++++++++++++++++++++++++++++++
 include/hw/misc/xilinx_slave_serial.h |  21 +++++++
 3 files changed, 127 insertions(+)
 create mode 100644 hw/misc/xilinx_slave_serial.c
 create mode 100644 include/hw/misc/xilinx_slave_serial.h
hw/misc/Makefile.objs +1 -0
index a68a201083..4599288e55 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_IMX) += imx7_ccm.o
 obj-$(CONFIG_IMX) += imx2_wdt.o
 obj-$(CONFIG_IMX) += imx7_snvs.o
 obj-$(CONFIG_IMX) += imx7_gpr.o
+obj-y += xilinx_slave_serial.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/xilinx_slave_serial.c new file +105 -0

105 lines not on this page · raw message

include/hw/misc/xilinx_slave_serial.h new file +21 -0
new file mode 100644
index 0000000000..f7b2e22be3
@@ -0,0 +1,21 @@
+#ifndef XILINX_SLAVE_SERIAL_H
+#define XILINX_SLAVE_SERIAL_H
+
+#include "hw/ssi/ssi.h"
+
+typedef struct XilinxSlaveSerialState {
+    /*< private >*/
+    SSISlave parent_obj;
+
+    qemu_irq done;
+    int state;
+} XilinxSlaveSerialState;
+
+#define TYPE_XILINX_SLAVE_SERIAL "xilinx:slave-serial"
+#define XILINX_SLAVE_SERIAL(obj) \
+    OBJECT_CHECK(XilinxSlaveSerialState, (obj), TYPE_XILINX_SLAVE_SERIAL)
+
+#define XILINX_SLAVE_SERIAL_GPIO_DONE   "xilinx:slave-serial:done"
+#define XILINX_SLAVE_SERIAL_GPIO_PROG_B "xilinx:slave-serial:prog-b"
+
+#endif /* XILINX_SLAVE_SERIAL_H */
Signature · 1 line
2.14.3
#1 lore raw
Quoted 8 lines · Andrey Smirnov

Add code to emulate Xilinx Slave Serial FPGA configuration port.

Hey,

Thanks for the patch!

I have some comments inline, if anything is unclear just email me back and I can provide more information or help.

Quoted 4 lines

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

You probably don't need a specific one, there are already some Xilinx ones in there you can use.

Maybe CONFIG_XILINX or CONFIG_XILINX_AXI

Quoted 11 lines

Thanks,
Andrey Smirnov

 hw/misc/Makefile.objs                 |   1 +
 hw/misc/xilinx_slave_serial.c         | 105 ++++++++++++++++++++++++++++++++++
 include/hw/misc/xilinx_slave_serial.h |  21 +++++++
 3 files changed, 127 insertions(+)
 create mode 100644 hw/misc/xilinx_slave_serial.c
 create mode 100644 include/hw/misc/xilinx_slave_serial.h

You will need to connect this to a machine as well.

Quoted 19 lines
hw/misc/Makefile.objs +1 -0
index a68a201083..4599288e55 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_IMX) += imx7_ccm.o
 obj-$(CONFIG_IMX) += imx2_wdt.o
 obj-$(CONFIG_IMX) += imx7_snvs.o
 obj-$(CONFIG_IMX) += imx7_gpr.o
+obj-y += xilinx_slave_serial.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/xilinx_slave_serial.c new file +0 -0
new file mode 100644
index 0000000000..607674fb60

hw/misc/xilinx_slave_serial.c line 7

Quoted 7 lines
hw/misc/xilinx_slave_serial.c new file +7 -0
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, Impinj, Inc.
+ *
+ * Code to emulate programming "port" of Xilinx FPGA in Slave Serial
+ * configuration connected via SPI, for more deatils see (p. 27):
+ *
+ * See https://www.xilinx.com/support/documentation/user_guides/ug380.pdf

Ah, so this is for a Spartan-6 device. We don't have any QEMU support for Spartan-6. What are you trying to use this for?

Quoted 8 lines
hw/misc/xilinx_slave_serial.c new file +8 -0
+ *
+ * Author: Andrey Smirnov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"

hw/misc/xilinx_slave_serial.c line 25

Quoted 10 lines
hw/misc/xilinx_slave_serial.c new file +10 -0
+#include "hw/misc/xilinx_slave_serial.h"
+#include "qemu/log.h"
+
+enum {
+    XILINX_SLAVE_SERIAL_STATE_RESET,
+    XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION,
+    XILINX_SLAVE_SERIAL_STATE_DONE,
+};
+
+static void xilinx_slave_serial_update_outputs(XilinxSlaveSerialState *xlnxss)

For function names try to use xlnx instead of xilinx, it just saves line length.

hw/misc/xilinx_slave_serial.c line 33

Quoted 8 lines
hw/misc/xilinx_slave_serial.c new file +8 -0
+{
+    qemu_set_irq(xlnxss->done,
+                 xlnxss->state == XILINX_SLAVE_SERIAL_STATE_DONE);
+}
+
+static void xilinx_slave_serial_reset(DeviceState *dev)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(dev);

This is generally just called 's'.

Quoted 82 lines
hw/misc/xilinx_slave_serial.c new file +72 -0
+
+    xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RESET;
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_prog_b(void *opaque, int n, int level)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(opaque);
+    assert(n == 0);
+
+    if (level) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_realize(SSISlave *ss, Error **errp)
+{
+    DeviceState *dev = DEVICE(ss);
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    qdev_init_gpio_in_named(dev,
+                            xilinx_slave_serial_prog_b,
+                            XILINX_SLAVE_SERIAL_GPIO_PROG_B,
+                            1);
+    qdev_init_gpio_out_named(dev, &xlnxss->done,
+                             XILINX_SLAVE_SERIAL_GPIO_DONE, 1);
+}
+
+static uint32_t xilinx_slave_serial_transfer(SSISlave *ss, uint32_t tx)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    if (xlnxss->state == XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_DONE;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+    return 0;
+}
+
+static void xilinx_slave_serial_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass   *dc = DEVICE_CLASS(klass);
+    SSISlaveClass *k  = SSI_SLAVE_CLASS(klass);
+
+    dc->reset      = xilinx_slave_serial_reset;
+    dc->desc       = "Xilinx Slave Serial";
+    k->realize     = xilinx_slave_serial_realize;
+    k->transfer    = xilinx_slave_serial_transfer;
+    /*
+     * Slave Serial configuration is not technically SPI and there's
+     * no CS signal
+     */
+    k->set_cs      = NULL;
+    k->cs_polarity = SSI_CS_NONE;
+}
+
+static const TypeInfo xilinx_slave_serial_info = {
+    .name          = TYPE_XILINX_SLAVE_SERIAL,
+    .parent        = TYPE_SSI_SLAVE,
+    .instance_size = sizeof(XilinxSlaveSerialState),
+    .class_init    = xilinx_slave_serial_class_init,
+};
+
+static void xilinx_slave_serial_register_type(void)
+{
+    type_register_static(&xilinx_slave_serial_info);
+}
+type_init(xilinx_slave_serial_register_type)
include/hw/misc/xilinx_slave_serial.h new file +4 -0
new file mode 100644
index 0000000000..f7b2e22be3
@@ -0,0 +1,21 @@
+#ifndef XILINX_SLAVE_SERIAL_H
+#define XILINX_SLAVE_SERIAL_H
+
+#include "hw/ssi/ssi.h"

include/hw/misc/xilinx_slave_serial.h line 14

Quoted 10 lines
include/hw/misc/xilinx_slave_serial.h new file +10 -0
+
+typedef struct XilinxSlaveSerialState {
+    /*< private >*/
+    SSISlave parent_obj;
+
+    qemu_irq done;
+    int state;
+} XilinxSlaveSerialState;
+
+#define TYPE_XILINX_SLAVE_SERIAL "xilinx:slave-serial"

Full stop instead of colon.

Overall the model looks fine, I'm just not sure what you are using it for as it isn't connected to anything.

Thanks,
Alistair

Quoted 11 lines
include/hw/misc/xilinx_slave_serial.h new file +7 -1
+#define XILINX_SLAVE_SERIAL(obj) \
+    OBJECT_CHECK(XilinxSlaveSerialState, (obj), TYPE_XILINX_SLAVE_SERIAL)
+
+#define XILINX_SLAVE_SERIAL_GPIO_DONE   "xilinx:slave-serial:done"
+#define XILINX_SLAVE_SERIAL_GPIO_PROG_B "xilinx:slave-serial:prog-b"
+
+#endif /* XILINX_SLAVE_SERIAL_H */
--

2.14.3

#2 lore raw
Quoted 20 lines · Alistair Francis
Quoted 8 lines · Andrey Smirnov

Add code to emulate Xilinx Slave Serial FPGA configuration port.

Hey,

Thanks for the patch!

I have some comments inline, if anything is unclear just email me back and I can provide more information or help.

Quoted 2 lines

---

Quoted 8 lines
Quoted 2 lines

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

You probably don't need a specific one, there are already some Xilinx ones in there you can use.

Maybe CONFIG_XILINX or CONFIG_XILINX_AXI

OK, will do if I ever re-spin this patch

Quoted 35 lines
Quoted 11 lines

Thanks,
Andrey Smirnov

 hw/misc/Makefile.objs                 |   1 +
 hw/misc/xilinx_slave_serial.c         | 105 ++++++++++++++++++++++++++++++++++
 include/hw/misc/xilinx_slave_serial.h |  21 +++++++
 3 files changed, 127 insertions(+)
 create mode 100644 hw/misc/xilinx_slave_serial.c
 create mode 100644 include/hw/misc/xilinx_slave_serial.h

You will need to connect this to a machine as well.

Quoted 21 lines
hw/misc/Makefile.objs +1 -0
index a68a201083..4599288e55 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_IMX) += imx7_ccm.o
 obj-$(CONFIG_IMX) += imx2_wdt.o
 obj-$(CONFIG_IMX) += imx7_snvs.o
 obj-$(CONFIG_IMX) += imx7_gpr.o
+obj-y += xilinx_slave_serial.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/xilinx_slave_serial.c new file +2 -0
new file mode 100644
index 0000000000..607674fb60
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, Impinj, Inc.
Quoted 9 lines

hw/misc/xilinx_slave_serial.c line 7

Quoted 5 lines
hw/misc/xilinx_slave_serial.c new file +5 -0
+ *
+ * Code to emulate programming "port" of Xilinx FPGA in Slave Serial
+ * configuration connected via SPI, for more deatils see (p. 27):
+ *
+ * See https://www.xilinx.com/support/documentation/user_guides/ug380.pdf

Ah, so this is for a Spartan-6 device. We don't have any QEMU support for Spartan-6. What are you trying to use this for?

The use-case for this patch is to fool FPGA configuration tools running on the guest into beliving that they successfully configure Spartan-6 device. I tested this code against "drivers/fpga/xilinx-spi.c" from Linux kernel.

Quoted 12 lines
Quoted 12 lines
hw/misc/xilinx_slave_serial.c new file +12 -0
+ *
+ * Author: Andrey Smirnov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/misc/xilinx_slave_serial.h"
+#include "qemu/log.h"
+
+enum {
Quoted 8 lines

hw/misc/xilinx_slave_serial.c line 25

Quoted 6 lines
hw/misc/xilinx_slave_serial.c new file +6 -0
+    XILINX_SLAVE_SERIAL_STATE_RESET,
+    XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION,
+    XILINX_SLAVE_SERIAL_STATE_DONE,
+};
+
+static void xilinx_slave_serial_update_outputs(XilinxSlaveSerialState *xlnxss)

For function names try to use xlnx instead of xilinx, it just saves line length.

Will fix if I re-spin this patch.

Quoted 11 lines

hw/misc/xilinx_slave_serial.c line 33

Quoted 9 lines
hw/misc/xilinx_slave_serial.c new file +8 -0
+{
+    qemu_set_irq(xlnxss->done,
+                 xlnxss->state == XILINX_SLAVE_SERIAL_STATE_DONE);
+}
+
+static void xilinx_slave_serial_reset(DeviceState *dev)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(dev);

This is generally just called 's'.

OK, will fix if I re-spin this patch

Quoted 87 lines
Quoted 87 lines
hw/misc/xilinx_slave_serial.c new file +72 -0
+
+    xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RESET;
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_prog_b(void *opaque, int n, int level)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(opaque);
+    assert(n == 0);
+
+    if (level) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_realize(SSISlave *ss, Error **errp)
+{
+    DeviceState *dev = DEVICE(ss);
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    qdev_init_gpio_in_named(dev,
+                            xilinx_slave_serial_prog_b,
+                            XILINX_SLAVE_SERIAL_GPIO_PROG_B,
+                            1);
+    qdev_init_gpio_out_named(dev, &xlnxss->done,
+                             XILINX_SLAVE_SERIAL_GPIO_DONE, 1);
+}
+
+static uint32_t xilinx_slave_serial_transfer(SSISlave *ss, uint32_t tx)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    if (xlnxss->state == XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_DONE;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+    return 0;
+}
+
+static void xilinx_slave_serial_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass   *dc = DEVICE_CLASS(klass);
+    SSISlaveClass *k  = SSI_SLAVE_CLASS(klass);
+
+    dc->reset      = xilinx_slave_serial_reset;
+    dc->desc       = "Xilinx Slave Serial";
+    k->realize     = xilinx_slave_serial_realize;
+    k->transfer    = xilinx_slave_serial_transfer;
+    /*
+     * Slave Serial configuration is not technically SPI and there's
+     * no CS signal
+     */
+    k->set_cs      = NULL;
+    k->cs_polarity = SSI_CS_NONE;
+}
+
+static const TypeInfo xilinx_slave_serial_info = {
+    .name          = TYPE_XILINX_SLAVE_SERIAL,
+    .parent        = TYPE_SSI_SLAVE,
+    .instance_size = sizeof(XilinxSlaveSerialState),
+    .class_init    = xilinx_slave_serial_class_init,
+};
+
+static void xilinx_slave_serial_register_type(void)
+{
+    type_register_static(&xilinx_slave_serial_info);
+}
+type_init(xilinx_slave_serial_register_type)
include/hw/misc/xilinx_slave_serial.h new file +8 -0
new file mode 100644
index 0000000000..f7b2e22be3
@@ -0,0 +1,21 @@
+#ifndef XILINX_SLAVE_SERIAL_H
+#define XILINX_SLAVE_SERIAL_H
+
+#include "hw/ssi/ssi.h"
+
+typedef struct XilinxSlaveSerialState {
+    /*< private >*/
+    SSISlave parent_obj;
Quoted 8 lines

include/hw/misc/xilinx_slave_serial.h line 14

Quoted 6 lines
include/hw/misc/xilinx_slave_serial.h new file +6 -0
+
+    qemu_irq done;
+    int state;
+} XilinxSlaveSerialState;
+
+#define TYPE_XILINX_SLAVE_SERIAL "xilinx:slave-serial"

Full stop instead of colon.

Good to know, will fix if I re-spin this patch

Quoted 3 lines

Overall the model looks fine, I'm just not sure what you are using it for as it isn't connected to anything.

I think this patch is similar to another one I submitted
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg02513.html in a sense that there's no board in upstream codebase that needs this feature and I am not yet upstreaming the code for the board that I use it for. Given the situation, I think I'll put this patch on hold until I have some other code to justify its inclusion.

Thanks,
Andrey Smrinov

#3 lore raw
Quoted 25 lines · Andrey Smirnov
Quoted 23 lines · Alistair Francis
Quoted 8 lines · Andrey Smirnov

Add code to emulate Xilinx Slave Serial FPGA configuration port.

Hey,

Thanks for the patch!

I have some comments inline, if anything is unclear just email me back and I can provide more information or help.

Quoted 4 lines

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

Quoted 51 lines
Quoted 5 lines

You probably don't need a specific one, there are already some Xilinx ones in there you can use.

Maybe CONFIG_XILINX or CONFIG_XILINX_AXI

OK, will do if I ever re-spin this patch

Quoted 43 lines
Quoted 11 lines

Thanks,
Andrey Smirnov

 hw/misc/Makefile.objs                 |   1 +
 hw/misc/xilinx_slave_serial.c         | 105 ++++++++++++++++++++++++++++++++++
 include/hw/misc/xilinx_slave_serial.h |  21 +++++++
 3 files changed, 127 insertions(+)
 create mode 100644 hw/misc/xilinx_slave_serial.c
 create mode 100644 include/hw/misc/xilinx_slave_serial.h

You will need to connect this to a machine as well.

Quoted 19 lines
hw/misc/Makefile.objs +1 -0
index a68a201083..4599288e55 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_IMX) += imx7_ccm.o
 obj-$(CONFIG_IMX) += imx2_wdt.o
 obj-$(CONFIG_IMX) += imx7_snvs.o
 obj-$(CONFIG_IMX) += imx7_gpr.o
+obj-y += xilinx_slave_serial.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/xilinx_slave_serial.c new file +0 -0
new file mode 100644
index 0000000000..607674fb60

hw/misc/xilinx_slave_serial.c line 7

Quoted 7 lines
hw/misc/xilinx_slave_serial.c new file +7 -0
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2017, Impinj, Inc.
+ *
+ * Code to emulate programming "port" of Xilinx FPGA in Slave Serial
+ * configuration connected via SPI, for more deatils see (p. 27):
+ *
+ * See https://www.xilinx.com/support/documentation/user_guides/ug380.pdf

Ah, so this is for a Spartan-6 device. We don't have any QEMU support for Spartan-6. What are you trying to use this for?

Well, this question is valid for all the ARM FDT devices...

Alistair: GSoC idea: have a easier way to integrate FDT devices into QEMU and automagically qtest them.

If devices have qtests for code coverage, I think we should accept them upstream, even if they are not yet plugged into a board.

The other way, there are motivated contributors who start sending patches but then never finish due to changes in life and reduced spare time, or lack of motivation due to the high quality asked by some maintainer or daily paid reviewers, which is a shame IMHO.

Speaking from experience I already found in the ML archives some pieces of unfinished code of devices I am thinking about implement, and few of them pretty finished, but never merged. The contributors comments are "Hey, I wrote this device and it works for me" garage-sale attitude "if you find something useful, take it, else let it in the trash".

Quoted 154 lines

The use-case for this patch is to fool FPGA configuration tools running on the guest into beliving that they successfully configure Spartan-6 device. I tested this code against "drivers/fpga/xilinx-spi.c" from Linux kernel.

Quoted 12 lines
Quoted 12 lines
hw/misc/xilinx_slave_serial.c new file +12 -0
+ *
+ * Author: Andrey Smirnov <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/misc/xilinx_slave_serial.h"
+#include "qemu/log.h"
+
+enum {
Quoted 8 lines

hw/misc/xilinx_slave_serial.c line 25

Quoted 6 lines
hw/misc/xilinx_slave_serial.c new file +6 -0
+    XILINX_SLAVE_SERIAL_STATE_RESET,
+    XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION,
+    XILINX_SLAVE_SERIAL_STATE_DONE,
+};
+
+static void xilinx_slave_serial_update_outputs(XilinxSlaveSerialState *xlnxss)

For function names try to use xlnx instead of xilinx, it just saves line length.

Will fix if I re-spin this patch.

Quoted 11 lines

hw/misc/xilinx_slave_serial.c line 33

Quoted 9 lines
hw/misc/xilinx_slave_serial.c new file +8 -0
+{
+    qemu_set_irq(xlnxss->done,
+                 xlnxss->state == XILINX_SLAVE_SERIAL_STATE_DONE);
+}
+
+static void xilinx_slave_serial_reset(DeviceState *dev)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(dev);

This is generally just called 's'.

OK, will fix if I re-spin this patch

Quoted 87 lines
Quoted 87 lines
hw/misc/xilinx_slave_serial.c new file +72 -0
+
+    xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RESET;
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_prog_b(void *opaque, int n, int level)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(opaque);
+    assert(n == 0);
+
+    if (level) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+}
+
+static void xilinx_slave_serial_realize(SSISlave *ss, Error **errp)
+{
+    DeviceState *dev = DEVICE(ss);
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    qdev_init_gpio_in_named(dev,
+                            xilinx_slave_serial_prog_b,
+                            XILINX_SLAVE_SERIAL_GPIO_PROG_B,
+                            1);
+    qdev_init_gpio_out_named(dev, &xlnxss->done,
+                             XILINX_SLAVE_SERIAL_GPIO_DONE, 1);
+}
+
+static uint32_t xilinx_slave_serial_transfer(SSISlave *ss, uint32_t tx)
+{
+    XilinxSlaveSerialState *xlnxss = XILINX_SLAVE_SERIAL(ss);
+
+    if (xlnxss->state == XILINX_SLAVE_SERIAL_STATE_RECONFIGURATION) {
+        xlnxss->state = XILINX_SLAVE_SERIAL_STATE_DONE;
+    }
+
+    xilinx_slave_serial_update_outputs(xlnxss);
+    return 0;
+}
+
+static void xilinx_slave_serial_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass   *dc = DEVICE_CLASS(klass);
+    SSISlaveClass *k  = SSI_SLAVE_CLASS(klass);
+
+    dc->reset      = xilinx_slave_serial_reset;
+    dc->desc       = "Xilinx Slave Serial";
+    k->realize     = xilinx_slave_serial_realize;
+    k->transfer    = xilinx_slave_serial_transfer;
+    /*
+     * Slave Serial configuration is not technically SPI and there's
+     * no CS signal
+     */
+    k->set_cs      = NULL;
+    k->cs_polarity = SSI_CS_NONE;
+}
+
+static const TypeInfo xilinx_slave_serial_info = {
+    .name          = TYPE_XILINX_SLAVE_SERIAL,
+    .parent        = TYPE_SSI_SLAVE,
+    .instance_size = sizeof(XilinxSlaveSerialState),
+    .class_init    = xilinx_slave_serial_class_init,
+};
+
+static void xilinx_slave_serial_register_type(void)
+{
+    type_register_static(&xilinx_slave_serial_info);
+}
+type_init(xilinx_slave_serial_register_type)
include/hw/misc/xilinx_slave_serial.h new file +8 -0
new file mode 100644
index 0000000000..f7b2e22be3
@@ -0,0 +1,21 @@
+#ifndef XILINX_SLAVE_SERIAL_H
+#define XILINX_SLAVE_SERIAL_H
+
+#include "hw/ssi/ssi.h"
+
+typedef struct XilinxSlaveSerialState {
+    /*< private >*/
+    SSISlave parent_obj;
Quoted 8 lines

include/hw/misc/xilinx_slave_serial.h line 14

Quoted 6 lines
include/hw/misc/xilinx_slave_serial.h new file +6 -0
+
+    qemu_irq done;
+    int state;
+} XilinxSlaveSerialState;
+
+#define TYPE_XILINX_SLAVE_SERIAL "xilinx:slave-serial"

Full stop instead of colon.

Good to know, will fix if I re-spin this patch

Quoted 3 lines

Overall the model looks fine, I'm just not sure what you are using it for as it isn't connected to anything.

I think this patch is similar to another one I submitted
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg02513.html in a sense that there's no board in upstream codebase that needs this feature and I am not yet upstreaming the code for the board that I use it for. Given the situation, I think I'll put this patch on hold until I have some other code to justify its inclusion.

Thanks,
Andrey Smrinov

#4 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé

If devices have qtests for code coverage, I think we should accept them upstream, even if they are not yet plugged into a board.

The other way, there are motivated contributors who start sending patches but then never finish due to changes in life and reduced spare time, or lack of motivation due to the high quality asked by some maintainer or daily paid reviewers, which is a shame IMHO.

The other side of this argument is that every new board and device we accept upstream is increased maintenance workload for us as upstream maintainers. If there's no board model that uses the device then it is completely useless to us and to our users, and so it's all downside.

thanks
-- PMM