soc/arm/silabs: support BLE with PM in Series 2 SoCs

Using EM2 or deeper sleep states (where HF clocks are off) requires
special care if BLE radio is used, since BLE radio relies on that clock,
and its power/clock requirements need to be taken into account
On SiLabs, radio PM is implemented as part of RAIL blob, which relies
on sl_power_manager HAL service. I've implemented SoC PM
state changes using sl_power_manager instead of emlib, and added
call to RAIL PM initialization in Gecko HCI driver.

Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
This commit is contained in:
Roman Dobrodii 2023-05-11 18:09:24 +02:00 committed by Anas Nashif
commit defb159ab1
9 changed files with 156 additions and 10 deletions

View file

@ -70,7 +70,7 @@ static atomic_t g_last_count;
static struct k_spinlock g_lock;
/* Set to true when timer is initialized */
static atomic_t g_init = ATOMIC_INIT(0);
static bool g_init;
static void burtc_isr(const void *arg)
{
@ -161,12 +161,10 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
uint32_t sys_clock_elapsed(void)
{
if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL) || !g_init) {
return 0;
} else if (atomic_get(&g_init)) {
return (BURTC_CounterGet() - g_last_count) / g_cyc_per_tick;
} else {
return 0;
return (BURTC_CounterGet() - g_last_count) / g_cyc_per_tick;
}
}
@ -176,10 +174,10 @@ uint32_t sys_clock_cycle_get_32(void)
* a value of some 32-bit hw_cycles counter which counts with
* z_clock_hw_cycles_per_sec frequency
*/
if (atomic_get(&g_init)) {
return BURTC_CounterGet();
} else {
if (!g_init) {
return 0;
} else {
return BURTC_CounterGet();
}
}
@ -222,7 +220,7 @@ static int burtc_init(void)
init.clkDiv = 1;
init.start = false;
BURTC_Init(&init);
atomic_set(&g_init, 1);
g_init = true;
/* Enable compare match interrupt */
BURTC_IntClear(BURTC_IF_COMP);