Lines Matching +full:watchdog +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
3 * Window watchdog device driver for Xilinx Versal WWDT
5 * Copyright (C) 2022 - 2023, Advanced Micro Devices, Inc.
16 #include <linux/watchdog.h>
32 /* Enable and Status Register Masks */
44 "Watchdog time in seconds. (default="
48 "Watchdog closed window percentage. (default="
51 * struct xwwdt_device - Watchdog device structure
54 * @xilinx_wwdt_wdd: watchdog device structure
69 struct watchdog_device *xilinx_wwdt_wdd = &xdev->xilinx_wwdt_wdd; in xilinx_wwdt_start()
74 time_out = xdev->freq * wdd->timeout; in xilinx_wwdt_start()
75 closed_timeout = div_u64(time_out * xdev->close_percent, 100); in xilinx_wwdt_start()
76 open_timeout = time_out - closed_timeout; in xilinx_wwdt_start()
77 wdd->min_hw_heartbeat_ms = xdev->close_percent * 10 * wdd->timeout; in xilinx_wwdt_start()
79 spin_lock(&xdev->spinlock); in xilinx_wwdt_start()
81 iowrite32(XWWDT_MWR_MASK, xdev->base + XWWDT_MWR_OFFSET); in xilinx_wwdt_start()
82 iowrite32(~(u32)XWWDT_ESR_WEN_MASK, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
83 iowrite32((u32)closed_timeout, xdev->base + XWWDT_FWR_OFFSET); in xilinx_wwdt_start()
84 iowrite32((u32)open_timeout, xdev->base + XWWDT_SWR_OFFSET); in xilinx_wwdt_start()
86 /* Enable the window watchdog timer */ in xilinx_wwdt_start()
87 control_status_reg = ioread32(xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
89 iowrite32(control_status_reg, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_start()
91 spin_unlock(&xdev->spinlock); in xilinx_wwdt_start()
93 dev_dbg(xilinx_wwdt_wdd->parent, "Watchdog Started!\n"); in xilinx_wwdt_start()
103 spin_lock(&xdev->spinlock); in xilinx_wwdt_keepalive()
105 /* Enable write access control bit for the window watchdog */ in xilinx_wwdt_keepalive()
106 iowrite32(XWWDT_MWR_MASK, xdev->base + XWWDT_MWR_OFFSET); in xilinx_wwdt_keepalive()
108 /* Trigger restart kick to watchdog */ in xilinx_wwdt_keepalive()
109 control_status_reg = ioread32(xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_keepalive()
111 iowrite32(control_status_reg, xdev->base + XWWDT_ESR_OFFSET); in xilinx_wwdt_keepalive()
113 spin_unlock(&xdev->spinlock); in xilinx_wwdt_keepalive()
122 .identity = "xlnx_window watchdog",
134 struct device *dev = &pdev->dev; in xwwdt_probe()
141 return -ENOMEM; in xwwdt_probe()
143 xilinx_wwdt_wdd = &xdev->xilinx_wwdt_wdd; in xwwdt_probe()
144 xilinx_wwdt_wdd->info = &xilinx_wwdt_ident; in xwwdt_probe()
145 xilinx_wwdt_wdd->ops = &xilinx_wwdt_ops; in xwwdt_probe()
146 xilinx_wwdt_wdd->parent = dev; in xwwdt_probe()
148 xdev->base = devm_platform_ioremap_resource(pdev, 0); in xwwdt_probe()
149 if (IS_ERR(xdev->base)) in xwwdt_probe()
150 return PTR_ERR(xdev->base); in xwwdt_probe()
156 xdev->freq = clk_get_rate(clk); in xwwdt_probe()
157 if (!xdev->freq) in xwwdt_probe()
158 return -EINVAL; in xwwdt_probe()
160 xilinx_wwdt_wdd->min_timeout = XWWDT_MIN_TIMEOUT; in xwwdt_probe()
161 xilinx_wwdt_wdd->timeout = XWWDT_DEFAULT_TIMEOUT; in xwwdt_probe()
162 xilinx_wwdt_wdd->max_hw_heartbeat_ms = 1000 * xilinx_wwdt_wdd->timeout; in xwwdt_probe()
165 xdev->close_percent = XWWDT_CLOSE_WINDOW_PERCENT; in xwwdt_probe()
167 xdev->close_percent = closed_window_percent; in xwwdt_probe()
169 watchdog_init_timeout(xilinx_wwdt_wdd, wwdt_timeout, &pdev->dev); in xwwdt_probe()
170 spin_lock_init(&xdev->spinlock); in xwwdt_probe()
178 dev_info(dev, "Xilinx window watchdog Timer with timeout %ds\n", in xwwdt_probe()
179 xilinx_wwdt_wdd->timeout); in xwwdt_probe()
185 { .compatible = "xlnx,versal-wwdt", },
193 .name = "Xilinx window watchdog",
201 MODULE_DESCRIPTION("Xilinx window watchdog driver");