From bef7a89823167059e4cd73de8ba0465fd4dd6a48 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Tue, 3 Jan 2023 14:27:26 +0100 Subject: [PATCH] drivers: clock_control: stm32wb: Lock CLK48 hsem On stm32wb, M0 core may enable and disable CLK48 when using RNG. Lock related hsem to prevent M0 to disable CLK48 when it doesn't need it anymore. Signed-off-by: Erwan Gouriou --- drivers/clock_control/clock_stm32_ll_common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/clock_control/clock_stm32_ll_common.c b/drivers/clock_control/clock_stm32_ll_common.c index 46e3b38b99f..3edbc649e41 100644 --- a/drivers/clock_control/clock_stm32_ll_common.c +++ b/drivers/clock_control/clock_stm32_ll_common.c @@ -640,6 +640,13 @@ static void set_up_fixed_clock_sources(void) LL_SYSCFG_VREFINT_EnableHSI48(); #endif /* CONFIG_SOC_SERIES_STM32L0X */ + /* + * STM32WB: Lock the CLK48 HSEM and do not release to prevent + * M0 core to disable this clock (used for RNG on M0). + * No-op on other series. + */ + z_stm32_hsem_lock(CFG_HW_CLK48_CONFIG_SEMID, HSEM_LOCK_DEFAULT_RETRY); + LL_RCC_HSI48_Enable(); while (LL_RCC_HSI48_IsReady() != 1) { }