[PATCH v3 5/6] watchdog: sandbox_wdt: set max_timeout_ms in probe

Juuso Rinta <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
Add a SANDBOX_WDT_MAX_TIMEOUT_MS define to sandbox asm/state.h
to emulate a hardware-limited maximum timeout.

Report the maximum timeout value to the wdt uclass by setting
max_timeout_ms in the per-device uclass-plat data during
sandbox_wdt_probe().

Signed-off-by: Juuso Rinta <[email protected]>
---
 arch/sandbox/include/asm/state.h |  2 ++
 drivers/watchdog/sandbox_wdt.c   | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 9dea0980bfc..742e4f5c6e9 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -38,6 +38,8 @@ struct sandbox_spi_info {
 	struct udevice *emul;
 };
 
+#define SANDBOX_WDT_MAX_TIMEOUT_MS	30000
+
 struct sandbox_wdt_info {
 	unsigned long long counter;
 	uint reset_count;
diff --git a/drivers/watchdog/sandbox_wdt.c b/drivers/watchdog/sandbox_wdt.c
index cd5eadbfd21..9a0cdac232a 100644
--- a/drivers/watchdog/sandbox_wdt.c
+++ b/drivers/watchdog/sandbox_wdt.c
@@ -43,6 +43,16 @@ static int sandbox_wdt_expire_now(struct udevice *dev, ulong flags)
 	return 0;
 }
 
+static int sandbox_wdt_probe(struct udevice *dev)
+{
+	struct wdt_uc_plat *plat = dev_get_uclass_plat(dev);
+
+	/* Store the emulated hardware max timeout in uclass plat data */
+	plat->max_timeout_ms = SANDBOX_WDT_MAX_TIMEOUT_MS;
+
+	return 0;
+}
+
 static const struct wdt_ops sandbox_wdt_ops = {
 	.start = sandbox_wdt_start,
 	.reset = sandbox_wdt_reset,
@@ -59,5 +69,6 @@ U_BOOT_DRIVER(wdt_sandbox) = {
 	.name = "wdt_sandbox",
 	.id = UCLASS_WDT,
 	.of_match = sandbox_wdt_ids,
+	.probe = sandbox_wdt_probe,
 	.ops = &sandbox_wdt_ops,
 };

-- 
2.39.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.