diff options
author | Xiaojuan Yang <yangxiaojuan@loongson.cn> | 2022-07-01 17:34:00 +0800 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-07-04 11:08:58 +0530 |
commit | e5c0367e2bbcf730e96614f63ea7575885fdde98 (patch) | |
tree | b706c453ab880d8d24eabd1e2060f58ecf963f33 /hw/rtc | |
parent | 53a5eb2e7a7f8cebb3010fc658e935679379a0fa (diff) |
hw/rtc/ls7a_rtc: Add reset function
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>
Diffstat (limited to 'hw/rtc')
-rw-r--r-- | hw/rtc/ls7a_rtc.c | 20 |
1 files changed, 20 insertions, 0 deletions
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"; } |