[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 20/25] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock in
From: |
Peter Maydell |
Subject: |
[PATCH v2 20/25] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input |
Date: |
Thu, 28 Jan 2021 11:41:40 +0000 |
Switch the CMSDK APB watchdog device over to using its Clock input;
the wdogclk_frq property is now ignored.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Luc Michel <luc@lmichel.fr>
Message-id: 20210121190622.22000-21-peter.maydell@linaro.org
---
hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
index b03bcb73628..9cad0c67da4 100644
--- a/hw/watchdog/cmsdk-apb-watchdog.c
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
@@ -310,6 +310,15 @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev)
ptimer_transaction_commit(s->timer);
}
+static void cmsdk_apb_watchdog_clk_update(void *opaque)
+{
+ CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(opaque);
+
+ ptimer_transaction_begin(s->timer);
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
+ ptimer_transaction_commit(s->timer);
+}
+
static void cmsdk_apb_watchdog_init(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
@@ -319,7 +328,8 @@ static void cmsdk_apb_watchdog_init(Object *obj)
s, "cmsdk-apb-watchdog", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->wdogint);
- s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL);
+ s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK",
+ cmsdk_apb_watchdog_clk_update, s);
s->is_luminary = false;
s->id = cmsdk_apb_watchdog_id;
@@ -329,9 +339,9 @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev,
Error **errp)
{
CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(dev);
- if (s->wdogclk_frq == 0) {
+ if (!clock_has_source(s->wdogclk)) {
error_setg(errp,
- "CMSDK APB watchdog: wdogclk-frq property must be set");
+ "CMSDK APB watchdog: WDOGCLK clock must be connected");
return;
}
@@ -342,7 +352,7 @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev,
Error **errp)
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
ptimer_transaction_begin(s->timer);
- ptimer_set_freq(s->timer, s->wdogclk_frq);
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
ptimer_transaction_commit(s->timer);
}
--
2.20.1
- [PATCH v2 09/25] hw/watchdog/cmsdk-apb-watchdog: Add Clock input, (continued)
- [PATCH v2 09/25] hw/watchdog/cmsdk-apb-watchdog: Add Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 11/25] hw/arm/armsse: Wire up clocks, Peter Maydell, 2021/01/28
- [PATCH v2 13/25] hw/arm/mps2: Create and connect SYSCLK Clock, Peter Maydell, 2021/01/28
- [PATCH v2 12/25] hw/arm/mps2: Inline CMSDK_APB_TIMER creation, Peter Maydell, 2021/01/28
- [PATCH v2 16/25] hw/arm/stellaris: Convert SSYS to QOM device, Peter Maydell, 2021/01/28
- [PATCH v2 18/25] hw/timer/cmsdk-apb-timer: Convert to use Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 19/25] hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 15/25] hw/arm/musca: Create and connect ARMSSE Clocks, Peter Maydell, 2021/01/28
- [PATCH v2 14/25] hw/arm/mps2-tz: Create and connect ARMSSE Clocks, Peter Maydell, 2021/01/28
- [PATCH v2 17/25] hw/arm/stellaris: Create Clock input for watchdog, Peter Maydell, 2021/01/28
- [PATCH v2 20/25] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input,
Peter Maydell <=
- [PATCH v2 22/25] hw/arm/armsse: Use Clock to set system_clock_scale, Peter Maydell, 2021/01/28
- [PATCH v2 21/25] tests/qtest/cmsdk-apb-watchdog-test: Test clock changes, Peter Maydell, 2021/01/28
- [PATCH v2 23/25] arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE, Peter Maydell, 2021/01/28
- [PATCH v2 24/25] arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE, Peter Maydell, 2021/01/28
- [PATCH v2 25/25] hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS, Peter Maydell, 2021/01/28
- Re: [PATCH v2 00/25] Convert CMSDK timer, watchdog, dualtimer to Clock framework, Philippe Mathieu-Daudé, 2021/01/28