Skip to content

Commit

Permalink
watchdog: at91sam9: get and use slow clock
Browse files Browse the repository at this point in the history
Commit dca1a4b ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.

Get and use the slow clock as it is necessary for the at91sam9 watchdog.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Alexandre Belloni authored and Wim Van Sebroeck committed Sep 9, 2015
1 parent f4fff94 commit a97a09b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions drivers/watchdog/at91sam9_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -90,6 +91,7 @@ struct at91wdt {
unsigned long heartbeat; /* WDT heartbeat in jiffies */
bool nowayout;
unsigned int irq;
struct clk *sclk;
};

/* ......................................................................... */
Expand Down Expand Up @@ -352,22 +354,37 @@ static int __init at91wdt_probe(struct platform_device *pdev)
if (IS_ERR(wdt->base))
return PTR_ERR(wdt->base);

wdt->sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(wdt->sclk))
return PTR_ERR(wdt->sclk);

err = clk_prepare_enable(wdt->sclk);
if (err) {
dev_err(&pdev->dev, "Could not enable slow clock\n");
return err;
}

if (pdev->dev.of_node) {
err = of_at91wdt_init(pdev->dev.of_node, wdt);
if (err)
return err;
goto err_clk;
}

err = at91_wdt_init(pdev, wdt);
if (err)
return err;
goto err_clk;

platform_set_drvdata(pdev, wdt);

pr_info("enabled (heartbeat=%d sec, nowayout=%d)\n",
wdt->wdd.timeout, wdt->nowayout);

return 0;

err_clk:
clk_disable_unprepare(wdt->sclk);

return err;
}

static int __exit at91wdt_remove(struct platform_device *pdev)
Expand All @@ -377,6 +394,7 @@ static int __exit at91wdt_remove(struct platform_device *pdev)

pr_warn("I quit now, hardware will probably reboot!\n");
del_timer(&wdt->timer);
clk_disable_unprepare(wdt->sclk);

return 0;
}
Expand Down

0 comments on commit a97a09b

Please sign in to comment.