Skip to content

Commit 9bb5d1e

Browse files
gellhaarkartben
authored andcommitted
soc: stm32wb: fix ble low-power
Release HSI CLK48 semaphore when going to sleep to allow C2 (M0) core to start and stop clock as needed while C1 core is not running. CLK48 is shared between RNG and USB. RNG is needed by M0 during BLE advertisement. If semaphore is locked, C2 core can start it when it needs to but not stop it. Fixes zephyrproject-rtos#69955. Signed-off-by: Jonny Gellhaar <[email protected]>
1 parent 0d02cdc commit 9bb5d1e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

soc/st/stm32/stm32wbx/power.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <zephyr/pm/pm.h>
88
#include <soc.h>
99
#include <zephyr/init.h>
10+
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
1011

1112
#include <stm32wbxx_ll_utils.h>
1213
#include <stm32wbxx_ll_bus.h>
@@ -85,6 +86,17 @@ void pm_state_set(enum pm_state state, uint8_t substate_id)
8586
return;
8687
}
8788

89+
if (IS_ENABLED(STM32_HSI48_ENABLED)) {
90+
/*
91+
* Release CLK48 semaphore to make sure M0 core can enable/disable
92+
* it as needed (shared between RNG and USB peripheral, M0 uses RNG
93+
* during BLE advertisement phase). It seems like if left locked M0
94+
* can enable the clock if needed but is not able (allowed) to stop
95+
* it, with increased power consumption as a result.
96+
*/
97+
z_stm32_hsem_unlock(CFG_HW_CLK48_CONFIG_SEMID);
98+
}
99+
88100
/* Release RCC semaphore */
89101
z_stm32_hsem_unlock(CFG_HW_RCC_SEMID);
90102

0 commit comments

Comments
 (0)