qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, zachp@xilinx.com, jues@xilinx.com,
	edgari@xilinx.com, kraxel@redhat.com, edgar.iglesias@gmail.com
Subject: [Qemu-devel] [RFC PATCH v5 10/14] qdev: Define qdev_get_gpio_out
Date: Mon, 27 Apr 2015 14:58:04 -0700	[thread overview]
Message-ID: <f9ca14592b51a26cb352565fb6ee27c62a087bf8.1430169159.git.peter.crosthwaite@xilinx.com> (raw)
In-Reply-To: <cover.1430169159.git.peter.crosthwaite@xilinx.com>

An API similar to the existing qdev_get_gpio_in() except gets outputs.
Useful for:

1: Implementing lightweight devices that don't want to keep pointers
to their own GPIOs. They can get their GPIO pointers at runtime from
QOM using this API.

2: testing or debugging code which may wish to override the
hardware generated value of of a GPIO with a user specified value
(E.G. interrupt injection).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 hw/core/qdev.c         | 12 ++++++++++++
 include/hw/qdev-core.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6e6a65d..d736613 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -490,6 +490,18 @@ qemu_irq qdev_get_gpio_in(DeviceState *dev, int n)
     return qdev_get_gpio_in_named(dev, NULL, n);
 }
 
+qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n)
+{
+    char *propname = g_strdup_printf("%s[%d]",
+                                     name ? name : "unnamed-gpio-out", n);
+    return (qemu_irq)object_property_get_link(OBJECT(dev), propname, NULL);
+}
+
+qemu_irq qdev_get_gpio_out(DeviceState *dev, int n)
+{
+    return qdev_get_gpio_out_named(dev, NULL, n);
+}
+
 void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
                                  qemu_irq pin)
 {
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4e673f9..95f7f0e 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -274,6 +274,8 @@ bool qdev_machine_modified(void);
 
 qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
 qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n);
+qemu_irq qdev_get_gpio_out(DeviceState *dev, int n);
+qemu_irq qdev_get_gpio_out_named(DeviceState *dev, const char *name, int n);
 
 void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
 void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
-- 
2.3.6.3.g2cc70ee

  parent reply	other threads:[~2015-04-27 21:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 21:57 [Qemu-devel] [RFC PATCH v5 00/14] data-driven device registers Peter Crosthwaite
2015-04-27 21:57 ` [Qemu-devel] [RFC PATCH v5 01/14] register: Add Register API Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 02/14] register: Add Memory API glue Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 03/14] register: Add support for decoding information Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 05/14] register: QOMify Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 04/14] register: Define REG and FIELD macros Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 06/14] register: Add block initialise helper Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 08/14] dma: Add Xilinx Zynq devcfg device model Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 07/14] bitops: Add ONES macro Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 09/14] xilinx_zynq: add devcfg to machine model Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 11/14] qdev: Add qdev_pass_all_gpios API Peter Crosthwaite
2015-04-27 21:58 ` Peter Crosthwaite [this message]
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 13/14] register: Add GPIO API Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 12/14] irq: Add opaque setter routine Peter Crosthwaite
2015-04-27 21:58 ` [Qemu-devel] [RFC PATCH v5 14/14] misc: Introduce ZynqMP IOU SLCR Peter Crosthwaite
2015-05-12  7:41 ` [Qemu-devel] [RFC PATCH v5 00/14] data-driven device registers Peter Crosthwaite

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f9ca14592b51a26cb352565fb6ee27c62a087bf8.1430169159.git.peter.crosthwaite@xilinx.com \
    --to=peter.crosthwaite@xilinx.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgari@xilinx.com \
    --cc=jues@xilinx.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zachp@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).