From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Marco Felsch <m.felsch@pengutronix.de>
Subject: [PATCH v2 4/7] watchdog: Add Hexagon EFI watchdog driver
Date: Thu, 12 Feb 2026 23:02:06 +0100 [thread overview]
Message-ID: <20260212-vmaster-customers-leicageo-system1600-v2-4-f590b7d5b0e9@pengutronix.de> (raw)
In-Reply-To: <20260212-vmaster-customers-leicageo-system1600-v2-0-f590b7d5b0e9@pengutronix.de>
The EFI system co-processor implements a watchdog device which must be
pinged to inform the MCU that the system is up and running.
Normaly the ping is done by Linux but sometimes it can become necessary
to do it within barebox too, e.g. to allow barebox debugging and
development.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/watchdog/Kconfig | 9 ++++
drivers/watchdog/Makefile | 1 +
drivers/watchdog/hgs_efi_wdt.c | 102 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 112 insertions(+)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index bf18782bdb58b20240d7762ce32f98c78c4cd12d..c962e8f22e5a7cb21ee93b3f82189cc8536781b9 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -195,4 +195,13 @@ config K3_RTI_WDT
Say Y here if you want to include support for the K3 watchdog
timer (RTI module) available in the K3 generation of processors.
+config HGS_EFI_WATCHDOG
+ bool "Hexagon Geosystems EFI watchdog"
+ depends on MFD_HGS_EFI || COMPILE_TEST
+ help
+ Say Y here if you want to include support for the Hexagon Geosystems
+ EFI watchdog timer.
+
+ If unsure, say N.
+
endif
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 85d8dbfa3f83d868ad84935ab98c5f7f64922f8e..187ab247ddcf61f9db8137425b3234b60a7062ac 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_STARFIVE_WDT) += starfive_wdt.o
obj-$(CONFIG_WDAT_WDT) += wdat_wdt.o
obj-$(CONFIG_CADENCE_WATCHDOG) += cadence_wdt.o
obj-$(CONFIG_K3_RTI_WDT) += rti_wdt.o
+obj-$(CONFIG_HGS_EFI_WATCHDOG) += hgs_efi_wdt.o
diff --git a/drivers/watchdog/hgs_efi_wdt.c b/drivers/watchdog/hgs_efi_wdt.c
new file mode 100644
index 0000000000000000000000000000000000000000..63297a0c27681917165ae422c3b94946ee99b401
--- /dev/null
+++ b/drivers/watchdog/hgs_efi_wdt.c
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2025 Pengutronix
+
+#include <common.h>
+#include <init.h>
+#include <of_device.h>
+#include <watchdog.h>
+
+#include <mfd/hgs-efi.h>
+
+struct hgs_efi_wdt_data {
+ unsigned int msg_id;
+};
+
+struct hgs_efi_wdt {
+ struct watchdog wdd;
+ struct hgs_efi *efi;
+ const struct hgs_efi_wdt_data *data;
+ bool pinged;
+};
+
+static struct hgs_efi_wdt *to_hgs_efi_wdt(struct watchdog *wdd)
+{
+ return container_of(wdd, struct hgs_efi_wdt, wdd);
+}
+
+static int hgs_efi_wdt_set_timeout(struct watchdog *wdd, unsigned int timeout)
+{
+ /*
+ * The set_timeout callback is required by the core, but we actually
+ * can't configure the watchdog, therefore return -ENOSYS.
+ */
+ return -ENOSYS;
+}
+
+static int hgs_efi_wdt_ping(struct watchdog *wdd)
+{
+ struct hgs_efi_wdt *efi_wd = to_hgs_efi_wdt(wdd);
+ struct device *dev = &wdd->dev;
+ struct hgs_sep_cmd cmd = {
+ .type = HGS_SEP_MSG_TYPE_EVENT,
+ .msg_id = efi_wd->data->msg_id,
+ };
+ int error;
+
+ /* The EFI watchdog doesn't have a timeout, once pinged */
+ if (efi_wd->pinged)
+ return 0;
+
+ error = hgs_efi_exec(efi_wd->efi, &cmd);
+ if (error) {
+ dev_warn(dev, "Failed to send OsRunning/SystemReady\n");
+ return error;
+ }
+
+ efi_wd->pinged = true;
+
+ return 0;
+}
+
+static int hgs_efi_wdt_drv_probe(struct device *dev)
+{
+ struct hgs_efi_wdt *efi_wd;
+ struct watchdog *wdd;
+ int error;
+
+ efi_wd = xzalloc(sizeof(*efi_wd));
+ efi_wd->efi = dev_get_priv(dev->parent);
+ efi_wd->data = of_device_get_match_data(dev);
+
+ wdd = &efi_wd->wdd;
+ wdd->hwdev = dev;
+ wdd->ping = hgs_efi_wdt_ping;
+ wdd->set_timeout = hgs_efi_wdt_set_timeout;
+ /* The watchdog is always running */
+ wdd->running = WDOG_HW_RUNNING;
+
+ error = watchdog_register(wdd);
+ if (error) {
+ dev_err(dev, "Failed to register watchdog device\n");
+ return error;
+ }
+
+ return 0;
+}
+
+const struct hgs_efi_wdt_data hgs_efi_wdt_gs05 = {
+ .msg_id = 0,
+};
+
+static struct of_device_id hgs_efi_wdt_of_match[] = {
+ { .compatible = "hgs,efi-gs05-wdt", .data = &hgs_efi_wdt_gs05 },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, hgs_efi_wdt_of_match);
+
+static struct driver hgs_efi_wdt_driver = {
+ .name = "hgs-efi-wdt",
+ .probe = hgs_efi_wdt_drv_probe,
+ .of_compatible = hgs_efi_wdt_of_match,
+};
+device_platform_driver(hgs_efi_wdt_driver);
--
2.47.3
next prev parent reply other threads:[~2026-02-12 22:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 22:02 [PATCH v2 0/7] Hexagon Geosystems GS05 Board Support Marco Felsch
2026-02-12 22:02 ` [PATCH v2 1/7] serdev: add proper error cleanup to serdev_device_open() Marco Felsch
2026-02-12 22:02 ` [PATCH v2 2/7] serdev: add serdev_device_close Marco Felsch
2026-02-12 22:02 ` [PATCH v2 3/7] mfd: Add Hexagon EFI driver Marco Felsch
2026-02-12 22:02 ` Marco Felsch [this message]
2026-02-12 22:02 ` [PATCH v2 5/7] commands: make run_command variadic Marco Felsch
2026-02-12 22:02 ` [PATCH v2 6/7] treewide: make use of new " Marco Felsch
2026-02-12 22:02 ` [PATCH v2 7/7] ARM: i.MX8MM: add Hexagon Geosystems GS05 Marco Felsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260212-vmaster-customers-leicageo-system1600-v2-4-f590b7d5b0e9@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox