Add drivers for Intel Keem Bay SoC watchdog
Subsystems (2)
v2 cover Add drivers for Intel Keem Bay SoC watchdog
From: Vijayakannan Ayyathurai <[email protected]>
Hi,
This patch set adds the watchdog timer driver support for Intel Keem Bay Soc.
Patch 1 holds the driver and Patch 2 holds the Device Tree binding documentation.
This driver was tested on the Keem Bay evaluation module board.
Thank you,
Vijay
Changes since v1:
- Fix indentation error in the dt-bindings file.
- Use true/false in the second arg of keembay_wdt_set_timeout_reg().
- Fix the watchdog start sequence.
- Avoid reduntant timeout register setting.
- Remove min usage to find actual time at keembay_wdt_set_timeout().
- Remove timeout configuration boundary check at keembay_wdt_set_pretimeout().
- Use devm_watchdog_register_device() for wdt registration, which eventually supports driver unload functionality as well.
Vijayakannan Ayyathurai (2):
watchdog: Add watchdog driver for Intel Keembay Soc
dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC
.../bindings/watchdog/intel,keembay-wdt.yaml | 57 ++++ drivers/watchdog/Kconfig | 13 + drivers/watchdog/Makefile | 1 + drivers/watchdog/keembay_wdt.c | 288 ++++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml create mode 100644 drivers/watchdog/keembay_wdt.c
base-commit: 3650b228f83adda7e5ee532e2b90429c03f7b9ec
prerequisite-patch-id: 822987dcf4c969ef6ac70359b088af06ba39042b
prerequisite-patch-id: 0a348762b660d0d817b8e70cc71647e83173c78c
prerequisite-patch-id: 54c661a006c7362053cb7602448d6c77419d5cf9
prerequisite-patch-id: d140d8534fb828778e0652fe5fcf6282e027f985
Signature · 1 line
2.17.1
PATCH v2 1/2 watchdog: Add watchdog driver for Intel Keembay Soc
From: Vijayakannan Ayyathurai <[email protected]>
Intel Keembay Soc requires watchdog timer support. Add watchdog driver to enable this.
--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/keembay_wdt.c | 288 +++++++++++++++++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 drivers/watchdog/keembay_wdt.c
drivers/watchdog/Kconfig +13 -0
@@ -2163,4 +2163,17 @@ config USBPCWATCHDOG Most people will say N. +config KEEMBAY_WATCHDOG + tristate "Intel Keem Bay SoC non-secure watchdog" + depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST) + select WATCHDOG_CORE + help + This option enable support for an In-secure watchdog timer driver for + Intel Keem Bay SoC. This WDT has a 32 bit timer and decrements in every + count unit. An interrupt will be triggered, when the count crosses + the thershold configured in the register. + + To compile this driver as a module, choose M here: the + module will be called keembay_wdt. + endif # WATCHDOG
drivers/watchdog/Makefile +1 -0
@@ -146,6 +146,7 @@ obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o obj-$(CONFIG_MLX_WDT) += mlx_wdt.o +obj-$(CONFIG_KEEMBAY_WATCHDOG) += keembay_wdt.o # M68K Architecture obj-$(CONFIG_M54xx_WATCHDOG) += m54xx_wdt.o
drivers/watchdog/keembay_wdt.c new file +288 -0
288 lines not on this page · raw message
Signature · 1 line
2.17.1
Guenter Roeck
maintainerRe: [PATCH v2 1/2] watchdog: Add watchdog driver for Intel Keembay Soc
Quoted 123 lines · On Wed, Nov 11, 2020 at 01:53:07AM +0800, [email protected]…
From: Vijayakannan Ayyathurai <[email protected]>
Intel Keembay Soc requires watchdog timer support. Add watchdog driver to enable this.
Signed-off-by Vijayakannan Ayyathurai <[email protected]>Acked-by Mark Gross <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/keembay_wdt.c | 288 +++++++++++++++++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 drivers/watchdog/keembay_wdt.cdrivers/watchdog/Kconfig +13
-0@@ -2163,4 +2163,17 @@ config USBPCWATCHDOG Most people will say N. +config KEEMBAY_WATCHDOG + tristate "Intel Keem Bay SoC non-secure watchdog" + depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST) + select WATCHDOG_CORE + help + This option enable support for an In-secure watchdog timer driver for + Intel Keem Bay SoC. This WDT has a 32 bit timer and decrements in every + count unit. An interrupt will be triggered, when the count crosses + the thershold configured in the register. + + To compile this driver as a module, choose M here: the + module will be called keembay_wdt. + endif # WATCHDOGdrivers/watchdog/Makefile +1
-0@@ -146,6 +146,7 @@ obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o obj-$(CONFIG_MLX_WDT) += mlx_wdt.o +obj-$(CONFIG_KEEMBAY_WATCHDOG) += keembay_wdt.o # M68K Architecture obj-$(CONFIG_M54xx_WATCHDOG) += m54xx_wdt.odrivers/watchdog/keembay_wdt.c new file +68
-0@@ -0,0 +1,288 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Watchdog driver for Intel Keem Bay non-secure watchdog. +* +* Copyright (C) 2020 Intel Corporation +*/ + +#include <linux/arm-smccc.h> +#include <linux/bits.h> +#include <linux/clk.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/limits.h> +#include <linux/module.h> +#include <linux/mod_devicetable.h> +#include <linux/platform_device.h> +#include <linux/reboot.h> +#include <linux/watchdog.h> + +/* Non-secure watchdog register offsets */ +#define TIM_WATCHDOG 0x0 +#define TIM_WATCHDOG_INT_THRES 0x4 +#define TIM_WDOG_EN 0x8 +#define TIM_SAFE 0xc + +#define WDT_ISR_MASK GENMASK(9, 8) +#define WDT_ISR_CLEAR 0x8200ff18 +#define WDT_UNLOCK 0xf1d0dead +#define WDT_LOAD_MAX U32_MAX +#define WDT_LOAD_MIN 1 +#define WDT_TIMEOUT 5 + +static unsigned int timeout =WDT_TIMEOUT ; +module_param (timeout, int,0 ); +MODULE_PARM_DESC(timeout, "Watchdog timeout period in seconds (default = " + __MODULE_STRING(WDT_TIMEOUT) ")"); + +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) ")"); + +struct keembay_wdt { +struct watchdog_device wdd; +struct clk *clk; +unsigned int rate; +int to_irq; +int th_irq; +void __iomem *base; +}; + +static inline u32 keembay_wdt_readl (struct keembay_wdt *wdt,u32 offset) +{ +return readl (wdt->base + offset); +} + +static inline void keembay_wdt_writel (struct keembay_wdt *wdt, +u32 offset,u32 val) +{ +writel (WDT_UNLOCK , wdt->base +TIM_SAFE ); +writel (val, wdt->base + offset); +} + +static void keembay_wdt_set_timeout_reg (struct watchdog_device *wdog,bool ping) +{ +struct keembay_wdt *wdt =watchdog_get_drvdata (wdog); +u32 th_val =0 ; +
drivers/watchdog/keembay_wdt.c line 78
Quoted 10 lines
drivers/watchdog/keembay_wdt.c new file +10
-0+if (ping) +keembay_wdt_writel (wdt,TIM_WATCHDOG , wdog->timeout * wdt->rate); + +if (!ping && wdog->pretimeout) { + th_val = wdog->timeout - wdog->pretimeout; +keembay_wdt_writel (wdt,TIM_WATCHDOG_INT_THRES , th_val * wdt->rate); + } + +if (!ping) +keembay_wdt_writel (wdt,TIM_WATCHDOG , wdog->timeout * wdt->rate);
I am a bit at loss here. This seems unnecessarily complex. Why not just the following ?
if (!ping && wdog->pretimeout) {
th_val = wdog->timeout - wdog->pretimeout;
keembay_wdt_writel(wdt, TIM_WATCHDOG_INT_THRES, th_val * wdt->rate);
}
keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout * wdt->rate);Thanks,
Guenter
RE: [PATCH v2 1/2] watchdog: Add watchdog driver for Intel Keembay Soc
Hi Guenter,
Quoted 23 lines
From: Guenter Roeck <[email protected]>
Quoted 6 lines · On Wed, Nov 11, 2020 at 01:53:07AM +0800, [email protected]…
From: Vijayakannan Ayyathurai <[email protected]>
Intel Keembay Soc requires watchdog timer support. Add watchdog driver to enable this.
+static void keembay_wdt_set_timeout_reg(struct
watchdog_device*wdog,bool ping)
drivers/watchdog/keembay_wdt.c
Quoted 6 lines
drivers/watchdog/keembay_wdt.c new file +6
-0+{ +struct keembay_wdt *wdt =watchdog_get_drvdata (wdog); +u32 th_val =0 ; + +if (ping) + keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout *
wdt->rate);drivers/watchdog/keembay_wdt.c
Quoted 4 lines
drivers/watchdog/keembay_wdt.c new file +4
-0+ +if (!ping && wdog->pretimeout) { + th_val = wdog->timeout - wdog->pretimeout; + keembay_wdt_writel(wdt, TIM_WATCHDOG_INT_THRES, th_val*
wdt->rate);
Quoted 9 lines
drivers/watchdog/keembay_wdt.c
Quoted 4 lines
drivers/watchdog/keembay_wdt.c new file +4
-0+ } + +if (!ping) + keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout *
wdt->rate);I am a bit at loss here. This seems unnecessarily complex. Why not just the following ?
Sure. I can follow the below way.
Let me know if there is further comments to improve for the next version.
Quoted 10 lines
if (!ping && wdog->pretimeout) { th_val = wdog->timeout - wdog->pretimeout; keembay_wdt_writel(wdt, TIM_WATCHDOG_INT_THRES, th_val * wdt->rate); } keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout * wdt-Quoted 1 line
rate);
Thanks,
Guenter
Thanks,
Vijay
Guenter Roeck
maintainerRe: [PATCH v2 1/2] watchdog: Add watchdog driver for Intel Keembay Soc
Quoted 31 lines · Vijayakannan
Hi Guenter,
Quoted 29 lines
From: Guenter Roeck <[email protected]>
Quoted 6 lines · On Wed, Nov 11, 2020 at 01:53:07AM +0800, [email protected]…
From: Vijayakannan Ayyathurai <[email protected]>
Intel Keembay Soc requires watchdog timer support. Add watchdog driver to enable this.
+static void keembay_wdt_set_timeout_reg(struct
watchdog_device*wdog,bool ping)
drivers/watchdog/keembay_wdt.c
Quoted 6 lines
drivers/watchdog/keembay_wdt.c new file +6
-0+{ +struct keembay_wdt *wdt =watchdog_get_drvdata (wdog); +u32 th_val =0 ; + +if (ping) + keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout *
wdt->rate);drivers/watchdog/keembay_wdt.c
Quoted 4 lines
drivers/watchdog/keembay_wdt.c new file +4
-0+ +if (!ping && wdog->pretimeout) { + th_val = wdog->timeout - wdog->pretimeout; + keembay_wdt_writel(wdt, TIM_WATCHDOG_INT_THRES, th_val*
wdt->rate);drivers/watchdog/keembay_wdt.c
Quoted 4 lines
drivers/watchdog/keembay_wdt.c new file +4
-0+ } + +if (!ping) + keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout *
wdt->rate);
Quoted 7 lines
Quoted 3 lines
I am a bit at loss here. This seems unnecessarily complex. Why not just the following ?
Sure. I can follow the below way.
Let me know if there is further comments to improve for the next version.
No, that was all. Driver looks good otherwise.
Guenter
Quoted 13 lines
Quoted 10 lines
if (!ping && wdog->pretimeout) { th_val = wdog->timeout - wdog->pretimeout; keembay_wdt_writel(wdt, TIM_WATCHDOG_INT_THRES, th_val * wdt->rate); } keembay_wdt_writel(wdt, TIM_WATCHDOG, wdog->timeout * wdt-Quoted 1 line
rate);
Thanks,
GuenterThanks,
Vijay
PATCH v2 2/2 dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC
In reply to [email protected]From: Vijayakannan Ayyathurai <[email protected]>
Add Device Tree binding document for Watchdog IP in the Intel Keem Bay SoC.
--- .../bindings/watchdog/intel,keembay-wdt.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml
Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml new file +57 -0
@@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/watchdog/intel,keembay-wdt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel Keem Bay SoC non-secure Watchdog Timer + +maintainers: + - Wan Ahmad Zainie <[email protected]> + +properties: + compatible: + enum: + - intel,keembay-wdt + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + interrupts: + items: + - description: interrupt specifier for threshold interrupt line + - description: interrupt specifier for timeout interrupt line + + interrupt-names: + items: + - const: threshold + - const: timeout + +required: + - compatible + - reg + - interrupts + - interrupt-names + - clocks + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + #define KEEM_BAY_A53_TIM + + watchdog: watchdog@2033009c { + compatible = "intel,keembay-wdt"; + reg = <0x2033009c 0x10>; + interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "threshold", "timeout"; + clocks = <&scmi_clk KEEM_BAY_A53_TIM>; + }; + +...
Signature · 1 line
2.17.1
Re: [PATCH v2 2/2] dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC
Quoted 4 lines · On Wed, 11 Nov 2020 01:53:08 +0800, [email protected] wrote:
From: Vijayakannan Ayyathurai <[email protected]>
Add Device Tree binding document for Watchdog IP in the Intel Keem Bay SoC.
Quoted 8 lines
Signed-off-by Vijayakannan Ayyathurai <[email protected]>Acked-by Mark Gross <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- .../bindings/watchdog/intel,keembay-wdt.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml
RE: [PATCH v2 2/2] dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC
Hi Rob,
Thanks for reviewing this patch.
Quoted 20 lines
From: Rob Herring <[email protected]>
Sent: Thursday, 12 November, 2020 4:04 AM
Subject: Re: [PATCH v2 2/2] dt-bindings: watchdog: Add bindings for Intel Keem Bay SoCQuoted 3 lines · On Wed, 11 Nov 2020 01:53:08 +0800, [email protected] wrote:
From: Vijayakannan Ayyathurai <[email protected]>
Add Device Tree binding document for Watchdog IP in the Intel Keem Bay
SoC.
Quoted 2 lines
Signed-off-by Vijayakannan AyyathuraiQuoted 6 lines
Acked-by Mark Gross <[email protected]>Acked-by Andy Shevchenko <[email protected]>--- .../bindings/watchdog/intel,keembay-wdt.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644
Quoted 4 lines
Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yamlQuoted 1 line
Reviewed-by Rob Herring <[email protected]>
Thanks,
Vijay
Quoted 38 lines · On Wed, Nov 11, 2020 at 01:53:06AM +0800, [email protected]…
From: Vijayakannan Ayyathurai <[email protected]>
Hi,
This patch set adds the watchdog timer driver support for Intel Keem Bay Soc.
Patch 1 holds the driver and Patch 2 holds the Device Tree binding documentation.
This driver was tested on the Keem Bay evaluation module board.
Thank you,
VijayChanges since v1:
- Fix indentation error in the dt-bindings file.
- Use true/false in the second arg ofkeembay_wdt_set_timeout_reg().
- Fix the watchdog start sequence.
- Avoid reduntant timeout register setting.
- Remove min usage to find actual time atkeembay_wdt_set_timeout().
- Remove timeout configuration boundary check atkeembay_wdt_set_pretimeout().
- Usedevm_watchdog_register_device()for wdt registration, which eventually supports driver unload functionality as well.Vijayakannan Ayyathurai (2):
watchdog: Add watchdog driver for Intel Keembay Soc
dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC.../bindings/watchdog/intel,keembay-wdt.yaml | 57 ++++ drivers/watchdog/Kconfig | 13 + drivers/watchdog/Makefile | 1 + drivers/watchdog/keembay_wdt.c | 288 ++++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml create mode 100644 drivers/watchdog/keembay_wdt.c
Quoted 5 lines
base-commit:
3650b228f83adda7e5ee532e2b90429c03f7b9ec
prerequisite-patch-id:822987dcf4c969ef6ac70359b088af06ba39042b
prerequisite-patch-id:0a348762b660d0d817b8e70cc71647e83173c78c
prerequisite-patch-id:54c661a006c7362053cb7602448d6c77419d5cf9
prerequisite-patch-id:d140d8534fb828778e0652fe5fcf6282e027f985
these patch-id's are not helpful to me if I want to to a test build of this patch. Those SHA1's are not available to others unless there is a public non-rebasing tree I can pull from. if there is one then you should provide the git remot URL for that otherwise I cannot fetch those prerequisites.
Maybe it would be better to list the mailing list archive URL for each change instead.
--mark
Quoted 3 lines
Signature · 1 line
2.17.1
Hi,
Quoted 18 lines
From: Ayyathurai, Vijayakannan <[email protected]>
Sent: Wednesday, 11 November, 2020 1:53 AM
Subject: [PATCH v2 0/2] Add drivers for Intel Keem Bay SoC watchdogFrom: Vijayakannan Ayyathurai <[email protected]>
Hi,
This patch set adds the watchdog timer driver support for Intel Keem Bay Soc.
Patch 1 holds the driver and Patch 2 holds the Device Tree binding documentation.
This driver was tested on the Keem Bay evaluation module board.
Thank you,
Vijay
Quoted 11 lines
Changes since v1:
- Fix indentation error in the dt-bindings file.
- Use true/false in the second arg ofkeembay_wdt_set_timeout_reg().
- Fix the watchdog start sequence.
- Avoid reduntant timeout register setting.
- Remove min usage to find actual time atkeembay_wdt_set_timeout().
- Remove timeout configuration boundary check atkeembay_wdt_set_pretimeout().
- Usedevm_watchdog_register_device()for wdt registration, which eventually supports driver unload functionality as well.
Please consider review this patch and let me know
if there is further feedback.
Quoted 14 lines
Vijayakannan Ayyathurai (2):
watchdog: Add watchdog driver for Intel Keembay Soc
dt-bindings: watchdog: Add bindings for Intel Keem Bay SoC.../bindings/watchdog/intel,keembay-wdt.yaml | 57 ++++ drivers/watchdog/Kconfig | 13 + drivers/watchdog/Makefile | 1 + drivers/watchdog/keembay_wdt.c | 288 ++++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/intel,keembay-wdt.yaml create mode 100644 drivers/watchdog/keembay_wdt.c
Quoted 3 lines
base-commit:
3650b228f83adda7e5ee532e2b90429c03f7b9ec--
2.17.1
Thanks,
Vijay