Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alexandre Belloni and committed by
Wim Van Sebroeck
a97a09bd f4fff94e

+20 -2
+20 -2
drivers/watchdog/at91sam9_wdt.c
··· 17 17 18 18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 19 19 20 + #include <linux/clk.h> 20 21 #include <linux/errno.h> 21 22 #include <linux/init.h> 22 23 #include <linux/interrupt.h> ··· 91 90 unsigned long heartbeat; /* WDT heartbeat in jiffies */ 92 91 bool nowayout; 93 92 unsigned int irq; 93 + struct clk *sclk; 94 94 }; 95 95 96 96 /* ......................................................................... */ ··· 354 352 if (IS_ERR(wdt->base)) 355 353 return PTR_ERR(wdt->base); 356 354 355 + wdt->sclk = devm_clk_get(&pdev->dev, NULL); 356 + if (IS_ERR(wdt->sclk)) 357 + return PTR_ERR(wdt->sclk); 358 + 359 + err = clk_prepare_enable(wdt->sclk); 360 + if (err) { 361 + dev_err(&pdev->dev, "Could not enable slow clock\n"); 362 + return err; 363 + } 364 + 357 365 if (pdev->dev.of_node) { 358 366 err = of_at91wdt_init(pdev->dev.of_node, wdt); 359 367 if (err) 360 - return err; 368 + goto err_clk; 361 369 } 362 370 363 371 err = at91_wdt_init(pdev, wdt); 364 372 if (err) 365 - return err; 373 + goto err_clk; 366 374 367 375 platform_set_drvdata(pdev, wdt); 368 376 ··· 380 368 wdt->wdd.timeout, wdt->nowayout); 381 369 382 370 return 0; 371 + 372 + err_clk: 373 + clk_disable_unprepare(wdt->sclk); 374 + 375 + return err; 383 376 } 384 377 385 378 static int __exit at91wdt_remove(struct platform_device *pdev) ··· 394 377 395 378 pr_warn("I quit now, hardware will probably reboot!\n"); 396 379 del_timer(&wdt->timer); 380 + clk_disable_unprepare(wdt->sclk); 397 381 398 382 return 0; 399 383 }