drivers: counter: gecko: Add SYSRTC stimer support

SiLabs' sleeptimer driver supports several hardware peripherals, of
which the counter driver so far only supports the RTCC-based variant.

This patch adds support for the SYSRTC-based sleeptimer implementation,
which is required for Gecko SoCs that do not have an RTCC module.

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
This commit is contained in:
Markus Fuchs 2023-07-28 14:27:42 +02:00 committed by Fabio Baltieri
parent 8474cdcaad
commit 27af62603c
4 changed files with 16 additions and 5 deletions

View file

@ -18,6 +18,7 @@ config COUNTER_GECKO_STIMER
default y
depends on DT_HAS_SILABS_GECKO_STIMER_ENABLED
select SOC_GECKO_RTCC
select SOC_GECKO_PRS
help
Enable the counter driver for Sleep Timer module for Silicon Labs
Gecko chips.

View file

@ -18,10 +18,20 @@
#include <em_cmu.h>
#include <sl_atomic.h>
#include <sl_sleeptimer.h>
#include <sli_sleeptimer_hal.h>
LOG_MODULE_REGISTER(counter_gecko, CONFIG_COUNTER_LOG_LEVEL);
#define STIMER_MAX_VALUE (_RTCC_CNT_MASK)
#if SL_SLEEPTIMER_PERIPHERAL == SL_SLEEPTIMER_PERIPHERAL_RTCC
#define STIMER_IRQ_HANDLER RTCC_IRQHandler
#define STIMER_MAX_VALUE _RTCC_CNT_MASK
#elif SL_SLEEPTIMER_PERIPHERAL == SL_SLEEPTIMER_PERIPHERAL_SYSRTC
#define STIMER_IRQ_HANDLER SYSRTC_APP_IRQHandler
#define STIMER_MAX_VALUE _SYSRTC_CNT_MASK
#else
#error "Unsupported sleep timer peripheral"
#endif
#define STIMER_ALARM_NUM 2
struct counter_gecko_config {
@ -270,7 +280,7 @@ BUILD_ASSERT((DT_INST_PROP(0, prescaler) > 0U) && (DT_INST_PROP(0, prescaler) <=
static void counter_gecko_0_irq_config(void)
{
IRQ_DIRECT_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), RTCC_IRQHandler, 0);
IRQ_DIRECT_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), STIMER_IRQ_HANDLER, 0);
irq_enable(DT_INST_IRQN(0));
}

View file

@ -199,8 +199,8 @@ config SOC_GECKO_DEV_INIT
config COUNTER_GECKO_STIMER
bool
help
Enable counter driver based on RTCC module for Silicon Labs Gecko
chips.
Enable counter driver based on the Sleep Timer driver for Silicon Labs
Gecko chips.
config SOC_GECKO_CMU
bool

View file

@ -219,7 +219,7 @@ manifest:
groups:
- hal
- name: hal_silabs
revision: fbb47a4067c460a2c26917ff34189fb4f32f654f
revision: d184c2ccc0ec5a7189d6d5cb7645c7f9bd38c2b5
path: modules/hal/silabs
groups:
- hal