OSDN Git Service

clock: Provide builtin multiplier/divider
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 12 Aug 2021 09:33:40 +0000 (10:33 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Wed, 1 Sep 2021 10:08:19 +0000 (11:08 +0100)
commit99abcbc7600c62c294e973db340adf6939932a93
tree61c3fa0f1a7f6a70925a76a6d4f450610f9e40fe
parenta860df4f540d438a9531c70ff4eb0995841e7202
clock: Provide builtin multiplier/divider

It is quite common for a clock tree to involve possibly programmable
clock multipliers or dividers, where the frequency of a clock is for
instance divided by 8 to produce a slower clock to feed to a
particular device.

Currently we provide no convenient mechanism for modelling this.  You
can implement it by having an input Clock and an output Clock, and
manually setting the period of the output clock in the period-changed
callback of the input clock, but that's quite clunky.

This patch adds support in the Clock objects themselves for setting a
multiplier or divider.  The effect of setting this on a clock is that
when the clock's period is changed, all the children of the clock are
set to period * multiplier / divider, rather than being set to the
same period as the parent clock.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alexandre Iooss <erdnaxe@crans.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Luc Michel <luc@lmichel.fr>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Message-id: 20210812093356.1946-10-peter.maydell@linaro.org
docs/devel/clocks.rst
hw/core/clock-vmstate.c
hw/core/clock.c
hw/core/trace-events
include/hw/clock.h