Skip to contentSkip to conversation

Xilinx DisplayPort.

PATCH Applied [email protected] 2 participants 15 messages Jun 13, 2016 – Jun 14, 2016 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

v10 cover Xilinx DisplayPort.

From: KONRAD Frederic <[email protected]>

This is the 10th version of this patch-set of the implementation of the Xilinx DisplayPort and DPDMA.

This 10th version fixes one bug with the I2C broadcast patch.

The fourth patch introduces an AUX bus needed by the DP to read the DPCD. It's also possible to connect an I2C device on it to do I2C through AUX commands. The drivers requires I2C broadcast write to be modeled as well which seemed to be missing currently upstream.

The tree can be cloned at:
[email protected]:fkonrad/xilinx_dp.git branch xilinx_dp_v10_release

Details of the DPDMA part:
* DPDMA is implemented as a QEMU SYSBUS device.
* Interrupts are implemented except the axi error and fifo.

Details of the XILINX-DP:
* DP is also implemented as a QEMU SYSBUS. Multiple memory regions are used to avoid having a single big region as there are holes in the DP memory map.
* An aux-bus has been implemented, it creates a memory map for aux slaves and has an i2c bus (which is already implemented in QEMU).
* The normal programmable i2c clock and controller implementation is missing from the QEMU tree so the easiest way for us was to implement a dummy-clk driver in the kernel. It's a clock which does nothing but fakes a clock such that the DPDMA driver works. The patch will be send separately.
* The graphic plane works on channel 3, video on channel 0 and audios on channel 4 and 5.

Thanks,
Fred

v9 -> V10 changes:
* globally:
* Rebased on current master (2c96c379ac7a22424c25d65b73e81b860f902868).
* i2c:
* Use QLIST_FOREACH_SAFE instead of QLIST_FOREACH when removing elements.
* Returns -1 for sc_send when any device on the bus returns -1.

V8 -> V9 changes:
* globally:
* Rebased on current master (6ed5546fa7bf12c5b87ef76bafb86e1d77ed6e85).
* aux:
* Coding style fix.

V7 -> V8 changes:
* globally:
* Rebased on current master (e854d0cf7847e70f5ed5dad5820fc1bbeda6f29e).
* include qemu/osdep.h.
* xlnx-dp:
* Coding style fix.
* Drop xlnx_dp_aux_get/set.

V6 -> V7 changes:
* globally:
* Rebased on current master (0430891ce162b986c6e02a7729a942ecd2a32ca4).
* Pick Peter's patch-set and rebase it on broadcast patch.
* xlnx-dp:
* Print some unimplemented debug trace instead of aborting.
* zynq-mp:
* Set realized before map the device.
* Coding style fix.
* aux:
* Factorize i2c access with i2c_send_recv.

V5 -> V6 changes:
* globally:
* Rebased on current master (38a762fec63fd5c035aae29ba9a77d357e21e4a7).
* Fix some coding style issues.

V4 -> V5 changes:
* aux:
* Move the header include/hw => include/hw/misc
* dpcd:
* Move the header hw/display => include/hw/display
* i2c-ddc:
* Move the header hw/i2c => include/hw/i2c
* xlnx-dpdma:
* Move the header hw/dma => include/hw/dma
* Fix some styles issues.
* xlnx-dp:
* Move the header hw/display => include/hw/display
* globally:
* Rebased on current master (c49d3411faae8ffaab8f7e5db47405a008411c10).

V3 -> V4 changes:
* xlnx_dpdma:
* Initialize operation_finished during reset.
* Add a function to trigger a VSYNC interrupt from the xlnx_dp.
* xlnx_dp:
* Fix the default pixman format for video buffer.
* Remove unused buffer.
* dpcd:
* Add the missing DPCD_LANE_X_STATUS.
* Set status field for all ports to avoid driver error.
* Use 4 lines by default.
* Use guest error in case of an outbound access.
* i2c broadcast:
* Use a list of device instead of relying on broadcast field to remove duped code.
* other:
* rebased on current master (774ee4772b6838b78741ea52d4bf26b8922244c5)

V2 -> V3 changes:
* dpcd:
* Add a CONFIG_DPCD.
* i2c-ddc:
* Fill in VMSD.
* aux:
* Remove address field.
* Add a CONFIG_AUX.
* dpdma:
* Fill in VMSD.
* Some coding style changes.
* dp:
* Fill in VMSD.
* Coding style changes.

V1 -> V2 changes:
* xlnx-zynqmp:
* Remove the dummy object_property_add_child(..).
* dpcd:
* Compile only when the ZYNQMP platform is compiled.
* Use qemu_log instead of printf.
* Compile test debug traces.
* Remove the unused current_reg.
* Remove the blank realize.
* Use dpcd_ prefixes instead of aux_ prefixes.
* Add a reset callback.
* Add the VMSD.
* Add size constraint in the MemoryRegionOps structure instead of asserting.
* Style fixes.
* aux:
* Compile only when the ZYNQMP platform is compiled.
* Remove the class init and the class for aux-slave.
* dpdma:
* Compile only when the ZYNQMP platform is compiled.
* Unify per channel macro in one, simplify the switch case.
* Use extractXX.
* Make DPDMA_GBL an or'ed register.
* dp:
* Compile only when the ZYNQMP platform is compiled.
* Don't look at the audio channel count.
* Use a third pixman plane when we do blending.
* other:
* Drop the useless "console: add qemu_alloc_display_format." patch as suggested by Gerd.
* Rebase on current master (f3e3b083d4c266ea864ae3c83da49d4086857679).

KONRAD Frederic (7):
i2cbus: remove unused dev field
i2c: implement broadcast write
introduce aux-bus
introduce dpcd module
introduce xlnx-dpdma
introduce xlnx-dp
arm: xlnx-zynqmp: Add xlnx-dp and xlnx-dpdma

Peter Crosthwaite (1):
i2c: Factor our send() and recv() common logic

Peter Maydell (1):
hw/i2c-ddc.c: Implement DDC I2C slave

 default-configs/aarch64-softmmu.mak |    3 +
 hw/arm/xlnx-zynqmp.c                |   32 +-
 hw/display/Makefile.objs            |    2 +
 hw/display/dpcd.c                   |  173 +++++
 hw/display/xlnx_dp.c                | 1336 +++++++++++++++++++++++++++++++++++
 hw/dma/Makefile.objs                |    1 +
 hw/dma/xlnx_dpdma.c                 |  794 +++++++++++++++++++++
 hw/i2c/Makefile.objs                |    1 +
 hw/i2c/core.c                       |  161 +++--
 hw/i2c/i2c-ddc.c                    |  307 ++++++++
 hw/misc/Makefile.objs               |    1 +
 hw/misc/aux.c                       |  292 ++++++++
 include/hw/arm/xlnx-zynqmp.h        |    4 +
 include/hw/display/dpcd.h           |  105 +++
 include/hw/display/xlnx_dp.h        |  109 +++
 include/hw/dma/xlnx_dpdma.h         |   85 +++
 include/hw/i2c/i2c-ddc.h            |   38 +
 include/hw/i2c/i2c.h                |    1 +
 include/hw/misc/aux.h               |  128 ++++
 19 files changed, 3511 insertions(+), 62 deletions(-)
 create mode 100644 hw/display/dpcd.c
 create mode 100644 hw/display/xlnx_dp.c
 create mode 100644 hw/dma/xlnx_dpdma.c
 create mode 100644 hw/i2c/i2c-ddc.c
 create mode 100644 hw/misc/aux.c
 create mode 100644 include/hw/display/dpcd.h
 create mode 100644 include/hw/display/xlnx_dp.h
 create mode 100644 include/hw/dma/xlnx_dpdma.h
 create mode 100644 include/hw/i2c/i2c-ddc.h
 create mode 100644 include/hw/misc/aux.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v10 1/9 i2cbus: remove unused dev field

From: KONRAD Frederic <[email protected]>

The dev field in i2cbus is not used.
So just drop it.

---
 hw/i2c/core.c | 1 -
 1 file changed, 1 deletion(-)
hw/i2c/core.c +0 -1
index ba22104..013ff68 100644
@@ -14,7 +14,6 @@ struct I2CBus
 {
     BusState qbus;
     I2CSlave *current_dev;
-    I2CSlave *dev;
     uint8_t saved_address;
 };
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v10 2/9 i2c: implement broadcast write

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This does a write to every slaves when the I2C bus get a write to address 0.

---
 hw/i2c/core.c | 134 ++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 79 insertions(+), 55 deletions(-)
hw/i2c/core.c +79 -55
index 013ff68..1fa8268 100644
@@ -10,11 +10,19 @@
 #include "qemu/osdep.h"
 #include "hw/i2c/i2c.h"
 
+typedef struct I2CNode I2CNode;
+
+struct I2CNode {
+    I2CSlave *elt;
+    QLIST_ENTRY(I2CNode) next;
+};
+
 struct I2CBus
 {
     BusState qbus;
-    I2CSlave *current_dev;
+    QLIST_HEAD(, I2CNode) current_devs;
     uint8_t saved_address;
+    bool broadcast;
 };
 
 static Property i2c_props[] = {
@@ -35,17 +43,12 @@ static void i2c_bus_pre_save(void *opaque)
 {
     I2CBus *bus = opaque;
 
-    bus->saved_address = bus->current_dev ? bus->current_dev->address : -1;
-}
-
-static int i2c_bus_post_load(void *opaque, int version_id)
-{
-    I2CBus *bus = opaque;
-
-    /* The bus is loaded before attached devices, so load and save the
-       current device id.  Devices will check themselves as loaded.  */
-    bus->current_dev = NULL;
-    return 0;
+    bus->saved_address = -1;
+    if (!QLIST_EMPTY(&bus->current_devs)) {
+        if (!bus->broadcast) {
+            bus->saved_address = QLIST_FIRST(&bus->current_devs)->elt->address;
+        }
+    }
 }
 
 static const VMStateDescription vmstate_i2c_bus = {
@@ -53,9 +56,9 @@ static const VMStateDescription vmstate_i2c_bus = {
     .version_id = 1,
     .minimum_version_id = 1,
     .pre_save = i2c_bus_pre_save,
-    .post_load = i2c_bus_post_load,
     .fields = (VMStateField[]) {
         VMSTATE_UINT8(saved_address, I2CBus),
+        VMSTATE_BOOL(broadcast, I2CBus),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -66,6 +69,7 @@ I2CBus *i2c_init_bus(DeviceState *parent, const char *name)
     I2CBus *bus;
 
     bus = I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name));
+    QLIST_INIT(&bus->current_devs);
     vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
     return bus;
 }
@@ -78,7 +82,7 @@ void i2c_set_slave_address(I2CSlave *dev, uint8_t address)
 /* Return nonzero if bus is busy.  */
 int i2c_bus_busy(I2CBus *bus)
 {
-    return bus->current_dev != NULL;
+    return !QLIST_EMPTY(&bus->current_devs);
 }
 
 /* Returns non-zero if the address is not valid.  */
@@ -86,95 +90,111 @@ int i2c_bus_busy(I2CBus *bus)
 int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
 {
     BusChild *kid;
-    I2CSlave *slave = NULL;
     I2CSlaveClass *sc;
+    I2CNode *node;
+
+    if (address == 0x00) {
+        /*
+         * This is a broadcast, the current_devs will be all the devices of the
+         * bus.
+         */
+        bus->broadcast = true;
+    }
 
     QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {
         DeviceState *qdev = kid->child;
         I2CSlave *candidate = I2C_SLAVE(qdev);
-        if (candidate->address == address) {
-            slave = candidate;
-            break;
+        if ((candidate->address == address) || (bus->broadcast)) {
+            node = g_malloc(sizeof(struct I2CNode));
+            node->elt = candidate;
+            QLIST_INSERT_HEAD(&bus->current_devs, node, next);
+            if (!bus->broadcast) {
+                break;
+            }
         }
     }
 
-    if (!slave) {
+    if (QLIST_EMPTY(&bus->current_devs)) {
         return 1;
     }
 
-    sc = I2C_SLAVE_GET_CLASS(slave);
-    /* If the bus is already busy, assume this is a repeated
-       start condition.  */
-    bus->current_dev = slave;
-    if (sc->event) {
-        sc->event(slave, recv ? I2C_START_RECV : I2C_START_SEND);
+    QLIST_FOREACH(node, &bus->current_devs, next) {
+        sc = I2C_SLAVE_GET_CLASS(node->elt);
+        /* If the bus is already busy, assume this is a repeated
+           start condition.  */
+        if (sc->event) {
+            sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND);
+        }
     }
     return 0;
 }
 
 void i2c_end_transfer(I2CBus *bus)
 {
-    I2CSlave *dev = bus->current_dev;
     I2CSlaveClass *sc;
+    I2CNode *node, *next;
 
-    if (!dev) {
+    if (QLIST_EMPTY(&bus->current_devs)) {
         return;
     }
 
-    sc = I2C_SLAVE_GET_CLASS(dev);
-    if (sc->event) {
-        sc->event(dev, I2C_FINISH);
+    QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) {
+        sc = I2C_SLAVE_GET_CLASS(node->elt);
+        if (sc->event) {
+            sc->event(node->elt, I2C_FINISH);
+        }
+        QLIST_REMOVE(node, next);
+        g_free(node);
     }
-
-    bus->current_dev = NULL;
+    bus->broadcast = false;
 }
 
 int i2c_send(I2CBus *bus, uint8_t data)
 {
-    I2CSlave *dev = bus->current_dev;
     I2CSlaveClass *sc;
-
-    if (!dev) {
-        return -1;
-    }
-
-    sc = I2C_SLAVE_GET_CLASS(dev);
-    if (sc->send) {
-        return sc->send(dev, data);
+    I2CNode *node;
+    int ret = 0;
+
+    QLIST_FOREACH(node, &bus->current_devs, next) {
+        sc = I2C_SLAVE_GET_CLASS(node->elt);
+        if (sc->send) {
+            ret = ret || sc->send(node->elt, data);
+        } else {
+            ret = -1;
+        }
     }
-
-    return -1;
+    return ret ? -1 : 0;
 }
 
 int i2c_recv(I2CBus *bus)
 {
-    I2CSlave *dev = bus->current_dev;
     I2CSlaveClass *sc;
 
-    if (!dev) {
+    if ((QLIST_EMPTY(&bus->current_devs)) || (bus->broadcast)) {
         return -1;
     }
 
-    sc = I2C_SLAVE_GET_CLASS(dev);
+    sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
     if (sc->recv) {
-        return sc->recv(dev);
+        return sc->recv(QLIST_FIRST(&bus->current_devs)->elt);
     }
-
     return -1;
 }
 
 void i2c_nack(I2CBus *bus)
 {
-    I2CSlave *dev = bus->current_dev;
     I2CSlaveClass *sc;
+    I2CNode *node;
 
-    if (!dev) {
+    if (QLIST_EMPTY(&bus->current_devs)) {
         return;
     }
 
-    sc = I2C_SLAVE_GET_CLASS(dev);
-    if (sc->event) {
-        sc->event(dev, I2C_NACK);
+    QLIST_FOREACH(node, &bus->current_devs, next) {
+        sc = I2C_SLAVE_GET_CLASS(node->elt);
+        if (sc->event) {
+            sc->event(node->elt, I2C_NACK);
+        }
     }
 }
 
@@ -182,9 +202,13 @@ static int i2c_slave_post_load(void *opaque, int version_id)
 {
     I2CSlave *dev = opaque;
     I2CBus *bus;
+    I2CNode *node;
+
     bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
-    if (bus->saved_address == dev->address) {
-        bus->current_dev = dev;
+    if ((bus->saved_address == dev->address) || (bus->broadcast)) {
+        node = g_malloc(sizeof(struct I2CNode));
+        node->elt = dev;
+        QLIST_INSERT_HEAD(&bus->current_devs, node, next);
     }
     return 0;
 }
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v10 3/9 i2c: Factor our send() and recv() common logic

In reply to [email protected]

From: Peter Crosthwaite <[email protected]>

Most of the control flow logic between send and recv (error checking etc) is the same. Factor this out into a common send_recv() API. This is then usable by clients, where the control logic for send and receive differs only by a boolean. E.g.

if (send)
i2c_send(...):
else
i2c_recv(...);

becomes:

i2c_send_recv(... , send);

Changes from FK:
* Rebased on master.
* Rebased on my i2c broadcast patch.

---
 hw/i2c/core.c        | 52 ++++++++++++++++++++++++++++++++++------------------
 include/hw/i2c/i2c.h |  1 +
 2 files changed, 35 insertions(+), 18 deletions(-)
hw/i2c/core.c +34 -18
index 1fa8268..abb3efb 100644
@@ -149,36 +149,52 @@ void i2c_end_transfer(I2CBus *bus)
     bus->broadcast = false;
 }
 
-int i2c_send(I2CBus *bus, uint8_t data)
+int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
 {
     I2CSlaveClass *sc;
     I2CNode *node;
     int ret = 0;
 
-    QLIST_FOREACH(node, &bus->current_devs, next) {
-        sc = I2C_SLAVE_GET_CLASS(node->elt);
-        if (sc->send) {
-            ret = ret || sc->send(node->elt, data);
-        } else {
-            ret = -1;
+    if (send) {
+        QLIST_FOREACH(node, &bus->current_devs, next) {
+            sc = I2C_SLAVE_GET_CLASS(node->elt);
+            if (sc->send) {
+                ret = ret || sc->send(node->elt, *data);
+            } else {
+                ret = -1;
+            }
+        }
+        return ret ? -1 : 0;
+    } else {
+        if ((QLIST_EMPTY(&bus->current_devs)) || (bus->broadcast)) {
+            return -1;
         }
+
+        sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
+        if (sc->recv) {
+            ret = sc->recv(QLIST_FIRST(&bus->current_devs)->elt);
+            if (ret < 0) {
+                return ret;
+            } else {
+                *data = ret;
+                return 0;
+            }
+        }
+        return -1;
     }
-    return ret ? -1 : 0;
 }
 
-int i2c_recv(I2CBus *bus)
+int i2c_send(I2CBus *bus, uint8_t data)
 {
-    I2CSlaveClass *sc;
+    return i2c_send_recv(bus, &data, true);
+}
 
-    if ((QLIST_EMPTY(&bus->current_devs)) || (bus->broadcast)) {
-        return -1;
-    }
+int i2c_recv(I2CBus *bus)
+{
+    uint8_t data;
+    int ret = i2c_send_recv(bus, &data, false);
 
-    sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
-    if (sc->recv) {
-        return sc->recv(QLIST_FIRST(&bus->current_devs)->elt);
-    }
-    return -1;
+    return ret < 0 ? ret : data;
 }
 
 void i2c_nack(I2CBus *bus)
include/hw/i2c/i2c.h +1 -0
index 4986ebc..c4085aa 100644
@@ -56,6 +56,7 @@ int i2c_bus_busy(I2CBus *bus);
 int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv);
 void i2c_end_transfer(I2CBus *bus);
 void i2c_nack(I2CBus *bus);
+int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send);
 int i2c_send(I2CBus *bus, uint8_t data);
 int i2c_recv(I2CBus *bus);
 
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v10 4/9 introduce aux-bus

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This introduces a new bus: aux-bus.

It contains an address space for aux slaves devices and a bridge to an I2C bus for I2C through AUX transactions.

---
 default-configs/aarch64-softmmu.mak |   1 +
 hw/misc/Makefile.objs               |   1 +
 hw/misc/aux.c                       | 292 ++++++++++++++++++++++++++++++++++++
 include/hw/misc/aux.h               | 128 ++++++++++++++++
 4 files changed, 422 insertions(+)
 create mode 100644 hw/misc/aux.c
 create mode 100644 include/hw/misc/aux.h
default-configs/aarch64-softmmu.mak +1 -0
index 96dd994..d3a2665 100644
@@ -3,4 +3,5 @@
 # We support all the 32 bit boards so need all their config
 include arm-softmmu.mak
 
+CONFIG_AUX=y
 CONFIG_XLNX_ZYNQMP=y
hw/misc/Makefile.objs +1 -0
index bc0dd2c..ffb49c1 100644
@@ -51,3 +51,4 @@ obj-$(CONFIG_MIPS_ITU) += mips_itu.o
 obj-$(CONFIG_PVPANIC) += pvpanic.o
 obj-$(CONFIG_EDU) += edu.o
 obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
+obj-$(CONFIG_AUX) += aux.o
hw/misc/aux.c new file +292 -0

292 lines not on this page · raw message

include/hw/misc/aux.h new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v10 5/9 introduce dpcd module

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This introduces dpcd module.
It wires on a aux-bus and can be accessed by the driver to get lane-speed, etc.

---
 default-configs/aarch64-softmmu.mak |   1 +
 hw/display/Makefile.objs            |   1 +
 hw/display/dpcd.c                   | 173 ++++++++++++++++++++++++++++++++++++
 include/hw/display/dpcd.h           | 105 ++++++++++++++++++++++
 4 files changed, 280 insertions(+)
 create mode 100644 hw/display/dpcd.c
 create mode 100644 include/hw/display/dpcd.h
default-configs/aarch64-softmmu.mak +1 -0
index d3a2665..87165b7 100644
@@ -4,4 +4,5 @@
 include arm-softmmu.mak
 
 CONFIG_AUX=y
+CONFIG_DPCD=y
 CONFIG_XLNX_ZYNQMP=y
hw/display/Makefile.objs +1 -0
index d99780e..ddf3275 100644
@@ -43,3 +43,4 @@ virtio-gpu.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu.o-libs += $(VIRGL_LIBS)
 virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
+obj-$(CONFIG_DPCD) += dpcd.o
hw/display/dpcd.c new file +173 -0

173 lines not on this page · raw message

include/hw/display/dpcd.h new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#6 lore raw

PATCH v10 6/9 hw/i2c-ddc.c: Implement DDC I2C slave

In reply to [email protected]

From: Peter Maydell <[email protected]>

Implement an I2C slave which implements DDC and returns the EDID data for an attached monitor.

- Rebased on the current master.
- Modified for QOM.

---
 default-configs/aarch64-softmmu.mak |   1 +
 hw/i2c/Makefile.objs                |   1 +
 hw/i2c/i2c-ddc.c                    | 307 ++++++++++++++++++++++++++++++++++++
 include/hw/i2c/i2c-ddc.h            |  38 +++++
 4 files changed, 347 insertions(+)
 create mode 100644 hw/i2c/i2c-ddc.c
 create mode 100644 include/hw/i2c/i2c-ddc.h
default-configs/aarch64-softmmu.mak +1 -0
index 87165b7..2449483 100644
@@ -4,5 +4,6 @@
 include arm-softmmu.mak
 
 CONFIG_AUX=y
+CONFIG_DDC=y
 CONFIG_DPCD=y
 CONFIG_XLNX_ZYNQMP=y
hw/i2c/Makefile.objs +1 -0
index 1fd54ed..a081b8e 100644
@@ -1,4 +1,5 @@
 common-obj-y += core.o smbus.o smbus_eeprom.o
+common-obj-$(CONFIG_DDC) += i2c-ddc.o
 common-obj-$(CONFIG_VERSATILE_I2C) += versatile_i2c.o
 common-obj-$(CONFIG_ACPI_X86) += smbus_ich9.o
 common-obj-$(CONFIG_APM) += pm_smbus.o
hw/i2c/i2c-ddc.c new file +307 -0

307 lines not on this page · raw message

include/hw/i2c/i2c-ddc.h new file +38 -0
new file mode 100644
index 0000000..cb8e62d
@@ -0,0 +1,38 @@
+/* A simple I2C slave for returning monitor EDID data via DDC.
+ *
+ * Copyright (c) 2011 Linaro Limited
+ * Written by Peter Maydell
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef I2C_DDC
+#define I2C_DDC
+
+/* A simple I2C slave which just returns the contents of its EDID blob. */
+
+struct I2CDDCState {
+    /*< private >*/
+    I2CSlave i2c;
+    /*< public >*/
+    bool firstbyte;
+    uint8_t reg;
+    uint8_t edid_blob[128];
+};
+
+typedef struct I2CDDCState I2CDDCState;
+
+#define TYPE_I2CDDC "i2c-ddc"
+#define I2CDDC(obj) OBJECT_CHECK(I2CDDCState, (obj), TYPE_I2CDDC)
+
+#endif /* !I2C_DDC */
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH v10 7/9 introduce xlnx-dpdma

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This is the implementation of the DPDMA.

---
 hw/dma/Makefile.objs        |   1 +
 hw/dma/xlnx_dpdma.c         | 794 ++++++++++++++++++++++++++++++++++++++++++++
 include/hw/dma/xlnx_dpdma.h |  85 +++++
 3 files changed, 880 insertions(+)
 create mode 100644 hw/dma/xlnx_dpdma.c
 create mode 100644 include/hw/dma/xlnx_dpdma.h
hw/dma/Makefile.objs +1 -0
index a1abbcf..8b0823e 100644
@@ -8,6 +8,7 @@ common-obj-$(CONFIG_XILINX_AXI) += xilinx_axidma.o
 common-obj-$(CONFIG_ETRAXFS) += etraxfs_dma.o
 common-obj-$(CONFIG_STP2000) += sparc32_dma.o
 common-obj-$(CONFIG_SUN4M) += sun4m_iommu.o
+obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dpdma.o
 
 obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
 obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
hw/dma/xlnx_dpdma.c new file +794 -0

794 lines not on this page · raw message

include/hw/dma/xlnx_dpdma.h new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#8 lore raw

PATCH v10 8/9 introduce xlnx-dp

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This is the implementation of the DisplayPort.
It has an aux-bus to access dpcd and edid.

Graphic plane is connected to the channel 3. Video plane is connected to the channel 0. Audio stream are connected to the channels 4 and 5.

---
 hw/display/Makefile.objs     |    1 +
 hw/display/xlnx_dp.c         | 1336 ++++++++++++++++++++++++++++++++++++++++++
 include/hw/display/xlnx_dp.h |  109 ++++
 3 files changed, 1446 insertions(+)
 create mode 100644 hw/display/xlnx_dp.c
 create mode 100644 include/hw/display/xlnx_dp.h
hw/display/Makefile.objs +1 -0
index ddf3275..063889b 100644
@@ -44,3 +44,4 @@ virtio-gpu.o-libs += $(VIRGL_LIBS)
 virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
 obj-$(CONFIG_DPCD) += dpcd.o
+obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dp.o
hw/display/xlnx_dp.c new file +1336 -0

1,336 lines not on this page · raw message

include/hw/display/xlnx_dp.h new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#9 lore raw

PATCH v10 9/9 arm: xlnx-zynqmp: Add xlnx-dp and xlnx-dpdma

In reply to [email protected]

From: KONRAD Frederic <[email protected]>

This adds the DP and the DPDMA to the Zynq MP platform.

---
 hw/arm/xlnx-zynqmp.c         | 32 +++++++++++++++++++++++++++++++-
 include/hw/arm/xlnx-zynqmp.h |  4 ++++
 2 files changed, 35 insertions(+), 1 deletion(-)
hw/arm/xlnx-zynqmp.c +31 -1
index 308d677..23c7199 100644
@@ -38,6 +38,12 @@
 #define SATA_ADDR           0xFD0C0000
 #define SATA_NUM_PORTS      2
 
+#define DP_ADDR             0xfd4a0000
+#define DP_IRQ              113
+
+#define DPDMA_ADDR          0xfd4c0000
+#define DPDMA_IRQ           116
+
 static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS] = {
     0xFF0B0000, 0xFF0C0000, 0xFF0D0000, 0xFF0E0000,
 };
@@ -165,6 +171,12 @@ static void xlnx_zynqmp_init(Object *obj)
                           TYPE_XILINX_SPIPS);
         qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());
     }
+
+    object_initialize(&s->dp, sizeof(s->dp), TYPE_XLNX_DP);
+    qdev_set_parent_bus(DEVICE(&s->dp), sysbus_get_default());
+
+    object_initialize(&s->dpdma, sizeof(s->dpdma), TYPE_XLNX_DPDMA);
+    qdev_set_parent_bus(DEVICE(&s->dpdma), sysbus_get_default());
 }
 
 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
@@ -388,8 +400,26 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
         object_property_add_alias(OBJECT(s), bus_name,
                                   OBJECT(&s->spi[i]), "spi0",
                                   &error_abort);
-	g_free(bus_name);
+        g_free(bus_name);
+    }
+
+    object_property_set_bool(OBJECT(&s->dp), true, "realized", &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->dp), 0, DP_ADDR);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->dp), 0, gic_spi[DP_IRQ]);
+
+    object_property_set_bool(OBJECT(&s->dpdma), true, "realized", &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
     }
+    object_property_set_link(OBJECT(&s->dp), OBJECT(&s->dpdma), "dpdma",
+                             &error_abort);
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
 }
 
 static Property xlnx_zynqmp_props[] = {
include/hw/arm/xlnx-zynqmp.h +4 -0
index 68f6eb0..c2931bf 100644
@@ -26,6 +26,8 @@
 #include "hw/ide/ahci.h"
 #include "hw/sd/sdhci.h"
 #include "hw/ssi/xilinx_spips.h"
+#include "hw/dma/xlnx_dpdma.h"
+#include "hw/display/xlnx_dp.h"
 
 #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"
 #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \
@@ -81,6 +83,8 @@ typedef struct XlnxZynqMPState {
     SysbusAHCIState sata;
     SDHCIState sdhci[XLNX_ZYNQMP_NUM_SDHCI];
     XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS];
+    XlnxDPState dp;
+    XlnxDPDMAState dpdma;
 
     char *boot_cpu;
     ARMCPU *boot_cpu_ptr;
Signature · 1 line
1.8.3.1
#11 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · On 13 June 2016 at 16:50, <[email protected]> wrote:

From: KONRAD Frederic <[email protected]>

This is the 10th version of this patch-set of the implementation of the Xilinx DisplayPort and DPDMA.

Quoted 8 lines
Quoted 1 line

This 10th version fixes one bug with the I2C broadcast patch.

Applied to target-arm.next, thanks.

-- PMM

Thanks!
Fred

#12 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 6 lines · On 13 June 2016 at 16:50, <[email protected]> wrote:

From: KONRAD Frederic <[email protected]>

This is the 10th version of this patch-set of the implementation of the Xilinx DisplayPort and DPDMA.

This 10th version fixes one bug with the I2C broadcast patch.

I found some minor build issues in this series, which I'm just going to fix up in my tree rather than making you respin this:

Format string issues which mean it doesn't build on OSX or 32-bit hosts:

/home/petmay01/linaro/qemu-for-merges/hw/display/xlnx_dp.c:700:5:
error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Werror=format=] /home/petmay01/linaro/qemu-for-merges/hw/display/xlnx_dp.c:709:5:
error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Werror=format=]

Clang build issues:

/Users/pm215/src/qemu-for-merges/hw/i2c/i2c-ddc.c:284:33: warning:
unused variable 'vmstate_i2c_ddc' [-Wunused-const-variable]

(vmstate wasn't actually wired up to dc->vmsd)

/Users/pm215/src/qemu-for-merges/hw/dma/xlnx_dpdma.c:307:20: warning:
unused function 'xlnx_dpdma_set_desc_next_address' [-Wunused-function]

Full diff of fixups:

hw/display/xlnx_dp.c +0 -0
index 552955f..be53b75 100644
@@ -697,7 +697,7 @@ static uint64_t xlnx_dp_read(void *opaque, hwaddr

offset, unsigned size)

         break;
     }

- DPRINTF("core read @%" PRIx64 " = 0x%8.8lX\n", offset << 2, ret);

+    DPRINTF("core read @%" PRIx64 " = 0x%8.8" PRIX64 "\n", offset << 2, ret);
     return ret;

}

@@ -706,7 +706,7 @@ static void xlnx_dp_write(void *opaque, hwaddr offset, uint64_t value,

 {
     XlnxDPState *s = XLNX_DP(opaque);

- DPRINTF("core write @%" PRIx64 " = 0x%8.8lX\n", offset, value);
+ DPRINTF("core write @%" PRIx64 " = 0x%8.8" PRIX64 "\n", offset, value);

     offset = offset >> 2;
hw/dma/xlnx_dpdma.c +0 -0
index 97a5da7..8ceb21d 100644
@@ -304,14 +304,6 @@ static uint64_t

xlnx_dpdma_descriptor_next_address(XlnxDPDMAState *s,
+ s->registers[DPDMA_DSCR_NEXT_ADDR_CH(channel)];
}

-static inline void xlnx_dpdma_set_desc_next_address(XlnxDPDMAState *s,
- uint8_t channel,
- uint64_t addr)
-{
- s->registers[DPDMA_DSCR_NEXT_ADDRE_CH(channel)] = extract64(addr, 32, 32);
- s->registers[DPDMA_DSCR_NEXT_ADDR_CH(channel)] = extract64(addr, 0, 32);
-}
-
static bool xlnx_dpdma_is_channel_enabled(XlnxDPDMAState *s,
uint8_t channel)
{

hw/i2c/i2c-ddc.c +11 -10
index 02cd374..b47ec9a 100644
@@ -270,27 +270,28 @@ static void i2c_ddc_init(Object *obj)
     build_edid_blob(&lcd_edid, s->edid_blob);
 }
 
+static const VMStateDescription vmstate_i2c_ddc = {
+    .name = TYPE_I2CDDC,
+    .version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL(firstbyte, I2CDDCState),
+        VMSTATE_UINT8(reg, I2CDDCState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static void i2c_ddc_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
 
     dc->reset = i2c_ddc_reset;
+    dc->vmsd = &vmstate_ic2_ddc;
     isc->event = i2c_ddc_event;
     isc->recv = i2c_ddc_rx;
     isc->send = i2c_ddc_tx;
 }
 
-static const VMStateDescription vmstate_i2c_ddc = {
-    .name = TYPE_I2CDDC,
-    .version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_BOOL(firstbyte, I2CDDCState),
-        VMSTATE_UINT8(reg, I2CDDCState),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
 static TypeInfo i2c_ddc_info = {
     .name = TYPE_I2CDDC,
     .parent = TYPE_I2C_SLAVE,

thanks
-- PMM

#13 lore raw
Quoted 22 lines · Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 6 lines · On 13 June 2016 at 16:50, <[email protected]> wrote:

From: KONRAD Frederic <[email protected]>

This is the 10th version of this patch-set of the implementation of the Xilinx DisplayPort and DPDMA.

This 10th version fixes one bug with the I2C broadcast patch.

I found some minor build issues in this series, which I'm just going to fix up in my tree rather than making you respin this:

Format string issues which mean it doesn't build on OSX or 32-bit hosts:

/home/petmay01/linaro/qemu-for-merges/hw/display/xlnx_dp.c:700:5:
error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Werror=format=] /home/petmay01/linaro/qemu-for-merges/hw/display/xlnx_dp.c:709:5:
error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Werror=format=]

Quoted 6 lines

Clang build issues:

/Users/pm215/src/qemu-for-merges/hw/i2c/i2c-ddc.c:284:33: warning:
unused variable 'vmstate_i2c_ddc' [-Wunused-const-variable]

(vmstate wasn't actually wired up to dc->vmsd)

Hi Peter,

oops be carefull there is a typo in your diff (see below)

Quoted 66 lines

/Users/pm215/src/qemu-for-merges/hw/dma/xlnx_dpdma.c:307:20: warning:
unused function 'xlnx_dpdma_set_desc_next_address' [-Wunused-function]

Full diff of fixups:

hw/display/xlnx_dp.c +2 -2
index 552955f..be53b75 100644
@@ -697,7 +697,7 @@ static uint64_t xlnx_dp_read(void *opaque, hwaddr
 offset, unsigned size)
         break;
     }
 
-    DPRINTF("core read @%" PRIx64 " = 0x%8.8lX\n", offset << 2, ret);
+    DPRINTF("core read @%" PRIx64 " = 0x%8.8" PRIX64 "\n", offset << 2, ret);
     return ret;
 }
@@ -706,7 +706,7 @@ static void xlnx_dp_write(void *opaque, hwaddr
 offset, uint64_t value,
 {
     XlnxDPState *s = XLNX_DP(opaque);
 
-    DPRINTF("core write @%" PRIx64 " = 0x%8.8lX\n", offset, value);
+    DPRINTF("core write @%" PRIx64 " = 0x%8.8" PRIX64 "\n", offset, value);
 
     offset = offset >> 2;
hw/dma/xlnx_dpdma.c +0 -8
index 97a5da7..8ceb21d 100644
@@ -304,14 +304,6 @@ static uint64_t
 xlnx_dpdma_descriptor_next_address(XlnxDPDMAState *s,
            + s->registers[DPDMA_DSCR_NEXT_ADDR_CH(channel)];
 }
 
-static inline void xlnx_dpdma_set_desc_next_address(XlnxDPDMAState *s,
-                                                      uint8_t channel,
-                                                      uint64_t addr)
-{
-    s->registers[DPDMA_DSCR_NEXT_ADDRE_CH(channel)] = extract64(addr, 32, 32);
-    s->registers[DPDMA_DSCR_NEXT_ADDR_CH(channel)] = extract64(addr, 0, 32);
-}
-
 static bool xlnx_dpdma_is_channel_enabled(XlnxDPDMAState *s,
                                             uint8_t channel)

{

hw/i2c/i2c-ddc.c +7 -0
index 02cd374..b47ec9a 100644
@@ -270,27 +270,28 @@ static void i2c_ddc_init(Object *obj)
     build_edid_blob(&lcd_edid, s->edid_blob);
 }
 
+static const VMStateDescription vmstate_i2c_ddc = {
+    .name = TYPE_I2CDDC,
+    .version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL(firstbyte, I2CDDCState),
+        VMSTATE_UINT8(reg, I2CDDCState),
+        VMSTATE_END_OF_LIST()

hw/i2c/i2c-ddc.c static void i2c_ddc_init(Object *obj) · line 289

Quoted 10 lines
hw/i2c/i2c-ddc.c +4 -0
+    }
+};
+
 static void i2c_ddc_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
 
     dc->reset = i2c_ddc_reset;
+    dc->vmsd = &vmstate_ic2_ddc;

vmstate_i2c_ddc*

Thanks,
Fred

Quoted 24 lines
hw/i2c/i2c-ddc.c +0 -10
     isc->event = i2c_ddc_event;
     isc->recv = i2c_ddc_rx;
     isc->send = i2c_ddc_tx;
 }
 
-static const VMStateDescription vmstate_i2c_ddc = {
-    .name = TYPE_I2CDDC,
-    .version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_BOOL(firstbyte, I2CDDCState),
-        VMSTATE_UINT8(reg, I2CDDCState),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
 static TypeInfo i2c_ddc_info = {
     .name = TYPE_I2CDDC,
     .parent = TYPE_I2C_SLAVE,

thanks
-- PMM

#14 lore raw
Quoted 1 line · KONRAD Frederic

oops be carefull there is a typo in your diff (see below)

Yeah, I caught that after I sent this email but before I sent out the updated pullreq.

-- PMM