[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() help
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper |
Date: |
Fri, 9 Apr 2021 08:23:57 +0200 |
Clocks are rarely left unconnected, but rather connected to ground
plane to avoid noise. When representing the clock tree, we want to
see such ground clock. As we might reuse this clock on various
boards, introduce the qdev_ground_clock() which return a singleton
ground clock.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/qdev-clock.h | 9 +++++++++
hw/core/qdev-clock.c | 11 +++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h
index ffa0f7ba09e..2f2d2da6cd6 100644
--- a/include/hw/qdev-clock.h
+++ b/include/hw/qdev-clock.h
@@ -161,4 +161,13 @@ typedef struct ClockPortInitElem ClockPortInitArray[];
*/
void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks);
+/**
+ * qdev_ground_clock:
+ * @returns: a pointer to the ground clock
+ *
+ * Get the special 'ground' clock. This clock can be used as input
+ * (unclocked) or output.
+ */
+Clock *qdev_ground_clock(void);
+
#endif /* QDEV_CLOCK_H */
diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
index 117f4c6ea4a..a46384a84b7 100644
--- a/hw/core/qdev-clock.c
+++ b/hw/core/qdev-clock.c
@@ -210,3 +210,14 @@ void qdev_connect_clock_in(DeviceState *dev, const char
*name, Clock *source)
assert(!dev->realized);
clock_set_source(qdev_get_clock_in(dev, name), source);
}
+
+Clock *qdev_ground_clock(void)
+{
+ static Clock *gnd_clk;
+
+ if (!gnd_clk) {
+ gnd_clk = clock_new(qdev_get_machine(), "gnd");
+ }
+
+ return gnd_clk;
+}
--
2.26.3
- [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 1/9] hw/core/clock: Increase clock propagation trace events verbosity, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 3/9] hw/arm: Use new machine_create_constant_clock() helper, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 2/9] hw/core/machine: Add machine_create_constant_clock() helper, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 4/9] hw/mips: Use new machine_create_constant_clock() helper, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper,
Philippe Mathieu-Daudé <=
- [RFC PATCH-for-6.1 6/9] hw/misc/bcm2835_cprman: Use qdev_ground_clock() helper, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 7/9] hw/misc/bcm2835_cprman: Feed 'xosc' from the board, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 8/9] hw/clock: Declare clock_new() internally, Philippe Mathieu-Daudé, 2021/04/09
- [RFC PATCH-for-6.1 9/9] hw/core/machine: Reset machine clocks using qemu_register_reset(), Philippe Mathieu-Daudé, 2021/04/09
- Re: [RFC PATCH-for-6.1 0/9] hw/clock: Strengthen machine (non-qdev) clock propagation, Philippe Mathieu-Daudé, 2021/04/09