Skip to contentSkip to conversation

watchdog: npcm: Add reset status detection support

PATCH Superseded Tomer Maimon 3 participants 16 messages Feb 10 – Feb 17

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

cover watchdog: npcm: Add reset status detection support

This series adds reset status detection support to the NPCM watchdog driver for both NPCM7XX (Poleg) and NPCM8XX (Arbel) platforms.

Patch 1 updates the device-tree bindings to support reset status detection on NPCM750 and NPCM8XX platforms. It introduces the nuvoton,card-reset-type, nuvoton,ext1-reset-type, and nuvoton,ext2-reset-type properties, and integrates the syscon interface required for accessing the reset status registers.

Patch 2 implements the watchdog driver changes, including the reset status detection infrastructure and platform restart support for both NPCM7XX and NPCM8XX.

Tomer Maimon (2):
dt-bindings: watchdog: Add NPCM reset status support
watchdog: npcm: Add reset status support

 .../watchdog/nuvoton,npcm750-wdt.yaml         |  51 +++++++-
 drivers/watchdog/npcm_wdt.c                   | 110 ++++++++++++++++++
 2 files changed, 159 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/2 dt-bindings: watchdog: Add NPCM reset status support

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +49 -2
index 7aa30f5b5c49..054cc0115af2 100644
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a watchdog.
   The watchdog supports a pre-timeout interrupt that fires 10ms before the
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM timer.
 
+  syscon:
+    description: phandle to the Global Control Register (GCR) syscon node.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  nuvoton,card-reset-type:
+    description: Reset type for external card reset signal detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
+  nuvoton,ext1-reset-type:
+    description: Reset type for external reset signal 1 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
+  nuvoton,ext2-reset-type:
+    description: Reset type for external reset signal 2 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
 required:
   - compatible
   - reg
   - interrupts
 
-unevaluatedProperties: false
+additionalProperties: false
 
 examples:
   - |
@@ -57,4 +100,8 @@ examples:
         interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
         reg = <0xf000801c 0x4>;
         clocks = <&clk NPCM7XX_CLK_TIMER>;
+        syscon = <&gcr>;
+        nuvoton,card-reset-type = "porst";
+        nuvoton,ext1-reset-type = "wd0";
+        nuvoton,ext2-reset-type = "wd2";
     };
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 25 lines · Tomer Maimon

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
index 7aa30f5b5c49..054cc0115af2 100644
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a watchdog.
   The watchdog supports a pre-timeout interrupt that fires 10ms before the
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 43

Quoted 4 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -0
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM timer.
 
+  syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

or just read the docs please.

Quoted 5 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +5 -0
+    description: phandle to the Global Control Register (GCR) syscon node.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  nuvoton,card-reset-type:
+    description: Reset type for external card reset signal detection.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 58

Quoted 10 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +10 -0
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4

You want it to be static configuration, so cannot be changed runtime? Why?

Quoted 24 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +24 -0
+
+  nuvoton,ext1-reset-type:
+    description: Reset type for external reset signal 1 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
+  nuvoton,ext2-reset-type:
+    description: Reset type for external reset signal 2 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 91

Quoted 10 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -1
+      - sw3
+      - sw4
+
 required:
   - compatible
   - reg
   - interrupts
 
-unevaluatedProperties: false
+additionalProperties: false

Why? Nothing explains this in the commit msg.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml examples: · line 107

Quoted 12 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -0
 examples:
   - |
@@ -57,4 +100,8 @@ examples:
         interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
         reg = <0xf000801c 0x4>;
         clocks = <&clk NPCM7XX_CLK_TIMER>;
+        syscon = <&gcr>;
+        nuvoton,card-reset-type = "porst";
+        nuvoton,ext1-reset-type = "wd0";
+        nuvoton,ext2-reset-type = "wd2";
     };

Best regards,
Krzysztof

author maintainer
#3 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Hi Krzysztof,

Thanks for your review.

Quoted 34 lines · Krzysztof Kozlowski
Quoted 6 lines · Tomer Maimon

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

Quoted 6 lines
---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml maintainers: · line 13

Quoted 6 lines

index 7aa30f5b5c49..054cc0115af2 100644

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +0 -0
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a

watchdog.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml maintainers: · line 14

Quoted 1 line
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +0 -0
   The watchdog supports a pre-timeout interrupt that fires 10ms before

the

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 41

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM

timer.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node
in nuvoton-common-npcm8xx.dtsi file, what should I do:
1. Modify the syson to nuvoton,sys-gcr like in the dtsi?
2. Still use the syscon property in the dtsi file, therefore stick with the syscon add.

Quoted 20 lines

or just read the docs please.

Quoted 1 line

+ description: phandle to the Global Control Register (GCR) syscon

node.

Quoted 4 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  nuvoton,card-reset-type:
+    description: Reset type for external card reset signal detection.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 58

Quoted 10 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +10 -0
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
Quoted 2 lines

You want it to be static configuration, so cannot be changed runtime? Why?

Yes, it is only an indication of the most recent reset in the BMC. In addition:
1. The driver reads the reset register during the probe. After this read, the reset register should be cleared so it’s ready for the next system reset.
2. I’m not aware of any service function that allows changing the reset indication at runtime.
.

Quoted 33 lines
Quoted 33 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +27 -0
+
+  nuvoton,ext1-reset-type:
+    description: Reset type for external reset signal 1 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
+  nuvoton,ext2-reset-type:
+    description: Reset type for external reset signal 2 detection.
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
+
 required:
   - compatible
   - reg
   - interrupts
Quoted 5 lines

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 91

Quoted 2 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-unevaluatedProperties: false
+additionalProperties: false

Why? Nothing explains this in the commit msg.

Mistake, will back to unevaluatedProperties: false

Quoted 19 lines
Quoted 6 lines

examples:
- |

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml examples: · line 107

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -0
@@ -57,4 +100,8 @@ examples:
         interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
         reg = <0xf000801c 0x4>;
         clocks = <&clk NPCM7XX_CLK_TIMER>;
+        syscon = <&gcr>;
+        nuvoton,card-reset-type = "porst";
+        nuvoton,ext1-reset-type = "wd0";
+        nuvoton,ext2-reset-type = "wd2";
     };

Best regards,
Krzysztof

Best regards,

Tomer

#4 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 40 lines · Tomer Maimon

Hi Krzysztof,

Thanks for your review.

Quoted 34 lines · Krzysztof Kozlowski
Quoted 6 lines · Tomer Maimon

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

Quoted 6 lines
---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml maintainers: · line 13

Quoted 6 lines

index 7aa30f5b5c49..054cc0115af2 100644

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +0 -0
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a

watchdog.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml maintainers: · line 14

Quoted 1 line
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +0 -0
   The watchdog supports a pre-timeout interrupt that fires 10ms before

the

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 41

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM

timer.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Either you document existing ABI or you add new (for new device). Commit msg MUST be explicit about it and provide the reasons. If wrong (e.g. discouraged) ABI was already used then it depends how and when it got into the kernel, e.g. if someone bypassed DT completely just to get it inside.

Quoted 27 lines

1. Modify the syson to nuvoton,sys-gcr like in the dtsi?
2. Still use the syscon property in the dtsi file, therefore stick with the syscon add.

Quoted 20 lines

or just read the docs please.

Quoted 1 line

+ description: phandle to the Global Control Register (GCR) syscon

node.

Quoted 4 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  nuvoton,card-reset-type:
+    description: Reset type for external card reset signal detection.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 58

Quoted 10 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +10 -0
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4
Quoted 2 lines

You want it to be static configuration, so cannot be changed runtime? Why?

Quoted 7 lines

Yes, it is only an indication of the most recent reset in the BMC. In addition:
1. The driver reads the reset register during the probe. After this read, the reset register should be cleared so it’s ready for the next system reset.
2. I’m not aware of any service function that allows changing the reset indication at runtime.

Huh? If the driver reads the reset you do not need this property at all.

Best regards,
Krzysztof

author maintainer
#5 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Hi Krzysztof,

Thanks for your comments.

Quoted 53 lines · Krzysztof Kozlowski
Quoted 5 lines · Tomer Maimon

Hi Krzysztof,

Thanks for your review.

On Tue, 10 Feb 2026 at 18:11, Krzysztof Kozlowski <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines · Tomer Maimon
Quoted 11 lines

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

diff --git

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 2 lines

index 7aa30f5b5c49..054cc0115af2 100644
---

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 1 line
Quoted 1 line
Quoted 1 line

+++

b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 16 lines
Quoted 16 lines

Review maintainers: · line 13

Quoted 3 lines
(quoted diff) +0 -0
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a

watchdog.

Review maintainers: · line 14

Quoted 1 line
(quoted diff) +0 -0
   The watchdog supports a pre-timeout interrupt that fires 10ms before

the

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 41

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM

timer.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

Quoted 8 lines

How is that file related to this binding?

Either you document existing ABI or you add new (for new device). Commit msg MUST be explicit about it and provide the reasons. If wrong (e.g. discouraged) ABI was already used then it depends how and when it got into the kernel, e.g. if someone bypassed DT completely just to get it inside.

The syscon property is already used in the upstream NPCM8xx DTSI watchdog node, so I will document it as existing ABI and mark it deprecated. I will add a new vendor‑specific property (nuvoton,sysgcr) as the preferred one, and explain this clearly in the commit message.

Quoted 38 lines
Quoted 3 lines

1. Modify the syson to nuvoton,sys-gcr like in the dtsi?
2. Still use the syscon property in the dtsi file, therefore stick with

the

Quoted 24 lines

syscon add.

Quoted 21 lines

or just read the docs please.

Quoted 1 line

+ description: phandle to the Global Control Register (GCR) syscon

node.

Quoted 4 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +4 -0
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  nuvoton,card-reset-type:
+    description: Reset type for external card reset signal detection.

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 58

Quoted 10 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +10 -0
+    enum:
+      - porst
+      - corst
+      - wd0
+      - wd1
+      - wd2
+      - sw1
+      - sw2
+      - sw3
+      - sw4

You want it to be static configuration, so cannot be changed runtime?

Why?

Quoted 8 lines
Quoted 1 line

Yes, it is only an indication of the most recent reset in the BMC. In addition:
1. The driver reads the reset register during the probe. After this read, the reset register should be cleared so it’s ready for the next system reset.
2. I’m not aware of any service function that allows changing the reset indication at runtime.

Quoted 2 lines

Huh? If the driver reads the reset you do not need this property at all.

I understand that since the driver can read the reset cause directly from the GCR, no DT properties should be used for this. I’ll drop the reset‑type properties and handle the mapping in the driver based on the SoC.

Quoted 4 lines

Best regards,
Krzysztof

Best regards,

Tomer

#6 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 61 lines · Tomer Maimon

Hi Krzysztof,

Thanks for your comments.

Quoted 55 lines · Krzysztof Kozlowski
Quoted 5 lines · Tomer Maimon

Hi Krzysztof,

Thanks for your review.

On Tue, 10 Feb 2026 at 18:11, Krzysztof Kozlowski <[email protected]>

Quoted 13 lines · wrote:
Quoted 13 lines · Tomer Maimon
Quoted 11 lines

Add reset status detection for NPCM7XX and NPCM8XX platforms via syscon integration. Document syscon property and three configurable reset type properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51 ++++++++++++++++++-
 1 file changed, 49 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

diff --git

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 2 lines

index 7aa30f5b5c49..054cc0115af2 100644
---

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 1 line
Quoted 1 line
Quoted 1 line

+++

b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 16 lines
Quoted 16 lines

Review maintainers: · line 13

Quoted 3 lines
(quoted diff) +0 -0
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters, and a

watchdog.

Review maintainers: · line 14

Quoted 1 line
(quoted diff) +0 -0
   The watchdog supports a pre-timeout interrupt that fires 10ms before

the

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 41

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM

timer.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Quoted 8 lines
Quoted 6 lines

Either you document existing ABI or you add new (for new device). Commit msg MUST be explicit about it and provide the reasons. If wrong (e.g. discouraged) ABI was already used then it depends how and when it got into the kernel, e.g. if someone bypassed DT completely just to get it inside.

The syscon property is already used in the upstream NPCM8xx DTSI watchdog node, so I will document it as existing ABI and mark it deprecated. I will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Quoted 8 lines

add a new vendor‑specific property (nuvoton,sysgcr) as the preferred one, and explain this clearly in the commit message.

Quoted 5 lines
Quoted 3 lines

1. Modify the syson to nuvoton,sys-gcr like in the dtsi?
2. Still use the syscon property in the dtsi file, therefore stick with

the

Quoted 1 line

syscon add.

Best regards,
Krzysztof

author maintainer
#7 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 76 lines · Krzysztof Kozlowski
Quoted 5 lines · Tomer Maimon

Hi Krzysztof,

Thanks for your comments.

On Mon, 16 Feb 2026 at 13:16, Krzysztof Kozlowski <[email protected]>

Quoted 11 lines · wrote:
Quoted 11 lines · Tomer Maimon
Quoted 5 lines

Hi Krzysztof,

Thanks for your review.

On Tue, 10 Feb 2026 at 18:11, Krzysztof Kozlowski <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines · Tomer Maimon
Quoted 1 line

Add reset status detection for NPCM7XX and NPCM8XX platforms via

syscon

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

integration. Document syscon property and three configurable reset

type

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

properties (nuvoton,card-reset-type, nuvoton,ext1-reset-type, nuvoton,ext2-reset-type)that map reset signal detection to specific reset bit positions.

---
 .../watchdog/nuvoton,npcm750-wdt.yaml         | 51

++++++++++++++++++-

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

index 7aa30f5b5c49..054cc0115af2 100644
---

a/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 1 line
Quoted 1 line
Quoted 1 line

+++

b/Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml

Quoted 3 lines
Quoted 3 lines

Review maintainers: · line 13

Quoted 3 lines
(quoted diff) +0 -0
@@ -12,7 +12,7 @@ maintainers:
 description:
   Nuvoton NPCM timer module provides five 24-bit timer counters,

and a

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

watchdog.

Quoted 1 line
(quoted diff) +0 -0
   The watchdog supports a pre-timeout interrupt that fires 10ms

before

Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines

the

Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml properties: · line 41

Quoted 8 lines
Documentation/devicetree/bindings/watchdog/nuvoton,npcm750-wdt.yaml +1 -1
-  expiry.
+  expiry and reset status detection via syscon integration.
 
 allOf:
   - $ref: watchdog.yaml#
@@ -40,12 +40,55 @@ properties:
   clock-frequency:
     description: Frequency in Hz of the clock that drives the NPCM

timer.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Quoted 8 lines
Quoted 6 lines

Either you document existing ABI or you add new (for new device). Commit msg MUST be explicit about it and provide the reasons. If wrong (e.g. discouraged) ABI was already used then it depends how and when it got into the kernel, e.g. if someone bypassed DT completely just to get it inside.

The syscon property is already used in the upstream NPCM8xx DTSI watchdog node, so I will document it as existing ABI and mark it deprecated. I

Quoted 7 lines

will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Understood. The syscon phandle is used by the watchdog driver to read and

clear the GCR reset‑status registers and then report the reset cause through the watchdog bootstatus bits.
Therefore, this property should appear in the binding only because the watchdog driver actually uses it — which I am implementing in this patch set.
I will document it accordingly, and also add the new nuvoton,sysgcr phandle as the preferred name.

Quoted 4 lines

add a new vendor‑specific property (nuvoton,sysgcr) as the preferred one,

Quoted 3 lines

and explain this clearly in the commit message.

Quoted 1 line
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

1. Modify the syson to nuvoton,sys-gcr like in the dtsi?
2. Still use the syscon property in the dtsi file, therefore stick with

the

Quoted 1 line

syscon add.

Best regards,
Krzysztof

Best regards,

Tomer

#8 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 20 lines · Tomer Maimon
Quoted 19 lines · Krzysztof Kozlowski
Quoted 19 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted in Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

Quoted 8 lines

How is that file related to this binding?

Either you document existing ABI or you add new (for new device). Commit msg MUST be explicit about it and provide the reasons. If wrong (e.g. discouraged) ABI was already used then it depends how and when it got into the kernel, e.g. if someone bypassed DT completely just to get it inside.

The syscon property is already used in the upstream NPCM8xx DTSI watchdog node, so I will document it as existing ABI and mark it deprecated. I

Quoted 7 lines
Quoted 7 lines

will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Understood. The syscon phandle is used by the watchdog driver to read and

You messed up quotes.

Can you point me to the line? I REALLY want to be sure that we are not wasting each other time, e.g. me looking at wrong code or you telling me some bollocks from downstream.

Quoted 7 lines

clear the GCR reset‑status registers and then report the reset cause through the watchdog bootstatus bits.
Therefore, this property should appear in the binding only because the watchdog driver actually uses it — which I am implementing in this patch set.
I will document it accordingly, and also add the new nuvoton,sysgcr phandle as the preferred name.

Best regards,
Krzysztof

author maintainer
#9 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 34 lines · Krzysztof Kozlowski
Quoted 1 line · Tomer Maimon

On Mon, 16 Feb 2026 at 16:48, Krzysztof Kozlowski <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted

in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Either you document existing ABI or you add new (for new device).

Commit

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

msg MUST be explicit about it and provide the reasons. If wrong

(e.g.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

discouraged) ABI was already used then it depends how and when it

got

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

into the kernel, e.g. if someone bypassed DT completely just to get

it

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

inside.

The syscon property is already used in the upstream NPCM8xx DTSI

watchdog

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

node, so I will document it as existing ABI and mark it deprecated. I

will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

Understood. The syscon phandle is used by the watchdog driver to read

and

You messed up quotes.

Can you point me to the line? I REALLY want to be sure that we are not wasting each other time, e.g. me looking at wrong code or you telling me some bollocks from downstream.

The syscon property is not used in the current upstream npcm_wdt driver. It is used *in this patch set*, which introduces the function npcm_get_reset_status(). Inside that function, the code calls:
gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); to obtain the GCR regmap, read the reset‑status registers, clear them, and report the reset cause via the watchdog bootstatus.
This usage is shown here:
https://www.spinics.net/lists/kernel/msg6045622.html
In addition, the watchdog maintainer confirmed that the reset cause can be exposed without the deprecated reset‑type DT properties:
https://www.spinics.net/lists/kernel/msg6052106.html

Given this, should I remove the unused syscon phandle from the NPCM8xx DTSI first, since no upstream driver currently uses it and it is therefore not part of the ABI?
In this patch set, I am adding the first upstream usage of the GCR regmap in the watchdog driver, so I plan to introduce the new, preferred nuvoton,sysgcr property in the binding and use it in the DTSI, without keeping the old syscon name unless you think backward compatibility is needed.

Please let me know if you prefer that I update the DTSI first or include the DTSI and binding changes in the same series.

Quoted 7 lines
Quoted 7 lines

clear the GCR reset‑status registers and then report the reset cause through the watchdog bootstatus bits.
Therefore, this property should appear in the binding only because the watchdog driver actually uses it — which I am implementing in this patch set.
I will document it accordingly, and also add the new nuvoton,sysgcr

Quoted 7 lines

phandle

Quoted 1 line

as the preferred name.

Best regards,
Krzysztof

Best regards,

Tomer

#10 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 39 lines · Tomer Maimon
Quoted 37 lines · Krzysztof Kozlowski
Quoted 1 line · Tomer Maimon

On Mon, 16 Feb 2026 at 16:48, Krzysztof Kozlowski <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted

in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Either you document existing ABI or you add new (for new device).

Commit

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

msg MUST be explicit about it and provide the reasons. If wrong

(e.g.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

discouraged) ABI was already used then it depends how and when it

got

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

into the kernel, e.g. if someone bypassed DT completely just to get

it

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

inside.

The syscon property is already used in the upstream NPCM8xx DTSI

watchdog

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

node, so I will document it as existing ABI and mark it deprecated. I

will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Understood. The syscon phandle is used by the watchdog driver to read

and

Quoted 8 lines
Quoted 6 lines

You messed up quotes.

Can you point me to the line? I REALLY want to be sure that we are not wasting each other time, e.g. me looking at wrong code or you telling me some bollocks from downstream.

The syscon property is not used in the current upstream npcm_wdt driver. It is used *in this patch set*, which introduces the function

Why would that matter for the ABI?

So no, your buggy DTS sneaked into the kernel before submitting bindings is not acceptable thus ABI which was NEVER reviewed must be removed.

Best regards,
Krzysztof

author maintainer
#11 lore raw

Re: [PATCH v1 1/2] dt-bindings: watchdog: Add NPCM reset status support

Quoted 47 lines · Krzysztof Kozlowski
Quoted 1 line · Tomer Maimon

On Mon, 16 Feb 2026 at 20:03, Krzysztof Kozlowski <[email protected]>

Quoted 44 lines · wrote:
Quoted 44 lines · Tomer Maimon
Quoted 1 line

On Mon, 16 Feb 2026 at 16:48, Krzysztof Kozlowski <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+ syscon:

First iteration. See "How to Get Your DT Schema Bindings Accepted

in

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Less Than 10 Iterations"

Thanks, it was very helpful.
the syscon property is already found in the WD node in nuvoton-common-npcm8xx.dtsi file, what should I do:

How is that file related to this binding?

Either you document existing ABI or you add new (for new device).

Commit

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

msg MUST be explicit about it and provide the reasons. If wrong

(e.g.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

discouraged) ABI was already used then it depends how and when it

got

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

into the kernel, e.g. if someone bypassed DT completely just to get

it

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

inside.

The syscon property is already used in the upstream NPCM8xx DTSI

watchdog

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

node, so I will document it as existing ABI and mark it deprecated. I

will

And how it is used? I cannot find its usage, so I do not agree on documenting it. Property should be removed or at least provide the justification/impact of removal, if you need it to stay.

Understood. The syscon phandle is used by the watchdog driver to read

and

You messed up quotes.

Can you point me to the line? I REALLY want to be sure that we are not wasting each other time, e.g. me looking at wrong code or you telling me some bollocks from downstream.

Quoted 7 lines
Quoted 2 lines

The syscon property is not used in the current upstream npcm_wdt driver. It is used *in this patch set*, which introduces the function

Why would that matter for the ABI?

So no, your buggy DTS sneaked into the kernel before submitting bindings is not acceptable thus ABI which was NEVER reviewed must be removed.

It will be removed from the DTSI.
I’ll send a new patch set that adds proper reset‑indication support using a new nuvoton,sysgcr phandle.

Quoted 5 lines

Best regards,
Krzysztof

Best regards,

Tomer

author maintainer
#12 lore raw

PATCH 2/2 watchdog: npcm: Add reset status support

In reply to Tomer Maimon

Add reset status detection for NPCM watchdog driver on both NPCM7XX and NPCM8XX platforms. Implement GCR register integration via syscon for reset status detection and configurable reset type mapping via device tree properties.

---
 drivers/watchdog/npcm_wdt.c | 110 ++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)
drivers/watchdog/npcm_wdt.c +110 -0
index e62ea054bc61..ebece5d6240a 100644
@@ -12,9 +12,25 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/watchdog.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+
+#define NPCM7XX_RESSR_OFFSET	0x6C
+#define NPCM7XX_INTCR2_OFFSET	0x60
 
 #define NPCM_WTCR	0x1C
 
+#define NPCM7XX_PORST	BIT(31)
+#define NPCM7XX_CORST	BIT(30)
+#define NPCM7XX_WD0RST	BIT(29)
+#define NPCM7XX_WD1RST	BIT(24)
+#define NPCM7XX_WD2RST	BIT(23)
+#define NPCM7XX_SWR1RST	BIT(28)
+#define NPCM7XX_SWR2RST	BIT(27)
+#define NPCM7XX_SWR3RST	BIT(26)
+#define NPCM7XX_SWR4RST	BIT(25)
+#define NPCM8XX_RST	(GENMASK(31, 23) | GENMASK(15, 12))
+
 #define NPCM_WTCLK	(BIT(10) | BIT(11))	/* Clock divider */
 #define NPCM_WTE	BIT(7)			/* Enable */
 #define NPCM_WTIE	BIT(6)			/* Enable irq */
@@ -45,6 +61,9 @@ struct npcm_wdt {
 	struct watchdog_device  wdd;
 	void __iomem		*reg;
 	struct clk		*clk;
+	u32			card_reset;
+	u32			ext1_reset;
+	u32			ext2_reset;
 };
 
 static inline struct npcm_wdt *to_npcm_wdt(struct watchdog_device *wdd)
@@ -185,6 +204,95 @@ static const struct watchdog_ops npcm_wdt_ops = {
 	.restart = npcm_wdt_restart,
 };
 
+static u32 npcm_wdt_reset_type(const char *reset_type)
+{
+	if (!strcmp(reset_type, "porst"))
+		return NPCM7XX_PORST;
+	else if (!strcmp(reset_type, "corst"))
+		return NPCM7XX_CORST;
+	else if (!strcmp(reset_type, "wd0"))
+		return NPCM7XX_WD0RST;
+	else if (!strcmp(reset_type, "wd1"))
+		return NPCM7XX_WD1RST;
+	else if (!strcmp(reset_type, "wd2"))
+		return NPCM7XX_WD2RST;
+	else if (!strcmp(reset_type, "sw1"))
+		return NPCM7XX_SWR1RST;
+	else if (!strcmp(reset_type, "sw2"))
+		return NPCM7XX_SWR2RST;
+	else if (!strcmp(reset_type, "sw3"))
+		return NPCM7XX_SWR3RST;
+	else if (!strcmp(reset_type, "sw4"))
+		return NPCM7XX_SWR4RST;
+
+	return 0;
+}
+
+static void npcm_get_reset_status(struct npcm_wdt *wdt, struct device *dev)
+{
+	const char *card_reset_type;
+	const char *ext1_reset_type;
+	const char *ext2_reset_type;
+	struct regmap *gcr_regmap;
+	u32 rstval, ressrval;
+	int ret;
+
+	gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
+	if (IS_ERR(gcr_regmap)) {
+		dev_warn(dev, "Failed to find gcr syscon, WD reset status not supported\n");
+		return;
+	}
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,card-reset-type",
+				      &card_reset_type);
+	if (ret)
+		wdt->card_reset = NPCM7XX_PORST;
+	else
+		wdt->card_reset = npcm_wdt_reset_type(card_reset_type);
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,ext1-reset-type",
+				      &ext1_reset_type);
+	if (ret)
+		wdt->ext1_reset = 0;
+	else
+		wdt->ext1_reset = npcm_wdt_reset_type(ext1_reset_type);
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,ext2-reset-type",
+				      &ext2_reset_type);
+	if (ret)
+		wdt->ext2_reset = 0;
+	else
+		wdt->ext2_reset = npcm_wdt_reset_type(ext2_reset_type);
+
+	regmap_read(gcr_regmap, NPCM7XX_INTCR2_OFFSET, &rstval);
+	/* prefer the most specific SoC first */
+	if (of_device_is_compatible(dev->of_node, "nuvoton,npcm845-wdt")) {
+		regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+			     rstval & ~NPCM8XX_RST);
+	} else if (of_device_is_compatible(dev->of_node, "nuvoton,npcm750-wdt")) {
+		if ((rstval & NPCM7XX_PORST) == 0) {
+			rstval = NPCM7XX_PORST;
+			regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+				     rstval | NPCM7XX_PORST);
+		} else {
+			rstval = 0;
+		}
+		regmap_read(gcr_regmap, NPCM7XX_RESSR_OFFSET, &ressrval);
+		rstval |= ressrval;
+		regmap_write(gcr_regmap, NPCM7XX_RESSR_OFFSET, ressrval);
+	}
+
+	if (rstval & wdt->card_reset)
+		wdt->wdd.bootstatus |= WDIOF_CARDRESET;
+	if (rstval & wdt->ext1_reset)
+		wdt->wdd.bootstatus |= WDIOF_EXTERN1;
+	if (rstval & wdt->ext2_reset)
+		wdt->wdd.bootstatus |= WDIOF_EXTERN2;
+}
+
 static int npcm_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -208,6 +316,8 @@ static int npcm_wdt_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
+	npcm_get_reset_status(wdt, dev);
+
 	wdt->wdd.info = &npcm_wdt_info;
 	wdt->wdd.ops = &npcm_wdt_ops;
 	wdt->wdd.min_timeout = 1;
Signature · 1 line
2.34.1
maintainer
#13 lore raw

Re: [PATCH v1 2/2] watchdog: npcm: Add reset status support

Quoted 80 lines · Tomer Maimon

Add reset status detection for NPCM watchdog driver on both NPCM7XX and NPCM8XX platforms. Implement GCR register integration via syscon for reset status detection and configurable reset type mapping via device tree properties.

---
  drivers/watchdog/npcm_wdt.c | 110 ++++++++++++++++++++++++++++++++++++
  1 file changed, 110 insertions(+)
drivers/watchdog/npcm_wdt.c +45 -0
index e62ea054bc61..ebece5d6240a 100644
@@ -12,9 +12,25 @@
  #include <linux/platform_device.h>
  #include <linux/slab.h>
  #include <linux/watchdog.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+
+#define NPCM7XX_RESSR_OFFSET	0x6C
+#define NPCM7XX_INTCR2_OFFSET	0x60
 
  #define NPCM_WTCR	0x1C
 
+#define NPCM7XX_PORST	BIT(31)
+#define NPCM7XX_CORST	BIT(30)
+#define NPCM7XX_WD0RST	BIT(29)
+#define NPCM7XX_WD1RST	BIT(24)
+#define NPCM7XX_WD2RST	BIT(23)
+#define NPCM7XX_SWR1RST	BIT(28)
+#define NPCM7XX_SWR2RST	BIT(27)
+#define NPCM7XX_SWR3RST	BIT(26)
+#define NPCM7XX_SWR4RST	BIT(25)
+#define NPCM8XX_RST	(GENMASK(31, 23) | GENMASK(15, 12))
+
  #define NPCM_WTCLK	(BIT(10) | BIT(11))	/* Clock divider */
  #define NPCM_WTE	BIT(7)			/* Enable */
  #define NPCM_WTIE	BIT(6)			/* Enable irq */
@@ -45,6 +61,9 @@ struct npcm_wdt {
  	struct watchdog_device  wdd;
  	void __iomem		*reg;
  	struct clk		*clk;
+	u32			card_reset;
+	u32			ext1_reset;
+	u32			ext2_reset;
  };
 
  static inline struct npcm_wdt *to_npcm_wdt(struct watchdog_device *wdd)
@@ -185,6 +204,95 @@ static const struct watchdog_ops npcm_wdt_ops = {
  	.restart = npcm_wdt_restart,
  };
 
+static u32 npcm_wdt_reset_type(const char *reset_type)
+{
+	if (!strcmp(reset_type, "porst"))
+		return NPCM7XX_PORST;
+	else if (!strcmp(reset_type, "corst"))
+		return NPCM7XX_CORST;
+	else if (!strcmp(reset_type, "wd0"))
+		return NPCM7XX_WD0RST;
+	else if (!strcmp(reset_type, "wd1"))
+		return NPCM7XX_WD1RST;
+	else if (!strcmp(reset_type, "wd2"))
+		return NPCM7XX_WD2RST;
+	else if (!strcmp(reset_type, "sw1"))
+		return NPCM7XX_SWR1RST;
+	else if (!strcmp(reset_type, "sw2"))
+		return NPCM7XX_SWR2RST;
+	else if (!strcmp(reset_type, "sw3"))
+		return NPCM7XX_SWR3RST;
+	else if (!strcmp(reset_type, "sw4"))
+		return NPCM7XX_SWR4RST;
+
+	return 0;
+}
+
+static void npcm_get_reset_status(struct npcm_wdt *wdt, struct device *dev)
+{

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 242

Quoted 10 lines
drivers/watchdog/npcm_wdt.c +10 -0
+	const char *card_reset_type;
+	const char *ext1_reset_type;
+	const char *ext2_reset_type;
+	struct regmap *gcr_regmap;
+	u32 rstval, ressrval;
+	int ret;
+
+	gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
+	if (IS_ERR(gcr_regmap)) {
+		dev_warn(dev, "Failed to find gcr syscon, WD reset status not supported\n");

A warning is quite strong here, given that this is new code and the syscon reference may not exist in existing devicetree files. notice should be good enough.

Quoted 6 lines
drivers/watchdog/npcm_wdt.c +6 -0
+		return;
+	}
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,card-reset-type",
+				      &card_reset_type);

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 258

Quoted 10 lines
drivers/watchdog/npcm_wdt.c +10 -0
+	if (ret)
+		wdt->card_reset = NPCM7XX_PORST;
+	else
+		wdt->card_reset = npcm_wdt_reset_type(card_reset_type);
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,ext1-reset-type",
+				      &ext1_reset_type);
+	if (ret)
+		wdt->ext1_reset = 0;

wdt is zero-allocated, so setting those variables to 0 is not necessary.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 270

Quoted 12 lines
drivers/watchdog/npcm_wdt.c +12 -0
+	else
+		wdt->ext1_reset = npcm_wdt_reset_type(ext1_reset_type);
+
+	ret = of_property_read_string(dev->of_node,
+				      "nuvoton,ext2-reset-type",
+				      &ext2_reset_type);
+	if (ret)
+		wdt->ext2_reset = 0;
+	else
+		wdt->ext2_reset = npcm_wdt_reset_type(ext2_reset_type);
+
+	regmap_read(gcr_regmap, NPCM7XX_INTCR2_OFFSET, &rstval);

This warrants an explanation/comment: Why is it not necessary to check the return value of the regmap operations ?

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 279

Quoted 9 lines
drivers/watchdog/npcm_wdt.c +9 -0
+	/* prefer the most specific SoC first */
+	if (of_device_is_compatible(dev->of_node, "nuvoton,npcm845-wdt")) {
+		regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+			     rstval & ~NPCM8XX_RST);
+	} else if (of_device_is_compatible(dev->of_node, "nuvoton,npcm750-wdt")) {
+		if ((rstval & NPCM7XX_PORST) == 0) {
+			rstval = NPCM7XX_PORST;
+			regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+				     rstval | NPCM7XX_PORST);

That "| NPCM7XX_PORST" is pretty pointless here since rstval was just set to that value.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 282

Quoted 3 lines
drivers/watchdog/npcm_wdt.c +3 -0
+		} else {
+			rstval = 0;
+		}

Another comment needed: This negates NPCM7XX_PORST and otherwise clear rstval. The reason is not immediately (or, rather, at all) obvious.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 286

Quoted 4 lines
drivers/watchdog/npcm_wdt.c +4 -0
+		regmap_read(gcr_regmap, NPCM7XX_RESSR_OFFSET, &ressrval);
+		rstval |= ressrval;
+		regmap_write(gcr_regmap, NPCM7XX_RESSR_OFFSET, ressrval);
+	}

If the device is not compatible to either chip, retval is just passed on and nothing is written to the chip. That warrants another comment.

[ Yes, I see that the driver does not currently support another chip.

Quoted 21 lines
drivers/watchdog/npcm_wdt.c +11 -0
+
+	if (rstval & wdt->card_reset)
+		wdt->wdd.bootstatus |= WDIOF_CARDRESET;
+	if (rstval & wdt->ext1_reset)
+		wdt->wdd.bootstatus |= WDIOF_EXTERN1;
+	if (rstval & wdt->ext2_reset)
+		wdt->wdd.bootstatus |= WDIOF_EXTERN2;
+}
+
  static int npcm_wdt_probe(struct platform_device *pdev)
  {
  	struct device *dev = &pdev->dev;
@@ -208,6 +316,8 @@ static int npcm_wdt_probe(struct platform_device *pdev)
  	if (irq < 0)
  		return irq;
 
+	npcm_get_reset_status(wdt, dev);
+
  	wdt->wdd.info = &npcm_wdt_info;
  	wdt->wdd.ops = &npcm_wdt_ops;
  	wdt->wdd.min_timeout = 1;
author maintainer
#14 lore raw

Re: [PATCH v1 2/2] watchdog: npcm: Add reset status support

Hi Guenter,

Thanks for your review.

From your comments and from Krzysztof’s earlier feedback, I understand that I cannot use Device Tree properties to describe software behavior, and DT should only describe hardware.

Given that, I am trying to understand what would be the correct upstream way to expose the different reset causes that the GCR reports. The watchdog framework provides only a few standardized bootstatus flags, and I would like to check whether it is acceptable to map the different reset causes into these existing flags.

For example, conceptually:

- WDIOF_CARDRESET → power‑on reset
- WDIOF_OVERHEAT → core reset
- WDIOF_FANFAULT → watchdog reset
- WDIOF_EXTERN1 → SW0 reset
- WDIOF_EXTERN2 → SW1 reset
- WDIOF_POWERUNDER → SW2 reset
- WDIOF_POWEROVER → SW3 reset

Is such a mapping acceptable?

Any guidance on the expected upstream approach would be greatly appreciated.

Thanks,
Tomer

Quoted 189 lines · Guenter Roeck
Quoted 69 lines · Tomer Maimon

Add reset status detection for NPCM watchdog driver on both NPCM7XX and NPCM8XX platforms. Implement GCR register integration via syscon for reset status detection and configurable reset type mapping via device tree properties.

---
  drivers/watchdog/npcm_wdt.c | 110 ++++++++++++++++++++++++++++++++++++
  1 file changed, 110 insertions(+)
drivers/watchdog/npcm_wdt.c +34 -0
index e62ea054bc61..ebece5d6240a 100644
@@ -12,9 +12,25 @@
  #include <linux/platform_device.h>
  #include <linux/slab.h>
  #include <linux/watchdog.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+
+#define NPCM7XX_RESSR_OFFSET 0x6C
+#define NPCM7XX_INTCR2_OFFSET        0x60
 
  #define NPCM_WTCR   0x1C
 
+#define NPCM7XX_PORST        BIT(31)
+#define NPCM7XX_CORST        BIT(30)
+#define NPCM7XX_WD0RST       BIT(29)
+#define NPCM7XX_WD1RST       BIT(24)
+#define NPCM7XX_WD2RST       BIT(23)
+#define NPCM7XX_SWR1RST      BIT(28)
+#define NPCM7XX_SWR2RST      BIT(27)
+#define NPCM7XX_SWR3RST      BIT(26)
+#define NPCM7XX_SWR4RST      BIT(25)
+#define NPCM8XX_RST  (GENMASK(31, 23) | GENMASK(15, 12))
+
  #define NPCM_WTCLK  (BIT(10) | BIT(11))     /* Clock divider */
  #define NPCM_WTE    BIT(7)                  /* Enable */
  #define NPCM_WTIE   BIT(6)                  /* Enable irq */
@@ -45,6 +61,9 @@ struct npcm_wdt {
      struct watchdog_device  wdd;
      void __iomem            *reg;
      struct clk              *clk;
+     u32                     card_reset;
+     u32                     ext1_reset;
+     u32                     ext2_reset;
  };
 
  static inline struct npcm_wdt *to_npcm_wdt(struct watchdog_device *wdd)
@@ -185,6 +204,95 @@ static const struct watchdog_ops npcm_wdt_ops = {
      .restart = npcm_wdt_restart,
  };
 
+static u32 npcm_wdt_reset_type(const char *reset_type)
+{
+     if (!strcmp(reset_type, "porst"))
+             return NPCM7XX_PORST;
+     else if (!strcmp(reset_type, "corst"))
+             return NPCM7XX_CORST;
+     else if (!strcmp(reset_type, "wd0"))
+             return NPCM7XX_WD0RST;
+     else if (!strcmp(reset_type, "wd1"))
+             return NPCM7XX_WD1RST;
+     else if (!strcmp(reset_type, "wd2"))
+             return NPCM7XX_WD2RST;
+     else if (!strcmp(reset_type, "sw1"))
+             return NPCM7XX_SWR1RST;
+     else if (!strcmp(reset_type, "sw2"))

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 231

Quoted 10 lines
drivers/watchdog/npcm_wdt.c +10 -0
+             return NPCM7XX_SWR2RST;
+     else if (!strcmp(reset_type, "sw3"))
+             return NPCM7XX_SWR3RST;
+     else if (!strcmp(reset_type, "sw4"))
+             return NPCM7XX_SWR4RST;
+
+     return 0;
+}
+
+static void npcm_get_reset_status(struct npcm_wdt *wdt, struct device

*dev)

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = {

Quoted 9 lines
drivers/watchdog/npcm_wdt.c +9 -0
+{
+     const char *card_reset_type;
+     const char *ext1_reset_type;
+     const char *ext2_reset_type;
+     struct regmap *gcr_regmap;
+     u32 rstval, ressrval;
+     int ret;
+
+     gcr_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,

"syscon");

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 242

Quoted 2 lines
drivers/watchdog/npcm_wdt.c +2 -0
+     if (IS_ERR(gcr_regmap)) {
+             dev_warn(dev, "Failed to find gcr syscon, WD reset status

not supported\n");

A warning is quite strong here, given that this is new code and the syscon reference may not exist in existing devicetree files. notice should be good enough.

Quoted 6 lines
drivers/watchdog/npcm_wdt.c +6 -0
+             return;
+     }
+
+     ret = of_property_read_string(dev->of_node,
+                                   "nuvoton,card-reset-type",
+                                   &card_reset_type);

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 258

Quoted 10 lines
drivers/watchdog/npcm_wdt.c +10 -0
+     if (ret)
+             wdt->card_reset = NPCM7XX_PORST;
+     else
+             wdt->card_reset = npcm_wdt_reset_type(card_reset_type);
+
+     ret = of_property_read_string(dev->of_node,
+                                   "nuvoton,ext1-reset-type",
+                                   &ext1_reset_type);
+     if (ret)
+             wdt->ext1_reset = 0;

wdt is zero-allocated, so setting those variables to 0 is not necessary.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 270

Quoted 12 lines
drivers/watchdog/npcm_wdt.c +12 -0
+     else
+             wdt->ext1_reset = npcm_wdt_reset_type(ext1_reset_type);
+
+     ret = of_property_read_string(dev->of_node,
+                                   "nuvoton,ext2-reset-type",
+                                   &ext2_reset_type);
+     if (ret)
+             wdt->ext2_reset = 0;
+     else
+             wdt->ext2_reset = npcm_wdt_reset_type(ext2_reset_type);
+
+     regmap_read(gcr_regmap, NPCM7XX_INTCR2_OFFSET, &rstval);

This warrants an explanation/comment: Why is it not necessary to check the return value of the regmap operations ?

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = {

Quoted 5 lines
drivers/watchdog/npcm_wdt.c +5 -0
+     /* prefer the most specific SoC first */
+     if (of_device_is_compatible(dev->of_node, "nuvoton,npcm845-wdt")) {
+             regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+                          rstval & ~NPCM8XX_RST);
+     } else if (of_device_is_compatible(dev->of_node,

"nuvoton,npcm750-wdt")) {

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 279

Quoted 4 lines
drivers/watchdog/npcm_wdt.c +4 -0
+             if ((rstval & NPCM7XX_PORST) == 0) {
+                     rstval = NPCM7XX_PORST;
+                     regmap_write(gcr_regmap, NPCM7XX_INTCR2_OFFSET,
+                                  rstval | NPCM7XX_PORST);

That "| NPCM7XX_PORST" is pretty pointless here since rstval was just set to that value.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 282

Quoted 3 lines
drivers/watchdog/npcm_wdt.c +3 -0
+             } else {
+                     rstval = 0;
+             }

Another comment needed: This negates NPCM7XX_PORST and otherwise clear rstval. The reason is not immediately (or, rather, at all) obvious.

drivers/watchdog/npcm_wdt.c static const struct watchdog_ops npcm_wdt_ops = { · line 286

Quoted 4 lines
drivers/watchdog/npcm_wdt.c +4 -0
+             regmap_read(gcr_regmap, NPCM7XX_RESSR_OFFSET, &ressrval);
+             rstval |= ressrval;
+             regmap_write(gcr_regmap, NPCM7XX_RESSR_OFFSET, ressrval);
+     }

If the device is not compatible to either chip, retval is just passed on and nothing is written to the chip. That warrants another comment.

[ Yes, I see that the driver does not currently support another chip.

drivers/watchdog/npcm_wdt.c static int npcm_wdt_probe(struct platform_device

Quoted 13 lines
drivers/watchdog/npcm_wdt.c +9 -0
+
+     if (rstval & wdt->card_reset)
+             wdt->wdd.bootstatus |= WDIOF_CARDRESET;
+     if (rstval & wdt->ext1_reset)
+             wdt->wdd.bootstatus |= WDIOF_EXTERN1;
+     if (rstval & wdt->ext2_reset)
+             wdt->wdd.bootstatus |= WDIOF_EXTERN2;
+}
+
  static int npcm_wdt_probe(struct platform_device *pdev)
  {
      struct device *dev = &pdev->dev;
@@ -208,6 +316,8 @@ static int npcm_wdt_probe(struct platform_device

*pdev)

Quoted 8 lines
drivers/watchdog/npcm_wdt.c +2 -0
      if (irq < 0)
              return irq;
 
+     npcm_get_reset_status(wdt, dev);
+
      wdt->wdd.info = &npcm_wdt_info;
      wdt->wdd.ops = &npcm_wdt_ops;
      wdt->wdd.min_timeout = 1;
maintainer
#15 lore raw

Re: [PATCH v1 2/2] watchdog: npcm: Add reset status support

Quoted 24 lines · Tomer Maimon

Hi Guenter,

Thanks for your review.

From your comments and from Krzysztof’s earlier feedback, I understand that I cannot use Device Tree properties to describe software behavior, and DT should only describe hardware.

Given that, I am trying to understand what would be the correct upstream way to expose the different reset causes that the GCR reports. The watchdog framework provides only a few standardized bootstatus flags, and I would like to check whether it is acceptable to map the different reset causes into these existing flags.

For example, conceptually:

- WDIOF_CARDRESET → power‑on reset
- WDIOF_OVERHEAT → core reset
- WDIOF_FANFAULT → watchdog reset
- WDIOF_EXTERN1 → SW0 reset
- WDIOF_EXTERN2 → SW1 reset
- WDIOF_POWERUNDER → SW2 reset
- WDIOF_POWEROVER → SW3 reset

Quoted 2 lines

Is such a mapping acceptable?

Ok with me as long as it is well documented (i.e., in Documentation/watchdog/npcm_wdt.rst or similar).

Guenter