From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70F3AC4332F for ; Thu, 3 Nov 2022 15:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R0DPNO+BdpOYRV/wnx+qvy2lkIT9g9ccmHX/G0kCCUI=; b=4wfB7/+LyXyd/o 9rOrDUh8tu76CqNhfkqeAHbPQahdYnyyoUn0a7SoqxqVtyTiLGM4uWU1QY0oeLHGLqwPxEC483C6l i4twbVi2BY109snU/8xGD4yFoRHMra5zUDTtCEI5zNbLGfE3KphKB4rMq5bq6b0GkOxBijjqvV2Ys e5h5j7eEGH4egasfIlkvImDrxNHVi66ZZ5Y33uaY+wog7oPD1ggxPoa23nV4BtUq9zMQTwLfbR2yi JJUsEqUPrZnQmJ6zwWIWhSEjHY4gumzMKRmESd0DhC071Ty3rWiYSXfro1BGmfRXzABnNW1/zhA3q rl8fuuwPk8GxSzHZmFoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqbmG-000CuH-5E; Thu, 03 Nov 2022 15:05:08 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqbmD-000Ct5-6J for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2022 15:05:06 +0000 Received: by mail-ot1-x331.google.com with SMTP id l42-20020a9d1b2d000000b0066c6366fbc3so1134576otl.3 for ; Thu, 03 Nov 2022 08:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=n+LMDPVxiSEBWz30xQrCRDeHZy70LgG1o1jfGXqxYeY=; b=UMeYriPiO7lwL6z/qS1RudNvF22v90Ona84GJxHd7cVu8922bHAXNvmfRq9OTVZrzX EF1oV1qH7wXpcXYCltJr+t6tbHs0jTA+luZDZNHE/UujMCesgRqLdKoa1auEuwEIFMi5 LFak0tc+Hk7bPEtEAL/5qqZEDeXaT/g0YTlvmcKQbHNRFWYuHp8L1FqrIltEtwZsFdBk eLs3jPtFrTTverMvMpTgp0CAJC+gpkeL/9opDie4Dyg56T8nuWVCPlsMarZjXxV1n0Rz cAVzt10cXG5+HKkHGouHmoHhNO0wQNMI62UZl72HfNCohmt/IbxouIIMW4tZwNOb3br2 riJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n+LMDPVxiSEBWz30xQrCRDeHZy70LgG1o1jfGXqxYeY=; b=v/d9ElPKss/FFq4tjsc35mmem2gjnvS6jjRX/qzC69zJH4jaTKcNkmNQamBBndmQ4E lx/1xPfynl3l5+Maiv45YI86X6giFpkcH5AS0P0oBPNjU+Nxt0blVxTSsg0ZfhlZMKIv yZ78AI/dC0SxP6vGoWRvMHx7Hs/52RcxhuxnnUbbnT5TOay+gj9shlE5Jd3aDbDKtiIs Y9q/biYZ74M1YjlrB34p/YmKpdnqdCoca8EBjbbkAoG2unkI3z4GpibUfJr/b+nDG3ko rn8DofJAZch+G6fLJ9eEe39sPS42U1xmKftyrqxnoQfim34FgakOIEnV5st0IuMJcr5G /wDw== X-Gm-Message-State: ACrzQf3sjP+r/zjgAv58Xpn23/WutHqcCBjSgcLJx/K7b30zOJw9X6Gd ZmQ/wkhLaXOLG8zktH1ThR4= X-Google-Smtp-Source: AMsMyM6y+XpWcpKs5/mVvU7JTTwYNV8cL+uzhoilDVBfn/1sVPOneHDsBvhPnvMTZTlhwVvLyei2qw== X-Received: by 2002:a9d:2ae8:0:b0:667:d857:55bc with SMTP id e95-20020a9d2ae8000000b00667d85755bcmr15348603otb.50.1667487903310; Thu, 03 Nov 2022 08:05:03 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u29-20020a056870d59d00b0013b09a56d59sm482055oao.27.2022.11.03.08.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:05:00 -0700 (PDT) Date: Thu, 3 Nov 2022 08:04:58 -0700 From: Guenter Roeck To: Andrej Picej Cc: linux-watchdog@vger.kernel.org, wim@linux-watchdog.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, Anson.Huang@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/3] watchdog: imx2_wdg: suspend watchdog in WAIT mode Message-ID: <20221103150458.GA146501@roeck-us.net> References: <20221103100358.176099-1-andrej.picej@norik.com> <20221103100358.176099-2-andrej.picej@norik.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221103100358.176099-2-andrej.picej@norik.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_080505_256842_7BAAB2DB X-CRM114-Status: GOOD ( 30.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 03, 2022 at 11:03:56AM +0100, Andrej Picej wrote: > Putting device into the "Suspend-To-Idle" mode causes watchdog to > trigger and resets 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 corresponds with Linux's > "Suspend-To-Idle". > > Signed-off-by: Andrej Picej > Reviewed-by: Fabio Estevam For my reference: Reviewed-by: Guenter Roeck This will have to wait for dt approval. Thanks, Guenter > --- > Changes in v3: > - fix spelling in commit message, > - fix and simplify property handling in probe, > - add a comment about unknown interaction between imx7d no-ping > functionality and "fsl,suspend-in-wait", > - property support handled by of_device_id data pointer. > > Changes in v2: > - validate the property with compatible string, as this functionality > is not supported by all devices. > --- > drivers/watchdog/imx2_wdt.c | 55 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 52 insertions(+), 3 deletions(-) > > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c > index d0c5d47ddede..19ab7b3d286b 100644 > --- a/drivers/watchdog/imx2_wdt.c > +++ b/drivers/watchdog/imx2_wdt.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -35,6 +36,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 */ > @@ -60,13 +62,19 @@ > > #define WDOG_SEC_TO_COUNT(s) ((s * 2 - 1) << 8) > > +struct imx2_wdt_data { > + bool wdw_supported; > +}; > + > struct imx2_wdt_device { > struct clk *clk; > struct regmap *regmap; > struct watchdog_device wdog; > + const struct imx2_wdt_data *data; > bool ext_reset; > bool clk_is_on; > bool no_ping; > + bool sleep_wait; > }; > > static bool nowayout = WATCHDOG_NOWAYOUT; > @@ -129,6 +137,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 */ > @@ -292,6 +303,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000; > wdog->parent = dev; > > + wdev->data = of_device_get_match_data(dev); > + > ret = platform_get_irq(pdev, 0); > if (ret > 0) > if (!devm_request_irq(dev, ret, imx2_wdt_isr, 0, > @@ -313,9 +326,18 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > > wdev->ext_reset = of_property_read_bool(dev->of_node, > "fsl,ext-reset-output"); > + > + if (of_property_read_bool(dev->of_node, "fsl,suspend-in-wait")) { > + if (!wdev->data->wdw_supported) { > + dev_err(dev, "suspend-in-wait not supported\n"); > + return -EINVAL; > + } > + wdev->sleep_wait = true; > + } > + > /* > * The i.MX7D doesn't support low power mode, so we need to ping the watchdog > - * during suspend. > + * during suspend. Interaction with "fsl,suspend-in-wait" is unknown! > */ > wdev->no_ping = !of_device_is_compatible(dev->of_node, "fsl,imx7d-wdt"); > platform_set_drvdata(pdev, wdog); > @@ -417,9 +439,36 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) > static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend, > imx2_wdt_resume); > > +struct imx2_wdt_data imx_wdt = { > + .wdw_supported = true, > +}; > + > +struct imx2_wdt_data imx_wdt_legacy = { > + .wdw_supported = false, > +}; > + > static const struct of_device_id imx2_wdt_dt_ids[] = { > - { .compatible = "fsl,imx21-wdt", }, > - { .compatible = "fsl,imx7d-wdt", }, > + { .compatible = "fsl,imx21-wdt", .data = &imx_wdt_legacy }, > + { .compatible = "fsl,imx25-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx27-wdt", .data = &imx_wdt_legacy }, > + { .compatible = "fsl,imx31-wdt", .data = &imx_wdt_legacy }, > + { .compatible = "fsl,imx35-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx50-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx51-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx53-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx6q-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx6sl-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx6sll-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx6sx-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx6ul-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx7d-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx8mm-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx8mn-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx8mp-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,imx8mq-wdt", .data = &imx_wdt }, > + { .compatible = "fsl,ls1012a-wdt", .data = &imx_wdt_legacy }, > + { .compatible = "fsl,ls1043a-wdt", .data = &imx_wdt_legacy }, > + { .compatible = "fsl,vf610-wdt", .data = &imx_wdt }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids); > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel