[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios()
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios() |
Date: |
Sun, 3 Aug 2014 18:58:37 -0700 |
Allows a container to take ownership of GPIOs in a contained
device and automatically connect them as GPIOs to the container.
This prepares for deprecation of the SYSBUS IRQ functionality, which
has this feature. We push it up to the device level instead of sysbus
level. There's nothing sysbus specific about passing GPIOs to
containers so its a legitimate device-level generic feature.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
hw/core/qdev.c | 28 ++++++++++++++++++++++++++++
include/hw/qdev-core.h | 3 +++
2 files changed, 31 insertions(+)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index bf2c227..708363f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -440,6 +440,34 @@ void qdev_connect_gpio_out(DeviceState * dev, int n,
qemu_irq pin)
qdev_connect_gpio_out_named(dev, NULL, n, pin);
}
+void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
+ const char *name)
+{
+ int i;
+ NamedGPIOList *ngl = qdev_get_named_gpio_list(dev, name);
+
+ for (i = 0; i < ngl->num_in; i++) {
+ char *propname = g_strdup_printf("%s[%d]",
+ ngl->name ? ngl->name :
+ "unnamed-gpio-in",
+ i);
+ object_property_add_alias(OBJECT(container), propname,
+ OBJECT(dev), propname,
+ &error_abort);
+ }
+ for (i = 0; i < ngl->num_out; i++) {
+ char *propname = g_strdup_printf("%s[%d]",
+ ngl->name ? ngl->name :
+ "unnamed-gpio-in",
+ i);
+ object_property_add_alias(OBJECT(container), propname,
+ OBJECT(dev), propname,
+ &error_abort);
+ }
+ QLIST_REMOVE(ngl, node);
+ QLIST_INSERT_HEAD(&container->gpios, ngl, node);
+}
+
BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
{
BusState *bus;
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index d3326b1..08dafda 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -289,6 +289,9 @@ void qdev_init_gpio_in_named(DeviceState *dev,
qemu_irq_handler handler,
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
const char *name, int n);
+void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
+ const char *name);
+
BusState *qdev_get_parent_bus(DeviceState *dev);
/*** BUS API. ***/
--
2.0.1.1.gfbfc394
- [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting an IRQ, (continued)
- [Qemu-devel] [PATCH v1 08/16] qdev: gpio: Add API for intercepting an IRQ, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 09/16] qtest/irq: Rework IRQ interception, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 10/16] irq: Remove qemu_irq_intercept_out, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 11/16] qdev: gpio: delete NamedGPIOList::out, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 12/16] qdev: gpio: Remove qdev_init_gpio_out x1 restriction, Peter Crosthwaite, 2014/08/03
- [Qemu-devel] [PATCH v1 13/16] qdev: gpio: Define qdev_pass_gpios(),
Peter Crosthwaite <=
[Qemu-devel] [PATCH v1 14/16] ssi: xilinx_spi: Initialise CS GPIOs as NULL, Peter Crosthwaite, 2014/08/03
[Qemu-devel] [PATCH v1 15/16] ppc: convert g_new(qemu_irq usages to g_new0, Peter Crosthwaite, 2014/08/03