mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/5] watchdog: Add Hexagon EFI watchdog driver
Date: Fri, 6 Feb 2026 14:13:48 +0100	[thread overview]
Message-ID: <ade6d330-a7a2-42cf-9813-c4b0bdf76b39@pengutronix.de> (raw)
In-Reply-To: <20260205-vmaster-customers-leicageo-system1600-v1-4-a80b234ce1a1@pengutronix.de>



On 2/5/26 4:45 PM, Marco Felsch wrote:
> 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 | 88 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 98 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

Thanks for making sure it compiles under COMPILE_TEST. :)


> +#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 is_running;

This is only ever read, but set no where.

> +};
> +
> +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)
> +{
> +	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 ret;
> +
> +	/* The watchdog can't be turned of */
> +	if (efi_wd->is_running && !timeout)
> +		return -ENOSYS;
> +
> +	/* The EFI watchdog doesn't have a timeout, once pinged */
> +	if (efi_wd->is_running)
> +		return 0;

A watchdog can also implement a ping callback, which may be suitable here.

> +static int hgs_efi_wdt_drv_probe(struct device *dev)
> +{
> +	struct hgs_efi_wdt *efi_wd;
> +	struct watchdog *wdd;
> +	int ret;
> +
> +	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->set_timeout = hgs_efi_wdt_set_timeout;

FYI, if you can query the EFI whether it's enabled, you can set
wdd->running to either WDOG_HW_RUNNING or WDOG_HW_NOT_RUNNING

> +
> +	ret = watchdog_register(wdd);
> +	if (ret)
> +		dev_err(dev, "Failed to register watchdog device\n");
> +
> +	return ret;
> +}
> +
> +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);
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2026-02-06 13:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 15:45 [PATCH 0/5] Hexagon Geosystems GS05 Board Support Marco Felsch
2026-02-05 15:45 ` [PATCH 1/5] ARM: i.MX8MM: add MX8MM_PAD_CTL defines Marco Felsch
2026-02-06 13:04   ` Ahmad Fatoum
2026-02-05 15:45 ` [PATCH 2/5] lib: hexdump: make use of pr_print Marco Felsch
2026-02-06 13:05   ` Ahmad Fatoum
2026-02-05 15:45 ` [PATCH 3/5] mfd: Add Hexagon EFI driver Marco Felsch
2026-02-06 13:09   ` Ahmad Fatoum
2026-02-06 15:52     ` Marco Felsch
2026-02-09  9:03   ` Sascha Hauer
2026-02-09 11:13     ` Marco Felsch
2026-02-09 13:46       ` Sascha Hauer
2026-02-05 15:45 ` [PATCH 4/5] watchdog: Add Hexagon EFI watchdog driver Marco Felsch
2026-02-06 13:13   ` Ahmad Fatoum [this message]
2026-02-06 16:34     ` Marco Felsch
2026-02-05 15:45 ` [PATCH 5/5] ARM: i.MX8MM: add Hexagon Geosystems GS05 Marco Felsch
2026-02-06 13:47   ` Ahmad Fatoum
2026-02-06 14:07     ` SCHNEIDER Johannes
2026-02-06 15:43       ` Marco Felsch
2026-02-06 17:12     ` Marco Felsch
2026-02-09 10:42   ` Sascha Hauer
2026-02-09 11:39     ` Marco Felsch
2026-02-09 13:40       ` Sascha Hauer
2026-02-05 15:50 ` [PATCH 0/5] Hexagon Geosystems GS05 Board Support 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=ade6d330-a7a2-42cf-9813-c4b0bdf76b39@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    --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