Skip to content

Commit

Permalink
watchdog: da9062: fix power management ops
Browse files Browse the repository at this point in the history
This fixes commit f6c98b0 ("watchdog: da9062: add power management
ops"). During discussion [1] we agreed that this should be configurable
because it is a device quirk if we can't use the hw watchdog auto
suspend function.

[1] https://lore.kernel.org/linux-watchdog/20191128171931.22563-1-m.felsch@pengutronix.de/

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Fixes: f6c98b0 ("watchdog: da9062: add power management ops")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200207071518.5559-1-m.felsch@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
  • Loading branch information
Marco Felsch authored and Wim Van Sebroeck committed Feb 17, 2020
1 parent e9a0e65 commit 8541673
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/watchdog/da9062_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/jiffies.h>
#include <linux/mfd/da9062/registers.h>
#include <linux/mfd/da9062/core.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/of.h>

Expand All @@ -31,6 +32,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)
Expand Down Expand Up @@ -193,6 +195,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;
Expand All @@ -219,6 +223,10 @@ static int da9062_wdt_probe(struct platform_device *pdev)
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);
Expand All @@ -229,6 +237,10 @@ static int __maybe_unused da9062_wdt_suspend(struct device *dev)
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);
Expand Down

0 comments on commit 8541673

Please sign in to comment.