diff options
| author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-08-16 05:23:43 -0400 |
|---|---|---|
| committer | Wim Van Sebroeck <wim@iguana.be> | 2015-09-09 15:38:52 -0400 |
| commit | a97a09bd119fbdf4ba8c634fed8f4148d1def1e0 (patch) | |
| tree | 90af60d8025852168cf758f7b4f9499e058339aa | |
| parent | f4fff94e3e3a712ef062c44b64ecf8f552f48ea4 (diff) | |
watchdog: at91sam9: get and use slow clock
Commit dca1a4b5ff6e ("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>
| -rw-r--r-- | drivers/watchdog/at91sam9_wdt.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index e4698f7c5f93..7e6acaf3ece4 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 19 | 19 | ||
| 20 | #include <linux/clk.h> | ||
| 20 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
| 21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 22 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
| @@ -90,6 +91,7 @@ struct at91wdt { | |||
| 90 | unsigned long heartbeat; /* WDT heartbeat in jiffies */ | 91 | unsigned long heartbeat; /* WDT heartbeat in jiffies */ |
| 91 | bool nowayout; | 92 | bool nowayout; |
| 92 | unsigned int irq; | 93 | unsigned int irq; |
| 94 | struct clk *sclk; | ||
| 93 | }; | 95 | }; |
| 94 | 96 | ||
| 95 | /* ......................................................................... */ | 97 | /* ......................................................................... */ |
| @@ -352,15 +354,25 @@ static int __init at91wdt_probe(struct platform_device *pdev) | |||
| 352 | if (IS_ERR(wdt->base)) | 354 | if (IS_ERR(wdt->base)) |
| 353 | return PTR_ERR(wdt->base); | 355 | return PTR_ERR(wdt->base); |
| 354 | 356 | ||
| 357 | wdt->sclk = devm_clk_get(&pdev->dev, NULL); | ||
| 358 | if (IS_ERR(wdt->sclk)) | ||
| 359 | return PTR_ERR(wdt->sclk); | ||
| 360 | |||
| 361 | err = clk_prepare_enable(wdt->sclk); | ||
| 362 | if (err) { | ||
| 363 | dev_err(&pdev->dev, "Could not enable slow clock\n"); | ||
| 364 | return err; | ||
| 365 | } | ||
| 366 | |||
| 355 | if (pdev->dev.of_node) { | 367 | if (pdev->dev.of_node) { |
| 356 | err = of_at91wdt_init(pdev->dev.of_node, wdt); | 368 | err = of_at91wdt_init(pdev->dev.of_node, wdt); |
| 357 | if (err) | 369 | if (err) |
| 358 | return err; | 370 | goto err_clk; |
| 359 | } | 371 | } |
| 360 | 372 | ||
| 361 | err = at91_wdt_init(pdev, wdt); | 373 | err = at91_wdt_init(pdev, wdt); |
| 362 | if (err) | 374 | if (err) |
| 363 | return err; | 375 | goto err_clk; |
| 364 | 376 | ||
| 365 | platform_set_drvdata(pdev, wdt); | 377 | platform_set_drvdata(pdev, wdt); |
| 366 | 378 | ||
| @@ -368,6 +380,11 @@ static int __init at91wdt_probe(struct platform_device *pdev) | |||
| 368 | wdt->wdd.timeout, wdt->nowayout); | 380 | wdt->wdd.timeout, wdt->nowayout); |
| 369 | 381 | ||
| 370 | return 0; | 382 | return 0; |
| 383 | |||
| 384 | err_clk: | ||
| 385 | clk_disable_unprepare(wdt->sclk); | ||
| 386 | |||
| 387 | return err; | ||
| 371 | } | 388 | } |
| 372 | 389 | ||
| 373 | static int __exit at91wdt_remove(struct platform_device *pdev) | 390 | static int __exit at91wdt_remove(struct platform_device *pdev) |
| @@ -377,6 +394,7 @@ static int __exit at91wdt_remove(struct platform_device *pdev) | |||
| 377 | 394 | ||
| 378 | pr_warn("I quit now, hardware will probably reboot!\n"); | 395 | pr_warn("I quit now, hardware will probably reboot!\n"); |
| 379 | del_timer(&wdt->timer); | 396 | del_timer(&wdt->timer); |
| 397 | clk_disable_unprepare(wdt->sclk); | ||
| 380 | 398 | ||
| 381 | return 0; | 399 | return 0; |
| 382 | } | 400 | } |
