Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pull watchdog fixes from Wim Van Sebroeck:
 "This will fix reboot issues with the imx2_wdt driver and it also drops
  some forgotten owner assignments from platform_drivers"

* git://www.linux-watchdog.org/linux-watchdog:
  watchdog: drop owner assignment from platform_drivers
  watchdog: imx2_wdt: Disable power down counter on boot
  watchdog: imx2_wdt: Improve power management support.
  • Loading branch information
Linus Torvalds committed Jan 24, 2015
2 parents 0012125 + 7a32757 commit f828d5e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
1 change: 0 additions & 1 deletion drivers/watchdog/cadence_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ static struct platform_driver cdns_wdt_driver = {
.shutdown = cdns_wdt_shutdown,
.driver = {
.name = "cdns-wdt",
.owner = THIS_MODULE,
.of_match_table = cdns_wdt_of_match,
.pm = &cdns_wdt_pm_ops,
},
Expand Down
40 changes: 31 additions & 9 deletions drivers/watchdog/imx2_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#define IMX2_WDT_WRSR 0x04 /* Reset Status Register */
#define IMX2_WDT_WRSR_TOUT (1 << 1) /* -> Reset due to Timeout */

#define IMX2_WDT_WMCR 0x08 /* Misc Register */

#define IMX2_WDT_MAX_TIME 128
#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */

Expand Down Expand Up @@ -274,6 +276,13 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)

imx2_wdt_ping_if_active(wdog);

/*
* Disable the watchdog power down counter at boot. Otherwise the power
* down counter will pull down the #WDOG interrupt line for one clock
* cycle.
*/
regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);

ret = watchdog_register_device(wdog);
if (ret) {
dev_err(&pdev->dev, "cannot register watchdog device\n");
Expand Down Expand Up @@ -327,18 +336,21 @@ static void imx2_wdt_shutdown(struct platform_device *pdev)
}

#ifdef CONFIG_PM_SLEEP
/* Disable watchdog if it is active during suspend */
/* Disable watchdog if it is active or non-active but still running */
static int imx2_wdt_suspend(struct device *dev)
{
struct watchdog_device *wdog = dev_get_drvdata(dev);
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);

imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME);
imx2_wdt_ping(wdog);
/* The watchdog IP block is running */
if (imx2_wdt_is_running(wdev)) {
imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME);
imx2_wdt_ping(wdog);

/* Watchdog has been stopped but IP block is still running */
if (!watchdog_active(wdog) && imx2_wdt_is_running(wdev))
del_timer_sync(&wdev->timer);
/* The watchdog is not active */
if (!watchdog_active(wdog))
del_timer_sync(&wdev->timer);
}

clk_disable_unprepare(wdev->clk);

Expand All @@ -354,15 +366,25 @@ static int imx2_wdt_resume(struct device *dev)
clk_prepare_enable(wdev->clk);

if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) {
/* Resumes from deep sleep we need restart
* the watchdog again.
/*
* If the watchdog is still active and resumes
* from deep sleep state, need to restart the
* watchdog again.
*/
imx2_wdt_setup(wdog);
imx2_wdt_set_timeout(wdog, wdog->timeout);
imx2_wdt_ping(wdog);
} else if (imx2_wdt_is_running(wdev)) {
/* Resuming from non-deep sleep state. */
imx2_wdt_set_timeout(wdog, wdog->timeout);
imx2_wdt_ping(wdog);
mod_timer(&wdev->timer, jiffies + wdog->timeout * HZ / 2);
/*
* But the watchdog is not active, then start
* the timer again.
*/
if (!watchdog_active(wdog))
mod_timer(&wdev->timer,
jiffies + wdog->timeout * HZ / 2);
}

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/watchdog/meson_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ static struct platform_driver meson_wdt_driver = {
.remove = meson_wdt_remove,
.shutdown = meson_wdt_shutdown,
.driver = {
.owner = THIS_MODULE,
.name = DRV_NAME,
.of_match_table = meson_wdt_dt_ids,
},
Expand Down

0 comments on commit f828d5e

Please sign in to comment.