From patchwork Sat Sep 30 08:19:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Grunau via B4 Relay X-Patchwork-Id: 13405027 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 C4F52E7735F for ; Sat, 30 Sep 2023 08:20:12 +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:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version :Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0QtFvRpjt7RmpHX7DW82pysn1jrYLT4Ff+PLRJvLMmw=; b=Bud/4ZFH5S9TWa RuXyprc4oSUype8rQgv6MK1ci2Ix5ZloN72Fny7RKws7LUMaXCJRbp2/jDSKE7jJUjEQ+zK5/ASBr yi2IXrdFPN5jVy25wUimyCDCBCVg8CLxZED+CZa4zH28ociIKMk3OE+/BJqJzTr/lvChXfCCQLDcI a+NIPYYWySoOrM9GU4uceH4dkyFY9RV3ZW0dmGg0W/l3m54dEr7sEKV0/+rTneclmI9W6srHW88a9 Goim8pLo/6HLe+NpkcWDgGZXFSYaHP6uCeBSxwkL8a4aWQcVgiS6iCUpKacPNLiBmGPIoi4dZvfc2 r4ublfI6oaGXf9Xyj1vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmVCO-009A1Q-1c; Sat, 30 Sep 2023 08:19:40 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qmVCJ-009A0m-1j for linux-arm-kernel@lists.infradead.org; Sat, 30 Sep 2023 08:19:37 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B0725CE1825; Sat, 30 Sep 2023 08:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id EE15DC433C8; Sat, 30 Sep 2023 08:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696061971; bh=M7ntc2U7ytqmb0p5ElJpWPn5HTPfSg5aIA/l+S9kpQ8=; h=From:Date:Subject:To:Cc:Reply-To:From; b=SEDL+KoMw9E7kNJD/VeOA3pa/RrO8yjgMVLtc4FcwU/P8j7SxJmH5O8LgW8ovA841 trFmNvwKI3YoEyjjUJyNq0HFbw6bgLuU3dSE4KBoyd/7lpS4eMdjQLPgTCYb76pkw8 mQDZjp0sbwAL/W6v4cKujSuZUpDTyHmhWj1jyeFDW8mdhPHRPhbKQopOZ+qx3XmeQe x0akqlxGRqF4DY7hxxM7wa5R6DQFZjorw+Y6yV/H2gZ+/r0+MyybDAFI0jTQ6dI3ZW oyt3A4yFEbcnbXbI6zIJaUeT1vY6MVJyVi/1rOmiqvBFR3DSQnlGwym7LM7Y+cGTao ACE2onYm4fmEA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF554E77362; Sat, 30 Sep 2023 08:19:30 +0000 (UTC) From: Janne Grunau via B4 Relay Date: Sat, 30 Sep 2023 10:19:26 +0200 Subject: [PATCH] watchdog: apple: Deactivate on suspend MIME-Version: 1.0 Message-Id: <20230930-apple-watchdog-suspend-v1-1-1998c0be9fd7@jannau.net> X-B4-Tracking: v=1; b=H4sIAA3aF2UC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI2MDS2MD3cSCgpxU3fLEkuSMlPx03eLS4oLUvBRd8zRzYwtjQ0Njg7QkJaD mgqLUtMwKsMHRsbW1AAVOok1oAAAA To: Hector Martin , Sven Peter , Alyssa Rosenzweig , Wim Van Sebroeck , Guenter Roeck Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Janne Grunau X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2007; i=j@jannau.net; h=from:subject:message-id; bh=+tQiILihRq5o4N62Yd4BUwts5HYkI5tfzlOjXU3MCSQ=; b=owGbwMvMwCG2UNrmdq9+ahrjabUkhlTxW4KTvB7z2UddmJ6rPD/L5aGfgFxyUCR/5qFClbwo+ YLZpqs7SlkYxDgYZMUUWZK0X3YwrK5RjKl9EAYzh5UJZAgDF6cATOSVPMP/iL75jLdTnDPNFrpY iG5aWeomdapyIjufzK5Fr/ZXdZgFMTK89XdY5lUubBX3a7fkvQOJl6cKsiydf2zdvNr8X7cCY1o ZAA== X-Developer-Key: i=j@jannau.net; a=openpgp; fpr=8B336A6BE4E5695E89B8532B81E806F586338419 X-Endpoint-Received: by B4 Relay for j@jannau.net/default with auth_id=62 X-Original-From: Janne Grunau X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230930_011935_944044_8FCE4A77 X-CRM114-Status: GOOD ( 12.35 ) 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: , Reply-To: j@jannau.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Janne Grunau The watchdog remains active after putting the system into suspend. Add PM callbacks to deactivate the watchdog on suspend an re-activate it on resume. Signed-off-by: Janne Grunau --- drivers/watchdog/apple_wdt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) --- base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d change-id: 20230930-apple-watchdog-suspend-7f73831130fb Best regards, diff --git a/drivers/watchdog/apple_wdt.c b/drivers/watchdog/apple_wdt.c index eddeb0fede89..2167e0ba705e 100644 --- a/drivers/watchdog/apple_wdt.c +++ b/drivers/watchdog/apple_wdt.c @@ -173,6 +173,8 @@ static int apple_wdt_probe(struct platform_device *pdev) if (!wdt->clk_rate) return -EINVAL; + platform_set_drvdata(pdev, wdt); + wdt->wdd.ops = &apple_wdt_ops; wdt->wdd.info = &apple_wdt_info; wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate; @@ -190,6 +192,28 @@ static int apple_wdt_probe(struct platform_device *pdev) return devm_watchdog_register_device(dev, &wdt->wdd); } +static int __maybe_unused apple_wdt_resume(struct device *dev) +{ + struct apple_wdt *wdt = dev_get_drvdata(dev); + + if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd)) + apple_wdt_start(&wdt->wdd); + + return 0; +} + +static int __maybe_unused apple_wdt_suspend(struct device *dev) +{ + struct apple_wdt *wdt = dev_get_drvdata(dev); + + if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd)) + apple_wdt_stop(&wdt->wdd); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(apple_wdt_pm_ops, apple_wdt_suspend, apple_wdt_resume); + static const struct of_device_id apple_wdt_of_match[] = { { .compatible = "apple,wdt" }, {}, @@ -200,6 +224,7 @@ static struct platform_driver apple_wdt_driver = { .driver = { .name = "apple-watchdog", .of_match_table = apple_wdt_of_match, + .pm = pm_sleep_ptr(&apple_wdt_pm_ops), }, .probe = apple_wdt_probe, };