Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp711593ybl; Wed, 8 Jan 2020 04:40:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxmt8JwL38UIZL6C/Ck7NLN+EuprlNBWJoj2n8hW74bwTClpQ+vG5XNpcYrigTuTWgdD2Em X-Received: by 2002:aca:c493:: with SMTP id u141mr2896293oif.62.1578487233846; Wed, 08 Jan 2020 04:40:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578487233; cv=none; d=google.com; s=arc-20160816; b=GwERbBVKjquqli33AknZHxTOUm6PFFbr6tMPfJpf6b6aIN2k7f6sSUQr/eionSAyZm d25TFWC9h71AsBAoVIhxAF8Sz8xpWPC/f2xfOjqLDtoIuQgAbnhGhFGtsLXCPpEiAyX8 GPzndpUo574igMophVV5ExEPGkl4FC363skjz6Cz9itdDLq32JUmfnzczuiU5gP4061x 6Ub06XYsY1zdPE/eo9l13+QGTO8bCHPKBNxIeG6hWae59vO+UkeM5MUGQdP5wzlbdLGP erTZnuTyoG/g9quHzmpknfsV+RI+LL22fJSlMzspvBPO+cNN4aMWNPR7KDjWQFDR288j elbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GXNyGlZJ6KqUxZmwn774yhdGteJK9WeWI9ZW0Nsd/c4=; b=ynxq7a3fWsNN5iKmw30hIH9kYr6BRYh9p5iORJyr6qNMxBfA5+llQcHA0aTj5ySq8Q hrjSNNylhzmt3DfLSWhdgG9Ga1iy1cG0jfUgVbyPq8CpK4Y6cuLFyxLBv8u3mM5qfitc ea30nvYhOaTyOUOfkpD5Moqo/x+UkQE8dlKI1s9msyiHjj1oS2RprqrdujkModk0KRLb mBuAARkOFzlC9LA3Yc0y5XHdxUCYlyYzW5RvXK+rAm3VP3QIXlqvcrT3APVtKxUmkY89 wtHe7HtEhTQqkm/7MwdTNt/U/4iHPpvZU+PF7wMzTPYBm9/+iWoqbLhEWLYS8bE9n89O 6TwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t74si1724968oih.155.2020.01.08.04.40.21; Wed, 08 Jan 2020 04:40:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbgAHJ5U (ORCPT + 99 others); Wed, 8 Jan 2020 04:57:20 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:60971 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbgAHJ5T (ORCPT ); Wed, 8 Jan 2020 04:57:19 -0500 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ip85L-0003Ir-1U; Wed, 08 Jan 2020 10:57:07 +0100 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ip85K-00067C-3i; Wed, 08 Jan 2020 10:57:06 +0100 From: Marco Felsch To: support.opensource@diasemi.com, linux@roeck-us.net, robh+dt@kernel.org, lee.jones@linaro.org, stwiss.opensource@diasemi.com, Adam.Thomson.Opensource@diasemi.com Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 3/3] watchdog: da9062: add power management ops Date: Wed, 8 Jan 2020 10:57:04 +0100 Message-Id: <20200108095704.23233-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200108095704.23233-1-m.felsch@pengutronix.de> References: <20200108095704.23233-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disable the watchdog during suspend if it is enabled and re-enable it on resume. So we can sleep without the interruptions. Signed-off-by: Marco Felsch --- v2: - add dlg,use-sw-pm check to differentiate between automatic and manual disabling/enabling. --- drivers/watchdog/da9062_wdt.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index e149e66a6ea9..c9b9d6394525 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 }; struct da9062_watchdog { struct da9062 *hw; struct watchdog_device wdtdev; + bool use_sw_pm; }; static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs) @@ -198,6 +200,8 @@ static int da9062_wdt_probe(struct platform_device *pdev) if (!wdt) return -ENOMEM; + wdt->use_sw_pm = device_property_present(dev, "dlg,use-sw-pm"); + wdt->hw = chip; wdt->wdtdev.info = &da9062_watchdog_info; @@ -212,6 +216,7 @@ static int da9062_wdt_probe(struct platform_device *pdev) watchdog_set_restart_priority(&wdt->wdtdev, 128); watchdog_set_drvdata(&wdt->wdtdev, wdt); + dev_set_drvdata(dev, &wdt->wdtdev); ret = devm_watchdog_register_device(dev, &wdt->wdtdev); if (ret < 0) @@ -220,10 +225,42 @@ static int da9062_wdt_probe(struct platform_device *pdev) return da9062_wdt_ping(&wdt->wdtdev); } +static int __maybe_unused da9062_wdt_suspend(struct device *dev) +{ + struct watchdog_device *wdd = dev_get_drvdata(dev); + struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd); + + if (!wdt->use_sw_pm) + return 0; + + if (watchdog_active(wdd)) + return da9062_wdt_stop(wdd); + + return 0; +} + +static int __maybe_unused da9062_wdt_resume(struct device *dev) +{ + struct watchdog_device *wdd = dev_get_drvdata(dev); + struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd); + + if (!wdt->use_sw_pm) + return 0; + + if (watchdog_active(wdd)) + return da9062_wdt_start(wdd); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, + da9062_wdt_suspend, da9062_wdt_resume); + static struct platform_driver da9062_wdt_driver = { .probe = da9062_wdt_probe, .driver = { .name = "da9062-watchdog", + .pm = &da9062_wdt_pm_ops, .of_match_table = da9062_compatible_id_table, }, }; -- 2.20.1