watchdog: xilinx: Add clock support
Add support for the clock. Currently we enable at probe and relinquish at remove. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Sören Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
d2a0015174
commit
9d6b4efc16
|
@ -7,6 +7,8 @@ Required properties:
|
||||||
- reg : Physical base address and size
|
- reg : Physical base address and size
|
||||||
|
|
||||||
Optional properties:
|
Optional properties:
|
||||||
|
- clocks : Input clock specifier. Refer to common clock
|
||||||
|
bindings.
|
||||||
- clock-frequency : Frequency of clock in Hz
|
- clock-frequency : Frequency of clock in Hz
|
||||||
- xlnx,wdt-enable-once : 0 - Watchdog can be restarted
|
- xlnx,wdt-enable-once : 0 - Watchdog can be restarted
|
||||||
1 - Watchdog can be enabled just once
|
1 - Watchdog can be enabled just once
|
||||||
|
@ -17,6 +19,7 @@ Example:
|
||||||
axi-timebase-wdt@40100000 {
|
axi-timebase-wdt@40100000 {
|
||||||
clock-frequency = <50000000>;
|
clock-frequency = <50000000>;
|
||||||
compatible = "xlnx,xps-timebase-wdt-1.00.a";
|
compatible = "xlnx,xps-timebase-wdt-1.00.a";
|
||||||
|
clocks = <&clkc 15>;
|
||||||
reg = <0x40100000 0x10000>;
|
reg = <0x40100000 0x10000>;
|
||||||
xlnx,wdt-enable-once = <0x0>;
|
xlnx,wdt-enable-once = <0x0>;
|
||||||
xlnx,wdt-interval = <0x1b>;
|
xlnx,wdt-interval = <0x1b>;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* 2 of the License, or (at your option) any later version.
|
* 2 of the License, or (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/clk.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
@ -45,6 +46,7 @@ struct xwdt_device {
|
||||||
u32 wdt_interval;
|
u32 wdt_interval;
|
||||||
spinlock_t spinlock;
|
spinlock_t spinlock;
|
||||||
struct watchdog_device xilinx_wdt_wdd;
|
struct watchdog_device xilinx_wdt_wdd;
|
||||||
|
struct clk *clk;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int xilinx_wdt_start(struct watchdog_device *wdd)
|
static int xilinx_wdt_start(struct watchdog_device *wdd)
|
||||||
|
@ -195,16 +197,30 @@ static int xwdt_probe(struct platform_device *pdev)
|
||||||
spin_lock_init(&xdev->spinlock);
|
spin_lock_init(&xdev->spinlock);
|
||||||
watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
|
watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
|
||||||
|
|
||||||
|
xdev->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
|
if (IS_ERR(xdev->clk)) {
|
||||||
|
if (PTR_ERR(xdev->clk) == -ENOENT)
|
||||||
|
xdev->clk = NULL;
|
||||||
|
else
|
||||||
|
return PTR_ERR(xdev->clk);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = clk_prepare_enable(xdev->clk);
|
||||||
|
if (rc) {
|
||||||
|
dev_err(&pdev->dev, "unable to enable clock\n");
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
rc = xwdt_selftest(xdev);
|
rc = xwdt_selftest(xdev);
|
||||||
if (rc == XWT_TIMER_FAILED) {
|
if (rc == XWT_TIMER_FAILED) {
|
||||||
dev_err(&pdev->dev, "SelfTest routine error\n");
|
dev_err(&pdev->dev, "SelfTest routine error\n");
|
||||||
return rc;
|
goto err_clk_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = watchdog_register_device(xilinx_wdt_wdd);
|
rc = watchdog_register_device(xilinx_wdt_wdd);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc);
|
dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc);
|
||||||
return rc;
|
goto err_clk_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n",
|
dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n",
|
||||||
|
@ -213,6 +229,10 @@ static int xwdt_probe(struct platform_device *pdev)
|
||||||
platform_set_drvdata(pdev, xdev);
|
platform_set_drvdata(pdev, xdev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
err_clk_disable:
|
||||||
|
clk_disable_unprepare(xdev->clk);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xwdt_remove(struct platform_device *pdev)
|
static int xwdt_remove(struct platform_device *pdev)
|
||||||
|
@ -220,6 +240,7 @@ static int xwdt_remove(struct platform_device *pdev)
|
||||||
struct xwdt_device *xdev = platform_get_drvdata(pdev);
|
struct xwdt_device *xdev = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
watchdog_unregister_device(&xdev->xilinx_wdt_wdd);
|
watchdog_unregister_device(&xdev->xilinx_wdt_wdd);
|
||||||
|
clk_disable_unprepare(xdev->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue