[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/46] hw/timer/cmsdk-apb-timer: Convert to use Clock input
From: |
Peter Maydell |
Subject: |
[PULL 39/46] hw/timer/cmsdk-apb-timer: Convert to use Clock input |
Date: |
Fri, 29 Jan 2021 11:00:05 +0000 |
Switch the CMSDK APB timer device over to using its Clock input; the
pclk-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>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20210128114145.20536-19-peter.maydell@linaro.org
Message-id: 20210121190622.22000-19-peter.maydell@linaro.org
---
hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
index c63145ff553..f053146d88f 100644
--- a/hw/timer/cmsdk-apb-timer.c
+++ b/hw/timer/cmsdk-apb-timer.c
@@ -204,6 +204,15 @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
ptimer_transaction_commit(s->timer);
}
+static void cmsdk_apb_timer_clk_update(void *opaque)
+{
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
+
+ ptimer_transaction_begin(s->timer);
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
+ ptimer_transaction_commit(s->timer);
+}
+
static void cmsdk_apb_timer_init(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
@@ -213,15 +222,16 @@ static void cmsdk_apb_timer_init(Object *obj)
s, "cmsdk-apb-timer", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->timerint);
- s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL);
+ s->pclk = qdev_init_clock_in(DEVICE(s), "pclk",
+ cmsdk_apb_timer_clk_update, s);
}
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
{
CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
- if (s->pclk_frq == 0) {
- error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
+ if (!clock_has_source(s->pclk)) {
+ error_setg(errp, "CMSDK APB timer: pclk clock must be connected");
return;
}
@@ -232,7 +242,7 @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error
**errp)
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
ptimer_transaction_begin(s->timer);
- ptimer_set_freq(s->timer, s->pclk_frq);
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
ptimer_transaction_commit(s->timer);
}
--
2.20.1
- [PULL 41/46] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input, (continued)
- [PULL 41/46] hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input, Peter Maydell, 2021/01/29
- [PULL 40/46] hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input, Peter Maydell, 2021/01/29
- [PULL 28/46] hw/timer/cmsdk-apb-timer: Add Clock input, Peter Maydell, 2021/01/29
- [PULL 42/46] tests/qtest/cmsdk-apb-watchdog-test: Test clock changes, Peter Maydell, 2021/01/29
- [PULL 44/46] arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE, Peter Maydell, 2021/01/29
- [PULL 45/46] arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE, Peter Maydell, 2021/01/29
- [PULL 31/46] hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ", Peter Maydell, 2021/01/29
- [PULL 35/46] hw/arm/mps2-tz: Create and connect ARMSSE Clocks, Peter Maydell, 2021/01/29
- [PULL 37/46] hw/arm/stellaris: Convert SSYS to QOM device, Peter Maydell, 2021/01/29
- [PULL 46/46] hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS, Peter Maydell, 2021/01/29
- [PULL 39/46] hw/timer/cmsdk-apb-timer: Convert to use Clock input,
Peter Maydell <=
- [PULL 43/46] hw/arm/armsse: Use Clock to set system_clock_scale, Peter Maydell, 2021/01/29
- Re: [PULL 00/46] target-arm queue, no-reply, 2021/01/29