Skip to content

stm32mp2: add wwdg1 and iwdg4 support #92319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lucbeaufils
Copy link
Contributor

This PR adds support for non-secure world M33 watchdogs.

Signed-off-by: Luc BEAUFILS luc.beaufils@savoirfairelinux.com

Like the H7x series, the MP2x series has a WWDG1 peripheral in the APB3
bus. The MP2 has the same LL function to freeze the watchdog in debug
mode.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
Add clock binding for WWDG1 peripheral in STM32MP2 series.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
Add the wwdg1 node, which is the wwdg for non-secure world.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
Copy link
Contributor

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you reorder commits to group them per peripherals? for instance first the WWDG then the IWDG commits?
with that LGTM

WWDG1 clock = ((MCU clock / LSMCU div) /APB3 prescaler)

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
The IWDG4 is on the APB3 bus on STM32MP2x SoCs. When the system is
in debug mode, the watchdog should be frozen to prevent it from
expiring and resetting the system during debugging sessions.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
Add the IWDG4 clock definition to the STM32MP2 clock bindings.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
This is the independent watchdog for the non-secure world of M33 core.

Signed-off-by: Luc BEAUFILS <luc.beaufils@savoirfairelinux.com>
@lucbeaufils lucbeaufils force-pushed the stm32mp2_peripheral_watchdog branch from dabb4f7 to 344a37f Compare June 30, 2025 07:13
@lucbeaufils lucbeaufils requested a review from arnopo June 30, 2025 07:14
Copy link

@@ -72,6 +72,11 @@ static int stm32_clock_control_get_subsys_rate(const struct device *dev,
case STM32_CLOCK_PERIPH_UART9:
*rate = LL_RCC_GetUARTClockFreq(LL_RCC_UART9_CLKSOURCE);
break;
case STM32_CLOCK_PERIPH_WWDG1:
/* The WWDG1 clock is derived from the APB3 clock */
int wwdg1_clock = 400000000 >> LL_RCC_Get_LSMCUDIVR();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should be able to retrieve the frequency instead of hardcoding it.
Seems that it is not implemented in LL.

@erwango : any advice to solve this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In STM32 MCU ports, this value comes from DT. So you can put in DT, but it should be somehow sync'ed with A4.
Alternatively, you may have HAL functions to query it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants