From 132289ec339a9bc579dd08bca1a720f928a06ea6 Mon Sep 17 00:00:00 2001 From: Matt Ihnen Date: Wed, 16 Apr 2025 08:55:24 -0500 Subject: [PATCH] drivers: entropy: stm32: fix compile errors for STM32L4 series The low level function names in the stm32l4xx low level driver are different than all the other stm32's even though the functionality is the same. This breaks the entropy module for these parts. This patch fixes the build and has been tested on a custom stm32l4p5 board. This STM32CubeL4 issue has been reported (ST Internal Reference: 207828). Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/88621 Signed-off-by: Matt Ihnen --- drivers/entropy/entropy_stm32.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/entropy/entropy_stm32.c b/drivers/entropy/entropy_stm32.c index 1f76d3b5126..4aa0cf1d9e5 100644 --- a/drivers/entropy/entropy_stm32.c +++ b/drivers/entropy/entropy_stm32.c @@ -232,10 +232,17 @@ static void configure_rng(void) LL_RNG_SetHealthConfig(rng, desired_htcr); #endif /* health_test_config */ +#if defined(CONFIG_SOC_SERIES_STM32L4X) + LL_RNG_ResetConditioningResetBit(rng); + /* Wait for conditioning reset process to be completed */ + while (LL_RNG_IsResetConditioningBitSet(rng) == 1) { + } +#else LL_RNG_DisableCondReset(rng); /* Wait for conditioning reset process to be completed */ while (LL_RNG_IsEnabledCondReset(rng) == 1) { } +#endif /* CONFIG_SOC_SERIES_STM32L4X */ } #endif /* STM32_CONDRST_SUPPORT */ @@ -285,13 +292,23 @@ static int recover_seed_error(RNG_TypeDef *rng) { uint32_t count_timeout = 0; - LL_RNG_EnableCondReset(rng); - LL_RNG_DisableCondReset(rng); +#if defined(CONFIG_SOC_SERIES_STM32L4X) + LL_RNG_SetConditioningResetBit(rng); + LL_RNG_ResetConditioningResetBit(rng); +#else + LL_RNG_EnableCondReset(rng); + LL_RNG_DisableCondReset(rng); +#endif /* CONFIG_SOC_SERIES_STM32L4X */ + /* When reset process is done cond reset bit is read 0 * This typically takes: 2 AHB clock cycles + 2 RNG clock cycles. */ +#if defined(CONFIG_SOC_SERIES_STM32L4X) + while (LL_RNG_IsResetConditioningBitSet(rng) || +#else while (LL_RNG_IsEnabledCondReset(rng) || +#endif /* CONFIG_SOC_SERIES_STM32L4X */ ll_rng_is_active_seis(rng) || ll_rng_is_active_secs(rng)) { count_timeout++;