From patchwork Mon Jul 4 09:33:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 587118 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1ec:0:0:0:0 with SMTP id 12csp650507map; Mon, 4 Jul 2022 02:45:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uxfx0IQsdjetCD2OooPtRBkkfwb2CkBR0NyoIoxu36xFq0U8341/0cR86VPeXFfmyzIiDe X-Received: by 2002:a25:eb08:0:b0:664:3fbd:f9c9 with SMTP id d8-20020a25eb08000000b006643fbdf9c9mr29947579ybs.88.1656927913368; Mon, 04 Jul 2022 02:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656927913; cv=none; d=google.com; s=arc-20160816; b=fkZPjCXtkC4mEHwvNWIgQ7pj7LS/BYrs0XVl/aBNLClI8Faql/KN6M9Cr63KdafB4x D9zTqBIe7d+Ib9Kj7qqWwZ4Gx2+p+qBbA4rti+TNU8kRuFBILNvXavZF6hPomrs7GaCV nf2aFOkdNXqF3G+ocdDCTUBge03Zi8iyC8epp+jeT6QL5PddBmN53N+x1EnlYVVgez/P 7Pi+46R10mJCBnA3ZoeH2wEIjCrBOlDbNJoRmUBsUmwXjkZdD8LVMiwiJax2w7uYcYsR NjZ4a/PKw25i/pj/0AILoL4vgwrVJARwJtgC98qBSKBuTbz5k/Wt2/efcOiHjU3oYE7G GtaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xRn3dlMBTLw7s8LlUcFJIo3Piu/j8Godlc8+nn+z6/k=; b=KHkRMMJxm4XidoEJ/B9IAJ4tJOcWUstf/jyaJFAqGmYOT/+Qh3gQ61W6GKAbeQ5Wvb D90B1ysUuklZTWTSkdr6F6yNCW3ULZ2f/mX01bk6oogf00wLkVMk11quzKY1Zi2Oszcj Y8dk1ZmX7cAP8g7WlFD7MPjMxt4hJAJFLFHlGX5tz7GOdfhai4n6Zw2AE51PQDzJh2Yy QoJXHDsNixr5+qn90kJXlCDZXbLvz8U2YZmH7l8G903HDo4pM7Tv+YVZvSwJe57MOhHs wa94pg4F2k98iRH7Y5k81R0qn1WpzqkwK6DSiKC5NWYDADvXFJXKJr3mF+d5FhGAq5Xg pICw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mxpuontj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 64-20020a810943000000b0031c980c30b4si3635008ywj.525.2022.07.04.02.45.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Jul 2022 02:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mxpuontj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8Idk-0000ex-RS for patch@linaro.org; Mon, 04 Jul 2022 05:45:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8ITm-0001AX-Tq for qemu-devel@nongnu.org; Mon, 04 Jul 2022 05:34:55 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:44918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8ITl-000504-B0 for qemu-devel@nongnu.org; Mon, 04 Jul 2022 05:34:54 -0400 Received: by mail-pl1-x629.google.com with SMTP id l6so8059279plg.11 for ; Mon, 04 Jul 2022 02:34:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xRn3dlMBTLw7s8LlUcFJIo3Piu/j8Godlc8+nn+z6/k=; b=MxpuontjrktHYdZuYoznkc5z6olhgKsQX0MWYBZY6hn8dg8kHRVOQbai+DXGJwonJw zuYjSLZnSTOc7ySkdr2j/013N4PwhstwfsrrU6GR9/tU8jk2FQk3TVsvpYc3a3p21ms1 CZ9h3mwel6vP0RlS0bHh8hM9f5UZYGjfLhZAmtBR1JGqi4exySmFTg+8hFvqU4pEUpDV NM8mA/bnGySY82SV8ARMeM48I6rJ4TJfHjcx9rw/yFIh8ChLR+9zHA1gJZ34QbsI2Ddt 7t/PemsVVo5U5h0P6vBHAIphODEE5LWwucc4OhGgpt1I61eIX4kq9mlnNQ3vZ+XCtK+L UxQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xRn3dlMBTLw7s8LlUcFJIo3Piu/j8Godlc8+nn+z6/k=; b=mCP7JiUrco2zG1MQw29erTuMRl5+RztJo2/sQ++geGr6Zv/uPKgVegyySHReurLOpe EMSopl9BJIn2b7/MjvLbYoieH8yxqLV/lTh8mc64Rz4UyGtHYzn0ag9vtrPfZ7Do9gv1 tYXG4JM/+AWA1svCRLkhdo96Obn5D69UkcxswMtDMFXZqTgIvzetCiMrcrSDPWieBO00 1kH+KsGAUIkXmedVN0UMzPAO1SvbUlLcv1zKRQAauXGh4WUhYdZMejsTpk6ANyK9WJBa nYIaYZKx8jxMixKA5q39dXT4wuvFzqvzt6d9jJsQEfCkRmW8uFbD1t50kR58vXv9aGj9 jdww== X-Gm-Message-State: AJIora8RCtemUu9F5DwbTKObOiwnqhQmvlfir90dSWUB4shHHe1hLnyo 8fxVsRykWQ0qrP6N9TAww/Ntux5OwB+S8TWd X-Received: by 2002:a17:902:cf03:b0:16b:e692:c104 with SMTP id i3-20020a170902cf0300b0016be692c104mr2717340plg.134.1656927292026; Mon, 04 Jul 2022 02:34:52 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id z5-20020aa79e45000000b00525b7f3e906sm15353355pfq.27.2022.07.04.02.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 02:34:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Xiaojuan Yang Subject: [PULL 18/23] hw/rtc/ls7a_rtc: Add reset function Date: Mon, 4 Jul 2022 15:03:52 +0530 Message-Id: <20220704093357.983255-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704093357.983255-1-richard.henderson@linaro.org> References: <20220704093357.983255-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Xiaojuan Yang Add ls7a rtc reset function to delete timers and clear regs when rtc reset. Signed-off-by: Xiaojuan Yang Message-Id: <20220701093407.2150607-5-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson --- 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"; }