From patchwork Wed Mar 30 09:45:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12795632 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 4B793C433EF for ; Wed, 30 Mar 2022 09:48:33 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=kxOiW40/EuEvvi8Ma4lMwgGzjD7qIZYbo8OjG8OPluw=; b=CPnKZZS7157Yez TGlH9jzfOmjqBoWa/+vyUse3LwyyM929MGPy0IH2Iunj1u2WV2yWoSWv/sqcO93tqEIx9SCatEDyn QHL0BLF1wnwqkwbWdRh3TXN/cNYGrlCqHH4gcVPejGTql+7+wbg59FC+XeqSQTZ2alcxQGPMRt2pH w5R9i/1Py1XjzuLN1Z1NXc8Z20Pp+vswA/sK9Xfd/XnJCyyhHI+b6qnr3uHU4oTvTEU8wp5sYeckl a0YTqyJwKw+iT9cAutlX+Q1gEVeXvXkvKAeLhFvmYDsvwKOuQu7VghbyZEHYSoSwI28cB7eEKBSpA xTHsz34S24xpmuq5AL/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZUv2-00F2hx-JQ; Wed, 30 Mar 2022 09:47:12 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZUts-00F2CV-6l for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2022 09:46:01 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7569C5C0194; Wed, 30 Mar 2022 05:45:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 30 Mar 2022 05:45:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; bh=IqPvKyQ6qMpku5I40/8FtZcCMepOPwE59gZVZv 4G8ug=; b=GNGeUDzw4n80hqW5Nu15s66q2bN2dPPSpD9CZ3PeCNqqwlE1Yv9NT5 lvoOf52XOAbrJ5cWuP7tuyqTnjAowimqbrkT/0BRIL8DT1PdqPPeGX47MjU3wq6s MTSrSpajJAoHt+d4d1KZoVlgP3bt7J33r9orVj+nbeczxek4O/gjb8yWC/45qeG+ fm59txCY+cW35cnFMf/D8kMAg9PqsRUYHia7P2q3LkP6Hl7EUeKLxYe4F2AUFi8q msn/GBLhcdRgq86A4FjaEUqn+VsdLtPMskrjfmZjgb5epRiT7tOXSwYVe48UYKnI xbCDwlSVjXEJAzrc+H9s2Oj//81rWGkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=IqPvKyQ6qMpku5I40/8FtZcCMepOP wE59gZVZv4G8ug=; b=AU48Hzmt8oM+KC2lRCEm0YCkQgtjbHkhJglj1RqP4Kf7N 9CX+Y/3Irngo/zcmYHwzM2CHPJL6BCxU6mGLp5y4qarIsLALTtsHPIQYUDsqRveP OUfqYbi2Vbwa1KgJlNcwRleT+orprUBe5py0ePcZGo3id88ZueVwz9jFwZr9+eY6 yd+ggDvJ0PtZ1R6ATNXK4mYVWOr3ULpsCV85b1ptYB6h8+HQYIa1aOb3KQTbKP7E SRcKnyMH1su9s9OsnRv60+0y+ltiBbHgj747lt4YYvrpL2HBmDFDQDXeL7KBTq4l 9E1kzCV6zy/ZKRjewZE4rL41N+UnWeOdEd/vU1IDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeivddgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgrihhr segrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeejleeihfdvtefgtd ethfdtgefftdeiffefjeeiffefveeuleejheejvefhffeukeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlihhsth grihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Mar 2022 05:45:54 -0400 (EDT) From: Alistair Francis To: wim@linux-watchdog.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, s.hauer@pengutronix.de, linux@roeck-us.net Cc: festevam@gmail.com, kernel@pengutronix.de, linux-imx@nxp.com, robh+dt@kernel.org, devicetree@vger.kernel.org, Alistair Francis Subject: [PATCH v5] watchdog: imx2_wdg: Allow ping on suspend Date: Wed, 30 Mar 2022 19:45:52 +1000 Message-Id: <20220330094552.31039-1-alistair@alistair23.me> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220330_024600_363466_6ACAC04A X-CRM114-Status: GOOD ( 17.19 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The i.MX watchdog cannot be disabled by software once it has been enabled. This means that it can't be stopped before suspend. For systems that enter low power mode this is fine, as the watchdog will be automatically stopped by hardware in low power mode. Not all i.MX platforms support low power mode in the mainline kernel. For example the i.MX7D does not enter low power mode and so will be rebooted 2 minutes after entering sleep states. This patch introduces the "fsl,imx7d-wdt" compatible string which enables ping on suspend support. This allows the i.MX7D systems to suspend without triggering the watchdog. Signed-off-by: Alistair Francis Reviewed-by: Guenter Roeck --- v5: - Fixup commit message description v4: - Fix spelling on allow/alow in title drivers/watchdog/imx2_wdt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 51bfb796898b..d0c5d47ddede 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -66,6 +66,7 @@ struct imx2_wdt_device { struct watchdog_device wdog; bool ext_reset; bool clk_is_on; + bool no_ping; }; static bool nowayout = WATCHDOG_NOWAYOUT; @@ -312,12 +313,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"); + /* + * The i.MX7D doesn't support low power mode, so we need to ping the watchdog + * during suspend. + */ + wdev->no_ping = !of_device_is_compatible(dev->of_node, "fsl,imx7d-wdt"); platform_set_drvdata(pdev, wdog); watchdog_set_drvdata(wdog, wdev); watchdog_set_nowayout(wdog, nowayout); watchdog_set_restart_priority(wdog, 128); watchdog_init_timeout(wdog, timeout, dev); - watchdog_stop_ping_on_suspend(wdog); + if (wdev->no_ping) + watchdog_stop_ping_on_suspend(wdog); if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, wdog->timeout); @@ -366,9 +373,11 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) imx2_wdt_ping(wdog); } - clk_disable_unprepare(wdev->clk); + if (wdev->no_ping) { + clk_disable_unprepare(wdev->clk); - wdev->clk_is_on = false; + wdev->clk_is_on = false; + } return 0; } @@ -380,11 +389,14 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); int ret; - ret = clk_prepare_enable(wdev->clk); - if (ret) - return ret; + if (wdev->no_ping) { + ret = clk_prepare_enable(wdev->clk); - wdev->clk_is_on = true; + if (ret) + return ret; + + wdev->clk_is_on = true; + } if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { /* @@ -407,6 +419,7 @@ static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend, static const struct of_device_id imx2_wdt_dt_ids[] = { { .compatible = "fsl,imx21-wdt", }, + { .compatible = "fsl,imx7d-wdt", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);