[PATCH 4/6] watchdog: octeontx_wdt: add get_timeout operation
Juuso Rinta
juuso.rinta at nokia.com
Fri Jul 10 06:51:20 CEST 2026
Implement the get_timeout operation for the OcteonTX watchdog driver.
Add a timeout_ms field to the private driver data. octeontx_wdt_start()
stores the timeout after applying overflow clamping.
octeontx_wdt_get_timeout() stores the effective timeout
in the timeout_ms output parameter.
Signed-off-by: Juuso Rinta <juuso.rinta at nokia.com>
---
drivers/watchdog/octeontx_wdt.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/octeontx_wdt.c b/drivers/watchdog/octeontx_wdt.c
index 7299a9f9739..e1286ac165c 100644
--- a/drivers/watchdog/octeontx_wdt.c
+++ b/drivers/watchdog/octeontx_wdt.c
@@ -31,6 +31,7 @@ struct octeontx_wdt_data {
struct octeontx_wdt {
void __iomem *reg;
const struct octeontx_wdt_data *data;
+ u64 timeout_ms;
struct clk clk;
};
@@ -38,7 +39,7 @@ static int octeontx_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
{
struct octeontx_wdt *priv = dev_get_priv(dev);
u64 clk_rate, val;
- u64 tout_wdog;
+ u64 tout_wdog, calculated_timeout;
if (priv->data->has_clk) {
clk_rate = clk_get_rate(&priv->clk);
@@ -61,6 +62,11 @@ static int octeontx_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
if (tout_wdog >= 0x10000)
tout_wdog = 0xffff;
+ /* Store calculated timeout in milliseconds for get_timeout */
+ calculated_timeout = (tout_wdog << 8) << priv->data->timer_shift;
+
+ priv->timeout_ms = clk_rate ? calculated_timeout * 1000 / clk_rate : 0;
+
val = FIELD_PREP(WDOG_MODE, 0x3) |
FIELD_PREP(WDOG_LEN, tout_wdog) |
FIELD_PREP(WDOG_CNT, tout_wdog << 8);
@@ -88,6 +94,14 @@ static int octeontx_wdt_expire_now(struct udevice *dev, ulong flags)
return 0;
}
+static int octeontx_wdt_get_timeout(struct udevice *dev, u64 *timeout_ms)
+{
+ struct octeontx_wdt *priv = dev_get_priv(dev);
+ *timeout_ms = priv->timeout_ms;
+
+ return 0;
+}
+
static int octeontx_wdt_reset(struct udevice *dev)
{
struct octeontx_wdt *priv = dev_get_priv(dev);
@@ -142,6 +156,7 @@ static const struct wdt_ops octeontx_wdt_ops = {
.start = octeontx_wdt_start,
.stop = octeontx_wdt_stop,
.expire_now = octeontx_wdt_expire_now,
+ .get_timeout = octeontx_wdt_get_timeout,
};
static const struct octeontx_wdt_data octeontx_data = {
--
2.39.2
More information about the U-Boot
mailing list