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 <he...@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.conno...@linaro.org>
+ *   Casey Connolly <casey.conno...@linaro.org>
+ *   Paul Sajna <he...@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)

Reply via email to