[PATCH v1] wdt: nuvoton: fix reset/expire function error and add dts

Jim Liu jim.t90615 at gmail.com
Tue Sep 26 11:04:07 CEST 2023


Signed-off-by: Jim Liu <JJLIU0 at nuvoton.com>
---
 arch/arm/dts/nuvoton-common-npcm8xx.dtsi | 24 ++++++++++++++++++++++++
 drivers/watchdog/npcm_wdt.c              | 12 ++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/arch/arm/dts/nuvoton-common-npcm8xx.dtsi b/arch/arm/dts/nuvoton-common-npcm8xx.dtsi
index fabe5925b7..87c77dcb2c 100644
--- a/arch/arm/dts/nuvoton-common-npcm8xx.dtsi
+++ b/arch/arm/dts/nuvoton-common-npcm8xx.dtsi
@@ -154,6 +154,30 @@
 				clock-names = "refclk";
 			};
 
+			watchdog0: watchdog at 801c {
+				compatible = "nuvoton,npcm750-wdt";
+				reg = <0x801c 0x4>;
+				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
+
+			watchdog1: watchdog at 901c {
+				compatible = "nuvoton,npcm750-wdt";
+				reg = <0x901c 0x4>;
+				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
+
+			watchdog2: watchdog at a01c {
+				compatible = "nuvoton,npcm750-wdt";
+				reg = <0xa01c 0x4>;
+				clocks = <&clk NPCM8XX_CLK_REFCLK>;
+				interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
+
 			serial0: serial at 0 {
 				compatible = "nuvoton,npcm845-uart", "nuvoton,npcm750-uart";
 				reg = <0x0 0x1000>;
diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index e56aa0ebe1..d6792bab35 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -69,17 +69,21 @@ static int npcm_wdt_stop(struct udevice *dev)
 static int npcm_wdt_reset(struct udevice *dev)
 {
 	struct npcm_wdt_priv *priv = dev_get_priv(dev);
+	u32 val;
 
-	writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, priv->regs);
+	val = readl(priv->regs);
+	writel(val | NPCM_WTR, priv->regs);
 
 	return 0;
 }
-
 static int npcm_wdt_expire_now(struct udevice *dev, ulong flags)
 {
-	return npcm_wdt_reset(dev);
-}
+	struct npcm_wdt_priv *priv = dev_get_priv(dev);
 
+	writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, priv->regs);
+
+	return 0;
+}
 static int npcm_wdt_of_to_plat(struct udevice *dev)
 {
 	struct npcm_wdt_priv *priv = dev_get_priv(dev);
-- 
2.25.1



More information about the U-Boot mailing list