qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Damien Hedde <damien.hedde@greensocs.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, pbonzini@redhat.com,
	peter.maydell@linaro.org, edgar.iglesias@xilinx.com,
	mark.burton@greensocs.com, saipava@xilinx.com,
	luc.michel@greensocs.com, alistair@alistair23.me,
	Damien Hedde <damien.hedde@greensocs.com>
Subject: [Qemu-devel] [RFC PATCH 2/6] qdev: add power/clock gating control on bus tree
Date: Fri, 27 Jul 2018 16:37:21 +0200	[thread overview]
Message-ID: <2b92ae960dfc47149945c9e47f90b4433d8eee35.1532701430.git.damien.hedde@greensocs.com> (raw)
In-Reply-To: <cover.1532701430.git.damien.hedde@greensocs.com>

Add functions [qdev|qbus]_set_[power|clock]_all(_fn).
Theses allow to control power and clock gating along a bus hierarchy.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
 include/hw/qdev-core.h | 20 +++++++++++++++++
 hw/core/qdev.c         | 51 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 659287e185..607c367738 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -464,4 +464,24 @@ void device_set_power(DeviceState *dev, bool en);
  */
 void device_set_clock(DeviceState *dev, bool en);
 
+/**
+ * qdev/qbus_set_power_all(_fn)
+ * Enable/Disable the power of a tree starting
+ * at given device or bus
+ */
+void qdev_set_power_all(DeviceState *dev, bool en);
+void qdev_set_power_all_fn(void *opaque, bool en);
+void qbus_set_power_all(BusState *bus, bool en);
+void qbus_set_power_all_fn(void *opaque, bool en);
+
+/**
+ * qdev/qbus_set_clock_all(_fn)
+ * Enable/Disable the clock of a tree starting
+ * at given device or bus
+ */
+void qdev_set_clock_all(DeviceState *dev, bool en);
+void qdev_set_clock_all_fn(void *opaque, bool en);
+void qbus_set_clock_all(BusState *bus, bool en);
+void qbus_set_clock_all_fn(void *opaque, bool en);
+
 #endif
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index bb6d36eab9..24b90bd45f 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -1138,6 +1138,57 @@ void device_set_clock(DeviceState *dev, bool en)
     }
 }
 
+static int qdev_set_power_one(DeviceState *dev, void *opaque)
+{
+    device_set_power(dev, *((bool *)opaque));
+    return 0;
+}
+
+void qdev_set_power_all(DeviceState *dev, bool en)
+{
+    qdev_walk_children(dev, NULL, NULL, qdev_set_power_one, NULL, &en);
+}
+
+void qdev_set_power_all_fn(void *opaque, bool en)
+{
+    qdev_set_power_all(DEVICE(opaque), en);
+}
+
+void qbus_set_power_all(BusState *bus, bool en)
+{
+    qbus_walk_children(bus, NULL, NULL, qdev_set_power_one, NULL, &en);
+}
+
+void qbus_set_power_all_fn(void *opaque, bool en)
+{
+    qbus_set_power_all(BUS(opaque), en);
+}
+
+static int qdev_set_clock_one(DeviceState *dev, void *opaque)
+{
+    device_set_clock(dev, *((bool *)opaque));
+    return 0;
+}
+
+void qdev_set_clock_all(DeviceState *dev, bool en)
+{
+    qdev_walk_children(dev, NULL, NULL, qdev_set_clock_one, NULL, &en);
+}
+
+void qdev_set_clock_all_fn(void *opaque, bool en)
+{
+    qdev_set_clock_all(DEVICE(opaque), en);
+}
+
+void qbus_set_clock_all(BusState *bus, bool en)
+{
+    qbus_walk_children(bus, NULL, NULL, qdev_set_clock_one, NULL, &en);
+}
+
+void qbus_set_clock_all_fn(void *opaque, bool en)
+{
+    qbus_set_clock_all(BUS(opaque), en);
+}
 
 Object *qdev_get_machine(void)
 {
-- 
2.18.0

  parent reply	other threads:[~2018-07-27 14:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 14:37 [Qemu-devel] [RFC PATCH 0/6] Clock and power gating support Damien Hedde
2018-07-27 14:37 ` [Qemu-devel] [RFC PATCH 1/6] qdev: add a power and clock " Damien Hedde
     [not found]   ` <994d20ce-5332-b0db-aac0-bc906ef12fdb@amsat.org>
2018-07-31 10:35     ` Damien Hedde
2018-07-27 14:37 ` Damien Hedde [this message]
2018-07-27 16:39   ` [Qemu-devel] [Qemu-arm] [RFC PATCH 2/6] qdev: add power/clock gating control on bus tree Philippe Mathieu-Daudé
2018-08-02 11:07     ` Damien Hedde
2018-07-27 14:37 ` [Qemu-devel] [RFC PATCH 3/6] sysbus: Specialize gating_update to enable/disable memory regions Damien Hedde
2018-07-27 16:43   ` Philippe Mathieu-Daudé
2018-07-27 14:37 ` [Qemu-devel] [RFC PATCH 4/6] cadence_uart: add clock/power gating support Damien Hedde
2018-07-27 17:13   ` Philippe Mathieu-Daudé
2018-07-27 14:37 ` [Qemu-devel] [RFC PATCH 5/6] zynq_slcr: add uart clock gating and soft reset support Damien Hedde
2018-07-27 14:37 ` [Qemu-devel] [RFC PATCH 6/6] xilinx_zynq: add uart clock gating support Damien Hedde
2018-07-27 14:59 ` [Qemu-devel] [RFC PATCH 0/6] Clock and power " Peter Maydell
2018-07-27 15:12   ` KONRAD Frederic
2018-07-30 13:17     ` Mark Burton

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=2b92ae960dfc47149945c9e47f90b4433d8eee35.1532701430.git.damien.hedde@greensocs.com \
    --to=damien.hedde@greensocs.com \
    --cc=alistair@alistair23.me \
    --cc=edgar.iglesias@xilinx.com \
    --cc=luc.michel@greensocs.com \
    --cc=mark.burton@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=saipava@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).