All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation
@ 2018-02-27 10:48 Linus Walleij
  2018-02-27 10:48 ` [Qemu-devel] [PATCH 1/5] i2c: Fix some brace style issues Linus Walleij
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:48 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

This series adds proper display bridge/connector emulation
for the Versatile Express, implementing a simple Silicon
Image 9022 emulation spawning a DDC I2C child.

After the series the Versatile Express is successfully
presented the "QEMU monitor" through DDC I2C.

The series includes two refactorings from Corey and a
minor bug fix for the i2c-ddc so that everything is smoothly
integrated.

Corey Minyard (2):
  i2c: Fix some brace style issues
  i2c: Move the bus class to i2c.h

Linus Walleij (3):
  hw/i2c-ddc: Do not fail writes
  hw/sii9022: Add support for Silicon Image SII9022
  arm/vexpress: Add proper display connector emulation

 default-configs/arm-softmmu.mak |   2 +
 hw/arm/vexpress.c               |   6 +-
 hw/display/Makefile.objs        |   1 +
 hw/display/sii9022.c            | 188 ++++++++++++++++++++++++++++++++++++++++
 hw/display/trace-events         |   5 ++
 hw/i2c/core.c                   |  18 ----
 hw/i2c/i2c-ddc.c                |   4 +-
 include/hw/i2c/i2c.h            |  23 ++++-
 8 files changed, 222 insertions(+), 25 deletions(-)
 create mode 100644 hw/display/sii9022.c

-- 
2.14.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/5] i2c: Fix some brace style issues
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
@ 2018-02-27 10:48 ` Linus Walleij
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 2/5] i2c: Move the bus class to i2c.h Linus Walleij
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:48 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

From: Corey Minyard <cminyard@mvista.com>

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 hw/i2c/core.c        | 3 +--
 include/hw/i2c/i2c.h | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index 59068f157eb5..9a54b61c1dbd 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -19,8 +19,7 @@ struct I2CNode {
 
 #define I2C_BROADCAST 0x00
 
-struct I2CBus
-{
+struct I2CBus {
     BusState qbus;
     QLIST_HEAD(, I2CNode) current_devs;
     uint8_t saved_address;
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 24e95d015589..8fd449f645f0 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -25,8 +25,7 @@ typedef struct I2CSlave I2CSlave;
 #define I2C_SLAVE_GET_CLASS(obj) \
      OBJECT_GET_CLASS(I2CSlaveClass, (obj), TYPE_I2C_SLAVE)
 
-typedef struct I2CSlaveClass
-{
+typedef struct I2CSlaveClass {
     DeviceClass parent_class;
 
     /* Callbacks provided by the device.  */
@@ -50,8 +49,7 @@ typedef struct I2CSlaveClass
     int (*event)(I2CSlave *s, enum i2c_event event);
 } I2CSlaveClass;
 
-struct I2CSlave
-{
+struct I2CSlave {
     DeviceState qdev;
 
     /* Remaining fields for internal use by the I2C code.  */
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/5] i2c: Move the bus class to i2c.h
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
  2018-02-27 10:48 ` [Qemu-devel] [PATCH 1/5] i2c: Fix some brace style issues Linus Walleij
@ 2018-02-27 10:49 ` Linus Walleij
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes Linus Walleij
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:49 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

From: Corey Minyard <cminyard@mvista.com>

Some devices need access to it.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 hw/i2c/core.c        | 17 -----------------
 include/hw/i2c/i2c.h | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index 9a54b61c1dbd..cfccefca3d6c 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -10,30 +10,13 @@
 #include "qemu/osdep.h"
 #include "hw/i2c/i2c.h"
 
-typedef struct I2CNode I2CNode;
-
-struct I2CNode {
-    I2CSlave *elt;
-    QLIST_ENTRY(I2CNode) next;
-};
-
 #define I2C_BROADCAST 0x00
 
-struct I2CBus {
-    BusState qbus;
-    QLIST_HEAD(, I2CNode) current_devs;
-    uint8_t saved_address;
-    bool broadcast;
-};
-
 static Property i2c_props[] = {
     DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
     DEFINE_PROP_END_OF_LIST(),
 };
 
-#define TYPE_I2C_BUS "i2c-bus"
-#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
-
 static const TypeInfo i2c_bus_info = {
     .name = TYPE_I2C_BUS,
     .parent = TYPE_BUS,
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 8fd449f645f0..d727379b487a 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -56,6 +56,23 @@ struct I2CSlave {
     uint8_t address;
 };
 
+#define TYPE_I2C_BUS "i2c-bus"
+#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
+
+typedef struct I2CNode I2CNode;
+
+struct I2CNode {
+    I2CSlave *elt;
+    QLIST_ENTRY(I2CNode) next;
+};
+
+struct I2CBus {
+    BusState qbus;
+    QLIST_HEAD(, I2CNode) current_devs;
+    uint8_t saved_address;
+    bool broadcast;
+};
+
 I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
 void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
 int i2c_bus_busy(I2CBus *bus);
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
  2018-02-27 10:48 ` [Qemu-devel] [PATCH 1/5] i2c: Fix some brace style issues Linus Walleij
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 2/5] i2c: Move the bus class to i2c.h Linus Walleij
@ 2018-02-27 10:49 ` Linus Walleij
  2018-02-27 23:38   ` Philippe Mathieu-Daudé
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022 Linus Walleij
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:49 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

The tx function of the DDC I2C slave emulation was returning 1
on all writes resulting in NACK in the I2C bus. Changing it to
0 makes the DDC I2C work fine with bit-banged I2C such as the
versatile I2C.

I guess it was not affecting whatever I2C controller this was
used with until now, but with the Versatile I2C it surely
does not work.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 hw/i2c/i2c-ddc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
index 199dac9e41c1..bec0c91e2dd0 100644
--- a/hw/i2c/i2c-ddc.c
+++ b/hw/i2c/i2c-ddc.c
@@ -259,12 +259,12 @@ static int i2c_ddc_tx(I2CSlave *i2c, uint8_t data)
         s->reg = data;
         s->firstbyte = false;
         DPRINTF("[EDID] Written new pointer: %u\n", data);
-        return 1;
+        return 0;
     }
 
     /* Ignore all writes */
     s->reg++;
-    return 1;
+    return 0;
 }
 
 static void i2c_ddc_init(Object *obj)
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
                   ` (2 preceding siblings ...)
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes Linus Walleij
@ 2018-02-27 10:49 ` Linus Walleij
  2018-02-27 17:19   ` Peter Maydell
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation Linus Walleij
  2018-02-27 17:26 ` [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Peter Maydell
  5 siblings, 1 reply; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:49 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

This adds support for emulating the Silicon Image SII9022 DVI/HDMI
bridge. It's not very clever right now, it just acknowledges
the switch into DDC I2C mode and back. Combining this with the
existing DDC I2C emulation gives the right behavior on the Versatile
Express emulation passing through the QEMU EDID to the emulated
platform.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Update license to GPLv2 or later + SPDX identifier
- Instantiate the DDC I2C as part of the class realization so
  we do not need to add the DDC "on the side" in machines
  using SII9022.
- Switch to using trace events instead of debug prints.
---
 hw/display/Makefile.objs |   1 +
 hw/display/sii9022.c     | 188 +++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/trace-events  |   5 ++
 3 files changed, 194 insertions(+)
 create mode 100644 hw/display/sii9022.c

diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index d3a4cb396eb9..3c7c75b94da5 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -3,6 +3,7 @@ common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
 common-obj-$(CONFIG_G364FB) += g364fb.o
 common-obj-$(CONFIG_JAZZ_LED) += jazz_led.o
 common-obj-$(CONFIG_PL110) += pl110.o
+common-obj-$(CONFIG_SII9022) += sii9022.o
 common-obj-$(CONFIG_SSD0303) += ssd0303.o
 common-obj-$(CONFIG_SSD0323) += ssd0323.o
 common-obj-$(CONFIG_XEN) += xenfb.o
diff --git a/hw/display/sii9022.c b/hw/display/sii9022.c
new file mode 100644
index 000000000000..b019ac0ca880
--- /dev/null
+++ b/hw/display/sii9022.c
@@ -0,0 +1,188 @@
+/*
+ * Silicon Image SiI9022
+ *
+ * This is a pretty hollow emulation: all we do is acknowledge that we
+ * exist (chip ID) and confirm that we get switched over into DDC mode
+ * so the emulated host can proceed to read out EDID data. All subsequent
+ * set-up of connectors etc will be acknowledged and ignored.
+ *
+ * Copyright (C) 2018 Linus Walleij
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "hw/i2c/i2c.h"
+#include "hw/i2c/i2c-ddc.h"
+#include "trace.h"
+
+#define SII9022_SYS_CTRL_DATA 0x1a
+#define SII9022_SYS_CTRL_PWR_DWN 0x10
+#define SII9022_SYS_CTRL_AV_MUTE 0x08
+#define SII9022_SYS_CTRL_DDC_BUS_REQ 0x04
+#define SII9022_SYS_CTRL_DDC_BUS_GRTD 0x02
+#define SII9022_SYS_CTRL_OUTPUT_MODE 0x01
+#define SII9022_SYS_CTRL_OUTPUT_HDMI 1
+#define SII9022_SYS_CTRL_OUTPUT_DVI 0
+#define SII9022_REG_CHIPID 0x1b
+#define SII9022_INT_ENABLE 0x3c
+#define SII9022_INT_STATUS 0x3d
+#define SII9022_INT_STATUS_HOTPLUG 0x01;
+#define SII9022_INT_STATUS_PLUGGED 0x04;
+
+#define TYPE_SII9022 "sii9022"
+#define SII9022(obj) OBJECT_CHECK(sii9022_state, (obj), TYPE_SII9022)
+
+typedef struct sii9022_state {
+    I2CSlave parent_obj;
+    uint8_t ptr;
+    bool addr_byte;
+    bool ddc_req;
+    bool ddc_skip_finish;
+    bool ddc;
+} sii9022_state;
+
+static const VMStateDescription vmstate_sii9022 = {
+    .name = "sii9022",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_I2C_SLAVE(parent_obj, sii9022_state),
+        VMSTATE_UINT8(ptr, sii9022_state),
+        VMSTATE_BOOL(addr_byte, sii9022_state),
+        VMSTATE_BOOL(ddc_req, sii9022_state),
+        VMSTATE_BOOL(ddc_skip_finish, sii9022_state),
+        VMSTATE_BOOL(ddc, sii9022_state),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static int sii9022_event(I2CSlave *i2c, enum i2c_event event)
+{
+    sii9022_state *s = SII9022(i2c);
+
+    switch (event) {
+    case I2C_START_SEND:
+        s->addr_byte = true;
+        break;
+    case I2C_START_RECV:
+        break;
+    case I2C_FINISH:
+        break;
+    case I2C_NACK:
+        break;
+    }
+
+    return 0;
+}
+
+static int sii9022_rx(I2CSlave *i2c)
+{
+    sii9022_state *s = SII9022(i2c);
+    uint8_t res = 0x00;
+
+    switch (s->ptr) {
+    case SII9022_SYS_CTRL_DATA:
+        if (s->ddc_req) {
+            /* Acknowledge DDC bus request */
+            res = SII9022_SYS_CTRL_DDC_BUS_GRTD | SII9022_SYS_CTRL_DDC_BUS_REQ;
+        }
+        break;
+    case SII9022_REG_CHIPID:
+        res = 0xb0;
+        break;
+    case SII9022_INT_STATUS:
+        /* Something is cold-plugged in, no interrupts */
+        res = SII9022_INT_STATUS_PLUGGED;
+        break;
+    default:
+        break;
+    }
+
+    trace_sii9022_read_reg(s->ptr, res);
+    s->ptr++;
+
+    return res;
+}
+
+static int sii9022_tx(I2CSlave *i2c, uint8_t data)
+{
+    sii9022_state *s = SII9022(i2c);
+
+    if (s->addr_byte) {
+        s->ptr = data;
+        s->addr_byte = false;
+        return 0;
+    }
+
+    switch (s->ptr) {
+    case SII9022_SYS_CTRL_DATA:
+        if (data & SII9022_SYS_CTRL_DDC_BUS_REQ) {
+            s->ddc_req = true;
+            if (data & SII9022_SYS_CTRL_DDC_BUS_GRTD) {
+                s->ddc = true;
+                /* Skip this finish since we just switched to DDC */
+                s->ddc_skip_finish = true;
+                trace_sii9022_switch_mode("DDC");
+            }
+        } else {
+            s->ddc_req = false;
+            s->ddc = false;
+            trace_sii9022_switch_mode("normal");
+        }
+        break;
+    default:
+        break;
+    }
+
+    trace_sii9022_write_reg(s->ptr, data);
+    s->ptr++;
+
+    return 0;
+}
+
+static void sii9022_reset(DeviceState *dev)
+{
+    sii9022_state *s = SII9022(dev);
+
+    s->ptr = 0;
+    s->addr_byte = false;
+}
+
+static void sii9022_realize(DeviceState *dev, Error **errp)
+{
+    I2CBus *bus;
+
+    bus = I2C_BUS(qdev_get_parent_bus(dev));
+    i2c_create_slave(bus, TYPE_I2CDDC, 0x50);
+}
+
+static void sii9022_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
+
+    k->event = sii9022_event;
+    k->recv = sii9022_rx;
+    k->send = sii9022_tx;
+    dc->reset = sii9022_reset;
+    dc->realize = sii9022_realize;
+    dc->vmsd = &vmstate_sii9022;
+}
+
+static const TypeInfo sii9022_info = {
+    .name          = TYPE_SII9022,
+    .parent        = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(sii9022_state),
+    .class_init    = sii9022_class_init,
+};
+
+static void sii9022_register_types(void)
+{
+    type_register_static(&sii9022_info);
+}
+
+type_init(sii9022_register_types)
diff --git a/hw/display/trace-events b/hw/display/trace-events
index da498c1def45..5a48c6cb6a6d 100644
--- a/hw/display/trace-events
+++ b/hw/display/trace-events
@@ -132,3 +132,8 @@ vga_cirrus_read_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
 vga_cirrus_write_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
 vga_cirrus_read_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
 vga_cirrus_write_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
+
+# hw/display/sii9022.c
+sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
+sii9022_write_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
+sii9022_switch_mode(const char *mode) "mode: %s"
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
                   ` (3 preceding siblings ...)
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022 Linus Walleij
@ 2018-02-27 10:49 ` Linus Walleij
  2018-02-27 17:12   ` Peter Maydell
  2018-02-27 23:34   ` Philippe Mathieu-Daudé
  2018-02-27 17:26 ` [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Peter Maydell
  5 siblings, 2 replies; 12+ messages in thread
From: Linus Walleij @ 2018-02-27 10:49 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: qemu-arm, Philippe Mathieu-Daudé, Corey Minyard, Linus Walleij

This adds the SiI9022 and EDID I2C devices to the ARM Versatile
Express machine, and selects the two I2C devices necessary in the
arm-softmmy.mak configuration so everything will build smoothly.

I am implementing proper handling of the graphics in the Linux
kernel and adding proper emulation of SiI9022 and EDID makes the
driver probe as nicely as before, retrieveing the resolutions
supported by the "QEMU monitor" and overall just working nice.

The assignment of the SiI9022 at address 0x39 and the EDID
DDC I2C at address 0x50 is not strictly correct: the DDC I2C
is there all the time but in the actual component it only
appears once activated inside the SiI9022, so ideally it should
be added and removed to the bus by the SiI9022. However for this
purpose it works fine to just have it around.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Only add the SII9022 now that it will by itself realize
  the DDCI2C as part of the bridge.
---
 default-configs/arm-softmmu.mak | 2 ++
 hw/arm/vexpress.c               | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index ca34cf446242..54f855d07206 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -21,6 +21,8 @@ CONFIG_STELLARIS_INPUT=y
 CONFIG_STELLARIS_ENET=y
 CONFIG_SSD0303=y
 CONFIG_SSD0323=y
+CONFIG_DDC=y
+CONFIG_SII9022=y
 CONFIG_ADS7846=y
 CONFIG_MAX111X=y
 CONFIG_SSI=y
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index dc5928ae1ab5..9fad79177a19 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -29,6 +29,7 @@
 #include "hw/arm/arm.h"
 #include "hw/arm/primecell.h"
 #include "hw/devices.h"
+#include "hw/i2c/i2c.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
@@ -537,6 +538,7 @@ static void vexpress_common_init(MachineState *machine)
     uint32_t sys_id;
     DriveInfo *dinfo;
     pflash_t *pflash0;
+    I2CBus *i2c;
     ram_addr_t vram_size, sram_size;
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *vram = g_new(MemoryRegion, 1);
@@ -628,7 +630,9 @@ static void vexpress_common_init(MachineState *machine)
     sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
     sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
 
-    /* VE_SERIALDVI: not modelled */
+    dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL);
+    i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
+    i2c_create_slave(i2c, "sii9022", 0x39);
 
     sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation Linus Walleij
@ 2018-02-27 17:12   ` Peter Maydell
  2018-02-27 23:34   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2018-02-27 17:12 UTC (permalink / raw)
  To: Linus Walleij
  Cc: QEMU Developers, qemu-arm, Philippe Mathieu-Daudé, Corey Minyard

On 27 February 2018 at 10:49, Linus Walleij <linus.walleij@linaro.org> wrote:
> This adds the SiI9022 and EDID I2C devices to the ARM Versatile
> Express machine, and selects the two I2C devices necessary in the
> arm-softmmy.mak configuration so everything will build smoothly.
>
> I am implementing proper handling of the graphics in the Linux
> kernel and adding proper emulation of SiI9022 and EDID makes the
> driver probe as nicely as before, retrieveing the resolutions
> supported by the "QEMU monitor" and overall just working nice.
>
> The assignment of the SiI9022 at address 0x39 and the EDID
> DDC I2C at address 0x50 is not strictly correct: the DDC I2C
> is there all the time but in the actual component it only
> appears once activated inside the SiI9022, so ideally it should
> be added and removed to the bus by the SiI9022. However for this
> purpose it works fine to just have it around.

This last paragraph in the commit message can just be
removed now the DDC I2C isn't created here, right?

> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Only add the SII9022 now that it will by itself realize
>   the DDCI2C as part of the bridge.
> ---
>  default-configs/arm-softmmu.mak | 2 ++
>  hw/arm/vexpress.c               | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)

(if this is the only problem with the patchset I'll just fix
it up in my tree)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022 Linus Walleij
@ 2018-02-27 17:19   ` Peter Maydell
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2018-02-27 17:19 UTC (permalink / raw)
  To: Linus Walleij
  Cc: QEMU Developers, qemu-arm, Philippe Mathieu-Daudé, Corey Minyard

On 27 February 2018 at 10:49, Linus Walleij <linus.walleij@linaro.org> wrote:
> This adds support for emulating the Silicon Image SII9022 DVI/HDMI
> bridge. It's not very clever right now, it just acknowledges
> the switch into DDC I2C mode and back. Combining this with the
> existing DDC I2C emulation gives the right behavior on the Versatile
> Express emulation passing through the QEMU EDID to the emulated
> platform.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> +typedef struct sii9022_state {
> +    I2CSlave parent_obj;
> +    uint8_t ptr;
> +    bool addr_byte;
> +    bool ddc_req;
> +    bool ddc_skip_finish;
> +    bool ddc;
> +} sii9022_state;

> +static void sii9022_reset(DeviceState *dev)
> +{
> +    sii9022_state *s = SII9022(dev);
> +
> +    s->ptr = 0;
> +    s->addr_byte = false;

I asked about reset before -- can we just add
     s->ddc_req = false;
     s->ddc_skip_finish = false;
     s->ddc = false;

?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation
  2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
                   ` (4 preceding siblings ...)
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation Linus Walleij
@ 2018-02-27 17:26 ` Peter Maydell
  2018-02-28 12:44   ` Linus Walleij
  5 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2018-02-27 17:26 UTC (permalink / raw)
  To: Linus Walleij
  Cc: QEMU Developers, qemu-arm, Philippe Mathieu-Daudé, Corey Minyard

On 27 February 2018 at 10:48, Linus Walleij <linus.walleij@linaro.org> wrote:
> This series adds proper display bridge/connector emulation
> for the Versatile Express, implementing a simple Silicon
> Image 9022 emulation spawning a DDC I2C child.
>
> After the series the Versatile Express is successfully
> presented the "QEMU monitor" through DDC I2C.
>
> The series includes two refactorings from Corey and a
> minor bug fix for the i2c-ddc so that everything is smoothly
> integrated.
>
> Corey Minyard (2):
>   i2c: Fix some brace style issues
>   i2c: Move the bus class to i2c.h
>
> Linus Walleij (3):
>   hw/i2c-ddc: Do not fail writes
>   hw/sii9022: Add support for Silicon Image SII9022
>   arm/vexpress: Add proper display connector emulation

Hi; I've applied this to target-arm.next with the tweak to
the commit message of patch 5 and the reset function in patch 4.
Let me know if you think those are wrong or you'd prefer to
respin the series yourself.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation Linus Walleij
  2018-02-27 17:12   ` Peter Maydell
@ 2018-02-27 23:34   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-02-27 23:34 UTC (permalink / raw)
  To: Linus Walleij, qemu-devel, Peter Maydell; +Cc: qemu-arm, Corey Minyard

[-- Attachment #1: Type: text/plain, Size: 2984 bytes --]

On 02/27/2018 07:49 AM, Linus Walleij wrote:
> This adds the SiI9022 and EDID I2C devices to the ARM Versatile
> Express machine, and selects the two I2C devices necessary in the
> arm-softmmy.mak configuration so everything will build smoothly.
> 
> I am implementing proper handling of the graphics in the Linux
> kernel and adding proper emulation of SiI9022 and EDID makes the
> driver probe as nicely as before, retrieveing the resolutions
> supported by the "QEMU monitor" and overall just working nice.
> 
> The assignment of the SiI9022 at address 0x39 and the EDID
> DDC I2C at address 0x50 is not strictly correct: the DDC I2C
> is there all the time but in the actual component it only
> appears once activated inside the SiI9022, so ideally it should
> be added and removed to the bus by the SiI9022. However for this
> purpose it works fine to just have it around.
> 
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
> ChangeLog v1->v2:
> - Only add the SII9022 now that it will by itself realize
>   the DDCI2C as part of the bridge.
> ---
>  default-configs/arm-softmmu.mak | 2 ++
>  hw/arm/vexpress.c               | 6 +++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
> index ca34cf446242..54f855d07206 100644
> --- a/default-configs/arm-softmmu.mak
> +++ b/default-configs/arm-softmmu.mak
> @@ -21,6 +21,8 @@ CONFIG_STELLARIS_INPUT=y
>  CONFIG_STELLARIS_ENET=y
>  CONFIG_SSD0303=y
>  CONFIG_SSD0323=y
> +CONFIG_DDC=y
> +CONFIG_SII9022=y
>  CONFIG_ADS7846=y
>  CONFIG_MAX111X=y
>  CONFIG_SSI=y
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index dc5928ae1ab5..9fad79177a19 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -29,6 +29,7 @@
>  #include "hw/arm/arm.h"
>  #include "hw/arm/primecell.h"
>  #include "hw/devices.h"
> +#include "hw/i2c/i2c.h"
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> @@ -537,6 +538,7 @@ static void vexpress_common_init(MachineState *machine)
>      uint32_t sys_id;
>      DriveInfo *dinfo;
>      pflash_t *pflash0;
> +    I2CBus *i2c;
>      ram_addr_t vram_size, sram_size;
>      MemoryRegion *sysmem = get_system_memory();
>      MemoryRegion *vram = g_new(MemoryRegion, 1);
> @@ -628,7 +630,9 @@ static void vexpress_common_init(MachineState *machine)
>      sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
>      sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
>  
> -    /* VE_SERIALDVI: not modelled */
> +    dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL);
> +    i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
> +    i2c_create_slave(i2c, "sii9022", 0x39);
>  
>      sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
>  
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes
  2018-02-27 10:49 ` [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes Linus Walleij
@ 2018-02-27 23:38   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-02-27 23:38 UTC (permalink / raw)
  To: Linus Walleij, qemu-devel, Peter Maydell; +Cc: qemu-arm, Corey Minyard

[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]

On 02/27/2018 07:49 AM, Linus Walleij wrote:
> The tx function of the DDC I2C slave emulation was returning 1
> on all writes resulting in NACK in the I2C bus. Changing it to
> 0 makes the DDC I2C work fine with bit-banged I2C such as the
> versatile I2C.
> 
> I guess it was not affecting whatever I2C controller this was
> used with until now, but with the Versatile I2C it surely
> does not work.
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  hw/i2c/i2c-ddc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
> index 199dac9e41c1..bec0c91e2dd0 100644
> --- a/hw/i2c/i2c-ddc.c
> +++ b/hw/i2c/i2c-ddc.c
> @@ -259,12 +259,12 @@ static int i2c_ddc_tx(I2CSlave *i2c, uint8_t data)
>          s->reg = data;
>          s->firstbyte = false;
>          DPRINTF("[EDID] Written new pointer: %u\n", data);
> -        return 1;
> +        return 0;
>      }
>  
>      /* Ignore all writes */
>      s->reg++;
> -    return 1;
> +    return 0;
>  }
>  
>  static void i2c_ddc_init(Object *obj)
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation
  2018-02-27 17:26 ` [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Peter Maydell
@ 2018-02-28 12:44   ` Linus Walleij
  0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2018-02-28 12:44 UTC (permalink / raw)
  To: Peter Maydell
  Cc: QEMU Developers, qemu-arm, Philippe Mathieu-Daudé, Corey Minyard

On Tue, Feb 27, 2018 at 6:26 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 27 February 2018 at 10:48, Linus Walleij <linus.walleij@linaro.org> wrote:
>> This series adds proper display bridge/connector emulation
>> for the Versatile Express, implementing a simple Silicon
>> Image 9022 emulation spawning a DDC I2C child.
>>
>> After the series the Versatile Express is successfully
>> presented the "QEMU monitor" through DDC I2C.
>>
>> The series includes two refactorings from Corey and a
>> minor bug fix for the i2c-ddc so that everything is smoothly
>> integrated.
>>
>> Corey Minyard (2):
>>   i2c: Fix some brace style issues
>>   i2c: Move the bus class to i2c.h
>>
>> Linus Walleij (3):
>>   hw/i2c-ddc: Do not fail writes
>>   hw/sii9022: Add support for Silicon Image SII9022
>>   arm/vexpress: Add proper display connector emulation
>
> Hi; I've applied this to target-arm.next with the tweak to
> the commit message of patch 5 and the reset function in patch 4.
> Let me know if you think those are wrong or you'd prefer to
> respin the series yourself.

I am certain you did it better than I could, thanks a lot.

I forgot about the reset business, sorry :(

I will test it once it hits the trunk!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-02-28 12:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 10:48 [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Linus Walleij
2018-02-27 10:48 ` [Qemu-devel] [PATCH 1/5] i2c: Fix some brace style issues Linus Walleij
2018-02-27 10:49 ` [Qemu-devel] [PATCH 2/5] i2c: Move the bus class to i2c.h Linus Walleij
2018-02-27 10:49 ` [Qemu-devel] [PATCH 3/5] hw/i2c-ddc: Do not fail writes Linus Walleij
2018-02-27 23:38   ` Philippe Mathieu-Daudé
2018-02-27 10:49 ` [Qemu-devel] [PATCH 4/5] hw/sii9022: Add support for Silicon Image SII9022 Linus Walleij
2018-02-27 17:19   ` Peter Maydell
2018-02-27 10:49 ` [Qemu-devel] [PATCH 5/5] arm/vexpress: Add proper display connector emulation Linus Walleij
2018-02-27 17:12   ` Peter Maydell
2018-02-27 23:34   ` Philippe Mathieu-Daudé
2018-02-27 17:26 ` [Qemu-devel] [PATCH 0/5] Versatile Express SiI9022 emulation Peter Maydell
2018-02-28 12:44   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.