qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock()


From: Peter Maydell
Subject: Re: [RFC PATCH-for-6.1 5/9] hw/core/qdev-clock: Add qdev_ground_clock() helper
Date: Mon, 19 Apr 2021 15:22:34 +0100

On Fri, 9 Apr 2021 at 07:24, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> 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;
> +}

I'm not really convinced that we need this, given that we have
exactly one user of it in the tree. I think if you happen to want
a fixed-frequency-0Hz clock it's not a big deal to just create
it like any other clock. If we had half a dozen users in the tree
I might feel differently.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]