Skip to contentSkip to conversation

Update watchdogs support on STM32MP platforms

PATCH Applied Antonio Borneo 5 participants 25 messages Nov 16 – Dec 4

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover Update watchdogs support on STM32MP platforms

This series allows the stm32_iwdg watchdog driver to determine whether the watchdog is already running and adds support for STM32MP2xx devices.

It also completes and rationalizes the configuration of secure and non-secure watchdogs across STM32MP devices and ST boards.

For STM32MP1xx devices, it enables the ARM SMC watchdog driver in the machine Kconfig.

Regards,
Antonio

Changes in v4:
- Add two fixes, one detected by Sashiko
- Add access-contollers property to bindingds
- Drop update on stm32mp21x DT since clock framework is still missing
- Add two fixes, one detected by Sashiko
- Integrate Sashiko comments
- Patch v4 06/15 (former v3 04/13) reposted unchanged, waiting for reply from Guenter Roeck
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Add support for detecting watchdog running status
- Add pretimeout irq support on STM32MP2xx
- Build ARM SMC watchdog driver on STM32MP1xx
- Use ARM SMC watchdog on platforms that have secure IWDG1 and use the
native stm32_iwdg driver when the IWDG1 is non-secure
- Add iwdg1 and iwdg2 nodes on STM32MP2xx platforms
- Add the alias in device trees to have the system watchdog allocated
as watchdog0, independently from the probe order
- Link to v2: https://lore.kernel.org/lkml/[email protected]/

Changes in v2:
- Drop addition of iwdg1 DT node, not needed as OP-TEE keep the watchdog
secure on all boards;
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

Amelie Delaunay (3):
ARM: dts: stm32: add iwdg1 node on stm32mp151 SoC
ARM: dts: stm32: enable iwdg1 on stm32mp15x ST boards
ARM: dts: stm32: enable arm smc watchdog on stm32mp15x scmi boards

Antonio Borneo (9):
watchdog: stm32_iwdg: set driver data before requesting interrupt
watchdog: stm32_iwdg: serialize accesses to EWCR register
watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0
ARM: stm32: enable arm smc watchdog on stm32mp1xx
dt-bindings: watchdog: st,stm32-iwdg: add access-controllers property
ARM: dts: stm32: move arm smc watchdog to stm32mp151 SoC
ARM: dts: stm32: add watchdog0 alias on ST stm32mp1xx boards
arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp231
arm64: dts: st: enable iwdg2 on stm32mp2xx ST boards

Clément Le Goffic (3):
watchdog: stm32_iwdg: get hardware version during probe
watchdog: stm32_iwdg: detect whether the watchdog is running
arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp251

 .../bindings/watchdog/st,stm32-iwdg.yaml      |  3 +
 arch/arm/boot/dts/st/stm32mp135f-dk.dts       |  1 +
 arch/arm/boot/dts/st/stm32mp15-scmi.dtsi      |  4 +
 arch/arm/boot/dts/st/stm32mp151.dtsi          | 16 ++++
 arch/arm/boot/dts/st/stm32mp157a-dk1-scmi.dts |  9 ++
 arch/arm/boot/dts/st/stm32mp157c-dk2-scmi.dts |  9 ++
 arch/arm/boot/dts/st/stm32mp157c-ed1-scmi.dts |  9 ++
 arch/arm/boot/dts/st/stm32mp157c-ed1.dts      |  6 ++
 arch/arm/boot/dts/st/stm32mp157c-ev1-scmi.dts |  9 ++
 .../arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi |  7 --
 arch/arm/boot/dts/st/stm32mp157f-dk2.dts      |  1 +
 arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi     |  6 ++
 arch/arm/mach-stm32/Kconfig                   |  2 +
 arch/arm64/boot/dts/st/stm32mp231.dtsi        | 20 +++++
 arch/arm64/boot/dts/st/stm32mp235f-dk.dts     |  6 ++
 arch/arm64/boot/dts/st/stm32mp251.dtsi        | 20 +++++
 arch/arm64/boot/dts/st/stm32mp257f-dk.dts     |  8 +-
 arch/arm64/boot/dts/st/stm32mp257f-ev1.dts    |  6 ++
 drivers/watchdog/stm32_iwdg.c                 | 86 +++++++++++++++----
 19 files changed, 201 insertions(+), 27 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/15 watchdog: stm32_iwdg: set driver data before requesting interrupt

The interrupt handler accesses the driver data, which is currently set after devm_request_irq() returns.

If the watchdog was started by the bootloader and a pretimeout interrupt is pending, the handler can run before the driver data is set, resulting in a NULL pointer dereference.

Move the IRQ request after setting the driver data to ensure it is available when the interrupt handler runs.

---
 drivers/watchdog/stm32_iwdg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/stm32_iwdg.c +4 -4
index a8d2db2d3cf8b..2bac4ce5ed3f8 100644
@@ -346,15 +346,15 @@ static int stm32_iwdg_probe(struct platform_device *pdev)
 	wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler *
 				    1000) / wdt->rate;
 
+	watchdog_set_drvdata(wdd, wdt);
+	watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT);
+	watchdog_init_timeout(wdd, 0, dev);
+
 	/* Initialize IRQ, this might override wdd->info, hence it is here. */
 	ret = stm32_iwdg_irq_init(pdev, wdt);
 	if (ret)
 		return ret;
 
-	watchdog_set_drvdata(wdd, wdt);
-	watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT);
-	watchdog_init_timeout(wdd, 0, dev);
-
 	/*
 	 * In case of CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set
 	 * (Means U-Boot/bootloaders leaves the watchdog running)
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/15 watchdog: stm32_iwdg: serialize accesses to EWCR register

In reply to Antonio Borneo

On STM32MP1xx platforms, EWCR contains both the pretimeout interrupt configuration and a write-only bit used to acknowledge the interrupt.

On SMP systems, the read-modify-write operation in the pretimeout IRQ handler can race with writes that update the pretimeout configuration.

Protect these accesses with a spinlock to prevent concurrent updates.
Don't use the helpers reg_read()/reg_write() in the critical sections as they rely on relaxed memory access, which are not ordered against locking.

Fixes 3ab1663af6c1 ("watchdog: stm32_iwdg: Add pretimeout support")
---
 drivers/watchdog/stm32_iwdg.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/watchdog/stm32_iwdg.c +17 -4
index 2bac4ce5ed3f8..487764b51667c 100644
@@ -19,6 +19,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_wakeirq.h>
+#include <linux/spinlock.h>
 #include <linux/watchdog.h>
 
 #define DEFAULT_TIMEOUT 10
@@ -82,6 +83,7 @@ struct stm32_iwdg {
 	struct clk		*clk_lsi;
 	struct clk		*clk_pclk;
 	unsigned int		rate;
+	spinlock_t		lock; /* serialize IWDG_EWCR register access */
 };
 
 static inline u32 reg_read(void __iomem *base, u32 reg)
@@ -98,6 +100,7 @@ static int stm32_iwdg_start(struct watchdog_device *wdd)
 {
 	struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd);
 	u32 tout, ptot, presc, iwdg_rlr, iwdg_ewcr, iwdg_pr, iwdg_sr;
+	unsigned long flags;
 	int ret;
 
 	dev_dbg(wdd->parent, "%s\n", __func__);
@@ -124,8 +127,11 @@ static int stm32_iwdg_start(struct watchdog_device *wdd)
 	/* set prescaler & reload registers */
 	reg_write(wdt->regs, IWDG_PR, iwdg_pr);
 	reg_write(wdt->regs, IWDG_RLR, iwdg_rlr);
-	if (wdt->data->has_early_wakeup)
-		reg_write(wdt->regs, IWDG_EWCR, iwdg_ewcr | EWCR_EWIE);
+	if (wdt->data->has_early_wakeup) {
+		spin_lock_irqsave(&wdt->lock, flags);
+		writel(iwdg_ewcr | EWCR_EWIE, wdt->regs + IWDG_EWCR);
+		spin_unlock_irqrestore(&wdt->lock, flags);
+	}
 	reg_write(wdt->regs, IWDG_KR, KR_KEY_ENABLE);
 
 	/* wait for the registers to be updated (max 100ms) */
@@ -185,11 +191,16 @@ static irqreturn_t stm32_iwdg_isr(int irq, void *wdog_arg)
 {
 	struct watchdog_device *wdd = wdog_arg;
 	struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd);
+	unsigned long flags;
 	u32 reg;
 
-	reg = reg_read(wdt->regs, IWDG_EWCR);
+	spin_lock_irqsave(&wdt->lock, flags);
+
+	reg = readl(wdt->regs + IWDG_EWCR);
 	reg |= EWCR_EWIC;
-	reg_write(wdt->regs, IWDG_EWCR, reg);
+	writel(reg, wdt->regs + IWDG_EWCR);
+
+	spin_unlock_irqrestore(&wdt->lock, flags);
 
 	watchdog_notify_pretimeout(wdd);
 
@@ -323,6 +334,8 @@ static int stm32_iwdg_probe(struct platform_device *pdev)
 	if (!wdt)
 		return -ENOMEM;
 
+	spin_lock_init(&wdt->lock);
+
 	wdt->data = of_device_get_match_data(&pdev->dev);
 	if (!wdt->data)
 		return -ENODEV;
Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 3/15 watchdog: stm32_iwdg: get hardware version during probe

In reply to Antonio Borneo

From: Clément Le Goffic <[email protected]>

Get the hardware version of the IWDG peripheral during probe.

---
 drivers/watchdog/stm32_iwdg.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/watchdog/stm32_iwdg.c +7 -0
index 487764b51667c..9a0dc52a96bc7 100644
@@ -31,6 +31,7 @@
 #define IWDG_SR		0x0C /* Status Register */
 #define IWDG_WINR	0x10 /* Windows Register */
 #define IWDG_EWCR	0x14 /* Early Wake-up Register */
+#define IWDG_VERR	0x3F4 /* Version Register */
 
 /* IWDG_KR register bit mask */
 #define KR_KEY_RELOAD	0xAAAA /* reload counter enable */
@@ -54,6 +55,9 @@
 #define EWCR_EWIC	BIT(14) /* Watchdog early interrupt acknowledge */
 #define EWCR_EWIE	BIT(15) /* Watchdog early interrupt enable */
 
+/* IWDG_VERR register mask */
+#define VERR_MASK	GENMASK(7, 0)
+
 /* set timeout to 100000 us */
 #define TIMEOUT_US	100000
 #define SLEEP_US	1000
@@ -83,6 +87,7 @@ struct stm32_iwdg {
 	struct clk		*clk_lsi;
 	struct clk		*clk_pclk;
 	unsigned int		rate;
+	unsigned int		hw_version;
 	spinlock_t		lock; /* serialize IWDG_EWCR register access */
 };
 
@@ -359,6 +364,8 @@ static int stm32_iwdg_probe(struct platform_device *pdev)
 	wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler *
 				    1000) / wdt->rate;
 
+	wdt->hw_version = reg_read(wdt->regs, IWDG_VERR) & VERR_MASK;
+
 	watchdog_set_drvdata(wdd, wdt);
 	watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT);
 	watchdog_init_timeout(wdd, 0, dev);
Signature · 1 line
2.34.1
#4 lore raw

PATCH v4 4/15 watchdog: stm32_iwdg: detect whether the watchdog is running

In reply to Antonio Borneo

From: Clément Le Goffic <[email protected]>

On STM32MP13x and STM32MP2xx platforms, the ONF bit in the IWDG status register indicates whether the watchdog is running. This feature was introduced with IWDG hardware version 3.1 and is not available on older versions, such as the one used on STM32MP15x.

On older hardware versions, determine the watchdog state by writing the current reload value back to the reload register, then checking the RVU (Reload Value Update) bit in the status register. The update completes only if the watchdog is already running.

Use this state information to service only watchdogs that were started by earlier boot stages.

---
 drivers/watchdog/stm32_iwdg.c | 40 ++++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/watchdog/stm32_iwdg.c +30 -10
index 9a0dc52a96bc7..1a5715ff9fab3 100644
@@ -50,6 +50,7 @@
 /* IWDG_SR register bit mask */
 #define SR_PVU	BIT(0) /* Watchdog prescaler value update */
 #define SR_RVU	BIT(1) /* Watchdog counter reload value update */
+#define SR_ONF	BIT(8) /* Watchdog enable status bit */
 
 #define EWCR_EWIT	GENMASK(11, 0) /* Watchdog counter window value */
 #define EWCR_EWIC	BIT(14) /* Watchdog early interrupt acknowledge */
@@ -58,6 +59,9 @@
 /* IWDG_VERR register mask */
 #define VERR_MASK	GENMASK(7, 0)
 
+/* IWDG Compatibility */
+#define ONF_MIN_VER	0x31
+
 /* set timeout to 100000 us */
 #define TIMEOUT_US	100000
 #define SLEEP_US	1000
@@ -261,6 +265,31 @@ static int stm32_iwdg_clk_init(struct platform_device *pdev,
 	return 0;
 }
 
+static bool stm32_iwdg_is_running(struct stm32_iwdg *wdt)
+{
+	bool running;
+	u32 rlr, sr;
+	int ret;
+
+	if (wdt->hw_version >= ONF_MIN_VER)
+		return (reg_read(wdt->regs, IWDG_SR) & SR_ONF) != 0;
+
+	/*
+	 * Workaround for old versions without IWDG_SR_ONF bit:
+	 * - write in IWDG_RLR_OFFSET
+	 * - wait for sync
+	 * - if sync succeeds, then iwdg is running
+	 */
+	reg_write(wdt->regs, IWDG_KR, KR_KEY_EWA);
+	rlr = reg_read(wdt->regs, IWDG_RLR);
+	reg_write(wdt->regs, IWDG_RLR, rlr);
+	ret = readl_poll_timeout(wdt->regs + IWDG_SR, sr, !(sr & SR_RVU), SLEEP_US, TIMEOUT_US);
+	running = ret ? false : true;
+	reg_write(wdt->regs, IWDG_KR, KR_KEY_DWA);
+
+	return running;
+}
+
 static const struct watchdog_info stm32_iwdg_info = {
 	.options	= WDIOF_SETTIMEOUT |
 			  WDIOF_MAGICCLOSE |
@@ -375,16 +404,7 @@ static int stm32_iwdg_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	/*
-	 * In case of CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set
-	 * (Means U-Boot/bootloaders leaves the watchdog running)
-	 * When we get here we should make a decision to prevent
-	 * any side effects before user space daemon will take care of it.
-	 * The best option, taking into consideration that there is no
-	 * way to read values back from hardware, is to enforce watchdog
-	 * being run with deterministic values.
-	 */
-	if (IS_ENABLED(CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED)) {
+	if (stm32_iwdg_is_running(wdt)) {
 		ret = stm32_iwdg_start(wdd);
 		if (ret)
 			return ret;
Signature · 1 line
2.34.1
#5 lore raw

PATCH v4 5/15 watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0

In reply to Antonio Borneo

IWDG hardware version 4.0, used on STM32MP2xx platforms, has an independent register ICR for acknowledging the pretimeout interrupts.
This removes the need for serializing the accesses to the EWCR register, used in previous versions.

Use the interrupt clear register (ICR) to acknowledge pretimeout interrupts on hardware version 4.0 and later.

Don't check for HW version in stm32_iwdg_start() and always take the lock. This makes the code simpler, avoiding the version check and the duplicated write with and without lock, while adding the negligible cost of the uncontended lock on HW v4.0.

---
 drivers/watchdog/stm32_iwdg.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/watchdog/stm32_iwdg.c +13 -5
index 1a5715ff9fab3..b3d39d916735f 100644
@@ -31,6 +31,7 @@
 #define IWDG_SR		0x0C /* Status Register */
 #define IWDG_WINR	0x10 /* Windows Register */
 #define IWDG_EWCR	0x14 /* Early Wake-up Register */
+#define IWDG_ICR	0x18 /* Interrupt Clear Register */
 #define IWDG_VERR	0x3F4 /* Version Register */
 
 /* IWDG_KR register bit mask */
@@ -56,11 +57,14 @@
 #define EWCR_EWIC	BIT(14) /* Watchdog early interrupt acknowledge */
 #define EWCR_EWIE	BIT(15) /* Watchdog early interrupt enable */
 
+#define ICR_EWIC	BIT(15) /* Watchdog early interrupt acknowledge */
+
 /* IWDG_VERR register mask */
 #define VERR_MASK	GENMASK(7, 0)
 
 /* IWDG Compatibility */
 #define ONF_MIN_VER	0x31
+#define ICR_MIN_VER	0x40
 
 /* set timeout to 100000 us */
 #define TIMEOUT_US	100000
@@ -203,13 +207,17 @@ static irqreturn_t stm32_iwdg_isr(int irq, void *wdog_arg)
 	unsigned long flags;
 	u32 reg;
 
-	spin_lock_irqsave(&wdt->lock, flags);
+	if (wdt->hw_version >= ICR_MIN_VER) {
+		reg_write(wdt->regs, IWDG_ICR, ICR_EWIC);
+	} else {
+		spin_lock_irqsave(&wdt->lock, flags);
 
-	reg = readl(wdt->regs + IWDG_EWCR);
-	reg |= EWCR_EWIC;
-	writel(reg, wdt->regs + IWDG_EWCR);
+		reg = readl(wdt->regs + IWDG_EWCR);
+		reg |= EWCR_EWIC;
+		writel(reg, wdt->regs + IWDG_EWCR);
 
-	spin_unlock_irqrestore(&wdt->lock, flags);
+		spin_unlock_irqrestore(&wdt->lock, flags);
+	}
 
 	watchdog_notify_pretimeout(wdd);
 
Signature · 1 line
2.34.1
#6 lore raw

PATCH v4 6/15 ARM: stm32: enable arm smc watchdog on stm32mp1xx

In reply to Antonio Borneo

The watchdog IWDG1 is secure by default on STM32MP1xx SoCs. On boards that keep it secure, Linux must use the arm,smc-wdt driver to ping it.

Enable the driver for mach-stm32 when ARCH_MULTI_V7 is enabled.

---
 arch/arm/mach-stm32/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-stm32/Kconfig +2 -0
index 4ac3384e397aa..de09b2afa0f2e 100644
@@ -13,6 +13,8 @@ menuconfig ARCH_STM32
 	select RESET_CONTROLLER
 	select STM32_EXTI if ARM_SINGLE_ARMV7M
 	select STM32_FIREWALL
+	select WATCHDOG if ARCH_MULTI_V7
+	select ARM_SMC_WATCHDOG if ARCH_MULTI_V7
 	help
 	  Support for STMicroelectronics STM32MP1 processors using Cortex-A7
 	  cores. Note that support for the earlier Cortex-M based variants
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v4 06/15] ARM: stm32: enable arm smc watchdog on stm32mp1xx

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ARM: stm32: selecting WATCHDOG and ARM_SMC_WATCHDOG forces built-in config --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] ARM: stm32: selecting WATCHDOG and ARM_SMC_WATCHDOG forces built-in config
--

commit 8f27de8f1df1e95c22eb21ddbb73d67212964859
Author: Antonio Borneo <[email protected]>

ARM: stm32: enable arm smc watchdog on stm32mp1xx

This commit selects WATCHDOG and ARM_SMC_WATCHDOG from ARCH_STM32 when ARCH_MULTI_V7 is enabled.

arch/arm/mach-stm32/Kconfig menuconfig ARCH_STM32 · line 17

Quoted 10 lines
arch/arm/mach-stm32/Kconfig +2 -0
index 4ac3384e397aa..de09b2afa0f2e 100644
@@ -13,6 +13,8 @@ menuconfig ARCH_STM32
 	select RESET_CONTROLLER
 	select STM32_EXTI if ARM_SINGLE_ARMV7M
 	select STM32_FIREWALL
+	select WATCHDOG if ARCH_MULTI_V7
+	select ARM_SMC_WATCHDOG if ARCH_MULTI_V7

[Severity: Low]
As reported by Guenter Roeck on v3 [1], does selecting WATCHDOG and the tristate ARM_SMC_WATCHDOG from the boolean ARCH_STM32 force both symbols to y whenever ARCH_MULTI_V7 is enabled? This prevents building arm_smc_wdt as a module or disabling WATCHDOG and ARM_SMC_WATCHDOG on multi-platform ARMv7 configurations that enable ARCH_STM32; enabling the driver in defconfig or via a default statement in drivers/watchdog/Kconfig (like STM32_WATCHDOG) would keep it configurable.

[1] https://lore.kernel.org/r/[email protected]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
maintainer
#8 lore raw

Re: [PATCH v4 06/15] ARM: stm32: enable arm smc watchdog on stm32mp1xx

In reply to Antonio Borneo
Quoted 6 lines · Antonio Borneo

The watchdog IWDG1 is secure by default on STM32MP1xx SoCs. On boards that keep it secure, Linux must use the arm,smc-wdt driver to ping it.

Enable the driver for mach-stm32 when ARCH_MULTI_V7 is enabled.

As mentioned before, that doesn't just enable it for STM32MP1xx SoCs, it force-enables it for all boards running ARCH_MULTI_V7. It also goes well beyond the current scope of "if ARCH_MULTI_V7" configurations. I would suggest NACK for that reason, but that isn't my call to make.

Guenter

Quoted 18 lines
---
  arch/arm/mach-stm32/Kconfig | 2 ++
  1 file changed, 2 insertions(+)
arch/arm/mach-stm32/Kconfig +2 -0
index 4ac3384e397aa..de09b2afa0f2e 100644
@@ -13,6 +13,8 @@ menuconfig ARCH_STM32
  	select RESET_CONTROLLER
  	select STM32_EXTI if ARM_SINGLE_ARMV7M
  	select STM32_FIREWALL
+	select WATCHDOG if ARCH_MULTI_V7
+	select ARM_SMC_WATCHDOG if ARCH_MULTI_V7
  	help
  	  Support for STMicroelectronics STM32MP1 processors using Cortex-A7
  	  cores. Note that support for the earlier Cortex-M based variants
#9 lore raw

Re: [PATCH v4 06/15] ARM: stm32: enable arm smc watchdog on stm32mp1xx

Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Antonio Borneo

The watchdog IWDG1 is secure by default on STM32MP1xx SoCs. On boards that keep it secure, Linux must use the arm,smc-wdt driver to ping it.

Enable the driver for mach-stm32 when ARCH_MULTI_V7 is enabled.

Quoted 6 lines

As mentioned before, that doesn't just enable it for STM32MP1xx SoCs, it force-enables it for all boards running ARCH_MULTI_V7. It also goes well beyond the current scope of "if ARCH_MULTI_V7" configurations. I would suggest NACK for that reason, but that isn't my call to make.

Guenter

Hi Guenter,

sorry if I take more of your time on this, but I haven't got your comments on my reply to this patch as v3 04/13.

On platforms STM32MP1xx the trusted firmware starts the watchdog. Since on such platforms the defconfig is multi_v7_defconfig, the upstream kernel configured with multi_v7_defconfig would need ARM_SMC_WATCHDOG to prevent a reset during kernel boot.

Clearly, my wish is to have an upstream kernel booting properly with defconfig.

arch/arm/mach-stm32/Kconfig handles two series of ARCH_STM32:
- the deprecated ARMv7M platforms that use stm32_defconfig;
- the ARMv7A platforms that use multi_v7_defconfig.

In this patch the condition 'if ARCH_MULTI_V7' is to enable the watchdog only on ARMv7A, not on ARMv7M.

Clearly any driver enabled for ARCH_STM32 will automatically be enabled for the other SoC that rely on the same defconfig.

Also reworking this patch by moving the change in drivers/watchdog/Kconfig as

config ARM_SMC_WATCHDOG
+ default y if (ARCH_STM32 && ARCH_MULTI_V7)

would still result in the arm SMC watchdog enabled for all the SoC that use multi_v7_defconfig.

What would be your suggestion to progress on this topic?

Thanks,
Antonio

Quoted 20 lines
Quoted 19 lines

---
  arch/arm/mach-stm32/Kconfig | 2 ++

  1 file changed, 2 insertions(+)
arch/arm/mach-stm32/Kconfig +0 -0
index 4ac3384e397aa..de09b2afa0f2e 100644
@@ -13,6 +13,8 @@ menuconfig ARCH_STM32

        select RESET_CONTROLLER
        select STM32_EXTI if ARM_SINGLE_ARMV7M
        select STM32_FIREWALL
+       select WATCHDOG if ARCH_MULTI_V7
+       select ARM_SMC_WATCHDOG if ARCH_MULTI_V7
        help
          Support for STMicroelectronics STM32MP1 processors using Cortex-A7 cores. Note that support for the earlier Cortex-M based variants

maintainer
#10 lore raw

Re: [PATCH v4 06/15] ARM: stm32: enable arm smc watchdog on stm32mp1xx

Quoted 43 lines · Antonio Borneo
Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Antonio Borneo

The watchdog IWDG1 is secure by default on STM32MP1xx SoCs. On boards that keep it secure, Linux must use the arm,smc-wdt driver to ping it.

Enable the driver for mach-stm32 when ARCH_MULTI_V7 is enabled.

Quoted 6 lines

As mentioned before, that doesn't just enable it for STM32MP1xx SoCs, it force-enables it for all boards running ARCH_MULTI_V7. It also goes well beyond the current scope of "if ARCH_MULTI_V7" configurations. I would suggest NACK for that reason, but that isn't my call to make.

Guenter

Hi Guenter,

sorry if I take more of your time on this, but I haven't got your comments on my reply to this patch as v3 04/13.

On platforms STM32MP1xx the trusted firmware starts the watchdog. Since on such platforms the defconfig is multi_v7_defconfig, the upstream kernel configured with multi_v7_defconfig would need ARM_SMC_WATCHDOG to prevent a reset during kernel boot.

Clearly, my wish is to have an upstream kernel booting properly with defconfig.

arch/arm/mach-stm32/Kconfig handles two series of ARCH_STM32:
- the deprecated ARMv7M platforms that use stm32_defconfig;
- the ARMv7A platforms that use multi_v7_defconfig.

In this patch the condition 'if ARCH_MULTI_V7' is to enable the watchdog only on ARMv7A, not on ARMv7M.

Clearly any driver enabled for ARCH_STM32 will automatically be enabled for the other SoC that rely on the same defconfig.

Also reworking this patch by moving the change in drivers/watchdog/Kconfig as

config ARM_SMC_WATCHDOG

(quoted diff) +1 -0
+	default y if (ARCH_STM32 && ARCH_MULTI_V7)
Quoted 5 lines

would still result in the arm SMC watchdog enabled for all the SoC that use multi_v7_defconfig.

What would be your suggestion to progress on this topic?

No. As you say yourself above, "the upstream kernel configured with multi_v7_defconfig would need ARM_SMC_WATCHDOG to prevent a reset during kernel boot". I fail to understand why you don't just add "CONFIG_ARM_SMC_WATCHDOG=m" to multi_v7_defconfig and instead want to force every single platform using multi_v7_defconfig to build this driver into the kernel even though almost all of them won't need (or want) it.

Guenter

#11 lore raw

Re: [PATCH v4 06/15] ARM: stm32: enable arm smc watchdog on stm32mp1xx

Quoted 50 lines · Guenter Roeck
Quoted 40 lines · Antonio Borneo
Quoted 8 lines · Guenter Roeck
Quoted 6 lines · Antonio Borneo

The watchdog IWDG1 is secure by default on STM32MP1xx SoCs. On boards that keep it secure, Linux must use the arm,smc-wdt driver to ping it.

Enable the driver for mach-stm32 when ARCH_MULTI_V7 is enabled.

Quoted 6 lines

As mentioned before, that doesn't just enable it for STM32MP1xx SoCs, it force-enables it for all boards running ARCH_MULTI_V7. It also goes well beyond the current scope of "if ARCH_MULTI_V7" configurations. I would suggest NACK for that reason, but that isn't my call to make.

Guenter

Hi Guenter,

sorry if I take more of your time on this, but I haven't got your comments on my reply to this patch as v3 04/13.

On platforms STM32MP1xx the trusted firmware starts the watchdog. Since on such platforms the defconfig is multi_v7_defconfig, the upstream kernel configured with multi_v7_defconfig would need ARM_SMC_WATCHDOG to prevent a reset during kernel boot.

Clearly, my wish is to have an upstream kernel booting properly with defconfig.

arch/arm/mach-stm32/Kconfig handles two series of ARCH_STM32:
- the deprecated ARMv7M platforms that use stm32_defconfig;
- the ARMv7A platforms that use multi_v7_defconfig.

In this patch the condition 'if ARCH_MULTI_V7' is to enable the watchdog only on ARMv7A, not on ARMv7M.

Clearly any driver enabled for ARCH_STM32 will automatically be enabled for the other SoC that rely on the same defconfig.

Also reworking this patch by moving the change in drivers/watchdog/Kconfig as

Quoted 8 lines

  config ARM_SMC_WATCHDOG
+       default y if (ARCH_STM32 && ARCH_MULTI_V7)

would still result in the arm SMC watchdog enabled for all the SoC that use multi_v7_defconfig.

What would be your suggestion to progress on this topic?

Quoted 6 lines

No. As you say yourself above, "the upstream kernel configured with multi_v7_defconfig would need ARM_SMC_WATCHDOG to prevent a reset during kernel boot". I fail to understand why you don't just add "CONFIG_ARM_SMC_WATCHDOG=m" to multi_v7_defconfig and instead want to force every single platform using multi_v7_defconfig to build this driver into the kernel even though almost all of them won't need (or want) it.

Thanks for the clarification. Understand your point. So let's drop this patch from this series.
I will send separately the proposal for multi_v7_defconfig.

Best Regards,
Antonio

#12 lore raw

PATCH v4 7/15 dt-bindings: watchdog: st,stm32-iwdg: add access-controllers property

In reply to Antonio Borneo

Add the optional access-controllers property to reference one domain access controllers protecting the watchdog peripheral.

---
 Documentation/devicetree/bindings/watchdog/st,stm32-iwdg.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/watchdog/st,stm32-iwdg.yaml +3 -0
index 86bd39d508500..daf782460bc09 100644
@@ -42,6 +42,9 @@ properties:
 
   wakeup-source: true
 
+  access-controllers:
+    maxItems: 1
+
 required:
   - compatible
   - reg
Signature · 1 line
2.34.1
maintainer Acked-by on v4 7/15
#13 lore raw

Re: [PATCH v4 07/15] dt-bindings: watchdog: st,stm32-iwdg: add access-controllers property

Quoted 10 lines · Antonio Borneo

Add the optional access-controllers property to reference one domain access controllers protecting the watchdog peripheral.

---
 Documentation/devicetree/bindings/watchdog/st,stm32-iwdg.yaml | 3 +++
 1 file changed, 3 insertions(+)
maintainer Applied
#14 lore raw

Re: [PATCH v4 07/15] dt-bindings: watchdog: st,stm32-iwdg: add access-controllers property

In reply to Antonio Borneo
Quoted 7 lines · Antonio Borneo

Add the optional access-controllers property to reference one domain access controllers protecting the watchdog peripheral.

Applied.

Thanks,
Guenter

#15 lore raw

PATCH v4 8/15 ARM: dts: stm32: add iwdg1 node on stm32mp151 SoC

In reply to Antonio Borneo

From: Amelie Delaunay <[email protected]>

On STM32MP15x boards where IWDG1 is exposed as a non-secure watchdog, Linux must register and periodically ping it if it was started by an earlier boot stage.

Add the IWDG1 node to the STM32MP151 SoC device tree as a child of the ETZPC node.

---
 arch/arm/boot/dts/st/stm32mp151.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/st/stm32mp151.dtsi +10 -0
index ae31883732388..e71b2ab58aa54 100644
@@ -2037,6 +2037,16 @@ i2c4: i2c@5c002000 {
 				status = "disabled";
 			};
 
+			iwdg1: watchdog@5c003000 {
+				compatible = "st,stm32mp1-iwdg";
+				reg = <0x5c003000 0x400>;
+				interrupts = <GIC_SPI 150 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&rcc IWDG1>, <&rcc CK_LSI>;
+				clock-names = "pclk", "lsi";
+				access-controllers = <&etzpc 2>;
+				status = "disabled";
+			};
+
 			i2c6: i2c@5c009000 {
 				compatible = "st,stm32mp15-i2c";
 				reg = <0x5c009000 0x400>;
Signature · 1 line
2.34.1
#16 lore raw

PATCH v4 9/15 ARM: dts: stm32: enable iwdg1 on stm32mp15x ST boards

In reply to Antonio Borneo

From: Amelie Delaunay <[email protected]>

On STM32MP15x ST boards where IWDG1 is exposed as a non-secure watchdog, Linux must register and periodically ping it if it was started by an earlier boot stage.

Enable the IWDG1 node on ST non-SCMI boards that use this non-secure watchdog configuration.

With two watchdogs now enabled on ST STM32MP1xx boards, assign the watchdog0 alias to the IWDG1 watchdog that may have been started by an earlier boot stage. This allows userspace to identify and ping the appropriate watchdog.

---
 arch/arm/boot/dts/st/stm32mp15-scmi.dtsi  | 4 ++++
 arch/arm/boot/dts/st/stm32mp157c-ed1.dts  | 6 ++++++
 arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi | 6 ++++++
 3 files changed, 16 insertions(+)
arch/arm/boot/dts/st/stm32mp15-scmi.dtsi +4 -0
index 98552fe45d4e0..cc9521b105262 100644
@@ -64,6 +64,10 @@ scmi_usb33: regulator@2 {
 	};
 };
 
+&iwdg1 {
+	status = "disabled";
+};
+
 &reg11 {
 	status = "disabled";
 };
arch/arm/boot/dts/st/stm32mp157c-ed1.dts +6 -0
index 49dd555cc228c..6c7dfbee29528 100644
@@ -19,6 +19,7 @@ / {
 
 	aliases {
 		serial0 = &uart4;
+		watchdog0 = &iwdg1;
 	};
 
 	chosen {
@@ -331,6 +332,11 @@ &ipcc {
 	status = "okay";
 };
 
+&iwdg1 {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &iwdg2 {
 	timeout-sec = <32>;
 	status = "okay";
arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi +6 -0
index 1a07ae09afb2a..9722e2ab07794 100644
@@ -13,6 +13,7 @@ aliases {
 		serial0 = &uart4;
 		serial1 = &usart3;
 		serial2 = &uart7;
+		watchdog0 = &iwdg1;
 	};
 
 	memory@c0000000 {
@@ -511,6 +512,11 @@ &ipcc {
 	status = "okay";
 };
 
+&iwdg1 {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &iwdg2 {
 	timeout-sec = <32>;
 	status = "okay";
Signature · 1 line
2.34.1
#17 lore raw

PATCH v4 10/15 ARM: dts: stm32: move arm smc watchdog to stm32mp151 SoC

In reply to Antonio Borneo

On boards where IWDG1 is secure and monitored by OP-TEE, Linux must control the watchdog through SMC calls.

Move the arm,smc-wdt node to the STM32MP151 SoC device tree so that board device trees can enable it as needed.

---
 arch/arm/boot/dts/st/stm32mp151.dtsi           | 6 ++++++
 arch/arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi | 7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)
arch/arm/boot/dts/st/stm32mp151.dtsi +6 -0
index e71b2ab58aa54..d00a36a8c93ba 100644
@@ -31,6 +31,12 @@ arm-pmu {
 		interrupt-parent = <&intc>;
 	};
 
+	arm_wdt: watchdog {
+		compatible = "arm,smc-wdt";
+		arm,smc-id = <0xbc000000>;
+		status = "disabled";
+	};
+
 	psci {
 		compatible = "arm,psci-1.0";
 		method = "smc";
arch/arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi +0 -7
index 172347769e025..27ea5e79efc66 100644
@@ -13,13 +13,6 @@ optee@de000000 {
 			no-map;
 		};
 	};
-
-	arm_wdt: watchdog {
-		compatible = "arm,smc-wdt";
-		arm,smc-id = <0xbc000000>;
-		status = "disabled";
-	};
-
 };
 
 &adc {
Signature · 1 line
2.34.1
#18 lore raw

PATCH v4 11/15 ARM: dts: stm32: enable arm smc watchdog on stm32mp15x scmi boards

In reply to Antonio Borneo

From: Amelie Delaunay <[email protected]>

On STM32MP15x SCMI boards, IWDG1 is secure and monitored by OP-TEE.

Enable the arm,smc-wdt node on ST SCMI board variants so that Linux can control the secure watchdog through SMC calls.

With two watchdogs now enabled on ST STM32MP1xx boards, assign the watchdog0 alias to the ARM SMC watchdog that may have been started by an earlier boot stage. This allows userspace to identify and ping the appropriate watchdog.

---
 arch/arm/boot/dts/st/stm32mp157a-dk1-scmi.dts | 9 +++++++++
 arch/arm/boot/dts/st/stm32mp157c-dk2-scmi.dts | 9 +++++++++
 arch/arm/boot/dts/st/stm32mp157c-ed1-scmi.dts | 9 +++++++++
 arch/arm/boot/dts/st/stm32mp157c-ev1-scmi.dts | 9 +++++++++
 4 files changed, 36 insertions(+)
arch/arm/boot/dts/st/stm32mp157a-dk1-scmi.dts +9 -0
index 53e40e2f776b7..2f4d212de3e9c 100644
@@ -13,6 +13,10 @@ / {
 	model = "STMicroelectronics STM32MP157A-DK1 SCMI Discovery Board";
 	compatible = "st,stm32mp157a-dk1-scmi", "st,stm32mp157";
 
+	aliases {
+		watchdog0 = &arm_wdt;
+	};
+
 	reserved-memory {
 		optee@de000000 {
 			reg = <0xde000000 0x2000000>;
@@ -21,6 +25,11 @@ optee@de000000 {
 	};
 };
 
+&arm_wdt {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &cpu0 {
 	clocks = <&scmi_clk CK_SCMI_MPU>;
 };
arch/arm/boot/dts/st/stm32mp157c-dk2-scmi.dts +9 -0
index 0790ed426ebc0..41ba8a5b756b1 100644
@@ -13,6 +13,10 @@ / {
 	model = "STMicroelectronics STM32MP157C-DK2 SCMI Discovery Board";
 	compatible = "st,stm32mp157c-dk2-scmi", "st,stm32mp157";
 
+	aliases {
+		watchdog0 = &arm_wdt;
+	};
+
 	reserved-memory {
 		optee@de000000 {
 			reg = <0xde000000 0x2000000>;
@@ -21,6 +25,11 @@ optee@de000000 {
 	};
 };
 
+&arm_wdt {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &cpu0 {
 	clocks = <&scmi_clk CK_SCMI_MPU>;
 };
arch/arm/boot/dts/st/stm32mp157c-ed1-scmi.dts +9 -0
index 0a3894aff4aea..2fad04ed60161 100644
@@ -13,6 +13,10 @@ / {
 	model = "STMicroelectronics STM32MP157C-ED1 SCMI eval daughter";
 	compatible = "st,stm32mp157c-ed1-scmi", "st,stm32mp157";
 
+	aliases {
+		watchdog0 = &arm_wdt;
+	};
+
 	reserved-memory {
 		optee@fe000000 {
 			reg = <0xfe000000 0x2000000>;
@@ -21,6 +25,11 @@ optee@fe000000 {
 	};
 };
 
+&arm_wdt {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &cpu0 {
 	clocks = <&scmi_clk CK_SCMI_MPU>;
 };
arch/arm/boot/dts/st/stm32mp157c-ev1-scmi.dts +9 -0
index c2b6efb1cbb74..d14506e9b6f0e 100644
@@ -13,6 +13,10 @@ / {
 	model = "STMicroelectronics STM32MP157C-EV1 SCMI eval daughter on eval mother";
 	compatible = "st,stm32mp157c-ev1-scmi", "st,stm32mp157c-ed1", "st,stm32mp157";
 
+	aliases {
+		watchdog0 = &arm_wdt;
+	};
+
 	reserved-memory {
 		optee@fe000000 {
 			reg = <0xfe000000 0x2000000>;
@@ -21,6 +25,11 @@ optee@fe000000 {
 	};
 };
 
+&arm_wdt {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &cpu0 {
 	clocks = <&scmi_clk CK_SCMI_MPU>;
 };
Signature · 1 line
2.34.1
#19 lore raw

PATCH v4 12/15 ARM: dts: stm32: add watchdog0 alias on ST stm32mp1xx boards

In reply to Antonio Borneo

With two watchdogs enabled on ST STM32MP1xx boards, assign the watchdog0 alias to the watchdog that may have been started by an earlier boot stage.

This allows userspace to identify and ping the appropriate watchdog.

---
 arch/arm/boot/dts/st/stm32mp135f-dk.dts  | 1 +
 arch/arm/boot/dts/st/stm32mp157f-dk2.dts | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/st/stm32mp135f-dk.dts +1 -0
index 2d6c5af7e4816..bd403acb1577f 100644
@@ -24,6 +24,7 @@ aliases {
 		serial1 = &usart1;
 		serial2 = &uart8;
 		serial3 = &usart2;
+		watchdog0 = &arm_wdt;
 	};
 
 	chosen {
arch/arm/boot/dts/st/stm32mp157f-dk2.dts +1 -0
index 8fa61e54d0261..02697c41a2f6c 100644
@@ -20,6 +20,7 @@ / {
 	aliases {
 		ethernet0 = &ethernet0;
 		serial3 = &usart2;
+		watchdog0 = &arm_wdt;
 	};
 
 	chosen {
Signature · 1 line
2.34.1
#20 lore raw

PATCH v4 13/15 arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp231

In reply to Antonio Borneo

Add the watchdog nodes to the SoC device tree.

---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/st/stm32mp231.dtsi +20 -0
index fefbf6f4f1537..db19429896eb3 100644
@@ -724,6 +724,26 @@ rng: rng@42020000 {
 				status = "disabled";
 			};
 
+			iwdg1: watchdog@44010000 {
+				compatible = "st,stm32mp1-iwdg";
+				reg = <0x44010000 0x400>;
+				interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&rcc CK_BUS_IWDG1>, <&scmi_clk CK_SCMI_LSI>;
+				clock-names = "pclk", "lsi";
+				access-controllers = <&rifsc 98>;
+				status = "disabled";
+			};
+
+			iwdg2: watchdog@44020000 {
+				compatible = "st,stm32mp1-iwdg";
+				reg = <0x44020000 0x400>;
+				interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&rcc CK_BUS_IWDG2>, <&scmi_clk CK_SCMI_LSI>;
+				clock-names = "pclk", "lsi";
+				access-controllers = <&rifsc 99>;
+				status = "disabled";
+			};
+
 			spi8: spi@46020000 {
 				compatible = "st,stm32mp25-spi";
 				reg = <0x46020000 0x400>;
Signature · 1 line
2.34.1
#21 lore raw

PATCH v4 14/15 arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp251

In reply to Antonio Borneo

From: Clément Le Goffic <[email protected]>

Add the watchdog nodes to the SoC device tree.

---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/st/stm32mp251.dtsi +20 -0
index dac3d2d23ff00..02064fd05a259 100644
@@ -1474,6 +1474,26 @@ rng: rng@42020000 {
 				status = "disabled";
 			};
 
+			iwdg1: watchdog@44010000 {
+				compatible = "st,stm32mp1-iwdg";
+				reg = <0x44010000 0x400>;
+				interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&rcc CK_BUS_IWDG1>, <&scmi_clk CK_SCMI_LSI>;
+				clock-names = "pclk", "lsi";
+				access-controllers = <&rifsc 98>;
+				status = "disabled";
+			};
+
+			iwdg2: watchdog@44020000 {
+				compatible = "st,stm32mp1-iwdg";
+				reg = <0x44020000 0x400>;
+				interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&rcc CK_BUS_IWDG2>, <&scmi_clk CK_SCMI_LSI>;
+				clock-names = "pclk", "lsi";
+				access-controllers = <&rifsc 99>;
+				status = "disabled";
+			};
+
 			spi8: spi@46020000 {
 				#address-cells = <1>;
 				#size-cells = <0>;
Signature · 1 line
2.34.1
#22 lore raw

PATCH v4 15/15 arm64: dts: st: enable iwdg2 on stm32mp2xx ST boards

In reply to Antonio Borneo

Enable the node for IWDG2 in the STM32MP2xx ST boards to make the watchdog available for userspace.

With two watchdogs now enabled on ST STM32MP2xx boards, assign the watchdog0 alias to the ARM SMC watchdog that may have been started by an earlier boot stage. This allows userspace to identify and ping the appropriate watchdog.

While there, sort alphabetically the aliases.

---
 arch/arm64/boot/dts/st/stm32mp235f-dk.dts  | 6 ++++++
 arch/arm64/boot/dts/st/stm32mp257f-dk.dts  | 8 +++++++-
 arch/arm64/boot/dts/st/stm32mp257f-ev1.dts | 6 ++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/st/stm32mp235f-dk.dts +6 -0
index f06b334dc9ce1..c71b914547308 100644
@@ -22,6 +22,7 @@ / {
 	aliases {
 		ethernet0 = &ethernet1;
 		serial0 = &usart2;
+		watchdog0 = &arm_wdt;
 	};
 
 	chosen {
@@ -263,6 +264,11 @@ &i2c8 {
 	/delete-property/dma-names;
 };
 
+&iwdg2 {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &ltdc {
 	status = "okay";
 	port {
arch/arm64/boot/dts/st/stm32mp257f-dk.dts +7 -1
index a8f18508db3e4..aa922abccdbc5 100644
@@ -21,9 +21,10 @@ / {
 
 	aliases {
 		ethernet0 = &ethernet1;
-		serial0 = &usart2;
 		mmc0 = &sdmmc1;
 		mmc1 = &sdmmc2;
+		serial0 = &usart2;
+		watchdog0 = &arm_wdt;
 	};
 
 	chosen {
@@ -271,6 +272,11 @@ &i2c8 {
 	/delete-property/dma-names;
 };
 
+&iwdg2 {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 &ltdc {
 	status = "okay";
 	port {
arch/arm64/boot/dts/st/stm32mp257f-ev1.dts +6 -0
index 782b4bb843eeb..dcfc29c620b02 100644
@@ -24,6 +24,7 @@ aliases {
 		ethernet1 = &ethernet1;
 		serial0 = &usart2;
 		serial1 = &usart6;
+		watchdog0 = &arm_wdt;
 	};
 
 	chosen {
@@ -294,6 +295,11 @@ &i2c8 {
 	/delete-property/dma-names;
 };
 
+&iwdg2 {
+	timeout-sec = <32>;
+	status = "okay";
+};
+
 /* use LPTIMER with tick broadcast for suspend mode */
 &lptimer3 {
 	status = "okay";
Signature · 1 line
2.34.1
maintainer
#23 lore raw
In reply to Antonio Borneo
Quoted 10 lines · Antonio Borneo

This series allows the stm32_iwdg watchdog driver to determine whether the watchdog is already running and adds support for STM32MP2xx devices.

It also completes and rationalizes the configuration of secure and non-secure watchdogs across STM32MP devices and ST boards.

For STM32MP1xx devices, it enables the ARM SMC watchdog driver in the machine Kconfig.

Applied: watchdog: stm32_iwdg: set driver data before requesting interrupt
Applied: watchdog: stm32_iwdg: serialize accesses to EWCR register
Applied: watchdog: stm32_iwdg: get hardware version during probe
Applied: watchdog: stm32_iwdg: detect whether the watchdog is running
Applied: watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0

Thanks,
Guenter

maintainer
#24 lore raw
In reply to Antonio Borneo

Hi Antonio

Quoted 82 lines · Antonio Borneo

This series allows the stm32_iwdg watchdog driver to determine whether the watchdog is already running and adds support for STM32MP2xx devices.

It also completes and rationalizes the configuration of secure and non-secure watchdogs across STM32MP devices and ST boards.

For STM32MP1xx devices, it enables the ARM SMC watchdog driver in the machine Kconfig.

Regards,
Antonio

Changes in v4:
- Add two fixes, one detected by Sashiko
- Add access-contollers property to bindingds
- Drop update on stm32mp21x DT since clock framework is still missing
- Add two fixes, one detected by Sashiko
- Integrate Sashiko comments
- Patch v4 06/15 (former v3 04/13) reposted unchanged, waiting for reply from Guenter Roeck
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
- Add support for detecting watchdog running status
- Add pretimeout irq support on STM32MP2xx
- Build ARM SMC watchdog driver on STM32MP1xx
- Use ARM SMC watchdog on platforms that have secure IWDG1 and use the
native stm32_iwdg driver when the IWDG1 is non-secure
- Add iwdg1 and iwdg2 nodes on STM32MP2xx platforms
- Add the alias in device trees to have the system watchdog allocated
as watchdog0, independently from the probe order
- Link to v2: https://lore.kernel.org/lkml/[email protected]/

Changes in v2:
- Drop addition of iwdg1 DT node, not needed as OP-TEE keep the watchdog
secure on all boards;
- Link to v1: https://lore.kernel.org/lkml/[email protected]/

Amelie Delaunay (3):
ARM: dts: stm32: add iwdg1 node on stm32mp151 SoC
ARM: dts: stm32: enable iwdg1 on stm32mp15x ST boards
ARM: dts: stm32: enable arm smc watchdog on stm32mp15x scmi boards

Antonio Borneo (9):
watchdog: stm32_iwdg: set driver data before requesting interrupt
watchdog: stm32_iwdg: serialize accesses to EWCR register
watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0
ARM: stm32: enable arm smc watchdog on stm32mp1xx
dt-bindings: watchdog: st,stm32-iwdg: add access-controllers property
ARM: dts: stm32: move arm smc watchdog to stm32mp151 SoC
ARM: dts: stm32: add watchdog0 alias on ST stm32mp1xx boards
arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp231
arm64: dts: st: enable iwdg2 on stm32mp2xx ST boards

Clément Le Goffic (3):
watchdog: stm32_iwdg: get hardware version during probe
watchdog: stm32_iwdg: detect whether the watchdog is running
arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp251

  .../bindings/watchdog/st,stm32-iwdg.yaml      |  3 +
  arch/arm/boot/dts/st/stm32mp135f-dk.dts       |  1 +
  arch/arm/boot/dts/st/stm32mp15-scmi.dtsi      |  4 +
  arch/arm/boot/dts/st/stm32mp151.dtsi          | 16 ++++
  arch/arm/boot/dts/st/stm32mp157a-dk1-scmi.dts |  9 ++
  arch/arm/boot/dts/st/stm32mp157c-dk2-scmi.dts |  9 ++
  arch/arm/boot/dts/st/stm32mp157c-ed1-scmi.dts |  9 ++
  arch/arm/boot/dts/st/stm32mp157c-ed1.dts      |  6 ++
  arch/arm/boot/dts/st/stm32mp157c-ev1-scmi.dts |  9 ++
  .../arm/boot/dts/st/stm32mp157f-dk2-scmi.dtsi |  7 --
  arch/arm/boot/dts/st/stm32mp157f-dk2.dts      |  1 +
  arch/arm/boot/dts/st/stm32mp15xx-dkx.dtsi     |  6 ++
  arch/arm/mach-stm32/Kconfig                   |  2 +
  arch/arm64/boot/dts/st/stm32mp231.dtsi        | 20 +++++
  arch/arm64/boot/dts/st/stm32mp235f-dk.dts     |  6 ++
  arch/arm64/boot/dts/st/stm32mp251.dtsi        | 20 +++++
  arch/arm64/boot/dts/st/stm32mp257f-dk.dts     |  8 +-
  arch/arm64/boot/dts/st/stm32mp257f-ev1.dts    |  6 ++
  drivers/watchdog/stm32_iwdg.c                 | 86 +++++++++++++++----
  19 files changed, 201 insertions(+), 27 deletions(-)
Quoted 1 line

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

DT patches applied on stm32-next. Config patch has been dropped.

regards
Alex