[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/23] hw/rtc/ls7a_rtc: Add reset function
From: |
Richard Henderson |
Subject: |
[PULL 18/23] hw/rtc/ls7a_rtc: Add reset function |
Date: |
Mon, 4 Jul 2022 15:03:52 +0530 |
From: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Add ls7a rtc reset function to delete timers and clear regs when rtc reset.
Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Message-Id: <20220701093407.2150607-5-yangxiaojuan@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
hw/rtc/ls7a_rtc.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/rtc/ls7a_rtc.c b/hw/rtc/ls7a_rtc.c
index f1e7a660e9..eb10cdb451 100644
--- a/hw/rtc/ls7a_rtc.c
+++ b/hw/rtc/ls7a_rtc.c
@@ -463,6 +463,25 @@ static void ls7a_rtc_realize(DeviceState *dev, Error
**errp)
}
+/* delete timer and clear reg when reset */
+static void ls7a_rtc_reset(DeviceState *dev)
+{
+ int i;
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ LS7ARtcState *d = LS7A_RTC(sbd);
+ for (i = 0; i < TIMER_NUMS; i++) {
+ if (toy_enabled(d)) {
+ timer_del(d->toy_timer[i]);
+ }
+ if (rtc_enabled(d)) {
+ timer_del(d->rtc_timer[i]);
+ }
+ d->toymatch[i] = 0;
+ d->rtcmatch[i] = 0;
+ }
+ d->cntrctl = 0;
+}
+
static int ls7a_rtc_pre_save(void *opaque)
{
LS7ARtcState *s = LS7A_RTC(opaque);
@@ -511,6 +530,7 @@ static void ls7a_rtc_class_init(ObjectClass *klass, void
*data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_ls7a_rtc;
dc->realize = ls7a_rtc_realize;
+ dc->reset = ls7a_rtc_reset;
dc->desc = "ls7a rtc";
}
--
2.34.1
- [PULL 06/23] scripts: add loongarch64 binfmt config, (continued)
- [PULL 06/23] scripts: add loongarch64 binfmt config, Richard Henderson, 2022/07/04
- [PULL 09/23] target/loongarch: Fix helper_asrtle_d/asrtgt_d raise wrong exception, Richard Henderson, 2022/07/04
- [PULL 10/23] target/loongarch: remove unused include hw/loader.h, Richard Henderson, 2022/07/04
- [PULL 12/23] default-configs: Add loongarch linux-user support, Richard Henderson, 2022/07/04
- [PULL 11/23] target/loongarch: Adjust functions and structure to support user-mode, Richard Henderson, 2022/07/04
- [PULL 14/23] hw/intc/loongarch_pch_msi: Fix msi vector convertion, Richard Henderson, 2022/07/04
- [PULL 13/23] target/loongarch: Update README, Richard Henderson, 2022/07/04
- [PULL 15/23] hw/rtc/ls7a_rtc: Fix uninitialied bugs and toymatch writing function, Richard Henderson, 2022/07/04
- [PULL 16/23] hw/rtc/ls7a_rtc: Fix timer call back function, Richard Henderson, 2022/07/04
- [PULL 17/23] hw/rtc/ls7a_rtc: Remove unimplemented device in realized function, Richard Henderson, 2022/07/04
- [PULL 18/23] hw/rtc/ls7a_rtc: Add reset function,
Richard Henderson <=
- [PULL 19/23] hw/rtc/ls7a_rtc: Fix rtc enable and disable function, Richard Henderson, 2022/07/04
- [PULL 20/23] hw/rtc/ls7a_rtc: Use tm struct pointer as arguments in toy_time_to_val(), Richard Henderson, 2022/07/04
- [PULL 21/23] hw/rtc/ls7a_rtc: Fix 'calculate' spelling errors, Richard Henderson, 2022/07/04
- [PULL 22/23] target/loongarch: Fix the meaning of ECFG reg's VS field, Richard Henderson, 2022/07/04
- [PULL 23/23] target/loongarch: Add lock when writing timer clear reg, Richard Henderson, 2022/07/04
- Re: [PULL 00/23] loongarch64 patch queue, Richard Henderson, 2022/07/04