path: root/hw/misc/npcm7xx_clk.c
diff options
authorPeter Maydell <peter.maydell@linaro.org>2021-01-29 14:58:55 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-02-15 13:16:12 +0000
commitb7878f38a00806c221c51001509329105f48af1f (patch)
treefda83058d394e6a1139f93ec5145bcbd85921b6c /hw/misc/npcm7xx_clk.c
parent7191258e926306472876b000e17c7e2b9f1be3ca (diff)
clock: Add ClockEvent parameter to callbacks
The Clock framework allows users to specify a callback which is called after the clock's period has been updated. Some users need to also have a callback which is called before the clock period is updated. As the first step in adding support for notifying Clock users on pre-update events, add an argument to the ClockCallback to specify what event is being notified, and add an argument to the various functions for registering a callback to specify which events are of interest to that callback. Note that the documentation update renders correct the previously incorrect claim in 'Adding a new clock' that callbacks "will be explained in a following section". Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Luc Michel <luc@lmichel.fr> --- v2->v3: used 'unsigned int' instead of 'int' for parameters and struct fields containing an event mask, as suggested by Philippe; fixed events argument to qdev_init_clock_in() with NULL callback pointer in npcm7xx_adc.c (spotted by Hao)
Diffstat (limited to 'hw/misc/npcm7xx_clk.c')
1 files changed, 22 insertions, 4 deletions
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
index 0bcae9ce95..a1ee67dc9a 100644
--- a/hw/misc/npcm7xx_clk.c
+++ b/hw/misc/npcm7xx_clk.c
@@ -586,15 +586,26 @@ static const DividerInitInfo divider_init_info_list[] = {
+static void npcm7xx_clk_update_pll_cb(void *opaque, ClockEvent event)
+ npcm7xx_clk_update_pll(opaque);
static void npcm7xx_clk_pll_init(Object *obj)
NPCM7xxClockPLLState *pll = NPCM7XX_CLOCK_PLL(obj);
pll->clock_in = qdev_init_clock_in(DEVICE(pll), "clock-in",
- npcm7xx_clk_update_pll, pll);
+ npcm7xx_clk_update_pll_cb, pll,
+ ClockUpdate);
pll->clock_out = qdev_init_clock_out(DEVICE(pll), "clock-out");
+static void npcm7xx_clk_update_sel_cb(void *opaque, ClockEvent event)
+ npcm7xx_clk_update_sel(opaque);
static void npcm7xx_clk_sel_init(Object *obj)
int i;
@@ -603,16 +614,23 @@ static void npcm7xx_clk_sel_init(Object *obj)
for (i = 0; i < NPCM7XX_CLK_SEL_MAX_INPUT; ++i) {
sel->clock_in[i] = qdev_init_clock_in(DEVICE(sel),
g_strdup_printf("clock-in[%d]", i),
- npcm7xx_clk_update_sel, sel);
+ npcm7xx_clk_update_sel_cb, sel, ClockUpdate);
sel->clock_out = qdev_init_clock_out(DEVICE(sel), "clock-out");
+static void npcm7xx_clk_update_divider_cb(void *opaque, ClockEvent event)
+ npcm7xx_clk_update_divider(opaque);
static void npcm7xx_clk_divider_init(Object *obj)
NPCM7xxClockDividerState *div = NPCM7XX_CLOCK_DIVIDER(obj);
div->clock_in = qdev_init_clock_in(DEVICE(div), "clock-in",
- npcm7xx_clk_update_divider, div);
+ npcm7xx_clk_update_divider_cb,
+ div, ClockUpdate);
div->clock_out = qdev_init_clock_out(DEVICE(div), "clock-out");
@@ -875,7 +893,7 @@ static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
int i;
- s->clkref = qdev_init_clock_in(DEVICE(s), "clkref", NULL, NULL);
+ s->clkref = qdev_init_clock_in(DEVICE(s), "clkref", NULL, NULL, 0);
/* First pass: init all converter modules */