From: Guenter Roeck <linux@roeck-us.net>
To: Primoz Fiser <primoz.fiser@norik.com>
Cc: linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Support Opensource <support.opensource@diasemi.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Marco Felsch <m.felsch@pengutronix.de>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Andrej Picej <andrej.picej@norik.com>,
upstream@phytec.de
Subject: Re: [PATCH 2/3] watchdog: da9063: optionally disable watchdog during suspend
Date: Sat, 14 May 2022 06:56:54 -0700 [thread overview]
Message-ID: <20220514135654.GA1227812@roeck-us.net> (raw)
In-Reply-To: <20220422072713.3172345-2-primoz.fiser@norik.com>
On Fri, Apr 22, 2022 at 09:27:12AM +0200, Primoz Fiser wrote:
> Optionally disable watchdog during suspend (if enabled) and re-enable
> it upon resume.
> This enables boards to sleep without being interrupted by the watchdog.
>
> This patch is based on commit f6c98b08381c ("watchdog: da9062: add
> power management ops") and commit 8541673d2a5f ("watchdog: da9062: fix
> power management ops") and brings the same functionality to DA9063.
>
> Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
> Reviewed-by: Adam Thomson <DLG-Adam.Thomson.Opensource@dm.renesas.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/da9063_wdt.c | 36 +++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
> index 9adad1862bbd..09a4af4c58fc 100644
> --- a/drivers/watchdog/da9063_wdt.c
> +++ b/drivers/watchdog/da9063_wdt.c
> @@ -18,6 +18,7 @@
> #include <linux/delay.h>
> #include <linux/mfd/da9063/registers.h>
> #include <linux/mfd/da9063/core.h>
> +#include <linux/property.h>
> #include <linux/regmap.h>
>
> /*
> @@ -26,6 +27,8 @@
> * others: timeout = 2048 ms * 2^(TWDSCALE-1).
> */
> static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 };
> +static bool use_sw_pm;
> +
> #define DA9063_TWDSCALE_DISABLE 0
> #define DA9063_TWDSCALE_MIN 1
> #define DA9063_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1)
> @@ -218,6 +221,8 @@ static int da9063_wdt_probe(struct platform_device *pdev)
> if (!wdd)
> return -ENOMEM;
>
> + use_sw_pm = device_property_present(dev, "dlg,use-sw-pm");
> +
> wdd->info = &da9063_watchdog_info;
> wdd->ops = &da9063_watchdog_ops;
> wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT;
> @@ -228,6 +233,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
>
> watchdog_set_restart_priority(wdd, 128);
> watchdog_set_drvdata(wdd, da9063);
> + dev_set_drvdata(dev, wdd);
>
> wdd->timeout = DA9063_WDG_TIMEOUT;
>
> @@ -249,10 +255,40 @@ static int da9063_wdt_probe(struct platform_device *pdev)
> return devm_watchdog_register_device(dev, wdd);
> }
>
> +static int __maybe_unused da9063_wdt_suspend(struct device *dev)
> +{
> + struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> + if (!use_sw_pm)
> + return 0;
> +
> + if (watchdog_active(wdd))
> + return da9063_wdt_stop(wdd);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused da9063_wdt_resume(struct device *dev)
> +{
> + struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> + if (!use_sw_pm)
> + return 0;
> +
> + if (watchdog_active(wdd))
> + return da9063_wdt_start(wdd);
> +
> + return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(da9063_wdt_pm_ops,
> + da9063_wdt_suspend, da9063_wdt_resume);
> +
> static struct platform_driver da9063_wdt_driver = {
> .probe = da9063_wdt_probe,
> .driver = {
> .name = DA9063_DRVNAME_WATCHDOG,
> + .pm = &da9063_wdt_pm_ops,
> },
> };
> module_platform_driver(da9063_wdt_driver);
next prev parent reply other threads:[~2022-05-14 13:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 7:27 [PATCH 1/3] dt-bindings: mfd: da9063: watchdog: add suspend disable option Primoz Fiser
2022-04-22 7:27 ` [PATCH 2/3] watchdog: da9063: optionally disable watchdog during suspend Primoz Fiser
2022-05-09 10:38 ` DLG Adam Thomson
2022-05-11 8:47 ` Primoz Fiser
2022-05-11 9:03 ` DLG Adam Thomson
2022-05-14 13:56 ` Guenter Roeck [this message]
2022-04-22 7:27 ` [PATCH 3/3] ARM: dts: imx6: phyFLEX: disable da9063 " Primoz Fiser
2022-05-14 13:57 ` Guenter Roeck
2022-05-02 20:56 ` [PATCH 1/3] dt-bindings: mfd: da9063: watchdog: add suspend disable option Rob Herring
2022-05-03 6:53 ` Primoz Fiser
2022-05-04 0:37 ` Rob Herring
2022-05-09 8:50 ` DLG Adam Thomson
2022-05-11 8:09 ` Primoz Fiser
2022-05-11 8:28 ` DLG Adam Thomson
2022-05-14 13:55 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220514135654.GA1227812@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andrej.picej@norik.com \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-imx@nxp.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=primoz.fiser@norik.com \
--cc=robh+dt@kernel.org \
--cc=support.opensource@diasemi.com \
--cc=upstream@phytec.de \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).