summaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>2014-09-25 22:23:42 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2014-10-23 16:41:26 +0200
commit17a96a146cb5195ab1f6b5cf48645f9f6450539f (patch)
treeef4fe63aa1c1b42712a10137adc4bfd2ec0aa61c /hw/core
parentaef0869e8ed83ec201488020a9a1cc44d85d72bf (diff)
downloadqemu-17a96a146cb5195ab1f6b5cf48645f9f6450539f.zip
qdev: gpio: Define qdev_pass_gpios()
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. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/qdev.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 31014e8769..c247fffd7f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -483,6 +483,32 @@ 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++) {
+ const char *nm = ngl->name ? ngl->name : "unnamed-gpio-in";
+ char *propname = g_strdup_printf("%s[%d]", nm, i);
+
+ object_property_add_alias(OBJECT(container), propname,
+ OBJECT(dev), propname,
+ &error_abort);
+ }
+ for (i = 0; i < ngl->num_out; i++) {
+ const char *nm = ngl->name ? ngl->name : "unnamed-gpio-out";
+ char *propname = g_strdup_printf("%s[%d]", nm, 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;