* [PATCH v2 0/2] Add the NXP S32 Watchdog
@ 2025-04-02 15:49 Daniel Lezcano
2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano
2025-04-02 15:49 ` [PATCH v2 2/2] watchdog: Add the Watchdog Timer for the NXP S32 platform Daniel Lezcano
0 siblings, 2 replies; 15+ messages in thread
From: Daniel Lezcano @ 2025-04-02 15:49 UTC (permalink / raw)
To: wim
Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc,
thomas.fossati, robh, krzk+dt, conor+dt, devicetree
The NXP S32 watchdog, referenced in the documentation as the Software
Watchdog Timer is actually a hardware watchdog. The system has one
watchdog per core but an assertation does not directly reset the
system as this behavior relies on a particular setup and another
component which is not part of these changes. However the first
watchdog on the system, tied with the Cortex-M4 #0 is a particular
case where it will reset the system directly. This is enough for the
watchdog purpose on Linux.
The watchdog relies on the default timeout described in the device
tree but if another timeout is needed at boot time, it can be changed
with the module parameter.
If the kernel has to service the watchdog in place of the userspace,
it can specify the 'early-enable' option at boot time.
And finally, if starting the watchdog has no wayback then the option
'nowayout' can be also specified in the boot option.
Changelog:
- v2:
- Removed debugfs code as considered pointless for a such simple
driver (Arnd Bergmann)
- Replaced __raw_readl / __raw_writel by readl and writel (Arnd Bergmann)
- Reordered alphabetically the headers (Guenter Roeck)
- Enclosed macro parameter into parenthesis (Guenter Roeck)
- Fixed checkpatch reported errors (Guenter Roeck)
- Clarified a ping on a stopped timer does not affect it (Guenter Roeck)
- Used wdt_is_running() to save an extra IO (Guenter Roeck)
- Fixed a misleading comment about starting the watchdog at boot time (Guenter Roeck)
- Replaced allocation size sizeof(struct ...) by sizeof(*var) (Krzysztof Kozlowski)
- Drop old way of describing the module and use table module device (Krzysztof Kozlowski)
- Replaced additionalProperties by unevaluatedProperties (Rob Herring)
- Removed the DT bindings description as it is obvious (Ghennadi Procopciuc)
- Fixed DT bindings compatible string (Krzysztof Kozlowski)
- v1: initial posting
Daniel Lezcano (2):
dt-bindings: watchdog: Add NXP Software Watchdog Timer
watchdog: Add the Watchdog Timer for the NXP S32 platform
.../bindings/watchdog/nxp,s32g2-swt.yaml | 42 +++
drivers/watchdog/Kconfig | 9 +
drivers/watchdog/Makefile | 1 +
drivers/watchdog/s32g_wdt.c | 313 ++++++++++++++++++
4 files changed, 365 insertions(+)
create mode 100644 Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml
create mode 100644 drivers/watchdog/s32g_wdt.c
--
2.43.0
^ permalink raw reply [flat|nested] 15+ messages in thread* [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 15:49 [PATCH v2 0/2] Add the NXP S32 Watchdog Daniel Lezcano @ 2025-04-02 15:49 ` Daniel Lezcano 2025-04-02 15:56 ` Krzysztof Kozlowski ` (2 more replies) 2025-04-02 15:49 ` [PATCH v2 2/2] watchdog: Add the Watchdog Timer for the NXP S32 platform Daniel Lezcano 1 sibling, 3 replies; 15+ messages in thread From: Daniel Lezcano @ 2025-04-02 15:49 UTC (permalink / raw) To: wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree Describe the Software Watchdog Timer available on the S32G platforms. Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Cc: Thomas Fossati <thomas.fossati@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- .../bindings/watchdog/nxp,s32g2-swt.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml diff --git a/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml b/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml new file mode 100644 index 000000000000..d5f2513c4e8f --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/nxp,s32g2-swt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP Software Watchdog Timer (SWT) + +maintainers: + - Daniel Lezcano <daniel.lezcano@kernel.org> + +allOf: + - $ref: watchdog.yaml# + +properties: + compatible: + - const: nxp,s32g2-swt + - items: + - const: nxp,s32g3-swt + - const: nxp,s32g2-swt + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + +required: + - compatible + - reg + - clocks + +unevaluatedProperties: false + +examples: + - | + watchdog@0x40100000 { + compatible = "nxp,s32g2-swt"; + reg = <0x40100000 0x1000>; + clocks = <&clks 0x3a>; + timeout-sec = <10>; + }; -- 2.43.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano @ 2025-04-02 15:56 ` Krzysztof Kozlowski 2025-04-02 23:01 ` Daniel Lezcano 2025-04-02 18:56 ` Rob Herring (Arm) 2025-04-03 6:19 ` Ghennadi Procopciuc 2 siblings, 1 reply; 15+ messages in thread From: Krzysztof Kozlowski @ 2025-04-02 15:56 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 02/04/2025 17:49, Daniel Lezcano wrote: > Describe the Software Watchdog Timer available on the S32G platforms. > > Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> > Cc: Thomas Fossati <thomas.fossati@linaro.org> > Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 15:56 ` Krzysztof Kozlowski @ 2025-04-02 23:01 ` Daniel Lezcano 2025-04-03 14:16 ` Krzysztof Kozlowski 0 siblings, 1 reply; 15+ messages in thread From: Daniel Lezcano @ 2025-04-02 23:01 UTC (permalink / raw) To: Krzysztof Kozlowski, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 02/04/2025 17:56, Krzysztof Kozlowski wrote: > On 02/04/2025 17:49, Daniel Lezcano wrote: >> Describe the Software Watchdog Timer available on the S32G platforms. >> >> Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >> Cc: Thomas Fossati <thomas.fossati@linaro.org> >> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> > > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > > Best regards, > Krzysztof I ran the make dt_binding_check but inadvertently removed the "oneOf:" after :/ -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 23:01 ` Daniel Lezcano @ 2025-04-03 14:16 ` Krzysztof Kozlowski 2025-04-03 15:33 ` Daniel Lezcano 0 siblings, 1 reply; 15+ messages in thread From: Krzysztof Kozlowski @ 2025-04-03 14:16 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 03/04/2025 01:01, Daniel Lezcano wrote: > On 02/04/2025 17:56, Krzysztof Kozlowski wrote: >> On 02/04/2025 17:49, Daniel Lezcano wrote: >>> Describe the Software Watchdog Timer available on the S32G platforms. >>> >>> Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >>> Cc: Thomas Fossati <thomas.fossati@linaro.org> >>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> >> >> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >> >> Best regards, >> Krzysztof > > I ran the make dt_binding_check but inadvertently removed the "oneOf:" > after :/ Other errors were also not fixed even though you got report on them on 29th of March. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-03 14:16 ` Krzysztof Kozlowski @ 2025-04-03 15:33 ` Daniel Lezcano 2025-04-03 15:35 ` Krzysztof Kozlowski 0 siblings, 1 reply; 15+ messages in thread From: Daniel Lezcano @ 2025-04-03 15:33 UTC (permalink / raw) To: Krzysztof Kozlowski, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 03/04/2025 16:16, Krzysztof Kozlowski wrote: > On 03/04/2025 01:01, Daniel Lezcano wrote: >> On 02/04/2025 17:56, Krzysztof Kozlowski wrote: >>> On 02/04/2025 17:49, Daniel Lezcano wrote: >>>> Describe the Software Watchdog Timer available on the S32G platforms. >>>> >>>> Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >>>> Cc: Thomas Fossati <thomas.fossati@linaro.org> >>>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> >>> >>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >>> >>> Best regards, >>> Krzysztof >> >> I ran the make dt_binding_check but inadvertently removed the "oneOf:" >> after :/ > Other errors were also not fixed even though you got report on them on > 29th of March. Which ones ? All errors were coming from the oneOf removal, after re-adding it they are all gone -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-03 15:33 ` Daniel Lezcano @ 2025-04-03 15:35 ` Krzysztof Kozlowski 2025-04-03 21:52 ` Daniel Lezcano 0 siblings, 1 reply; 15+ messages in thread From: Krzysztof Kozlowski @ 2025-04-03 15:35 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 03/04/2025 17:33, Daniel Lezcano wrote: > On 03/04/2025 16:16, Krzysztof Kozlowski wrote: >> On 03/04/2025 01:01, Daniel Lezcano wrote: >>> On 02/04/2025 17:56, Krzysztof Kozlowski wrote: >>>> On 02/04/2025 17:49, Daniel Lezcano wrote: >>>>> Describe the Software Watchdog Timer available on the S32G platforms. >>>>> >>>>> Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >>>>> Cc: Thomas Fossati <thomas.fossati@linaro.org> >>>>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> >>>> >>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >>>> >>>> Best regards, >>>> Krzysztof >>> >>> I ran the make dt_binding_check but inadvertently removed the "oneOf:" >>> after :/ >> Other errors were also not fixed even though you got report on them on >> 29th of March. > > Which ones ? > > All errors were coming from the oneOf removal, after re-adding it they > are all gone The same as from previous patchset - wrong unit address, maybe more. > Best regards, Krzysztof ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-03 15:35 ` Krzysztof Kozlowski @ 2025-04-03 21:52 ` Daniel Lezcano 0 siblings, 0 replies; 15+ messages in thread From: Daniel Lezcano @ 2025-04-03 21:52 UTC (permalink / raw) To: Krzysztof Kozlowski, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 03/04/2025 17:35, Krzysztof Kozlowski wrote: > On 03/04/2025 17:33, Daniel Lezcano wrote: >> On 03/04/2025 16:16, Krzysztof Kozlowski wrote: >>> On 03/04/2025 01:01, Daniel Lezcano wrote: >>>> On 02/04/2025 17:56, Krzysztof Kozlowski wrote: >>>>> On 02/04/2025 17:49, Daniel Lezcano wrote: >>>>>> Describe the Software Watchdog Timer available on the S32G platforms. >>>>>> >>>>>> Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> >>>>>> Cc: Thomas Fossati <thomas.fossati@linaro.org> >>>>>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> >>>>> >>>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >>>>> >>>>> Best regards, >>>>> Krzysztof >>>> >>>> I ran the make dt_binding_check but inadvertently removed the "oneOf:" >>>> after :/ >>> Other errors were also not fixed even though you got report on them on >>> 29th of March. >> >> Which ones ? >> >> All errors were coming from the oneOf removal, after re-adding it they >> are all gone > > > The same as from previous patchset - wrong unit address, maybe more. Indeed, my parser was not up-to-date and did not reported the error. Thanks for pointing this out -- Daniel -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano 2025-04-02 15:56 ` Krzysztof Kozlowski @ 2025-04-02 18:56 ` Rob Herring (Arm) 2025-04-03 6:19 ` Ghennadi Procopciuc 2 siblings, 0 replies; 15+ messages in thread From: Rob Herring (Arm) @ 2025-04-02 18:56 UTC (permalink / raw) To: Daniel Lezcano Cc: devicetree, linux-watchdog, S32, wim, krzk+dt, linux, conor+dt, ghennadi.procopciuc, linux-kernel, thomas.fossati On Wed, 02 Apr 2025 17:49:39 +0200, Daniel Lezcano wrote: > Describe the Software Watchdog Timer available on the S32G platforms. > > Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> > Cc: Thomas Fossati <thomas.fossati@linaro.org> > Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> > --- > .../bindings/watchdog/nxp,s32g2-swt.yaml | 42 +++++++++++++++++++ > 1 file changed, 42 insertions(+) > create mode 100644 Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml > My bot found errors running 'make dt_binding_check' on your patch: yamllint warnings/errors: ./Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml:17:7: [warning] wrong indentation: expected 4 but found 6 (indentation) dtschema/dtc warnings/errors: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml: ignoring, error in schema: properties: compatible /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml: properties:compatible: [{'const': 'nxp,s32g2-swt'}, {'items': [{'const': 'nxp,s32g3-swt'}, {'const': 'nxp,s32g2-swt'}]}] is not of type 'object', 'boolean' from schema $id: http://json-schema.org/draft-07/schema# /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.yaml: properties:compatible: [{'const': 'nxp,s32g2-swt'}, {'items': [{'const': 'nxp,s32g3-swt'}, {'const': 'nxp,s32g2-swt'}]}] is not of type 'object', 'boolean' from schema $id: http://devicetree.org/meta-schemas/keywords.yaml# Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.example.dts:18.29-23.11: Warning (unit_address_format): /example-0/watchdog@0x40100000: unit name should not have leading "0x" Documentation/devicetree/bindings/watchdog/nxp,s32g2-swt.example.dtb: /example-0/watchdog@0x40100000: failed to match any schema with compatible: ['nxp,s32g2-swt'] doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250402154942.3645283-2-daniel.lezcano@linaro.org The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano 2025-04-02 15:56 ` Krzysztof Kozlowski 2025-04-02 18:56 ` Rob Herring (Arm) @ 2025-04-03 6:19 ` Ghennadi Procopciuc 2025-04-03 15:10 ` Daniel Lezcano 2 siblings, 1 reply; 15+ messages in thread From: Ghennadi Procopciuc @ 2025-04-03 6:19 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree On 4/2/2025 6:49 PM, Daniel Lezcano wrote: [ ... ] > +examples: > + - | > + watchdog@0x40100000 { > + compatible = "nxp,s32g2-swt"; > + reg = <0x40100000 0x1000>; > + clocks = <&clks 0x3a>; > + timeout-sec = <10>; > + }; The S32G reference manual specifies two clocks for the SWT module: one for the registers and another for the counter itself. Shouldn't both clocks be represented in the bindings? -- Regards, Ghennadi ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-03 6:19 ` Ghennadi Procopciuc @ 2025-04-03 15:10 ` Daniel Lezcano 2025-04-04 6:35 ` Ghennadi Procopciuc 0 siblings, 1 reply; 15+ messages in thread From: Daniel Lezcano @ 2025-04-03 15:10 UTC (permalink / raw) To: Ghennadi Procopciuc, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree, Vincent Guittot On 03/04/2025 08:19, Ghennadi Procopciuc wrote: > On 4/2/2025 6:49 PM, Daniel Lezcano wrote: > [ ... ] >> +examples: >> + - | >> + watchdog@0x40100000 { >> + compatible = "nxp,s32g2-swt"; >> + reg = <0x40100000 0x1000>; >> + clocks = <&clks 0x3a>; >> + timeout-sec = <10>; >> + }; > > The S32G reference manual specifies two clocks for the SWT module: one > for the registers and another for the counter itself. Shouldn't both > clocks be represented in the bindings? AFAICS, there are two clocks as described in the documentation for the s32g2 page 846, section 23.7.3.3 SWT clocking. The module and the register clock are fed by the XBAR_DIV3_CLK which is an system clock always-on. The counter is fed by the FIRC_CLK which described as "FIRC_CLK is the default clock for the entire system at power-up." From my understanding, we should not describe the XBAR_DIV3_CLK as it is a system clock. And the FIRC_CLK is only there to get the clock rate in the driver. -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-03 15:10 ` Daniel Lezcano @ 2025-04-04 6:35 ` Ghennadi Procopciuc 2025-04-06 20:33 ` Daniel Lezcano 0 siblings, 1 reply; 15+ messages in thread From: Ghennadi Procopciuc @ 2025-04-04 6:35 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree, Vincent Guittot On 4/3/2025 6:10 PM, Daniel Lezcano wrote: > On 03/04/2025 08:19, Ghennadi Procopciuc wrote: >> On 4/2/2025 6:49 PM, Daniel Lezcano wrote: >> [ ... ] >>> +examples: >>> + - | >>> + watchdog@0x40100000 { >>> + compatible = "nxp,s32g2-swt"; >>> + reg = <0x40100000 0x1000>; >>> + clocks = <&clks 0x3a>; >>> + timeout-sec = <10>; >>> + }; >> >> The S32G reference manual specifies two clocks for the SWT module: one >> for the registers and another for the counter itself. Shouldn't both >> clocks be represented in the bindings? > > AFAICS, there are two clocks as described in the documentation for the > s32g2 page 846, section 23.7.3.3 SWT clocking. This diagram illustrates the module clocks and their connections to the S32GS system clocks. From the module's perspective, there are three clocks: MODULE_CLOCK, REG_INTF, and COUNTER_CLOCK. Specifically, on S32G2 SoCs, the first two are connected to XBAR_DIV3_CLK, while the counter clock is linked to FIRC_CLK. Based on my understanding of the device tree, this configuration should be listed as follows: clocks = <&clks XBAR_DIV3_CLK>, <&clks XBAR_DIV3_CLK>, <&clks FIRC_CLK>; clock-names = "module", "reg", "counter"; Configuring it this way allows flexibility to reuse the same clocking scheme for other SoCs where the integration is performed differently. It is possible that the 'module' and 'reg' clocks could be linked to two distinct system clocks. > > The module and the register clock are fed by the XBAR_DIV3_CLK which is > an system clock always-on. XBAR_DIV3_CLK is not an always-on clock, meaning it is not available during suspend, if that is what you mean by always-on. The SIRC can be considered the only always-on clock on this device. > > The counter is fed by the FIRC_CLK which described as "FIRC_CLK is the > default clock for the entire system at power-up." > > From my understanding, we should not describe the XBAR_DIV3_CLK as it is > a system clock. > > And the FIRC_CLK is only there to get the clock rate in the driver. > -- Regards, Ghennadi ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-04 6:35 ` Ghennadi Procopciuc @ 2025-04-06 20:33 ` Daniel Lezcano 2025-04-07 4:53 ` Ghennadi Procopciuc 0 siblings, 1 reply; 15+ messages in thread From: Daniel Lezcano @ 2025-04-06 20:33 UTC (permalink / raw) To: Ghennadi Procopciuc, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree, Vincent Guittot On 04/04/2025 08:35, Ghennadi Procopciuc wrote: > On 4/3/2025 6:10 PM, Daniel Lezcano wrote: >> On 03/04/2025 08:19, Ghennadi Procopciuc wrote: >>> On 4/2/2025 6:49 PM, Daniel Lezcano wrote: >>> [ ... ] >>>> +examples: >>>> + - | >>>> + watchdog@0x40100000 { >>>> + compatible = "nxp,s32g2-swt"; >>>> + reg = <0x40100000 0x1000>; >>>> + clocks = <&clks 0x3a>; >>>> + timeout-sec = <10>; >>>> + }; >>> >>> The S32G reference manual specifies two clocks for the SWT module: one >>> for the registers and another for the counter itself. Shouldn't both >>> clocks be represented in the bindings? >> >> AFAICS, there are two clocks as described in the documentation for the >> s32g2 page 846, section 23.7.3.3 SWT clocking. > > This diagram illustrates the module clocks and their connections to the > S32GS system clocks. From the module's perspective, there are three > clocks: MODULE_CLOCK, REG_INTF, and COUNTER_CLOCK. Specifically, on > S32G2 SoCs, the first two are connected to XBAR_DIV3_CLK, while the > counter clock is linked to FIRC_CLK. Based on my understanding of the > device tree, this configuration should be listed as follows: > > clocks = <&clks XBAR_DIV3_CLK>, <&clks XBAR_DIV3_CLK>, <&clks FIRC_CLK>; > clock-names = "module", "reg", "counter"; > > Configuring it this way allows flexibility to reuse the same clocking > scheme for other SoCs where the integration is performed differently. It > is possible that the 'module' and 'reg' clocks could be linked to two > distinct system clocks. That is something we can handle when the other SoC will be in the process of being upstream, no ? I don't see how that can help with the current hardware we are describing. What is the benefit ? I would prefer to stick to what is needed today >> The module and the register clock are fed by the XBAR_DIV3_CLK which is >> an system clock always-on. > > XBAR_DIV3_CLK is not an always-on clock, meaning it is not available > during suspend, if that is what you mean by always-on. The SIRC can be > considered the only always-on clock on this device. > >> >> The counter is fed by the FIRC_CLK which described as "FIRC_CLK is the >> default clock for the entire system at power-up." >> >> From my understanding, we should not describe the XBAR_DIV3_CLK as it is >> a system clock. >> >> And the FIRC_CLK is only there to get the clock rate in the driver. >> > -- <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer 2025-04-06 20:33 ` Daniel Lezcano @ 2025-04-07 4:53 ` Ghennadi Procopciuc 0 siblings, 0 replies; 15+ messages in thread From: Ghennadi Procopciuc @ 2025-04-07 4:53 UTC (permalink / raw) To: Daniel Lezcano, wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree, Vincent Guittot On 4/6/2025 11:33 PM, Daniel Lezcano wrote: > On 04/04/2025 08:35, Ghennadi Procopciuc wrote: >> On 4/3/2025 6:10 PM, Daniel Lezcano wrote: >>> On 03/04/2025 08:19, Ghennadi Procopciuc wrote: >>>> On 4/2/2025 6:49 PM, Daniel Lezcano wrote: >>>> [ ... ] >>>>> +examples: >>>>> + - | >>>>> + watchdog@0x40100000 { >>>>> + compatible = "nxp,s32g2-swt"; >>>>> + reg = <0x40100000 0x1000>; >>>>> + clocks = <&clks 0x3a>; >>>>> + timeout-sec = <10>; >>>>> + }; >>>> >>>> The S32G reference manual specifies two clocks for the SWT module: one >>>> for the registers and another for the counter itself. Shouldn't both >>>> clocks be represented in the bindings? >>> >>> AFAICS, there are two clocks as described in the documentation for the >>> s32g2 page 846, section 23.7.3.3 SWT clocking. >> >> This diagram illustrates the module clocks and their connections to the >> S32GS system clocks. From the module's perspective, there are three >> clocks: MODULE_CLOCK, REG_INTF, and COUNTER_CLOCK. Specifically, on >> S32G2 SoCs, the first two are connected to XBAR_DIV3_CLK, while the >> counter clock is linked to FIRC_CLK. Based on my understanding of the >> device tree, this configuration should be listed as follows: >> >> clocks = <&clks XBAR_DIV3_CLK>, <&clks XBAR_DIV3_CLK>, <&clks FIRC_CLK>; >> clock-names = "module", "reg", "counter"; >> >> Configuring it this way allows flexibility to reuse the same clocking >> scheme for other SoCs where the integration is performed differently. It >> is possible that the 'module' and 'reg' clocks could be linked to two >> distinct system clocks. > > That is something we can handle when the other SoC will be in the > process of being upstream, no ? > > I don't see how that can help with the current hardware we are > describing. What is the benefit ? > The benefit is that the binding accurately describes the hardware module, and no changes are expected in this area over time, even if different integrations of the module are performed on other SoCs. Otherwise, the binding will contain a different set of clocks depending on the SoC integration, even though the exact same hardware IP is used. > I would prefer to stick to what is needed today > >>> The module and the register clock are fed by the XBAR_DIV3_CLK which is >>> an system clock always-on. >> >> XBAR_DIV3_CLK is not an always-on clock, meaning it is not available >> during suspend, if that is what you mean by always-on. The SIRC can be >> considered the only always-on clock on this device. >> >>> >>> The counter is fed by the FIRC_CLK which described as "FIRC_CLK is the >>> default clock for the entire system at power-up." >>> >>> From my understanding, we should not describe the XBAR_DIV3_CLK as >>> it is >>> a system clock. >>> >>> And the FIRC_CLK is only there to get the clock rate in the driver. >>> >> > > -- Regards, Ghennadi ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 2/2] watchdog: Add the Watchdog Timer for the NXP S32 platform 2025-04-02 15:49 [PATCH v2 0/2] Add the NXP S32 Watchdog Daniel Lezcano 2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano @ 2025-04-02 15:49 ` Daniel Lezcano 1 sibling, 0 replies; 15+ messages in thread From: Daniel Lezcano @ 2025-04-02 15:49 UTC (permalink / raw) To: wim Cc: linux, linux-watchdog, linux-kernel, S32, ghennadi.procopciuc, thomas.fossati, robh, krzk+dt, conor+dt, devicetree The S32 platform has several Watchdog Timer available and tied with a CPU. The SWT0 is the only one which directly asserts the reset line, other SWT require an external setup to configure the reset behavior which is not part of this change. As a side note, in the NXP documentation, the s32g2 and s32g3 reference manuals refer the watchdog as the 'Software Timer Watchdog' where the name can be misleading as it is actually a hardware watchdog. The maximum watchdog timeout value depends on the clock feeding the SWT counter which is 32bits wide. On the s32g274-rb2, the clock has a rate of 51MHz which result on 83 seconds maximum timeout. The timeout can be specified via the device tree with the usual existing bindings 'timeout-sec' or via the module param timeout. The watchdog can be loaded with the 'nowayout' option, preventing the watchdog to be stopped. The watchdog can be started at boot time with the 'early-enable' option, thus letting the watchdog framework to service the watchdog counter. The watchdog support the magic character to stop when the userspace releases the device. Cc: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Cc: Thomas Fossati <thomas.fossati@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- drivers/watchdog/Kconfig | 9 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/s32g_wdt.c | 313 ++++++++++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100644 drivers/watchdog/s32g_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index f81705f8539a..4ab4275ef49f 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -792,6 +792,15 @@ config IMX7ULP_WDT To compile this driver as a module, choose M here: the module will be called imx7ulp_wdt. +config S32G_WDT + tristate "S32G Watchdog" + depends on ARCH_S32 || COMPILE_TEST + select WATCHDOG_CORE + help + This is the driver for the hardware watchdog on the NXP + S32G platforms. If you wish to have watchdog support + enabled, say Y, otherwise say N. + config DB500_WATCHDOG tristate "ST-Ericsson DB800 watchdog" depends on MFD_DB8500_PRCMU diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 8411626fa162..d0f9826e32c3 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -69,6 +69,7 @@ obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o obj-$(CONFIG_IMX_SC_WDT) += imx_sc_wdt.o obj-$(CONFIG_IMX7ULP_WDT) += imx7ulp_wdt.o +obj-$(CONFIG_S32G_WDT) += s32g_wdt.o obj-$(CONFIG_DB500_WATCHDOG) += db8500_wdt.o obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o diff --git a/drivers/watchdog/s32g_wdt.c b/drivers/watchdog/s32g_wdt.c new file mode 100644 index 000000000000..a585ff1b372c --- /dev/null +++ b/drivers/watchdog/s32g_wdt.c @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Watchdog driver for S32G SoC + * + * Copyright 2017-2019, 2021-2025 NXP. + * + */ +#include <linux/clk.h> +#include <linux/debugfs.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/watchdog.h> + +#define DRIVER_NAME "s32g-swt" + +#define S32G_SWT_CR(__base) ((__base) + 0x00) /* Control Register offset */ +#define S32G_SWT_CR_SM (BIT(9) | BIT(10)) /* -> Service Mode */ +#define S32G_SWT_CR_STP BIT(2) /* -> Stop Mode Control */ +#define S32G_SWT_CR_FRZ BIT(1) /* -> Debug Mode Control */ +#define S32G_SWT_CR_WEN BIT(0) /* -> Watchdog Enable */ + +#define S32G_SWT_TO(__base) ((__base) + 0x08) /* Timeout Register offset */ + +#define S32G_SWT_SR(__base) ((__base) + 0x10) /* Service Register offset */ +#define S32G_WDT_SEQ1 0xA602 /* -> service sequence number 1 */ +#define S32G_WDT_SEQ2 0xB480 /* -> service sequence number 2 */ + +#define S32G_SWT_CO(__base) ((__base) + 0x14) /* Counter output register */ + +#define S32G_WDT_DEFAULT_TIMEOUT 30 + +struct s32g_wdt_device { + int rate; + void __iomem *base; + struct watchdog_device wdog; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); + +static unsigned int timeout_param = S32G_WDT_DEFAULT_TIMEOUT; +module_param(timeout_param, uint, 0); +MODULE_PARM_DESC(timeout_param, "Watchdog timeout in seconds (default=" + __MODULE_STRING(S32G_WDT_DEFAULT_TIMEOUT) ")"); + +static bool early_enable; +module_param(early_enable, bool, 0); +MODULE_PARM_DESC(early_enable, + "Watchdog is started on module insertion (default=false)"); + +static const struct watchdog_info s32g_wdt_info = { + .identity = "s32g watchdog", + .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | + WDIOC_GETTIMEOUT | WDIOC_GETTIMELEFT, +}; + +static struct s32g_wdt_device *wdd_to_s32g_wdt(struct watchdog_device *wdd) +{ + return container_of(wdd, struct s32g_wdt_device, wdog); +} + +static unsigned int wdog_sec_to_count(struct s32g_wdt_device *wdev, unsigned int timeout) +{ + return wdev->rate * timeout; +} + +static int s32g_wdt_ping(struct watchdog_device *wdog) +{ + struct s32g_wdt_device *wdev = wdd_to_s32g_wdt(wdog); + + writel(S32G_WDT_SEQ1, S32G_SWT_SR(wdev->base)); + writel(S32G_WDT_SEQ2, S32G_SWT_SR(wdev->base)); + + return 0; +} + +static int s32g_wdt_start(struct watchdog_device *wdog) +{ + struct s32g_wdt_device *wdev = wdd_to_s32g_wdt(wdog); + unsigned long val; + + val = readl(S32G_SWT_CR(wdev->base)); + + val |= S32G_SWT_CR_WEN; + + writel(val, S32G_SWT_CR(wdev->base)); + + return 0; +} + +static int s32g_wdt_stop(struct watchdog_device *wdog) +{ + struct s32g_wdt_device *wdev = wdd_to_s32g_wdt(wdog); + unsigned long val; + + val = readl(S32G_SWT_CR(wdev->base)); + + val &= ~S32G_SWT_CR_WEN; + + writel(val, S32G_SWT_CR(wdev->base)); + + return 0; +} + +static int s32g_wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout) +{ + struct s32g_wdt_device *wdev = wdd_to_s32g_wdt(wdog); + + writel(wdog_sec_to_count(wdev, timeout), S32G_SWT_TO(wdev->base)); + + /* + * Conforming to the documentation, the timeout counter is + * loaded when servicing is operated (aka ping) or when the + * counter is enabled. In case the watchdog is already started + * it must be stopped and started again to update the timeout + * register or a ping can be sent to refresh the counter. Here + * we choose to send a ping to the watchdog which is harmless + * if the watchdog is stopped. + */ + return s32g_wdt_ping(wdog); +} + +static unsigned int s32g_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct s32g_wdt_device *wdev = wdd_to_s32g_wdt(wdog); + unsigned long counter; + bool is_running; + + /* + * The counter output can be read only if the SWT is + * disabled. Given the latency between the internal counter + * and the counter output update, there can be very small + * difference. However, we can accept this matter of fact + * given the resolution is a second based unit for the output. + */ + is_running = watchdog_hw_running(wdog); + + if (is_running) + s32g_wdt_stop(wdog); + + counter = readl(S32G_SWT_CO(wdev->base)); + + if (is_running) + s32g_wdt_start(wdog); + + return counter / wdev->rate; +} + +static const struct watchdog_ops s32g_wdt_ops = { + .owner = THIS_MODULE, + .start = s32g_wdt_start, + .stop = s32g_wdt_stop, + .ping = s32g_wdt_ping, + .set_timeout = s32g_wdt_set_timeout, + .get_timeleft = s32g_wdt_get_timeleft, +}; + +static void s32g_wdt_init(struct s32g_wdt_device *wdev) +{ + unsigned long val; + + /* Set the watchdog's Time-Out value */ + val = wdog_sec_to_count(wdev, wdev->wdog.timeout); + + writel(val, S32G_SWT_TO(wdev->base)); + + /* + * Get the control register content. We are at init time, the + * watchdog should not be started. + */ + val = readl(S32G_SWT_CR(wdev->base)); + + /* + * We want to allow the watchdog timer to be stopped when + * device enters debug mode. + */ + val |= S32G_SWT_CR_FRZ; + + /* + * However, when the CPU is in WFI or suspend mode, the + * watchdog must continue. The documentation refers it as the + * stopped mode. + */ + val &= ~S32G_SWT_CR_STP; + + /* + * Use Fixed Service Sequence to ping the watchdog which is + * 0x00 configuration value for the service mode. It should be + * already set because it is the default value but we reset it + * in case. + */ + val &= ~S32G_SWT_CR_SM; + + writel(val, S32G_SWT_CR(wdev->base)); + + /* + * When the 'early_enable' option is set, we start the + * watchdog from the kernel. + */ + if (early_enable) { + s32g_wdt_start(&wdev->wdog); + set_bit(WDOG_HW_RUNNING, &wdev->wdog.status); + } +} + +static int s32g_wdt_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct resource *res; + struct clk *clk; + struct s32g_wdt_device *wdev; + struct watchdog_device *wdog; + int ret; + + wdev = devm_kzalloc(dev, sizeof(*wdev), GFP_KERNEL); + if (!wdev) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + wdev->base = devm_ioremap_resource(dev, res); + if (IS_ERR(wdev->base)) + return dev_err_probe(&pdev->dev, PTR_ERR(wdev->base), "Can not get resource\n"); + + clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), "Can't get Watchdog clock\n"); + + wdev->rate = clk_get_rate(clk); + if (!wdev->rate) { + dev_err(dev, "Input clock rate is not valid\n"); + return -EINVAL; + } + + wdog = &wdev->wdog; + wdog->info = &s32g_wdt_info; + wdog->ops = &s32g_wdt_ops; + + /* + * The code converts the timeout into a counter a value, if + * the value is less than 0x100, then it is clamped by the SWT + * module, so it is safe to specify a zero value as the + * minimum timeout. + */ + wdog->min_timeout = 0; + + /* + * The counter register is a 32 bits long, so the maximum + * counter value is UINT_MAX and the timeout in second is the + * value divided by the rate. + * + * For instance, a rate of 51MHz lead to 84 seconds maximum + * timeout. + */ + wdog->max_timeout = UINT_MAX / wdev->rate; + + /* + * The module param and the DT 'timeout-sec' property will + * override the default value if they are specified. + */ + ret = watchdog_init_timeout(wdog, timeout_param, dev); + if (ret) + return ret; + + /* + * As soon as the watchdog is started, there is no way to stop + * it if the 'nowayout' option is set at boot time + */ + watchdog_set_nowayout(wdog, nowayout); + + /* + * The devm_ version of the watchdog_register_device() + * function will call watchdog_unregister_device() when the + * device is removed. + */ + watchdog_stop_on_unregister(wdog); + + s32g_wdt_init(wdev); + + ret = devm_watchdog_register_device(dev, wdog); + if (ret) + return dev_err_probe(dev, ret, "Cannot register watchdog device\n"); + + dev_info(dev, "S32G Watchdog Timer Registered, timeout=%ds, nowayout=%d, early_enable=%d\n", + wdog->timeout, nowayout, early_enable); + + return 0; +} + +static const struct of_device_id s32g_wdt_dt_ids[] = { + { .compatible = "nxp,s32g2-swt" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, s32g_wdt_dt_ids); + +static struct platform_driver s32g_wdt_driver = { + .probe = s32g_wdt_probe, + .driver = { + .name = DRIVER_NAME, + .of_match_table = s32g_wdt_dt_ids, + }, +}; + +module_platform_driver(s32g_wdt_driver); + +MODULE_AUTHOR("Daniel Lezcano <daniel.lezcano@linaro.org>"); +MODULE_DESCRIPTION("Watchdog driver for S32G SoC"); +MODULE_LICENSE("GPL"); -- 2.43.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-04-07 4:53 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-04-02 15:49 [PATCH v2 0/2] Add the NXP S32 Watchdog Daniel Lezcano 2025-04-02 15:49 ` [PATCH v2 1/2] dt-bindings: watchdog: Add NXP Software Watchdog Timer Daniel Lezcano 2025-04-02 15:56 ` Krzysztof Kozlowski 2025-04-02 23:01 ` Daniel Lezcano 2025-04-03 14:16 ` Krzysztof Kozlowski 2025-04-03 15:33 ` Daniel Lezcano 2025-04-03 15:35 ` Krzysztof Kozlowski 2025-04-03 21:52 ` Daniel Lezcano 2025-04-02 18:56 ` Rob Herring (Arm) 2025-04-03 6:19 ` Ghennadi Procopciuc 2025-04-03 15:10 ` Daniel Lezcano 2025-04-04 6:35 ` Ghennadi Procopciuc 2025-04-06 20:33 ` Daniel Lezcano 2025-04-07 4:53 ` Ghennadi Procopciuc 2025-04-02 15:49 ` [PATCH v2 2/2] watchdog: Add the Watchdog Timer for the NXP S32 platform Daniel Lezcano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox