[PATCH v2 2/2] watchdog: qcom: improve driver with more functionality

Paul Sajna hello at paulsajna.com
Wed Apr 23 04:04:03 CEST 2025


Tested stop and start in the console with reset (service watchdog) commented out and ensured start eventually reset from the watchdog. All seems good. Squashed and preparing to push v3.

On Tuesday, April 22nd, 2025 at 3:46 PM, Paul Sajna <hello at paulsajna.com> wrote:

> 
> 
> I tested reset and stop pretty thoroughly. I suppose "start" could use some more checking. I'll squash and fix a line of code I noticed I accidentally duplicated, then retest that this evening (Pacific Time)
> 
> On Tuesday, April 22nd, 2025 at 12:50 PM, Casey Connolly casey.connolly at linaro.org wrote:
> 
> > Hi Paul,
> > 
> > Please squash this patch into the first one, otherwise this looks good.
> > Did you test start/stop/reset?
> > 
> > Kind regards,
> > 
> > On 4/22/25 01:20, Paul Sajna wrote:
> > 
> > > - add the ability to start the watchdog
> > > - add the ability to reset the watchdog
> > > - remove the automatic disable in the probe function
> > > - use log macros for errors
> > > 
> > > Signed-off-by: Paul Sajna hello at paulsajna.com
> > > ---
> > > drivers/watchdog/qcom-wdt.c | 32 +++++++++++++++++++++++++-------
> > > 1 file changed, 25 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> > > index a7ce31ef811c717fd16700aa7d984a000763a93e..88e5fc7906825ac258393495682a75a5010473b0 100644
> > > --- a/drivers/watchdog/qcom-wdt.c
> > > +++ b/drivers/watchdog/qcom-wdt.c
> > > @@ -4,12 +4,14 @@
> > > * Copyright (c) Linaro Ltd. 2024
> > > *
> > > * Authors:
> > > - * Caleb Connolly caleb.connolly at linaro.org
> > > + * Casey Connolly casey.connolly at linaro.org
> > > + * Paul Sajna hello at paulsajna.com
> > > *
> > > * Derived from linux/drivers/watchdog/qcom-wdt.c
> > > */
> > > 
> > > #include <dm.h>
> > > +#include <dm/device_compat.h>
> > > #include <wdt.h>
> > > 
> > > #include <asm/io.h>
> > > @@ -50,7 +52,16 @@ static void __iomem *wdt_addr(struct qcom_wdt *wdt, enum wdt_reg reg)
> > > 
> > > int qcom_wdt_start(struct udevice dev, u64 timeout_ms, ulong flags)
> > > {
> > > - / unimplemented */
> > > + struct qcom_wdt *wdt = dev_get_priv(dev);
> > > +
> > > + writel(0, wdt_addr(wdt, WDT_EN));
> > > + writel(1, wdt_addr(wdt, WDT_RST));
> > > + writel(1, wdt_addr(wdt, WDT_EN));
> > > + writel(1, wdt_addr(wdt, WDT_EN));
> > > + if (readl(wdt_addr(wdt, WDT_EN)) != 1) {
> > > + dev_err(dev, "Failed to enable Qualcomm watchdog!\n");
> > > + return -EIO;
> > > + }
> > > return 0;
> > > }
> > > 
> > > @@ -60,29 +71,36 @@ int qcom_wdt_stop(struct udevice *dev)
> > > 
> > > writel(0, wdt_addr(wdt, WDT_EN));
> > > if (readl(wdt_addr(wdt, WDT_EN))) {
> > > - printf("Failed to disable Qualcomm watchdog!\n");
> > > + dev_err(dev, "Failed to disable Qualcomm watchdog!\n");
> > > return -EIO;
> > > }
> > > 
> > > return 0;
> > > }
> > > 
> > > +int qcom_wdt_reset(struct udevice *dev)
> > > +{
> > > + struct qcom_wdt *wdt = dev_get_priv(dev);
> > > +
> > > + writel(1, wdt_addr(wdt, WDT_RST));
> > > + return 0;
> > > +}
> > > +
> > > static int qcom_wdt_probe(struct udevice *dev)
> > > {
> > > struct qcom_wdt *wdt = dev_get_priv(dev);
> > > struct qcom_wdt_match_data *data = (void *)dev_get_driver_data(dev);
> > > - int ret;
> > > 
> > > wdt->base = dev_read_addr_ptr(dev);
> > > wdt->layout = data->offset;
> > > 
> > > - ret = qcom_wdt_stop(dev);
> > > -
> > > - return ret;
> > > + return 0;
> > > }
> > > 
> > > static const struct wdt_ops qcom_wdt_ops = {
> > > + .start = qcom_wdt_start,
> > > .stop = qcom_wdt_stop,
> > > + .reset = qcom_wdt_reset,
> > > };
> > > 
> > > static const struct udevice_id qcom_wdt_ids[] = {
> > 
> > --
> > Casey (she/they)


More information about the U-Boot mailing list