Lines Matching +full:milli +full:- +full:seconds

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc.
50 "Watchdog time in seconds. (default="
57 * struct xwwdt_device - Watchdog device structure
79 struct watchdog_device *xilinx_wwdt_wdd = &xdev->xilinx_wwdt_wdd; in xilinx_wwdt_start()
82 spin_lock(&xdev->spinlock); in xilinx_wwdt_start()
84 iowrite32(XWWDT_MWR_MASK, xdev->base + XWWDT_MWR_OFFSET); in xilinx_wwdt_start()
85 iowrite32(~(u32)XWWDT_ESR_WEN_MASK, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
86 iowrite32((u32)xdev->closed_timeout, xdev->base + XWWDT_FWR_OFFSET); in xilinx_wwdt_start()
87 iowrite32((u32)xdev->open_timeout, xdev->base + XWWDT_SWR_OFFSET); in xilinx_wwdt_start()
90 control_status_reg = ioread32(xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
92 iowrite32(control_status_reg, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
94 spin_unlock(&xdev->spinlock); in xilinx_wwdt_start()
96 dev_dbg(xilinx_wwdt_wdd->parent, "Watchdog Started!\n"); in xilinx_wwdt_start()
106 spin_lock(&xdev->spinlock); in xilinx_wwdt_keepalive()
109 iowrite32(XWWDT_MWR_MASK, xdev->base + XWWDT_MWR_OFFSET); in xilinx_wwdt_keepalive()
112 control_status_reg = ioread32(xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_keepalive()
114 iowrite32(control_status_reg, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_keepalive()
116 spin_unlock(&xdev->spinlock); in xilinx_wwdt_keepalive()
137 struct device *dev = &pdev->dev; in xwwdt_probe()
149 return -ENOMEM; in xwwdt_probe()
151 xilinx_wwdt_wdd = &xdev->xilinx_wwdt_wdd; in xwwdt_probe()
152 xilinx_wwdt_wdd->info = &xilinx_wwdt_ident; in xwwdt_probe()
153 xilinx_wwdt_wdd->ops = &xilinx_wwdt_ops; in xwwdt_probe()
154 xilinx_wwdt_wdd->parent = dev; in xwwdt_probe()
156 xdev->base = devm_platform_ioremap_resource(pdev, 0); in xwwdt_probe()
157 if (IS_ERR(xdev->base)) in xwwdt_probe()
158 return PTR_ERR(xdev->base); in xwwdt_probe()
164 xdev->freq = clk_get_rate(clk); in xwwdt_probe()
165 if (xdev->freq < 1000000) in xwwdt_probe()
166 return -EINVAL; in xwwdt_probe()
168 xilinx_wwdt_wdd->min_timeout = XWWDT_MIN_TIMEOUT; in xwwdt_probe()
169 xilinx_wwdt_wdd->timeout = XWWDT_DEFAULT_TIMEOUT; in xwwdt_probe()
170 xilinx_wwdt_wdd->max_hw_heartbeat_ms = in xwwdt_probe()
171 div64_u64(XWWDT_MAX_COUNT_WINDOW_COMBINED, xdev->freq) * 1000; in xwwdt_probe()
174 xdev->close_percent = XWWDT_CLOSE_WINDOW_PERCENT; in xwwdt_probe()
176 xdev->close_percent = closed_window_percent; in xwwdt_probe()
178 watchdog_init_timeout(xilinx_wwdt_wdd, wwdt_timeout, &pdev->dev); in xwwdt_probe()
180 /* Calculate ticks for 1 milli-second */ in xwwdt_probe()
181 ms_count = div_u64(xdev->freq, 1000); in xwwdt_probe()
182 timeout_ms = xilinx_wwdt_wdd->timeout * 1000; in xwwdt_probe()
185 if (timeout_ms > xilinx_wwdt_wdd->max_hw_heartbeat_ms) { in xwwdt_probe()
191 xdev->closed_timeout = 0; in xwwdt_probe()
192 xdev->open_timeout = XWWDT_MAX_COUNT_WINDOW; in xwwdt_probe()
193 xilinx_wwdt_wdd->min_hw_heartbeat_ms = 0; in xwwdt_probe()
194 xilinx_wwdt_wdd->max_hw_heartbeat_ms = xilinx_wwdt_wdd->max_hw_heartbeat_ms / 2; in xwwdt_probe()
196 xdev->closed_timeout = div64_u64(timeout_count * xdev->close_percent, 100); in xwwdt_probe()
197 xilinx_wwdt_wdd->min_hw_heartbeat_ms = in xwwdt_probe()
198 div64_u64(timeout_ms * xdev->close_percent, 100); in xwwdt_probe()
200 if (timeout_ms > xilinx_wwdt_wdd->max_hw_heartbeat_ms / 2) { in xwwdt_probe()
201 max_per_window_ms = xilinx_wwdt_wdd->max_hw_heartbeat_ms / 2; in xwwdt_probe()
202 min_per_window_ms = timeout_ms - max_per_window_ms; in xwwdt_probe()
204 if (xilinx_wwdt_wdd->min_hw_heartbeat_ms > max_per_window_ms) { in xwwdt_probe()
205 dev_info(xilinx_wwdt_wdd->parent, in xwwdt_probe()
207 xdev->close_percent); in xwwdt_probe()
208 xdev->closed_timeout = max_per_window_ms * ms_count; in xwwdt_probe()
209 xilinx_wwdt_wdd->min_hw_heartbeat_ms = max_per_window_ms; in xwwdt_probe()
210 } else if (xilinx_wwdt_wdd->min_hw_heartbeat_ms < min_per_window_ms) { in xwwdt_probe()
211 dev_info(xilinx_wwdt_wdd->parent, in xwwdt_probe()
213 xdev->close_percent); in xwwdt_probe()
214 xdev->closed_timeout = min_per_window_ms * ms_count; in xwwdt_probe()
215 xilinx_wwdt_wdd->min_hw_heartbeat_ms = min_per_window_ms; in xwwdt_probe()
218 xdev->open_timeout = timeout_count - xdev->closed_timeout; in xwwdt_probe()
221 spin_lock_init(&xdev->spinlock); in xwwdt_probe()
230 xilinx_wwdt_wdd->timeout); in xwwdt_probe()
236 { .compatible = "xlnx,versal-wwdt", },