All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaojuan Yang <yangxiaojuan@loongson.cn>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, gaosong@loongson.cn,
	maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk,
	mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca,
	f4bug@amsat.org, peter.maydell@linaro.org
Subject: [PATCH 04/11] hw/rtc/ls7a_rtc: Add reset function
Date: Fri,  1 Jul 2022 17:34:00 +0800	[thread overview]
Message-ID: <20220701093407.2150607-5-yangxiaojuan@loongson.cn> (raw)
In-Reply-To: <20220701093407.2150607-1-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>
---
 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.31.1



  parent reply	other threads:[~2022-07-01  9:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  9:33 [PATCH v2 00/11] Fix bugs for LoongArch virt machine Xiaojuan Yang
2022-07-01  9:33 ` [PATCH 01/11] hw/rtc/ls7a_rtc: Fix uninitialied bugs and toymatch writing function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:33 ` [PATCH 02/11] hw/rtc/ls7a_rtc: Fix timer call back function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:33 ` [PATCH 03/11] hw/rtc/ls7a_rtc: Remove unimplemented device in realized function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:34 ` Xiaojuan Yang [this message]
2022-07-01  9:34 ` [PATCH 05/11] hw/rtc/ls7a_rtc: Fix rtc enable and disable function Xiaojuan Yang
2022-07-04  5:14   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 06/11] hw/rtc/ls7a_rtc: Use tm struct pointer as arguments in toy_time_to_val() Xiaojuan Yang
2022-07-04  5:15   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 07/11] hw/rtc/ls7a_rtc: Fix 'calculate' spelling errors Xiaojuan Yang
2022-07-04  5:15   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 08/11] target/loongarch: Fix the meaning of ECFG reg's VS field Xiaojuan Yang
2022-07-04  5:18   ` Richard Henderson
2022-07-04  6:04     ` gaosong
2022-07-01  9:34 ` [PATCH 09/11] target/loongarch: Add lock when writing timer clear reg Xiaojuan Yang
2022-07-04  5:19   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 10/11] hw/intc/loongarch_ipi: Fix ipi device access of 64bits Xiaojuan Yang
2022-07-04  5:28   ` Richard Henderson
2022-07-04  9:09     ` gaosong
2022-07-01  9:34 ` [PATCH 11/11] hw/intc/loongarch_ipi: Fix mail send and any send function Xiaojuan Yang
2022-07-04  5:37   ` Richard Henderson
2022-07-04  9:10     ` gaosong
2022-07-04  9:26       ` Richard Henderson
2022-07-04  5:41 ` [PATCH v2 00/11] Fix bugs for LoongArch virt machine Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220701093407.2150607-5-yangxiaojuan@loongson.cn \
    --to=yangxiaojuan@loongson.cn \
    --cc=ani@anisinha.ca \
    --cc=f4bug@amsat.org \
    --cc=gaosong@loongson.cn \
    --cc=imammedo@redhat.com \
    --cc=maobibo@loongson.cn \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.