Lines Matching +full:wdt +full:- +full:enable +full:- +full:once
1 // SPDX-License-Identifier: GPL-2.0+
5 * (C) Copyright 2013 - 2014 Xilinx, Inc.
21 /* Register offsets for the Wdt device */
29 #define XWT_CSR0_EWDT1_MASK BIT(1) /* Enable bit 1 */
32 #define XWT_CSRX_EWDT2_MASK BIT(0) /* Enable bit 2 */
54 ret = clk_enable(xdev->clk); in xilinx_wdt_start()
56 dev_err(wdd->parent, "Failed to enable clock\n"); in xilinx_wdt_start()
60 spin_lock(&xdev->spinlock); in xilinx_wdt_start()
62 /* Clean previous status and enable the watchdog timer */ in xilinx_wdt_start()
63 control_status_reg = ioread32(xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_start()
67 xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_start()
69 iowrite32(XWT_CSRX_EWDT2_MASK, xdev->base + XWT_TWCSR1_OFFSET); in xilinx_wdt_start()
71 spin_unlock(&xdev->spinlock); in xilinx_wdt_start()
73 dev_dbg(wdd->parent, "Watchdog Started!\n"); in xilinx_wdt_start()
83 spin_lock(&xdev->spinlock); in xilinx_wdt_stop()
85 control_status_reg = ioread32(xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_stop()
88 xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_stop()
90 iowrite32(0, xdev->base + XWT_TWCSR1_OFFSET); in xilinx_wdt_stop()
92 spin_unlock(&xdev->spinlock); in xilinx_wdt_stop()
94 clk_disable(xdev->clk); in xilinx_wdt_stop()
96 dev_dbg(wdd->parent, "Watchdog Stopped!\n"); in xilinx_wdt_stop()
106 spin_lock(&xdev->spinlock); in xilinx_wdt_keepalive()
108 control_status_reg = ioread32(xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_keepalive()
110 iowrite32(control_status_reg, xdev->base + XWT_TWCSR0_OFFSET); in xilinx_wdt_keepalive()
112 spin_unlock(&xdev->spinlock); in xilinx_wdt_keepalive()
137 spin_lock(&xdev->spinlock); in xwdt_selftest()
139 timer_value1 = ioread32(xdev->base + XWT_TBR_OFFSET); in xwdt_selftest()
140 timer_value2 = ioread32(xdev->base + XWT_TBR_OFFSET); in xwdt_selftest()
145 timer_value2 = ioread32(xdev->base + XWT_TBR_OFFSET); in xwdt_selftest()
148 spin_unlock(&xdev->spinlock); in xwdt_selftest()
158 struct device *dev = &pdev->dev; in xwdt_probe()
166 return -ENOMEM; in xwdt_probe()
168 xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd; in xwdt_probe()
169 xilinx_wdt_wdd->info = &xilinx_wdt_ident; in xwdt_probe()
170 xilinx_wdt_wdd->ops = &xilinx_wdt_ops; in xwdt_probe()
171 xilinx_wdt_wdd->parent = dev; in xwdt_probe()
173 xdev->base = devm_platform_ioremap_resource(pdev, 0); in xwdt_probe()
174 if (IS_ERR(xdev->base)) in xwdt_probe()
175 return PTR_ERR(xdev->base); in xwdt_probe()
177 rc = of_property_read_u32(dev->of_node, "xlnx,wdt-interval", in xwdt_probe()
178 &xdev->wdt_interval); in xwdt_probe()
180 dev_warn(dev, "Parameter \"xlnx,wdt-interval\" not found\n"); in xwdt_probe()
182 rc = of_property_read_u32(dev->of_node, "xlnx,wdt-enable-once", in xwdt_probe()
186 "Parameter \"xlnx,wdt-enable-once\" not found\n"); in xwdt_probe()
190 xdev->clk = devm_clk_get_prepared(dev, NULL); in xwdt_probe()
191 if (IS_ERR(xdev->clk)) { in xwdt_probe()
192 if (PTR_ERR(xdev->clk) != -ENOENT) in xwdt_probe()
193 return PTR_ERR(xdev->clk); in xwdt_probe()
199 xdev->clk = NULL; in xwdt_probe()
201 rc = of_property_read_u32(dev->of_node, "clock-frequency", in xwdt_probe()
207 pfreq = clk_get_rate(xdev->clk); in xwdt_probe()
211 * Twice of the 2^wdt_interval / freq because the first wdt overflow is in xwdt_probe()
212 * ignored (interrupt), reset is only generated at second wdt overflow in xwdt_probe()
214 if (pfreq && xdev->wdt_interval) in xwdt_probe()
215 xilinx_wdt_wdd->timeout = 2 * ((1 << xdev->wdt_interval) / in xwdt_probe()
218 spin_lock_init(&xdev->spinlock); in xwdt_probe()
221 rc = clk_enable(xdev->clk); in xwdt_probe()
223 dev_err(dev, "unable to enable clock\n"); in xwdt_probe()
230 clk_disable(xdev->clk); in xwdt_probe()
234 clk_disable(xdev->clk); in xwdt_probe()
241 xilinx_wdt_wdd->timeout); in xwdt_probe()
249 * xwdt_suspend - Suspend the device.
258 if (watchdog_active(&xdev->xilinx_wdt_wdd)) in xwdt_suspend()
259 xilinx_wdt_stop(&xdev->xilinx_wdt_wdd); in xwdt_suspend()
265 * xwdt_resume - Resume the device.
275 if (watchdog_active(&xdev->xilinx_wdt_wdd)) in xwdt_resume()
276 ret = xilinx_wdt_start(&xdev->xilinx_wdt_wdd); in xwdt_resume()
285 { .compatible = "xlnx,xps-timebase-wdt-1.00.a", },
286 { .compatible = "xlnx,xps-timebase-wdt-1.01.a", },