Message ID | 20221019111714.1953262-2-andrej.picej@norik.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp329305wrs; Wed, 19 Oct 2022 06:32:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hsmyQt04wLZguykJ8v8iXbH/+9MKVJPT6YUrg9oeZs639cQ6/Fk2ZLTOLfDKZNBilorfQ X-Received: by 2002:a17:907:3e1b:b0:78d:ccd0:c9f8 with SMTP id hp27-20020a1709073e1b00b0078dccd0c9f8mr6890672ejc.705.1666186351931; Wed, 19 Oct 2022 06:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186351; cv=none; d=google.com; s=arc-20160816; b=0nNugbi8aT2wthtIShOtALdbr348atcWZjLtCoWWNCmtl1AZK5m9gpqIz/YGXa9f+2 ciW/7+clkovv7ct+VcJBoSS5z9cGR+zjgBSQxhFieONW98x9mJ8xzqOQGvkiXPc7Yh0x UnJ6dbdbOpkfVpAdQy0K7ZbGhNDvSgBE0vENENHOPCB7c2LUXzyHPP8rK4rvr7xm4w8v fEYFIZI06Aqkv+e7Y3fnRqhEiClKSEWMM00EXgMkez8nw76loHBc43f9yZB1gvjqdOO7 TNj4hcXF3mJSy7ERI3yLCyJRyEehuED6sgVq851S1vl/2iH4Ew2kDxO+CxZ72aO5PumF x00A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZIxTik8qCVScEWj5sC/9qAFim//UicDvI+RfOQzsGsQ=; b=vEsFrXsPJmAyzAPKVoKbcSJC5MaCfuG/sZvC6qQUHuZOqUj7eW8FSgGCeM5JxtHF/3 jv2emHj2U1jLHwe58XyNwI3vRSeKitUu4kNrYWG0cpDI+isXPM+H28GwqdKfGLFPKVPh /b/zcYq18AdZX8qPcFQ6ZczLp/W+wJctpMCnMIa+naoP1v1U6gGEX1ULyVhgXCe+e/9r MLFtaorGFGC07vMCBOl6AK4X+pfA17cq5HfCU4hh6FpM2wwuN0niu6CQ27w3HRyygiDW HmqUgJ9yy0F43cvG1ZYFfp3XYPkoINoPeMKuUhpzhtKhOsQwPYMGNKr8Srala+U1aoEo FRog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@norik.com header.s=default header.b="Blppzso/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a056402191100b0045cfb63a018si15946530edz.31.2022.10.19.06.32.06; Wed, 19 Oct 2022 06:32:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@norik.com header.s=default header.b="Blppzso/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232505AbiJSNQI (ORCPT <rfc822;samuel.l.nystrom@gmail.com> + 99 others); Wed, 19 Oct 2022 09:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232319AbiJSNPi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Oct 2022 09:15:38 -0400 Received: from cpanel.siel.si (cpanel.siel.si [46.19.9.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6AF8303EF; Wed, 19 Oct 2022 06:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=norik.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ZIxTik8qCVScEWj5sC/9qAFim//UicDvI+RfOQzsGsQ=; b=Blppzso/pr2nGSHf+R1U1YeYg2 JADA3gtzViPRS5E6/JCew3xPWqEXj4sG39/Ume+6UlIlnSYqoTrzm72yTMxSW4SFkWyhgr6yhdVMK V6LUd9d2qMNVA/4tJs04U2VIdwx8FkZkBtqs25dpBPK4gdO0tXfBT9+saANuArPeCZSzK1VNPsg3i x/M2Hz+Lxf5Pp7CZ49FsyOmjgBP9nh+YBvp75kBUQ3de2zSflCTIzwecH0LZI6TdC3DR6jIblHvE9 BEACG1uEWcfOEH8AeHDbVhSWJsfSnCW/JSsbVPD0/E6lA0sajEa5QNZT3QM+mSnjQKs4AZN9ABs+B FEeIazLA==; Received: from 89-212-21-243.static.t-2.net ([89.212.21.243]:45936 helo=localhost.localdomain) by cpanel.siel.si with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from <andrej.picej@norik.com>) id 1ol74W-007ZXa-AK; Wed, 19 Oct 2022 13:17:16 +0200 From: Andrej Picej <andrej.picej@norik.com> To: linux-watchdog@vger.kernel.org Cc: shawnguo@kernel.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-imx@nxp.com, festevam@gmail.com, kernel@pengutronix.de, s.hauer@pengutronix.de, wim@linux-watchdog.org, robh+dt@kernel.org Subject: [PATCH 1/3] watchdog: imx2_wdg: suspend watchdog in WAIT mode Date: Wed, 19 Oct 2022 13:17:12 +0200 Message-Id: <20221019111714.1953262-2-andrej.picej@norik.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019111714.1953262-1-andrej.picej@norik.com> References: <20221019111714.1953262-1-andrej.picej@norik.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.siel.si X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - norik.com X-Get-Message-Sender-Via: cpanel.siel.si: authenticated_id: andrej.picej@norik.com X-Authenticated-Sender: cpanel.siel.si: andrej.picej@norik.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123020088623323?= X-GMAIL-MSGID: =?utf-8?q?1747123020088623323?= |
Series |
Suspending i.MX watchdog in WAIT mode
|
|
Commit Message
Andrej Picej
Oct. 19, 2022, 11:17 a.m. UTC
Putting device into the "Suspend-To-Idle" mode causes watchdog to
trigger and reset the board after set watchdog timeout period elapses.
Introduce new device-tree property "fsl,suspend-in-wait" which suspends
watchdog in WAIT mode. This is done by setting WDW bit in WCR
(Watchdog Control Register) Watchdog operation is restored after exiting
WAIT mode as expected. WAIT mode coresponds with Linux's
"Suspend-To-Idle".
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
---
drivers/watchdog/imx2_wdt.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On Wed, Oct 19, 2022 at 01:17:12PM +0200, Andrej Picej wrote: > Putting device into the "Suspend-To-Idle" mode causes watchdog to > trigger and reset the board after set watchdog timeout period elapses. > > Introduce new device-tree property "fsl,suspend-in-wait" which suspends > watchdog in WAIT mode. This is done by setting WDW bit in WCR > (Watchdog Control Register) Watchdog operation is restored after exiting > WAIT mode as expected. WAIT mode coresponds with Linux's > "Suspend-To-Idle". > Does that have any impact on suspend/resume handling in the driver, specifically with the "no_ping" variable used for fsl,imx7d-wdt ? Thanks, Guenter > Signed-off-by: Andrej Picej <andrej.picej@norik.com> > --- > drivers/watchdog/imx2_wdt.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c > index d0c5d47ddede..150ba83ce176 100644 > --- a/drivers/watchdog/imx2_wdt.c > +++ b/drivers/watchdog/imx2_wdt.c > @@ -35,6 +35,7 @@ > > #define IMX2_WDT_WCR 0x00 /* Control Register */ > #define IMX2_WDT_WCR_WT (0xFF << 8) /* -> Watchdog Timeout Field */ > +#define IMX2_WDT_WCR_WDW BIT(7) /* -> Watchdog disable for WAIT */ > #define IMX2_WDT_WCR_WDA BIT(5) /* -> External Reset WDOG_B */ > #define IMX2_WDT_WCR_SRS BIT(4) /* -> Software Reset Signal */ > #define IMX2_WDT_WCR_WRE BIT(3) /* -> WDOG Reset Enable */ > @@ -67,6 +68,7 @@ struct imx2_wdt_device { > bool ext_reset; > bool clk_is_on; > bool no_ping; > + bool sleep_wait; > }; > > static bool nowayout = WATCHDOG_NOWAYOUT; > @@ -129,6 +131,9 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog) > > /* Suspend timer in low power mode, write once-only */ > val |= IMX2_WDT_WCR_WDZST; > + /* Suspend timer in low power WAIT mode, write once-only */ > + if (wdev->sleep_wait) > + val |= IMX2_WDT_WCR_WDW; > /* Strip the old watchdog Time-Out value */ > val &= ~IMX2_WDT_WCR_WT; > /* Generate internal chip-level reset if WDOG times out */ > @@ -313,6 +318,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > > wdev->ext_reset = of_property_read_bool(dev->of_node, > "fsl,ext-reset-output"); > + wdev->sleep_wait = of_property_read_bool(dev->of_node, > + "fsl,suspend-in-wait"); > /* > * The i.MX7D doesn't support low power mode, so we need to ping the watchdog > * during suspend. > -- > 2.25.1 >
On 19. 10. 22 17:33, Guenter Roeck wrote: > On Wed, Oct 19, 2022 at 01:17:12PM +0200, Andrej Picej wrote: >> Putting device into the "Suspend-To-Idle" mode causes watchdog to >> trigger and reset the board after set watchdog timeout period elapses. >> >> Introduce new device-tree property "fsl,suspend-in-wait" which suspends >> watchdog in WAIT mode. This is done by setting WDW bit in WCR >> (Watchdog Control Register) Watchdog operation is restored after exiting >> WAIT mode as expected. WAIT mode coresponds with Linux's >> "Suspend-To-Idle". >> > > Does that have any impact on suspend/resume handling in the driver, > specifically with the "no_ping" variable used for fsl,imx7d-wdt ? I assumed that it has the same impact as WDZST bit, which is also set for imx7d. So probably no impact. But I'm not really sure (unfortunately I don't have access to imx7d to test). If I understand correctly the "no-ping" variable is used because there is no support for low-power modes for imx7d. So imx7d devices never enter any of the low-power modes so WDZST and WDW bit shouldn't have effect on that. What I wanted to do with this "fsl,suspend-in-wait" is that if people run into the problems where device resets undesirably during WAIT mode, they can set this property and the watchdog will be suspended in WAIT mode. Default behaviour of the driver stays the same if the flag is not set. This was tested with imx6ul devices. Best regards, Andrej > > Thanks, > Guenter > >> Signed-off-by: Andrej Picej <andrej.picej@norik.com> >> --- >> drivers/watchdog/imx2_wdt.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c >> index d0c5d47ddede..150ba83ce176 100644 >> --- a/drivers/watchdog/imx2_wdt.c >> +++ b/drivers/watchdog/imx2_wdt.c >> @@ -35,6 +35,7 @@ >> >> #define IMX2_WDT_WCR 0x00 /* Control Register */ >> #define IMX2_WDT_WCR_WT (0xFF << 8) /* -> Watchdog Timeout Field */ >> +#define IMX2_WDT_WCR_WDW BIT(7) /* -> Watchdog disable for WAIT */ >> #define IMX2_WDT_WCR_WDA BIT(5) /* -> External Reset WDOG_B */ >> #define IMX2_WDT_WCR_SRS BIT(4) /* -> Software Reset Signal */ >> #define IMX2_WDT_WCR_WRE BIT(3) /* -> WDOG Reset Enable */ >> @@ -67,6 +68,7 @@ struct imx2_wdt_device { >> bool ext_reset; >> bool clk_is_on; >> bool no_ping; >> + bool sleep_wait; >> }; >> >> static bool nowayout = WATCHDOG_NOWAYOUT; >> @@ -129,6 +131,9 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog) >> >> /* Suspend timer in low power mode, write once-only */ >> val |= IMX2_WDT_WCR_WDZST; >> + /* Suspend timer in low power WAIT mode, write once-only */ >> + if (wdev->sleep_wait) >> + val |= IMX2_WDT_WCR_WDW; >> /* Strip the old watchdog Time-Out value */ >> val &= ~IMX2_WDT_WCR_WT; >> /* Generate internal chip-level reset if WDOG times out */ >> @@ -313,6 +318,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) >> >> wdev->ext_reset = of_property_read_bool(dev->of_node, >> "fsl,ext-reset-output"); >> + wdev->sleep_wait = of_property_read_bool(dev->of_node, >> + "fsl,suspend-in-wait"); >> /* >> * The i.MX7D doesn't support low power mode, so we need to ping the watchdog >> * during suspend. >> -- >> 2.25.1 >>
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index d0c5d47ddede..150ba83ce176 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -35,6 +35,7 @@ #define IMX2_WDT_WCR 0x00 /* Control Register */ #define IMX2_WDT_WCR_WT (0xFF << 8) /* -> Watchdog Timeout Field */ +#define IMX2_WDT_WCR_WDW BIT(7) /* -> Watchdog disable for WAIT */ #define IMX2_WDT_WCR_WDA BIT(5) /* -> External Reset WDOG_B */ #define IMX2_WDT_WCR_SRS BIT(4) /* -> Software Reset Signal */ #define IMX2_WDT_WCR_WRE BIT(3) /* -> WDOG Reset Enable */ @@ -67,6 +68,7 @@ struct imx2_wdt_device { bool ext_reset; bool clk_is_on; bool no_ping; + bool sleep_wait; }; static bool nowayout = WATCHDOG_NOWAYOUT; @@ -129,6 +131,9 @@ static inline void imx2_wdt_setup(struct watchdog_device *wdog) /* Suspend timer in low power mode, write once-only */ val |= IMX2_WDT_WCR_WDZST; + /* Suspend timer in low power WAIT mode, write once-only */ + if (wdev->sleep_wait) + val |= IMX2_WDT_WCR_WDW; /* Strip the old watchdog Time-Out value */ val &= ~IMX2_WDT_WCR_WT; /* Generate internal chip-level reset if WDOG times out */ @@ -313,6 +318,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) wdev->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output"); + wdev->sleep_wait = of_property_read_bool(dev->of_node, + "fsl,suspend-in-wait"); /* * The i.MX7D doesn't support low power mode, so we need to ping the watchdog * during suspend.