Skip to contentSkip to conversation

Connect the SPI devices to ZynqMP

PATCH Superseded Alistair Francis 3 participants 13 messages Sep 29, 2015 – Oct 7, 2015 1 message not in the archive Arm/Zynq architecture

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover Connect the SPI devices to ZynqMP

Connect the SPI devices to Xilinx's ZynqMP.

I also need to make some changes to the actual SPI device to imporove the fuctionality, but for the time being this works.

Alistair Francis (3):
ssi: Move ssi.h into a seperate directory
xilinx_spips: Seperate the state struct into a header
xlnx-zynqmp: Connect the SPI devices

 hw/arm/pxa2xx.c                     |   2 +-
 hw/arm/spitz.c                      |   2 +-
 hw/arm/stellaris.c                  |   2 +-
 hw/arm/strongarm.c                  |   2 +-
 hw/arm/tosa.c                       |   2 +-
 hw/arm/xilinx_zynq.c                |   2 +-
 hw/arm/xlnx-zynqmp.c                |  46 ++++++++++++-
 hw/arm/z2.c                         |   2 +-
 hw/block/m25p80.c                   |   2 +-
 hw/display/ads7846.c                |   2 +-
 hw/display/ssd0323.c                |   2 +-
 hw/microblaze/petalogix_ml605_mmu.c |   2 +-
 hw/misc/max111x.c                   |   2 +-
 hw/sd/ssi-sd.c                      |   2 +-
 hw/ssi/pl022.c                      |   2 +-
 hw/ssi/ssi.c                        |   2 +-
 hw/ssi/xilinx_spi.c                 |   2 +-
 hw/ssi/xilinx_spips.c               | 104 +---------------------------
 include/hw/arm/xlnx-zynqmp.h        |   4 ++
 include/hw/ssi.h                    |  94 -------------------------
 include/hw/ssi/ssi.h                |  96 ++++++++++++++++++++++++++
 include/hw/ssi/xilinx_spips.h       | 134 ++++++++++++++++++++++++++++++++++++
 22 files changed, 296 insertions(+), 214 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
 create mode 100644 include/hw/ssi/xilinx_spips.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 ssi: Move ssi.h into a seperate directory

Move the ssi.h include file into the ssi directory.

---

 hw/arm/pxa2xx.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/arm/strongarm.c                  |  2 +-
 hw/arm/tosa.c                       |  2 +-
 hw/arm/xilinx_zynq.c                |  2 +-
 hw/arm/z2.c                         |  2 +-
 hw/block/m25p80.c                   |  2 +-
 hw/display/ads7846.c                |  2 +-
 hw/display/ssd0323.c                |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c |  2 +-
 hw/misc/max111x.c                   |  2 +-
 hw/sd/ssi-sd.c                      |  2 +-
 hw/ssi/pl022.c                      |  2 +-
 hw/ssi/ssi.c                        |  2 +-
 hw/ssi/xilinx_spi.c                 |  2 +-
 hw/ssi/xilinx_spips.c               |  2 +-
 include/hw/ssi.h                    | 94 ------------------------------------
 include/hw/ssi/ssi.h                | 96 +++++++++++++++++++++++++++++++++++++
 19 files changed, 113 insertions(+), 111 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
hw/arm/pxa2xx.c +1 -1
index 164260a..534c06f 100644
@@ -12,7 +12,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
hw/arm/spitz.c +1 -1
index 2af03be..c9405af 100644
@@ -16,7 +16,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/pcmcia.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
 #include "hw/devices.h"
hw/arm/stellaris.c +1 -1
index 3d6486f..c785e90 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "qemu/timer.h"
hw/arm/strongarm.c +1 -1
index 9624ecb..4d2ba02 100644
@@ -34,7 +34,7 @@
 #include "hw/arm/arm.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG
 
hw/arm/tosa.c +1 -1
index 51d0b89..6b210a6 100644
@@ -19,7 +19,7 @@
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
hw/arm/xilinx_zynq.c +1 -1
index 9f89483..9db9602 100644
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/error-report.h"
 
 #define NUM_SPI_FLASHES 4
hw/arm/z2.c +1 -1
index b44eb76..c82fe2c 100644
@@ -16,7 +16,7 @@
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/block/flash.h"
hw/block/m25p80.c +1 -1
index efc43dd..44830c7 100644
@@ -24,7 +24,7 @@
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifndef M25P80_ERR_DEBUG
 #define M25P80_ERR_DEBUG 0
hw/display/ads7846.c +1 -1
index 3f35369..cb82317 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 typedef struct {
hw/display/ssd0323.c +1 -1
index 9727007..7545da8 100644
@@ -10,7 +10,7 @@
 /* The controller can support a variety of different displays, but we only
    implement one.  Most of the commends relating to brightness and geometry
    setup are ignored. */
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 //#define DEBUG_SSD0323 1
hw/microblaze/petalogix_ml605_mmu.c +1 -1
index 462060f..5366cec 100644
@@ -35,7 +35,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/char/serial.h"
 #include "exec/address-spaces.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #include "boot.h"
 
hw/misc/max111x.c +1 -1
index bef3651..d619d61 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 typedef struct {
     SSISlave parent_obj;
hw/sd/ssi-sd.c +1 -1
index e4b2d4f..4fe00fd 100644
@@ -12,7 +12,7 @@
 
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/sd.h"
 
 //#define DEBUG_SSI_SD 1
hw/ssi/pl022.c +1 -1
index 61d568f..0bbf633 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG_PL022 1
 
hw/ssi/ssi.c +1 -1
index 2aab79b..a0f57c0 100644
@@ -12,7 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 struct SSIBus {
     BusState parent_obj;
hw/ssi/xilinx_spi.c +1 -1
index 620573c..94bb2a7 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifdef XILINX_SPI_ERR_DEBUG
 #define DB_PRINT(...) do { \
hw/ssi/xilinx_spips.c +1 -1
index 0910f54..e9471ff 100644
@@ -27,7 +27,7 @@
 #include "hw/ptimer.h"
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
include/hw/ssi.h deleted +0 -94

94 lines not on this page · raw message

include/hw/ssi/ssi.h new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [Qemu-devel] [PATCH v1 1/3] ssi: Move ssi.h into a seperate directory

Quoted 16 lines · Alistair Francis

Move the ssi.h include file into the ssi directory.

---

 hw/arm/pxa2xx.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/arm/strongarm.c                  |  2 +-
 hw/arm/tosa.c                       |  2 +-
 hw/arm/xilinx_zynq.c                |  2 +-
 hw/arm/z2.c                         |  2 +-
 hw/block/m25p80.c                   |  2 +-
 hw/display/ads7846.c                |  2 +-
 hw/display/ssd0323.c                |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c |  2 +-
Quoted 8 lines
 hw/misc/max111x.c                   |  2 +-
 hw/sd/ssi-sd.c                      |  2 +-
 hw/ssi/pl022.c                      |  2 +-
 hw/ssi/ssi.c                        |  2 +-
 hw/ssi/xilinx_spi.c                 |  2 +-
 hw/ssi/xilinx_spips.c               |  2 +-
 include/hw/ssi.h                    | 94 ------------------------------------
 include/hw/ssi/ssi.h                | 96 +++++++++++++++++++++++++++++++++++++

Curious as to why git didn't pick this up as a rename (I think it should handle small diffs in the renaming). Do you have rename detection turned on?

Regards,
Peter

Quoted 430 lines
 19 files changed, 113 insertions(+), 111 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
hw/arm/pxa2xx.c +1 -1
index 164260a..534c06f 100644
@@ -12,7 +12,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
hw/arm/spitz.c +1 -1
index 2af03be..c9405af 100644
@@ -16,7 +16,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/pcmcia.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
 #include "hw/devices.h"
hw/arm/stellaris.c +1 -1
index 3d6486f..c785e90 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "qemu/timer.h"
hw/arm/strongarm.c +1 -1
index 9624ecb..4d2ba02 100644
@@ -34,7 +34,7 @@
 #include "hw/arm/arm.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG
 
hw/arm/tosa.c +1 -1
index 51d0b89..6b210a6 100644
@@ -19,7 +19,7 @@
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
hw/arm/xilinx_zynq.c +1 -1
index 9f89483..9db9602 100644
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/error-report.h"
 
 #define NUM_SPI_FLASHES 4
hw/arm/z2.c +1 -1
index b44eb76..c82fe2c 100644
@@ -16,7 +16,7 @@
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/block/flash.h"
hw/block/m25p80.c +1 -1
index efc43dd..44830c7 100644
@@ -24,7 +24,7 @@
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifndef M25P80_ERR_DEBUG
 #define M25P80_ERR_DEBUG 0
hw/display/ads7846.c +1 -1
index 3f35369..cb82317 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 typedef struct {
hw/display/ssd0323.c +1 -1
index 9727007..7545da8 100644
@@ -10,7 +10,7 @@
 /* The controller can support a variety of different displays, but we only
    implement one.  Most of the commends relating to brightness and geometry
    setup are ignored. */
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 //#define DEBUG_SSD0323 1
hw/microblaze/petalogix_ml605_mmu.c +1 -1
index 462060f..5366cec 100644
@@ -35,7 +35,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/char/serial.h"
 #include "exec/address-spaces.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #include "boot.h"
 
hw/misc/max111x.c +1 -1
index bef3651..d619d61 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 typedef struct {
     SSISlave parent_obj;
hw/sd/ssi-sd.c +1 -1
index e4b2d4f..4fe00fd 100644
@@ -12,7 +12,7 @@
 
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/sd.h"
 
 //#define DEBUG_SSI_SD 1
hw/ssi/pl022.c +1 -1
index 61d568f..0bbf633 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG_PL022 1
 
hw/ssi/ssi.c +1 -1
index 2aab79b..a0f57c0 100644
@@ -12,7 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 struct SSIBus {
     BusState parent_obj;
hw/ssi/xilinx_spi.c +1 -1
index 620573c..94bb2a7 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifdef XILINX_SPI_ERR_DEBUG
 #define DB_PRINT(...) do { \
hw/ssi/xilinx_spips.c +1 -1
index 0910f54..e9471ff 100644
@@ -27,7 +27,7 @@
 #include "hw/ptimer.h"
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
include/hw/ssi.h deleted +0 -94
deleted file mode 100644
index df0f838..0000000
@@ -1,94 +0,0 @@
-/* QEMU Synchronous Serial Interface support.  */
-
-/* In principle SSI is a point-point interface.  As such the qemu
-   implementation has a single slave device on a "bus".
-   However it is fairly common for boards to have multiple slaves
-   connected to a single master, and select devices with an external
-   chip select.  This is implemented in qemu by having an explicit mux device.
-   It is assumed that master and slave are both using the same transfer width.
-   */
-
-#ifndef QEMU_SSI_H
-#define QEMU_SSI_H
-
-#include "hw/qdev.h"
-
-typedef struct SSISlave SSISlave;
-
-#define TYPE_SSI_SLAVE "ssi-slave"
-#define SSI_SLAVE(obj) \
-     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_CLASS(klass) \
-     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
-
-#define SSI_GPIO_CS "ssi-gpio-cs"
-
-typedef enum {
-    SSI_CS_NONE = 0,
-    SSI_CS_LOW,
-    SSI_CS_HIGH,
-} SSICSMode;
-
-/* Slave devices.  */
-typedef struct SSISlaveClass {
-    DeviceClass parent_class;
-
-    int (*init)(SSISlave *dev);
-
-    /* if you have standard or no CS behaviour, just override transfer.
-     * This is called when the device cs is active (true by default).
-     */
-    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
-    /* called when the CS line changes. Optional, devices only need to implement
-     * this if they have side effects associated with the cs line (beyond
-     * tristating the txrx lines).
-     */
-    int (*set_cs)(SSISlave *dev, bool select);
-    /* define whether or not CS exists and is active low/high */
-    SSICSMode cs_polarity;
-
-    /* if you have non-standard CS behaviour override this to take control
-     * of the CS behaviour at the device level. transfer, set_cs, and
-     * cs_polarity are unused if this is overwritten. Transfer_raw will
-     * always be called for the device for every txrx access to the parent bus
-     */
-    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
-} SSISlaveClass;
-
-struct SSISlave {
-    DeviceState parent_obj;
-
-    /* Chip select state */
-    bool cs;
-};
-
-#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
-
-extern const VMStateDescription vmstate_ssi_slave;
-
-#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(SSISlave),                                  \
-    .vmsd       = &vmstate_ssi_slave,                                \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
-}
-
-DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
-DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
-
-/* Master interface.  */
-SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
-
-uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
-
-/* Automatically connect all children nodes a spi controller as slaves */
-void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
-                             SSIBus *bus);
-
-/* max111x.c */
-void max111x_set_input(DeviceState *dev, int line, uint8_t value);
-
-#endif
include/hw/ssi/ssi.h new file +96 -1
new file mode 100644
index 0000000..4a0a539
@@ -0,0 +1,96 @@
+/* QEMU Synchronous Serial Interface support.  */
+
+/* In principle SSI is a point-point interface.  As such the qemu
+   implementation has a single slave device on a "bus".
+   However it is fairly common for boards to have multiple slaves
+   connected to a single master, and select devices with an external
+   chip select.  This is implemented in qemu by having an explicit mux device.
+   It is assumed that master and slave are both using the same transfer width.
+   */
+
+#ifndef QEMU_SSI_H
+#define QEMU_SSI_H
+
+#include "hw/qdev.h"
+
+typedef struct SSISlave SSISlave;
+typedef struct SSISlaveClass SSISlaveClass;
+typedef enum SSICSMode SSICSMode;
+
+#define TYPE_SSI_SLAVE "ssi-slave"
+#define SSI_SLAVE(obj) \
+     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
+
+#define SSI_GPIO_CS "ssi-gpio-cs"
+
+enum SSICSMode {
+    SSI_CS_NONE = 0,
+    SSI_CS_LOW,
+    SSI_CS_HIGH,
+};
+
+/* Slave devices.  */
+struct SSISlaveClass {
+    DeviceClass parent_class;
+
+    int (*init)(SSISlave *dev);
+
+    /* if you have standard or no CS behaviour, just override transfer.
+     * This is called when the device cs is active (true by default).
+     */
+    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
+    /* called when the CS line changes. Optional, devices only need to implement
+     * this if they have side effects associated with the cs line (beyond
+     * tristating the txrx lines).
+     */
+    int (*set_cs)(SSISlave *dev, bool select);
+    /* define whether or not CS exists and is active low/high */
+    SSICSMode cs_polarity;
+
+    /* if you have non-standard CS behaviour override this to take control
+     * of the CS behaviour at the device level. transfer, set_cs, and
+     * cs_polarity are unused if this is overwritten. Transfer_raw will
+     * always be called for the device for every txrx access to the parent bus
+     */
+    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
+};
+
+struct SSISlave {
+    DeviceState parent_obj;
+
+    /* Chip select state */
+    bool cs;
+};
+
+#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
+
+extern const VMStateDescription vmstate_ssi_slave;
+
+#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(SSISlave),                                  \
+    .vmsd       = &vmstate_ssi_slave,                                \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
+}
+
+DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
+
+/* Master interface.  */
+SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
+
+uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
+
+/* Automatically connect all children nodes a spi controller as slaves */
+void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
+                             SSIBus *bus);
+
+/* max111x.c */
+void max111x_set_input(DeviceState *dev, int line, uint8_t value);
+
+#endif
--

1.9.1

#3 lore raw

Re: [Qemu-devel] [PATCH v1 1/3] ssi: Move ssi.h into a seperate directory

Quoted 27 lines · Peter Crosthwaite
Quoted 16 lines · Alistair Francis

Move the ssi.h include file into the ssi directory.

---

 hw/arm/pxa2xx.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/arm/strongarm.c                  |  2 +-
 hw/arm/tosa.c                       |  2 +-
 hw/arm/xilinx_zynq.c                |  2 +-
 hw/arm/z2.c                         |  2 +-
 hw/block/m25p80.c                   |  2 +-
 hw/display/ads7846.c                |  2 +-
 hw/display/ssd0323.c                |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c |  2 +-
Quoted 8 lines
 hw/misc/max111x.c                   |  2 +-
 hw/sd/ssi-sd.c                      |  2 +-
 hw/ssi/pl022.c                      |  2 +-
 hw/ssi/ssi.c                        |  2 +-
 hw/ssi/xilinx_spi.c                 |  2 +-
 hw/ssi/xilinx_spips.c               |  2 +-
 include/hw/ssi.h                    | 94 ------------------------------------
 include/hw/ssi/ssi.h                | 96 +++++++++++++++++++++++++++++++++++++
Quoted 3 lines

Curious as to why git didn't pick this up as a rename (I think it should handle small diffs in the renaming). Do you have rename detection turned on?

I do have rename detection turned on. I think the reason it didn't is because I tiddied up the code a little bit when I moved it. Checkpatch was reproting errors on the struct typedeffs so I had to change that.

Thanks,

Alistair

Quoted 435 lines

Regards,
Peter

Quoted 430 lines
 19 files changed, 113 insertions(+), 111 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
hw/arm/pxa2xx.c +1 -1
index 164260a..534c06f 100644
@@ -12,7 +12,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
hw/arm/spitz.c +1 -1
index 2af03be..c9405af 100644
@@ -16,7 +16,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/pcmcia.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
 #include "hw/devices.h"
hw/arm/stellaris.c +1 -1
index 3d6486f..c785e90 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "qemu/timer.h"
hw/arm/strongarm.c +1 -1
index 9624ecb..4d2ba02 100644
@@ -34,7 +34,7 @@
 #include "hw/arm/arm.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG
 
hw/arm/tosa.c +1 -1
index 51d0b89..6b210a6 100644
@@ -19,7 +19,7 @@
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
hw/arm/xilinx_zynq.c +1 -1
index 9f89483..9db9602 100644
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/error-report.h"
 
 #define NUM_SPI_FLASHES 4
hw/arm/z2.c +1 -1
index b44eb76..c82fe2c 100644
@@ -16,7 +16,7 @@
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/block/flash.h"
hw/block/m25p80.c +1 -1
index efc43dd..44830c7 100644
@@ -24,7 +24,7 @@
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifndef M25P80_ERR_DEBUG
 #define M25P80_ERR_DEBUG 0
hw/display/ads7846.c +1 -1
index 3f35369..cb82317 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 typedef struct {
hw/display/ssd0323.c +1 -1
index 9727007..7545da8 100644
@@ -10,7 +10,7 @@
 /* The controller can support a variety of different displays, but we only
    implement one.  Most of the commends relating to brightness and geometry
    setup are ignored. */
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 //#define DEBUG_SSD0323 1
hw/microblaze/petalogix_ml605_mmu.c +1 -1
index 462060f..5366cec 100644
@@ -35,7 +35,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/char/serial.h"
 #include "exec/address-spaces.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #include "boot.h"
 
hw/misc/max111x.c +1 -1
index bef3651..d619d61 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 typedef struct {
     SSISlave parent_obj;
hw/sd/ssi-sd.c +1 -1
index e4b2d4f..4fe00fd 100644
@@ -12,7 +12,7 @@
 
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/sd.h"
 
 //#define DEBUG_SSI_SD 1
hw/ssi/pl022.c +1 -1
index 61d568f..0bbf633 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG_PL022 1
 
hw/ssi/ssi.c +1 -1
index 2aab79b..a0f57c0 100644
@@ -12,7 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 struct SSIBus {
     BusState parent_obj;
hw/ssi/xilinx_spi.c +1 -1
index 620573c..94bb2a7 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifdef XILINX_SPI_ERR_DEBUG
 #define DB_PRINT(...) do { \
hw/ssi/xilinx_spips.c +1 -1
index 0910f54..e9471ff 100644
@@ -27,7 +27,7 @@
 #include "hw/ptimer.h"
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
include/hw/ssi.h deleted +0 -94
deleted file mode 100644
index df0f838..0000000
@@ -1,94 +0,0 @@
-/* QEMU Synchronous Serial Interface support.  */
-
-/* In principle SSI is a point-point interface.  As such the qemu
-   implementation has a single slave device on a "bus".
-   However it is fairly common for boards to have multiple slaves
-   connected to a single master, and select devices with an external
-   chip select.  This is implemented in qemu by having an explicit mux device.
-   It is assumed that master and slave are both using the same transfer width.
-   */
-
-#ifndef QEMU_SSI_H
-#define QEMU_SSI_H
-
-#include "hw/qdev.h"
-
-typedef struct SSISlave SSISlave;
-
-#define TYPE_SSI_SLAVE "ssi-slave"
-#define SSI_SLAVE(obj) \
-     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_CLASS(klass) \
-     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
-
-#define SSI_GPIO_CS "ssi-gpio-cs"
-
-typedef enum {
-    SSI_CS_NONE = 0,
-    SSI_CS_LOW,
-    SSI_CS_HIGH,
-} SSICSMode;
-
-/* Slave devices.  */
-typedef struct SSISlaveClass {
-    DeviceClass parent_class;
-
-    int (*init)(SSISlave *dev);
-
-    /* if you have standard or no CS behaviour, just override transfer.
-     * This is called when the device cs is active (true by default).
-     */
-    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
-    /* called when the CS line changes. Optional, devices only need to implement
-     * this if they have side effects associated with the cs line (beyond
-     * tristating the txrx lines).
-     */
-    int (*set_cs)(SSISlave *dev, bool select);
-    /* define whether or not CS exists and is active low/high */
-    SSICSMode cs_polarity;
-
-    /* if you have non-standard CS behaviour override this to take control
-     * of the CS behaviour at the device level. transfer, set_cs, and
-     * cs_polarity are unused if this is overwritten. Transfer_raw will
-     * always be called for the device for every txrx access to the parent bus
-     */
-    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
-} SSISlaveClass;
-
-struct SSISlave {
-    DeviceState parent_obj;
-
-    /* Chip select state */
-    bool cs;
-};
-
-#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
-
-extern const VMStateDescription vmstate_ssi_slave;
-
-#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(SSISlave),                                  \
-    .vmsd       = &vmstate_ssi_slave,                                \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
-}
-
-DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
-DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
-
-/* Master interface.  */
-SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
-
-uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
-
-/* Automatically connect all children nodes a spi controller as slaves */
-void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
-                             SSIBus *bus);
-
-/* max111x.c */
-void max111x_set_input(DeviceState *dev, int line, uint8_t value);
-
-#endif
include/hw/ssi/ssi.h new file +96 -1
new file mode 100644
index 0000000..4a0a539
@@ -0,0 +1,96 @@
+/* QEMU Synchronous Serial Interface support.  */
+
+/* In principle SSI is a point-point interface.  As such the qemu
+   implementation has a single slave device on a "bus".
+   However it is fairly common for boards to have multiple slaves
+   connected to a single master, and select devices with an external
+   chip select.  This is implemented in qemu by having an explicit mux device.
+   It is assumed that master and slave are both using the same transfer width.
+   */
+
+#ifndef QEMU_SSI_H
+#define QEMU_SSI_H
+
+#include "hw/qdev.h"
+
+typedef struct SSISlave SSISlave;
+typedef struct SSISlaveClass SSISlaveClass;
+typedef enum SSICSMode SSICSMode;
+
+#define TYPE_SSI_SLAVE "ssi-slave"
+#define SSI_SLAVE(obj) \
+     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
+
+#define SSI_GPIO_CS "ssi-gpio-cs"
+
+enum SSICSMode {
+    SSI_CS_NONE = 0,
+    SSI_CS_LOW,
+    SSI_CS_HIGH,
+};
+
+/* Slave devices.  */
+struct SSISlaveClass {
+    DeviceClass parent_class;
+
+    int (*init)(SSISlave *dev);
+
+    /* if you have standard or no CS behaviour, just override transfer.
+     * This is called when the device cs is active (true by default).
+     */
+    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
+    /* called when the CS line changes. Optional, devices only need to implement
+     * this if they have side effects associated with the cs line (beyond
+     * tristating the txrx lines).
+     */
+    int (*set_cs)(SSISlave *dev, bool select);
+    /* define whether or not CS exists and is active low/high */
+    SSICSMode cs_polarity;
+
+    /* if you have non-standard CS behaviour override this to take control
+     * of the CS behaviour at the device level. transfer, set_cs, and
+     * cs_polarity are unused if this is overwritten. Transfer_raw will
+     * always be called for the device for every txrx access to the parent bus
+     */
+    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
+};
+
+struct SSISlave {
+    DeviceState parent_obj;
+
+    /* Chip select state */
+    bool cs;
+};
+
+#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
+
+extern const VMStateDescription vmstate_ssi_slave;
+
+#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(SSISlave),                                  \
+    .vmsd       = &vmstate_ssi_slave,                                \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
+}
+
+DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
+
+/* Master interface.  */
+SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
+
+uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
+
+/* Automatically connect all children nodes a spi controller as slaves */
+void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
+                             SSIBus *bus);
+
+/* max111x.c */
+void max111x_set_input(DeviceState *dev, int line, uint8_t value);
+
+#endif
--

1.9.1

#4 lore raw

Re: [Qemu-devel] [PATCH v1 1/3] ssi: Move ssi.h into a seperate directory

Quoted 29 lines · Alistair Francis
Quoted 27 lines · Peter Crosthwaite
Quoted 24 lines · Alistair Francis

Move the ssi.h include file into the ssi directory.

---

 hw/arm/pxa2xx.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/arm/strongarm.c                  |  2 +-
 hw/arm/tosa.c                       |  2 +-
 hw/arm/xilinx_zynq.c                |  2 +-
 hw/arm/z2.c                         |  2 +-
 hw/block/m25p80.c                   |  2 +-
 hw/display/ads7846.c                |  2 +-
 hw/display/ssd0323.c                |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c |  2 +-
 hw/misc/max111x.c                   |  2 +-
 hw/sd/ssi-sd.c                      |  2 +-
 hw/ssi/pl022.c                      |  2 +-
 hw/ssi/ssi.c                        |  2 +-
 hw/ssi/xilinx_spi.c                 |  2 +-
 hw/ssi/xilinx_spips.c               |  2 +-
 include/hw/ssi.h                    | 94 ------------------------------------
 include/hw/ssi/ssi.h                | 96 +++++++++++++++++++++++++++++++++++++
Quoted 8 lines
Quoted 3 lines

Curious as to why git didn't pick this up as a rename (I think it should handle small diffs in the renaming). Do you have rename detection turned on?

I do have rename detection turned on. I think the reason it didn't is because I tiddied up the code a little bit when I moved it. Checkpatch was reproting errors on the struct typedeffs so I had to change that.

Can we do it in two steps and take the hit on the checkpatch fails on P1? Checkpatch fails are acceptable for pure mass-code movements. There is also probably some way to set your rename detction to higher level that should pick it up.

Regards,
Peter

Quoted 439 lines

Thanks,

Alistair

Quoted 435 lines

Regards,
Peter

Quoted 430 lines
 19 files changed, 113 insertions(+), 111 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
hw/arm/pxa2xx.c +1 -1
index 164260a..534c06f 100644
@@ -12,7 +12,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
hw/arm/spitz.c +1 -1
index 2af03be..c9405af 100644
@@ -16,7 +16,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/pcmcia.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
 #include "hw/devices.h"
hw/arm/stellaris.c +1 -1
index 3d6486f..c785e90 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "qemu/timer.h"
hw/arm/strongarm.c +1 -1
index 9624ecb..4d2ba02 100644
@@ -34,7 +34,7 @@
 #include "hw/arm/arm.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG
 
hw/arm/tosa.c +1 -1
index 51d0b89..6b210a6 100644
@@ -19,7 +19,7 @@
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
hw/arm/xilinx_zynq.c +1 -1
index 9f89483..9db9602 100644
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/error-report.h"
 
 #define NUM_SPI_FLASHES 4
hw/arm/z2.c +1 -1
index b44eb76..c82fe2c 100644
@@ -16,7 +16,7 @@
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/block/flash.h"
hw/block/m25p80.c +1 -1
index efc43dd..44830c7 100644
@@ -24,7 +24,7 @@
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifndef M25P80_ERR_DEBUG
 #define M25P80_ERR_DEBUG 0
hw/display/ads7846.c +1 -1
index 3f35369..cb82317 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 typedef struct {
hw/display/ssd0323.c +1 -1
index 9727007..7545da8 100644
@@ -10,7 +10,7 @@
 /* The controller can support a variety of different displays, but we only
    implement one.  Most of the commends relating to brightness and geometry
    setup are ignored. */
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 //#define DEBUG_SSD0323 1
hw/microblaze/petalogix_ml605_mmu.c +1 -1
index 462060f..5366cec 100644
@@ -35,7 +35,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/char/serial.h"
 #include "exec/address-spaces.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #include "boot.h"
 
hw/misc/max111x.c +1 -1
index bef3651..d619d61 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 typedef struct {
     SSISlave parent_obj;
hw/sd/ssi-sd.c +1 -1
index e4b2d4f..4fe00fd 100644
@@ -12,7 +12,7 @@
 
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/sd.h"
 
 //#define DEBUG_SSI_SD 1
hw/ssi/pl022.c +1 -1
index 61d568f..0bbf633 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG_PL022 1
 
hw/ssi/ssi.c +1 -1
index 2aab79b..a0f57c0 100644
@@ -12,7 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 struct SSIBus {
     BusState parent_obj;
hw/ssi/xilinx_spi.c +1 -1
index 620573c..94bb2a7 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifdef XILINX_SPI_ERR_DEBUG
 #define DB_PRINT(...) do { \
hw/ssi/xilinx_spips.c +1 -1
index 0910f54..e9471ff 100644
@@ -27,7 +27,7 @@
 #include "hw/ptimer.h"
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
include/hw/ssi.h deleted +0 -94
deleted file mode 100644
index df0f838..0000000
@@ -1,94 +0,0 @@
-/* QEMU Synchronous Serial Interface support.  */
-
-/* In principle SSI is a point-point interface.  As such the qemu
-   implementation has a single slave device on a "bus".
-   However it is fairly common for boards to have multiple slaves
-   connected to a single master, and select devices with an external
-   chip select.  This is implemented in qemu by having an explicit mux device.
-   It is assumed that master and slave are both using the same transfer width.
-   */
-
-#ifndef QEMU_SSI_H
-#define QEMU_SSI_H
-
-#include "hw/qdev.h"
-
-typedef struct SSISlave SSISlave;
-
-#define TYPE_SSI_SLAVE "ssi-slave"
-#define SSI_SLAVE(obj) \
-     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_CLASS(klass) \
-     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
-
-#define SSI_GPIO_CS "ssi-gpio-cs"
-
-typedef enum {
-    SSI_CS_NONE = 0,
-    SSI_CS_LOW,
-    SSI_CS_HIGH,
-} SSICSMode;
-
-/* Slave devices.  */
-typedef struct SSISlaveClass {
-    DeviceClass parent_class;
-
-    int (*init)(SSISlave *dev);
-
-    /* if you have standard or no CS behaviour, just override transfer.
-     * This is called when the device cs is active (true by default).
-     */
-    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
-    /* called when the CS line changes. Optional, devices only need to implement
-     * this if they have side effects associated with the cs line (beyond
-     * tristating the txrx lines).
-     */
-    int (*set_cs)(SSISlave *dev, bool select);
-    /* define whether or not CS exists and is active low/high */
-    SSICSMode cs_polarity;
-
-    /* if you have non-standard CS behaviour override this to take control
-     * of the CS behaviour at the device level. transfer, set_cs, and
-     * cs_polarity are unused if this is overwritten. Transfer_raw will
-     * always be called for the device for every txrx access to the parent bus
-     */
-    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
-} SSISlaveClass;
-
-struct SSISlave {
-    DeviceState parent_obj;
-
-    /* Chip select state */
-    bool cs;
-};
-
-#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
-
-extern const VMStateDescription vmstate_ssi_slave;
-
-#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(SSISlave),                                  \
-    .vmsd       = &vmstate_ssi_slave,                                \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
-}
-
-DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
-DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
-
-/* Master interface.  */
-SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
-
-uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
-
-/* Automatically connect all children nodes a spi controller as slaves */
-void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
-                             SSIBus *bus);
-
-/* max111x.c */
-void max111x_set_input(DeviceState *dev, int line, uint8_t value);
-
-#endif
include/hw/ssi/ssi.h new file +96 -1
new file mode 100644
index 0000000..4a0a539
@@ -0,0 +1,96 @@
+/* QEMU Synchronous Serial Interface support.  */
+
+/* In principle SSI is a point-point interface.  As such the qemu
+   implementation has a single slave device on a "bus".
+   However it is fairly common for boards to have multiple slaves
+   connected to a single master, and select devices with an external
+   chip select.  This is implemented in qemu by having an explicit mux device.
+   It is assumed that master and slave are both using the same transfer width.
+   */
+
+#ifndef QEMU_SSI_H
+#define QEMU_SSI_H
+
+#include "hw/qdev.h"
+
+typedef struct SSISlave SSISlave;
+typedef struct SSISlaveClass SSISlaveClass;
+typedef enum SSICSMode SSICSMode;
+
+#define TYPE_SSI_SLAVE "ssi-slave"
+#define SSI_SLAVE(obj) \
+     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
+
+#define SSI_GPIO_CS "ssi-gpio-cs"
+
+enum SSICSMode {
+    SSI_CS_NONE = 0,
+    SSI_CS_LOW,
+    SSI_CS_HIGH,
+};
+
+/* Slave devices.  */
+struct SSISlaveClass {
+    DeviceClass parent_class;
+
+    int (*init)(SSISlave *dev);
+
+    /* if you have standard or no CS behaviour, just override transfer.
+     * This is called when the device cs is active (true by default).
+     */
+    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
+    /* called when the CS line changes. Optional, devices only need to implement
+     * this if they have side effects associated with the cs line (beyond
+     * tristating the txrx lines).
+     */
+    int (*set_cs)(SSISlave *dev, bool select);
+    /* define whether or not CS exists and is active low/high */
+    SSICSMode cs_polarity;
+
+    /* if you have non-standard CS behaviour override this to take control
+     * of the CS behaviour at the device level. transfer, set_cs, and
+     * cs_polarity are unused if this is overwritten. Transfer_raw will
+     * always be called for the device for every txrx access to the parent bus
+     */
+    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
+};
+
+struct SSISlave {
+    DeviceState parent_obj;
+
+    /* Chip select state */
+    bool cs;
+};
+
+#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
+
+extern const VMStateDescription vmstate_ssi_slave;
+
+#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(SSISlave),                                  \
+    .vmsd       = &vmstate_ssi_slave,                                \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
+}
+
+DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
+
+/* Master interface.  */
+SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
+
+uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
+
+/* Automatically connect all children nodes a spi controller as slaves */
+void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
+                             SSIBus *bus);
+
+/* max111x.c */
+void max111x_set_input(DeviceState *dev, int line, uint8_t value);
+
+#endif
--

1.9.1

#5 lore raw

Re: [Qemu-devel] [PATCH v1 1/3] ssi: Move ssi.h into a seperate directory

Quoted 40 lines · Peter Crosthwaite
Quoted 29 lines · Alistair Francis
Quoted 27 lines · Peter Crosthwaite
Quoted 24 lines · Alistair Francis

Move the ssi.h include file into the ssi directory.

---

 hw/arm/pxa2xx.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/arm/strongarm.c                  |  2 +-
 hw/arm/tosa.c                       |  2 +-
 hw/arm/xilinx_zynq.c                |  2 +-
 hw/arm/z2.c                         |  2 +-
 hw/block/m25p80.c                   |  2 +-
 hw/display/ads7846.c                |  2 +-
 hw/display/ssd0323.c                |  2 +-
 hw/microblaze/petalogix_ml605_mmu.c |  2 +-
 hw/misc/max111x.c                   |  2 +-
 hw/sd/ssi-sd.c                      |  2 +-
 hw/ssi/pl022.c                      |  2 +-
 hw/ssi/ssi.c                        |  2 +-
 hw/ssi/xilinx_spi.c                 |  2 +-
 hw/ssi/xilinx_spips.c               |  2 +-
 include/hw/ssi.h                    | 94 ------------------------------------
 include/hw/ssi/ssi.h                | 96 +++++++++++++++++++++++++++++++++++++
Quoted 8 lines
Quoted 3 lines

Curious as to why git didn't pick this up as a rename (I think it should handle small diffs in the renaming). Do you have rename detection turned on?

I do have rename detection turned on. I think the reason it didn't is because I tiddied up the code a little bit when I moved it. Checkpatch was reproting errors on the struct typedeffs so I had to change that.

Quoted 4 lines

Can we do it in two steps and take the hit on the checkpatch fails on P1? Checkpatch fails are acceptable for pure mass-code movements. There is also probably some way to set your rename detction to higher level that should pick it up.

I managed to change the rename detection (-M for git format-patch) and now the diff passes checkpatch and indicates a rename.

Thanks,

Alistair

Quoted 444 lines

Regards,
Peter

Quoted 439 lines

Thanks,

Alistair

Quoted 435 lines

Regards,
Peter

Quoted 430 lines
 19 files changed, 113 insertions(+), 111 deletions(-)
 delete mode 100644 include/hw/ssi.h
 create mode 100644 include/hw/ssi/ssi.h
hw/arm/pxa2xx.c +1 -1
index 164260a..534c06f 100644
@@ -12,7 +12,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/char/serial.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/char.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
hw/arm/spitz.c +1 -1
index 2af03be..c9405af 100644
@@ -16,7 +16,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/pcmcia.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
 #include "hw/devices.h"
hw/arm/stellaris.c +1 -1
index 3d6486f..c785e90 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "qemu/timer.h"
hw/arm/strongarm.c +1 -1
index 9624ecb..4d2ba02 100644
@@ -34,7 +34,7 @@
 #include "hw/arm/arm.h"
 #include "sysemu/char.h"
 #include "sysemu/sysemu.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG
 
hw/arm/tosa.c +1 -1
index 51d0b89..6b210a6 100644
@@ -19,7 +19,7 @@
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
hw/arm/xilinx_zynq.c +1 -1
index 9f89483..9db9602 100644
@@ -24,7 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/error-report.h"
 
 #define NUM_SPI_FLASHES 4
hw/arm/z2.c +1 -1
index b44eb76..c82fe2c 100644
@@ -16,7 +16,7 @@
 #include "hw/arm/arm.h"
 #include "hw/devices.h"
 #include "hw/i2c/i2c.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/boards.h"
 #include "sysemu/sysemu.h"
 #include "hw/block/flash.h"
hw/block/m25p80.c +1 -1
index efc43dd..44830c7 100644
@@ -24,7 +24,7 @@
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifndef M25P80_ERR_DEBUG
 #define M25P80_ERR_DEBUG 0
hw/display/ads7846.c +1 -1
index 3f35369..cb82317 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 typedef struct {
hw/display/ssd0323.c +1 -1
index 9727007..7545da8 100644
@@ -10,7 +10,7 @@
 /* The controller can support a variety of different displays, but we only
    implement one.  Most of the commends relating to brightness and geometry
    setup are ignored. */
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "ui/console.h"
 
 //#define DEBUG_SSD0323 1
hw/microblaze/petalogix_ml605_mmu.c +1 -1
index 462060f..5366cec 100644
@@ -35,7 +35,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/char/serial.h"
 #include "exec/address-spaces.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #include "boot.h"
 
hw/misc/max111x.c +1 -1
index bef3651..d619d61 100644
@@ -10,7 +10,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 typedef struct {
     SSISlave parent_obj;
hw/sd/ssi-sd.c +1 -1
index e4b2d4f..4fe00fd 100644
@@ -12,7 +12,7 @@
 
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "hw/sd.h"
 
 //#define DEBUG_SSI_SD 1
hw/ssi/pl022.c +1 -1
index 61d568f..0bbf633 100644
@@ -8,7 +8,7 @@
  */
 
 #include "hw/sysbus.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 //#define DEBUG_PL022 1
 
hw/ssi/ssi.c +1 -1
index 2aab79b..a0f57c0 100644
@@ -12,7 +12,7 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 struct SSIBus {
     BusState parent_obj;
hw/ssi/xilinx_spi.c +1 -1
index 620573c..94bb2a7 100644
@@ -29,7 +29,7 @@
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
 
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 
 #ifdef XILINX_SPI_ERR_DEBUG
 #define DB_PRINT(...) do { \
hw/ssi/xilinx_spips.c +1 -1
index 0910f54..e9471ff 100644
@@ -27,7 +27,7 @@
 #include "hw/ptimer.h"
 #include "qemu/log.h"
 #include "qemu/fifo8.h"
-#include "hw/ssi.h"
+#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
include/hw/ssi.h deleted +0 -94
deleted file mode 100644
index df0f838..0000000
@@ -1,94 +0,0 @@
-/* QEMU Synchronous Serial Interface support.  */
-
-/* In principle SSI is a point-point interface.  As such the qemu
-   implementation has a single slave device on a "bus".
-   However it is fairly common for boards to have multiple slaves
-   connected to a single master, and select devices with an external
-   chip select.  This is implemented in qemu by having an explicit mux device.
-   It is assumed that master and slave are both using the same transfer width.
-   */
-
-#ifndef QEMU_SSI_H
-#define QEMU_SSI_H
-
-#include "hw/qdev.h"
-
-typedef struct SSISlave SSISlave;
-
-#define TYPE_SSI_SLAVE "ssi-slave"
-#define SSI_SLAVE(obj) \
-     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_CLASS(klass) \
-     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
-#define SSI_SLAVE_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
-
-#define SSI_GPIO_CS "ssi-gpio-cs"
-
-typedef enum {
-    SSI_CS_NONE = 0,
-    SSI_CS_LOW,
-    SSI_CS_HIGH,
-} SSICSMode;
-
-/* Slave devices.  */
-typedef struct SSISlaveClass {
-    DeviceClass parent_class;
-
-    int (*init)(SSISlave *dev);
-
-    /* if you have standard or no CS behaviour, just override transfer.
-     * This is called when the device cs is active (true by default).
-     */
-    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
-    /* called when the CS line changes. Optional, devices only need to implement
-     * this if they have side effects associated with the cs line (beyond
-     * tristating the txrx lines).
-     */
-    int (*set_cs)(SSISlave *dev, bool select);
-    /* define whether or not CS exists and is active low/high */
-    SSICSMode cs_polarity;
-
-    /* if you have non-standard CS behaviour override this to take control
-     * of the CS behaviour at the device level. transfer, set_cs, and
-     * cs_polarity are unused if this is overwritten. Transfer_raw will
-     * always be called for the device for every txrx access to the parent bus
-     */
-    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
-} SSISlaveClass;
-
-struct SSISlave {
-    DeviceState parent_obj;
-
-    /* Chip select state */
-    bool cs;
-};
-
-#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
-
-extern const VMStateDescription vmstate_ssi_slave;
-
-#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
-    .name       = (stringify(_field)),                               \
-    .size       = sizeof(SSISlave),                                  \
-    .vmsd       = &vmstate_ssi_slave,                                \
-    .flags      = VMS_STRUCT,                                        \
-    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
-}
-
-DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
-DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
-
-/* Master interface.  */
-SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
-
-uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
-
-/* Automatically connect all children nodes a spi controller as slaves */
-void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
-                             SSIBus *bus);
-
-/* max111x.c */
-void max111x_set_input(DeviceState *dev, int line, uint8_t value);
-
-#endif
include/hw/ssi/ssi.h new file +96 -1
new file mode 100644
index 0000000..4a0a539
@@ -0,0 +1,96 @@
+/* QEMU Synchronous Serial Interface support.  */
+
+/* In principle SSI is a point-point interface.  As such the qemu
+   implementation has a single slave device on a "bus".
+   However it is fairly common for boards to have multiple slaves
+   connected to a single master, and select devices with an external
+   chip select.  This is implemented in qemu by having an explicit mux device.
+   It is assumed that master and slave are both using the same transfer width.
+   */
+
+#ifndef QEMU_SSI_H
+#define QEMU_SSI_H
+
+#include "hw/qdev.h"
+
+typedef struct SSISlave SSISlave;
+typedef struct SSISlaveClass SSISlaveClass;
+typedef enum SSICSMode SSICSMode;
+
+#define TYPE_SSI_SLAVE "ssi-slave"
+#define SSI_SLAVE(obj) \
+     OBJECT_CHECK(SSISlave, (obj), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(SSISlaveClass, (klass), TYPE_SSI_SLAVE)
+#define SSI_SLAVE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(SSISlaveClass, (obj), TYPE_SSI_SLAVE)
+
+#define SSI_GPIO_CS "ssi-gpio-cs"
+
+enum SSICSMode {
+    SSI_CS_NONE = 0,
+    SSI_CS_LOW,
+    SSI_CS_HIGH,
+};
+
+/* Slave devices.  */
+struct SSISlaveClass {
+    DeviceClass parent_class;
+
+    int (*init)(SSISlave *dev);
+
+    /* if you have standard or no CS behaviour, just override transfer.
+     * This is called when the device cs is active (true by default).
+     */
+    uint32_t (*transfer)(SSISlave *dev, uint32_t val);
+    /* called when the CS line changes. Optional, devices only need to implement
+     * this if they have side effects associated with the cs line (beyond
+     * tristating the txrx lines).
+     */
+    int (*set_cs)(SSISlave *dev, bool select);
+    /* define whether or not CS exists and is active low/high */
+    SSICSMode cs_polarity;
+
+    /* if you have non-standard CS behaviour override this to take control
+     * of the CS behaviour at the device level. transfer, set_cs, and
+     * cs_polarity are unused if this is overwritten. Transfer_raw will
+     * always be called for the device for every txrx access to the parent bus
+     */
+    uint32_t (*transfer_raw)(SSISlave *dev, uint32_t val);
+};
+
+struct SSISlave {
+    DeviceState parent_obj;
+
+    /* Chip select state */
+    bool cs;
+};
+
+#define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
+
+extern const VMStateDescription vmstate_ssi_slave;
+
+#define VMSTATE_SSI_SLAVE(_field, _state) {                          \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(SSISlave),                                  \
+    .vmsd       = &vmstate_ssi_slave,                                \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, SSISlave),    \
+}
+
+DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
+DeviceState *ssi_create_slave_no_init(SSIBus *bus, const char *name);
+
+/* Master interface.  */
+SSIBus *ssi_create_bus(DeviceState *parent, const char *name);
+
+uint32_t ssi_transfer(SSIBus *bus, uint32_t val);
+
+/* Automatically connect all children nodes a spi controller as slaves */
+void ssi_auto_connect_slaves(DeviceState *parent, qemu_irq *cs_lines,
+                             SSIBus *bus);
+
+/* max111x.c */
+void max111x_set_input(DeviceState *dev, int line, uint8_t value);
+
+#endif
--

1.9.1

#6 lore raw

PATCH 2/3 xilinx_spips: Seperate the state struct into a header

In reply to Alistair Francis

Seperate out the XilinxSPIPS struct into a seperate header file.

---

 hw/ssi/xilinx_spips.c         | 104 +-------------------------------
 include/hw/ssi/xilinx_spips.h | 134 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+), 103 deletions(-)
 create mode 100644 include/hw/ssi/xilinx_spips.h
hw/ssi/xilinx_spips.c +1 -103
index e9471ff..417c581 100644
@@ -26,9 +26,8 @@
 #include "sysemu/sysemu.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
-#include "qemu/fifo8.h"
-#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
+#include "hw/ssi/xilinx_spips.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
 #define XILINX_SPIPS_ERR_DEBUG 0
@@ -41,70 +40,6 @@
     } \
 } while (0);
 
-/* config register */
-#define R_CONFIG            (0x00 / 4)
-#define IFMODE              (1U << 31)
-#define ENDIAN              (1 << 26)
-#define MODEFAIL_GEN_EN     (1 << 17)
-#define MAN_START_COM       (1 << 16)
-#define MAN_START_EN        (1 << 15)
-#define MANUAL_CS           (1 << 14)
-#define CS                  (0xF << 10)
-#define CS_SHIFT            (10)
-#define PERI_SEL            (1 << 9)
-#define REF_CLK             (1 << 8)
-#define FIFO_WIDTH          (3 << 6)
-#define BAUD_RATE_DIV       (7 << 3)
-#define CLK_PH              (1 << 2)
-#define CLK_POL             (1 << 1)
-#define MODE_SEL            (1 << 0)
-#define R_CONFIG_RSVD       (0x7bf40000)
-
-/* interrupt mechanism */
-#define R_INTR_STATUS       (0x04 / 4)
-#define R_INTR_EN           (0x08 / 4)
-#define R_INTR_DIS          (0x0C / 4)
-#define R_INTR_MASK         (0x10 / 4)
-#define IXR_TX_FIFO_UNDERFLOW   (1 << 6)
-#define IXR_RX_FIFO_FULL        (1 << 5)
-#define IXR_RX_FIFO_NOT_EMPTY   (1 << 4)
-#define IXR_TX_FIFO_FULL        (1 << 3)
-#define IXR_TX_FIFO_NOT_FULL    (1 << 2)
-#define IXR_TX_FIFO_MODE_FAIL   (1 << 1)
-#define IXR_RX_FIFO_OVERFLOW    (1 << 0)
-#define IXR_ALL                 ((IXR_TX_FIFO_UNDERFLOW<<1)-1)
-
-#define R_EN                (0x14 / 4)
-#define R_DELAY             (0x18 / 4)
-#define R_TX_DATA           (0x1C / 4)
-#define R_RX_DATA           (0x20 / 4)
-#define R_SLAVE_IDLE_COUNT  (0x24 / 4)
-#define R_TX_THRES          (0x28 / 4)
-#define R_RX_THRES          (0x2C / 4)
-#define R_TXD1              (0x80 / 4)
-#define R_TXD2              (0x84 / 4)
-#define R_TXD3              (0x88 / 4)
-
-#define R_LQSPI_CFG         (0xa0 / 4)
-#define R_LQSPI_CFG_RESET       0x03A002EB
-#define LQSPI_CFG_LQ_MODE       (1U << 31)
-#define LQSPI_CFG_TWO_MEM       (1 << 30)
-#define LQSPI_CFG_SEP_BUS       (1 << 30)
-#define LQSPI_CFG_U_PAGE        (1 << 28)
-#define LQSPI_CFG_MODE_EN       (1 << 25)
-#define LQSPI_CFG_MODE_WIDTH    8
-#define LQSPI_CFG_MODE_SHIFT    16
-#define LQSPI_CFG_DUMMY_WIDTH   3
-#define LQSPI_CFG_DUMMY_SHIFT   8
-#define LQSPI_CFG_INST_CODE     0xFF
-
-#define R_LQSPI_STS         (0xA4 / 4)
-#define LQSPI_STS_WR_RECVD      (1 << 1)
-
-#define R_MOD_ID            (0xFC / 4)
-
-#define R_MAX (R_MOD_ID+1)
-
 /* size of TXRX FIFOs */
 #define RXFF_A          32
 #define TXFF_A          32
@@ -135,30 +70,6 @@ typedef enum {
 } FlashCMD;
 
 typedef struct {
-    SysBusDevice parent_obj;
-
-    MemoryRegion iomem;
-    MemoryRegion mmlqspi;
-
-    qemu_irq irq;
-    int irqline;
-
-    uint8_t num_cs;
-    uint8_t num_busses;
-
-    uint8_t snoop_state;
-    qemu_irq *cs_lines;
-    SSIBus **spi;
-
-    Fifo8 rx_fifo;
-    Fifo8 tx_fifo;
-
-    uint8_t num_txrx_bytes;
-
-    uint32_t regs[R_MAX];
-} XilinxSPIPS;
-
-typedef struct {
     XilinxSPIPS parent_obj;
 
     uint8_t lqspi_buf[LQSPI_CACHE_SIZE];
@@ -174,19 +85,6 @@ typedef struct XilinxSPIPSClass {
     uint32_t tx_fifo_size;
 } XilinxSPIPSClass;
 
-#define TYPE_XILINX_SPIPS "xlnx.ps7-spi"
-#define TYPE_XILINX_QSPIPS "xlnx.ps7-qspi"
-
-#define XILINX_SPIPS(obj) \
-     OBJECT_CHECK(XilinxSPIPS, (obj), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_CLASS(klass) \
-     OBJECT_CLASS_CHECK(XilinxSPIPSClass, (klass), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(XilinxSPIPSClass, (obj), TYPE_XILINX_SPIPS)
-
-#define XILINX_QSPIPS(obj) \
-     OBJECT_CHECK(XilinxQSPIPS, (obj), TYPE_XILINX_QSPIPS)
-
 static inline int num_effective_busses(XilinxSPIPS *s)
 {
     return (s->regs[R_LQSPI_CFG] & LQSPI_CFG_SEP_BUS &&
include/hw/ssi/xilinx_spips.h new file +134 -0

134 lines not on this page · raw message

Signature · 1 line
1.9.1
#7 lore raw

Re: [Qemu-devel] [PATCH v1 2/3] xilinx_spips: Seperate the state struct into a header

Quoted 27 lines · Alistair Francis

Seperate out the XilinxSPIPS struct into a seperate header file.

---

 hw/ssi/xilinx_spips.c         | 104 +-------------------------------
 include/hw/ssi/xilinx_spips.h | 134 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+), 103 deletions(-)
 create mode 100644 include/hw/ssi/xilinx_spips.h
hw/ssi/xilinx_spips.c +1 -2
index e9471ff..417c581 100644
@@ -26,9 +26,8 @@
 #include "sysemu/sysemu.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
-#include "qemu/fifo8.h"
-#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
+#include "hw/ssi/xilinx_spips.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
 #define XILINX_SPIPS_ERR_DEBUG 0

hw/ssi/xilinx_spips.c line 47

Quoted 7 lines
hw/ssi/xilinx_spips.c +0 -4
@@ -41,70 +40,6 @@
     } \
 } while (0);
 
-/* config register */
-#define R_CONFIG            (0x00 / 4)
-#define IFMODE              (1U << 31)
-#define ENDIAN              (1 << 26)

Some of these macro names are too generic for the global namespace. Until we have a proper solution on how to handle namespace collisions for programmers model macros, I suggest taking the bare minimum to the header (which is going to whatever is used for the struct def itself). Preface those defs with XLNX_SPIPS_ accordingly (if there are any - probably just R_MAX).

Regards,
Peter

Quoted 257 lines
hw/ssi/xilinx_spips.c +0 -97
-#define MODEFAIL_GEN_EN     (1 << 17)
-#define MAN_START_COM       (1 << 16)
-#define MAN_START_EN        (1 << 15)
-#define MANUAL_CS           (1 << 14)
-#define CS                  (0xF << 10)
-#define CS_SHIFT            (10)
-#define PERI_SEL            (1 << 9)
-#define REF_CLK             (1 << 8)
-#define FIFO_WIDTH          (3 << 6)
-#define BAUD_RATE_DIV       (7 << 3)
-#define CLK_PH              (1 << 2)
-#define CLK_POL             (1 << 1)
-#define MODE_SEL            (1 << 0)
-#define R_CONFIG_RSVD       (0x7bf40000)
-
-/* interrupt mechanism */
-#define R_INTR_STATUS       (0x04 / 4)
-#define R_INTR_EN           (0x08 / 4)
-#define R_INTR_DIS          (0x0C / 4)
-#define R_INTR_MASK         (0x10 / 4)
-#define IXR_TX_FIFO_UNDERFLOW   (1 << 6)
-#define IXR_RX_FIFO_FULL        (1 << 5)
-#define IXR_RX_FIFO_NOT_EMPTY   (1 << 4)
-#define IXR_TX_FIFO_FULL        (1 << 3)
-#define IXR_TX_FIFO_NOT_FULL    (1 << 2)
-#define IXR_TX_FIFO_MODE_FAIL   (1 << 1)
-#define IXR_RX_FIFO_OVERFLOW    (1 << 0)
-#define IXR_ALL                 ((IXR_TX_FIFO_UNDERFLOW<<1)-1)
-
-#define R_EN                (0x14 / 4)
-#define R_DELAY             (0x18 / 4)
-#define R_TX_DATA           (0x1C / 4)
-#define R_RX_DATA           (0x20 / 4)
-#define R_SLAVE_IDLE_COUNT  (0x24 / 4)
-#define R_TX_THRES          (0x28 / 4)
-#define R_RX_THRES          (0x2C / 4)
-#define R_TXD1              (0x80 / 4)
-#define R_TXD2              (0x84 / 4)
-#define R_TXD3              (0x88 / 4)
-
-#define R_LQSPI_CFG         (0xa0 / 4)
-#define R_LQSPI_CFG_RESET       0x03A002EB
-#define LQSPI_CFG_LQ_MODE       (1U << 31)
-#define LQSPI_CFG_TWO_MEM       (1 << 30)
-#define LQSPI_CFG_SEP_BUS       (1 << 30)
-#define LQSPI_CFG_U_PAGE        (1 << 28)
-#define LQSPI_CFG_MODE_EN       (1 << 25)
-#define LQSPI_CFG_MODE_WIDTH    8
-#define LQSPI_CFG_MODE_SHIFT    16
-#define LQSPI_CFG_DUMMY_WIDTH   3
-#define LQSPI_CFG_DUMMY_SHIFT   8
-#define LQSPI_CFG_INST_CODE     0xFF
-
-#define R_LQSPI_STS         (0xA4 / 4)
-#define LQSPI_STS_WR_RECVD      (1 << 1)
-
-#define R_MOD_ID            (0xFC / 4)
-
-#define R_MAX (R_MOD_ID+1)
-
 /* size of TXRX FIFOs */
 #define RXFF_A          32
 #define TXFF_A          32
@@ -135,30 +70,6 @@ typedef enum {
 } FlashCMD;
 
 typedef struct {
-    SysBusDevice parent_obj;
-
-    MemoryRegion iomem;
-    MemoryRegion mmlqspi;
-
-    qemu_irq irq;
-    int irqline;
-
-    uint8_t num_cs;
-    uint8_t num_busses;
-
-    uint8_t snoop_state;
-    qemu_irq *cs_lines;
-    SSIBus **spi;
-
-    Fifo8 rx_fifo;
-    Fifo8 tx_fifo;
-
-    uint8_t num_txrx_bytes;
-
-    uint32_t regs[R_MAX];
-} XilinxSPIPS;
-
-typedef struct {
     XilinxSPIPS parent_obj;
 
     uint8_t lqspi_buf[LQSPI_CACHE_SIZE];
@@ -174,19 +85,6 @@ typedef struct XilinxSPIPSClass {
     uint32_t tx_fifo_size;
 } XilinxSPIPSClass;
 
-#define TYPE_XILINX_SPIPS "xlnx.ps7-spi"
-#define TYPE_XILINX_QSPIPS "xlnx.ps7-qspi"
-
-#define XILINX_SPIPS(obj) \
-     OBJECT_CHECK(XilinxSPIPS, (obj), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_CLASS(klass) \
-     OBJECT_CLASS_CHECK(XilinxSPIPSClass, (klass), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(XilinxSPIPSClass, (obj), TYPE_XILINX_SPIPS)
-
-#define XILINX_QSPIPS(obj) \
-     OBJECT_CHECK(XilinxQSPIPS, (obj), TYPE_XILINX_QSPIPS)
-
 static inline int num_effective_busses(XilinxSPIPS *s)
 {
     return (s->regs[R_LQSPI_CFG] & LQSPI_CFG_SEP_BUS &&
include/hw/ssi/xilinx_spips.h new file +134 -1
new file mode 100644
index 0000000..31671ec
@@ -0,0 +1,134 @@
+/*
+ * Header file for the Xilinx Zynq SPI controller
+ *
+ * Copyright (C) 2015 Xilinx Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef XLNX_SPIPS_H
+#define XLNX_SPIPS_H
+
+#include "hw/ssi/ssi.h"
+#include "qemu/fifo8.h"
+
+typedef struct XilinxSPIPS XilinxSPIPS;
+
+/* config register */
+#define R_CONFIG                (0x00 / 4)
+#define IFMODE                  (1U << 31)
+#define ENDIAN                  (1 << 26)
+#define MODEFAIL_GEN_EN         (1 << 17)
+#define MAN_START_COM           (1 << 16)
+#define MAN_START_EN            (1 << 15)
+#define MANUAL_CS               (1 << 14)
+#define CS                      (0xF << 10)
+#define CS_SHIFT                (10)
+#define PERI_SEL                (1 << 9)
+#define REF_CLK                 (1 << 8)
+#define FIFO_WIDTH              (3 << 6)
+#define BAUD_RATE_DIV           (7 << 3)
+#define CLK_PH                  (1 << 2)
+#define CLK_POL                 (1 << 1)
+#define MODE_SEL                (1 << 0)
+#define R_CONFIG_RSVD           (0x7bf40000)
+
+/* interrupt mechanism */
+#define R_INTR_STATUS           (0x04 / 4)
+#define R_INTR_EN               (0x08 / 4)
+#define R_INTR_DIS              (0x0C / 4)
+#define R_INTR_MASK             (0x10 / 4)
+#define IXR_TX_FIFO_UNDERFLOW   (1 << 6)
+#define IXR_RX_FIFO_FULL        (1 << 5)
+#define IXR_RX_FIFO_NOT_EMPTY   (1 << 4)
+#define IXR_TX_FIFO_FULL        (1 << 3)
+#define IXR_TX_FIFO_NOT_FULL    (1 << 2)
+#define IXR_TX_FIFO_MODE_FAIL   (1 << 1)
+#define IXR_RX_FIFO_OVERFLOW    (1 << 0)
+#define IXR_ALL                 ((IXR_TX_FIFO_UNDERFLOW << 1) - 1)
+
+#define R_EN                    (0x14 / 4)
+#define R_DELAY                 (0x18 / 4)
+#define R_TX_DATA               (0x1C / 4)
+#define R_RX_DATA               (0x20 / 4)
+#define R_SLAVE_IDLE_COUNT      (0x24 / 4)
+#define R_TX_THRES              (0x28 / 4)
+#define R_RX_THRES              (0x2C / 4)
+#define R_TXD1                  (0x80 / 4)
+#define R_TXD2                  (0x84 / 4)
+#define R_TXD3                  (0x88 / 4)
+
+#define R_LQSPI_CFG             (0xa0 / 4)
+#define R_LQSPI_CFG_RESET       0x03A002EB
+#define LQSPI_CFG_LQ_MODE       (1U << 31)
+#define LQSPI_CFG_TWO_MEM       (1 << 30)
+#define LQSPI_CFG_SEP_BUS       (1 << 30)
+#define LQSPI_CFG_U_PAGE        (1 << 28)
+#define LQSPI_CFG_MODE_EN       (1 << 25)
+#define LQSPI_CFG_MODE_WIDTH    8
+#define LQSPI_CFG_MODE_SHIFT    16
+#define LQSPI_CFG_DUMMY_WIDTH   3
+#define LQSPI_CFG_DUMMY_SHIFT   8
+#define LQSPI_CFG_INST_CODE     0xFF
+
+#define R_LQSPI_STS             (0xA4 / 4)
+#define LQSPI_STS_WR_RECVD      (1 << 1)
+
+#define R_MOD_ID                (0xFC / 4)
+
+#define R_MAX                   (R_MOD_ID + 1)
+
+struct XilinxSPIPS {
+    SysBusDevice parent_obj;
+
+    MemoryRegion iomem;
+    MemoryRegion mmlqspi;
+
+    qemu_irq irq;
+    int irqline;
+
+    uint8_t num_cs;
+    uint8_t num_busses;
+
+    uint8_t snoop_state;
+    qemu_irq *cs_lines;
+    SSIBus **spi;
+
+    Fifo8 rx_fifo;
+    Fifo8 tx_fifo;
+
+    uint8_t num_txrx_bytes;
+
+    uint32_t regs[R_MAX];
+};
+
+#define TYPE_XILINX_SPIPS "xlnx.ps7-spi"
+#define TYPE_XILINX_QSPIPS "xlnx.ps7-qspi"
+
+#define XILINX_SPIPS(obj) \
+     OBJECT_CHECK(XilinxSPIPS, (obj), TYPE_XILINX_SPIPS)
+#define XILINX_SPIPS_CLASS(klass) \
+     OBJECT_CLASS_CHECK(XilinxSPIPSClass, (klass), TYPE_XILINX_SPIPS)
+#define XILINX_SPIPS_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(XilinxSPIPSClass, (obj), TYPE_XILINX_SPIPS)
+
+#define XILINX_QSPIPS(obj) \
+     OBJECT_CHECK(XilinxQSPIPS, (obj), TYPE_XILINX_QSPIPS)
+
+#endif /* XLNX_SPIPS_H */
--

1.9.1

#8 lore raw

Re: [Qemu-devel] [PATCH v1 2/3] xilinx_spips: Seperate the state struct into a header

Quoted 32 lines · Peter Crosthwaite
Quoted 30 lines · Alistair Francis

Seperate out the XilinxSPIPS struct into a seperate header file.

---

 hw/ssi/xilinx_spips.c         | 104 +-------------------------------
 include/hw/ssi/xilinx_spips.h | 134 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+), 103 deletions(-)
 create mode 100644 include/hw/ssi/xilinx_spips.h
hw/ssi/xilinx_spips.c +1 -2
index e9471ff..417c581 100644
@@ -26,9 +26,8 @@
 #include "sysemu/sysemu.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
-#include "qemu/fifo8.h"
-#include "hw/ssi/ssi.h"
 #include "qemu/bitops.h"
+#include "hw/ssi/xilinx_spips.h"
 
 #ifndef XILINX_SPIPS_ERR_DEBUG
 #define XILINX_SPIPS_ERR_DEBUG 0
@@ -41,70 +40,6 @@
     } \
 } while (0);
 
Quoted 11 lines

hw/ssi/xilinx_spips.c line 47

Quoted 4 lines
hw/ssi/xilinx_spips.c +0 -4
-/* config register */
-#define R_CONFIG            (0x00 / 4)
-#define IFMODE              (1U << 31)
-#define ENDIAN              (1 << 26)

Some of these macro names are too generic for the global namespace. Until we have a proper solution on how to handle namespace collisions for programmers model macros, I suggest taking the bare minimum to the header (which is going to whatever is used for the struct def itself). Preface those defs with XLNX_SPIPS_ accordingly (if there are any - probably just R_MAX).

Ok, I have just taken the bare minimum into the header.

The only problem with that is now some of the macros have XLNX_SPIS_* and some don't, but that isn't really a big problem.

Thanks,

Alistair

Quoted 262 lines

Regards,
Peter

Quoted 257 lines
hw/ssi/xilinx_spips.c +0 -97
-#define MODEFAIL_GEN_EN     (1 << 17)
-#define MAN_START_COM       (1 << 16)
-#define MAN_START_EN        (1 << 15)
-#define MANUAL_CS           (1 << 14)
-#define CS                  (0xF << 10)
-#define CS_SHIFT            (10)
-#define PERI_SEL            (1 << 9)
-#define REF_CLK             (1 << 8)
-#define FIFO_WIDTH          (3 << 6)
-#define BAUD_RATE_DIV       (7 << 3)
-#define CLK_PH              (1 << 2)
-#define CLK_POL             (1 << 1)
-#define MODE_SEL            (1 << 0)
-#define R_CONFIG_RSVD       (0x7bf40000)
-
-/* interrupt mechanism */
-#define R_INTR_STATUS       (0x04 / 4)
-#define R_INTR_EN           (0x08 / 4)
-#define R_INTR_DIS          (0x0C / 4)
-#define R_INTR_MASK         (0x10 / 4)
-#define IXR_TX_FIFO_UNDERFLOW   (1 << 6)
-#define IXR_RX_FIFO_FULL        (1 << 5)
-#define IXR_RX_FIFO_NOT_EMPTY   (1 << 4)
-#define IXR_TX_FIFO_FULL        (1 << 3)
-#define IXR_TX_FIFO_NOT_FULL    (1 << 2)
-#define IXR_TX_FIFO_MODE_FAIL   (1 << 1)
-#define IXR_RX_FIFO_OVERFLOW    (1 << 0)
-#define IXR_ALL                 ((IXR_TX_FIFO_UNDERFLOW<<1)-1)
-
-#define R_EN                (0x14 / 4)
-#define R_DELAY             (0x18 / 4)
-#define R_TX_DATA           (0x1C / 4)
-#define R_RX_DATA           (0x20 / 4)
-#define R_SLAVE_IDLE_COUNT  (0x24 / 4)
-#define R_TX_THRES          (0x28 / 4)
-#define R_RX_THRES          (0x2C / 4)
-#define R_TXD1              (0x80 / 4)
-#define R_TXD2              (0x84 / 4)
-#define R_TXD3              (0x88 / 4)
-
-#define R_LQSPI_CFG         (0xa0 / 4)
-#define R_LQSPI_CFG_RESET       0x03A002EB
-#define LQSPI_CFG_LQ_MODE       (1U << 31)
-#define LQSPI_CFG_TWO_MEM       (1 << 30)
-#define LQSPI_CFG_SEP_BUS       (1 << 30)
-#define LQSPI_CFG_U_PAGE        (1 << 28)
-#define LQSPI_CFG_MODE_EN       (1 << 25)
-#define LQSPI_CFG_MODE_WIDTH    8
-#define LQSPI_CFG_MODE_SHIFT    16
-#define LQSPI_CFG_DUMMY_WIDTH   3
-#define LQSPI_CFG_DUMMY_SHIFT   8
-#define LQSPI_CFG_INST_CODE     0xFF
-
-#define R_LQSPI_STS         (0xA4 / 4)
-#define LQSPI_STS_WR_RECVD      (1 << 1)
-
-#define R_MOD_ID            (0xFC / 4)
-
-#define R_MAX (R_MOD_ID+1)
-
 /* size of TXRX FIFOs */
 #define RXFF_A          32
 #define TXFF_A          32
@@ -135,30 +70,6 @@ typedef enum {
 } FlashCMD;
 
 typedef struct {
-    SysBusDevice parent_obj;
-
-    MemoryRegion iomem;
-    MemoryRegion mmlqspi;
-
-    qemu_irq irq;
-    int irqline;
-
-    uint8_t num_cs;
-    uint8_t num_busses;
-
-    uint8_t snoop_state;
-    qemu_irq *cs_lines;
-    SSIBus **spi;
-
-    Fifo8 rx_fifo;
-    Fifo8 tx_fifo;
-
-    uint8_t num_txrx_bytes;
-
-    uint32_t regs[R_MAX];
-} XilinxSPIPS;
-
-typedef struct {
     XilinxSPIPS parent_obj;
 
     uint8_t lqspi_buf[LQSPI_CACHE_SIZE];
@@ -174,19 +85,6 @@ typedef struct XilinxSPIPSClass {
     uint32_t tx_fifo_size;
 } XilinxSPIPSClass;
 
-#define TYPE_XILINX_SPIPS "xlnx.ps7-spi"
-#define TYPE_XILINX_QSPIPS "xlnx.ps7-qspi"
-
-#define XILINX_SPIPS(obj) \
-     OBJECT_CHECK(XilinxSPIPS, (obj), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_CLASS(klass) \
-     OBJECT_CLASS_CHECK(XilinxSPIPSClass, (klass), TYPE_XILINX_SPIPS)
-#define XILINX_SPIPS_GET_CLASS(obj) \
-     OBJECT_GET_CLASS(XilinxSPIPSClass, (obj), TYPE_XILINX_SPIPS)
-
-#define XILINX_QSPIPS(obj) \
-     OBJECT_CHECK(XilinxQSPIPS, (obj), TYPE_XILINX_QSPIPS)
-
 static inline int num_effective_busses(XilinxSPIPS *s)
 {
     return (s->regs[R_LQSPI_CFG] & LQSPI_CFG_SEP_BUS &&
include/hw/ssi/xilinx_spips.h new file +134 -1
new file mode 100644
index 0000000..31671ec
@@ -0,0 +1,134 @@
+/*
+ * Header file for the Xilinx Zynq SPI controller
+ *
+ * Copyright (C) 2015 Xilinx Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef XLNX_SPIPS_H
+#define XLNX_SPIPS_H
+
+#include "hw/ssi/ssi.h"
+#include "qemu/fifo8.h"
+
+typedef struct XilinxSPIPS XilinxSPIPS;
+
+/* config register */
+#define R_CONFIG                (0x00 / 4)
+#define IFMODE                  (1U << 31)
+#define ENDIAN                  (1 << 26)
+#define MODEFAIL_GEN_EN         (1 << 17)
+#define MAN_START_COM           (1 << 16)
+#define MAN_START_EN            (1 << 15)
+#define MANUAL_CS               (1 << 14)
+#define CS                      (0xF << 10)
+#define CS_SHIFT                (10)
+#define PERI_SEL                (1 << 9)
+#define REF_CLK                 (1 << 8)
+#define FIFO_WIDTH              (3 << 6)
+#define BAUD_RATE_DIV           (7 << 3)
+#define CLK_PH                  (1 << 2)
+#define CLK_POL                 (1 << 1)
+#define MODE_SEL                (1 << 0)
+#define R_CONFIG_RSVD           (0x7bf40000)
+
+/* interrupt mechanism */
+#define R_INTR_STATUS           (0x04 / 4)
+#define R_INTR_EN               (0x08 / 4)
+#define R_INTR_DIS              (0x0C / 4)
+#define R_INTR_MASK             (0x10 / 4)
+#define IXR_TX_FIFO_UNDERFLOW   (1 << 6)
+#define IXR_RX_FIFO_FULL        (1 << 5)
+#define IXR_RX_FIFO_NOT_EMPTY   (1 << 4)
+#define IXR_TX_FIFO_FULL        (1 << 3)
+#define IXR_TX_FIFO_NOT_FULL    (1 << 2)
+#define IXR_TX_FIFO_MODE_FAIL   (1 << 1)
+#define IXR_RX_FIFO_OVERFLOW    (1 << 0)
+#define IXR_ALL                 ((IXR_TX_FIFO_UNDERFLOW << 1) - 1)
+
+#define R_EN                    (0x14 / 4)
+#define R_DELAY                 (0x18 / 4)
+#define R_TX_DATA               (0x1C / 4)
+#define R_RX_DATA               (0x20 / 4)
+#define R_SLAVE_IDLE_COUNT      (0x24 / 4)
+#define R_TX_THRES              (0x28 / 4)
+#define R_RX_THRES              (0x2C / 4)
+#define R_TXD1                  (0x80 / 4)
+#define R_TXD2                  (0x84 / 4)
+#define R_TXD3                  (0x88 / 4)
+
+#define R_LQSPI_CFG             (0xa0 / 4)
+#define R_LQSPI_CFG_RESET       0x03A002EB
+#define LQSPI_CFG_LQ_MODE       (1U << 31)
+#define LQSPI_CFG_TWO_MEM       (1 << 30)
+#define LQSPI_CFG_SEP_BUS       (1 << 30)
+#define LQSPI_CFG_U_PAGE        (1 << 28)
+#define LQSPI_CFG_MODE_EN       (1 << 25)
+#define LQSPI_CFG_MODE_WIDTH    8
+#define LQSPI_CFG_MODE_SHIFT    16
+#define LQSPI_CFG_DUMMY_WIDTH   3
+#define LQSPI_CFG_DUMMY_SHIFT   8
+#define LQSPI_CFG_INST_CODE     0xFF
+
+#define R_LQSPI_STS             (0xA4 / 4)
+#define LQSPI_STS_WR_RECVD      (1 << 1)
+
+#define R_MOD_ID                (0xFC / 4)
+
+#define R_MAX                   (R_MOD_ID + 1)
+
+struct XilinxSPIPS {
+    SysBusDevice parent_obj;
+
+    MemoryRegion iomem;
+    MemoryRegion mmlqspi;
+
+    qemu_irq irq;
+    int irqline;
+
+    uint8_t num_cs;
+    uint8_t num_busses;
+
+    uint8_t snoop_state;
+    qemu_irq *cs_lines;
+    SSIBus **spi;
+
+    Fifo8 rx_fifo;
+    Fifo8 tx_fifo;
+
+    uint8_t num_txrx_bytes;
+
+    uint32_t regs[R_MAX];
+};
+
+#define TYPE_XILINX_SPIPS "xlnx.ps7-spi"
+#define TYPE_XILINX_QSPIPS "xlnx.ps7-qspi"
+
+#define XILINX_SPIPS(obj) \
+     OBJECT_CHECK(XilinxSPIPS, (obj), TYPE_XILINX_SPIPS)
+#define XILINX_SPIPS_CLASS(klass) \
+     OBJECT_CLASS_CHECK(XilinxSPIPSClass, (klass), TYPE_XILINX_SPIPS)
+#define XILINX_SPIPS_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(XilinxSPIPSClass, (obj), TYPE_XILINX_SPIPS)
+
+#define XILINX_QSPIPS(obj) \
+     OBJECT_CHECK(XilinxQSPIPS, (obj), TYPE_XILINX_QSPIPS)
+
+#endif /* XLNX_SPIPS_H */
--

1.9.1

A message that is not in the archive (sent off-list or not yet received): 8bb979aa8ed92d7ee31f2625fa161699d4424268.1443567485.git.alistair.francis@xilinx.com

#10 lore raw

Re: [Qemu-devel] [PATCH v1 3/3] xlnx-zynqmp: Connect the SPI devices

Quoted 65 lines · Alistair Francis

Connect the Xilinx SPI device to the ZynqMP model.

---

 hw/arm/xlnx-zynqmp.c         | 46 +++++++++++++++++++++++++++++++++++++++++++-
 include/hw/arm/xlnx-zynqmp.h |  4 ++++
 2 files changed, 49 insertions(+), 1 deletion(-)
hw/arm/xlnx-zynqmp.c +27 -1
index a9097f9..4b8d095 100644
@@ -48,6 +48,14 @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = {
     21, 22,
 };
 
+static const uint64_t spi_addr[XLNX_ZYNQMP_NUM_SPIS] = {
+    0xFF040000, 0xFF050000,
+};
+
+static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = {
+    19, 20,
+};
+
 typedef struct XlnxZynqMPGICRegion {
     int region_index;
     uint32_t address;
@@ -97,13 +105,19 @@ static void xlnx_zynqmp_init(Object *obj)
 
     object_initialize(&s->sata, sizeof(s->sata), TYPE_SYSBUS_AHCI);
     qdev_set_parent_bus(DEVICE(&s->sata), sysbus_get_default());
+
+    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
+        object_initialize(&s->spi[i], sizeof(s->spi[i]),
+                          TYPE_XILINX_SPIPS);
+        qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());
+    }
 }
 
 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 {
     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
     MemoryRegion *system_memory = get_system_memory();
-    uint8_t i;
+    uint8_t i, j;
     const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
     qemu_irq gic_spi[GIC_NUM_SPI_INTR];
     Error *err = NULL;
@@ -258,6 +272,36 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
+
+    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
+        SSIBus *spi_bus;
+        char bus_name[6];
+
+        object_property_set_int(OBJECT(&s->spi[i]), XLNX_ZYNQMP_NUM_SPIS,
+                                "num-busses", &error_abort);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
+        if (err) {
+            error_propagate(errp, err);
+            return;
+        }

hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) · line 296

Quoted 10 lines
hw/arm/xlnx-zynqmp.c +10 -0
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                           gic_spi[spi_intr[i]]);
+
+        snprintf(bus_name, 6, "spi%d", i);
+        spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->spi[i]), bus_name);
+
+        for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
+            DeviceState *flash_dev = ssi_create_slave(spi_bus, "m25p80");

Are they actual m25p80's or are you trying to be generic? "M25P80' is overloaded, often used to mean the greater family of SPI flashes while also being a specific part. In this usage, it means the specific part. M25P80 is a very old part.

This should however be on the machine level. The bus needs to be connected to the SoC object as a child bus, and the board level creates the flashes (ep108).

Regards,
Peter

Quoted 43 lines
hw/arm/xlnx-zynqmp.c +8 -0
+            qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
+                                                      SSI_GPIO_CS, 0);
+
+            sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]),
+                               i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
+                               cs_line);
+        }
+    }
 }
 
 static Property xlnx_zynqmp_props[] = {
include/hw/arm/xlnx-zynqmp.h +4 -1
index 4005a99..6d1d2a9 100644
@@ -24,6 +24,7 @@
 #include "hw/char/cadence_uart.h"
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
+#include "hw/ssi/xilinx_spips.h"
 
 #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"
 #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \
@@ -33,6 +34,8 @@
 #define XLNX_ZYNQMP_NUM_RPU_CPUS 2
 #define XLNX_ZYNQMP_NUM_GEMS 4
 #define XLNX_ZYNQMP_NUM_UARTS 2
+#define XLNX_ZYNQMP_NUM_SPIS 2
+#define XLNX_ZYNQMP_NUM_SPI_FLASHES 4
 
 #define XLNX_ZYNQMP_NUM_OCM_BANKS 4
 #define XLNX_ZYNQMP_OCM_RAM_0_ADDRESS 0xFFFC0000
@@ -63,6 +66,7 @@ typedef struct XlnxZynqMPState {
     CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS];
     CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS];
     SysbusAHCIState sata;
+    XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS];
 
     char *boot_cpu;
     ARMCPU *boot_cpu_ptr;
--

1.9.1

#11 lore raw

Re: [Qemu-devel] [PATCH v1 3/3] xlnx-zynqmp: Connect the SPI devices

Quoted 74 lines · Peter Crosthwaite
Quoted 72 lines · Alistair Francis

Connect the Xilinx SPI device to the ZynqMP model.

---

 hw/arm/xlnx-zynqmp.c         | 46 +++++++++++++++++++++++++++++++++++++++++++-
 include/hw/arm/xlnx-zynqmp.h |  4 ++++
 2 files changed, 49 insertions(+), 1 deletion(-)
hw/arm/xlnx-zynqmp.c +34 -1
index a9097f9..4b8d095 100644
@@ -48,6 +48,14 @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = {
     21, 22,
 };
 
+static const uint64_t spi_addr[XLNX_ZYNQMP_NUM_SPIS] = {
+    0xFF040000, 0xFF050000,
+};
+
+static const int spi_intr[XLNX_ZYNQMP_NUM_SPIS] = {
+    19, 20,
+};
+
 typedef struct XlnxZynqMPGICRegion {
     int region_index;
     uint32_t address;
@@ -97,13 +105,19 @@ static void xlnx_zynqmp_init(Object *obj)
 
     object_initialize(&s->sata, sizeof(s->sata), TYPE_SYSBUS_AHCI);
     qdev_set_parent_bus(DEVICE(&s->sata), sysbus_get_default());
+
+    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
+        object_initialize(&s->spi[i], sizeof(s->spi[i]),
+                          TYPE_XILINX_SPIPS);
+        qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());
+    }
 }
 
 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 {
     XlnxZynqMPState *s = XLNX_ZYNQMP(dev);
     MemoryRegion *system_memory = get_system_memory();
-    uint8_t i;
+    uint8_t i, j;
     const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]";
     qemu_irq gic_spi[GIC_NUM_SPI_INTR];
     Error *err = NULL;
@@ -258,6 +272,36 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
 
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]);
+
+    for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
+        SSIBus *spi_bus;
+        char bus_name[6];
+
+        object_property_set_int(OBJECT(&s->spi[i]), XLNX_ZYNQMP_NUM_SPIS,
+                                "num-busses", &error_abort);
+        object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
+        if (err) {
+            error_propagate(errp, err);
+            return;
+        }
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
+                           gic_spi[spi_intr[i]]);
+
+        snprintf(bus_name, 6, "spi%d", i);
+        spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->spi[i]), bus_name);
Quoted 8 lines

hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) · line 296

Quoted 3 lines
hw/arm/xlnx-zynqmp.c +3 -0
+
+        for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
+            DeviceState *flash_dev = ssi_create_slave(spi_bus, "m25p80");

Are they actual m25p80's or are you trying to be generic? "M25P80' is overloaded, often used to mean the greater family of SPI flashes while also being a specific part. In this usage, it means the specific part. M25P80 is a very old part.

Good point, I'll update it with the actual part.

Quoted 4 lines

This should however be on the machine level. The bus needs to be connected to the SoC object as a child bus, and the board level creates the flashes (ep108).

Ok, fixed in v2.

Thanks,

Alistair

Quoted 48 lines

Regards,
Peter

Quoted 43 lines
hw/arm/xlnx-zynqmp.c +8 -0
+            qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
+                                                      SSI_GPIO_CS, 0);
+
+            sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]),
+                               i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
+                               cs_line);
+        }
+    }
 }
 
 static Property xlnx_zynqmp_props[] = {
include/hw/arm/xlnx-zynqmp.h +4 -1
index 4005a99..6d1d2a9 100644
@@ -24,6 +24,7 @@
 #include "hw/char/cadence_uart.h"
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
+#include "hw/ssi/xilinx_spips.h"
 
 #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"
 #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \
@@ -33,6 +34,8 @@
 #define XLNX_ZYNQMP_NUM_RPU_CPUS 2
 #define XLNX_ZYNQMP_NUM_GEMS 4
 #define XLNX_ZYNQMP_NUM_UARTS 2
+#define XLNX_ZYNQMP_NUM_SPIS 2
+#define XLNX_ZYNQMP_NUM_SPI_FLASHES 4
 
 #define XLNX_ZYNQMP_NUM_OCM_BANKS 4
 #define XLNX_ZYNQMP_OCM_RAM_0_ADDRESS 0xFFFC0000
@@ -63,6 +66,7 @@ typedef struct XlnxZynqMPState {
     CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS];
     CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS];
     SysbusAHCIState sata;
+    XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS];
 
     char *boot_cpu;
     ARMCPU *boot_cpu_ptr;
--

1.9.1

#12 lore raw
In reply to Alistair Francis
Quoted 9 lines · Alistair Francis

Connect the SPI devices to Xilinx's ZynqMP.

I also need to make some changes to the actual SPI device to imporove the fuctionality, but for the time being this works.

Alistair Francis (3):
ssi: Move ssi.h into a seperate directory
xilinx_spips: Seperate the state struct into a header
xlnx-zynqmp: Connect the SPI devices

s/eperate/eparate/g

Cheers.

Signature · 2 lines
Andrea Bolognani
Software Engineer - Virtualization Team
#13 lore raw
Quoted 6 lines · Andrea Bolognani
Quoted 5 lines · Alistair Francis

Connect the SPI devices to Xilinx's ZynqMP.

I also need to make some changes to the actual SPI device to imporove the fuctionality, but for the time being this works.

Quoted 6 lines
Quoted 4 lines

Alistair Francis (3):
ssi: Move ssi.h into a seperate directory
xilinx_spips: Seperate the state struct into a header
xlnx-zynqmp: Connect the SPI devices

s/eperate/eparate/g

Good catch, fixed in version 2.

Thanks,

Alistair

Quoted 8 lines

Cheers.

--
Andrea Bolognani
Software Engineer - Virtualization Team