Skip to content

Conversation

@smalae
Copy link
Contributor

@smalae smalae commented Apr 17, 2025

Enable sleeptimer counter driver for siwx91x device

Enable the counter driver for Sleep Timer module for Silicon Labs
Gecko chips.

if SOC_FAMILY_SILABS_SIWX91X
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why a new Kconfig option needs to be added, the existing one should be sufficient and work for both Series 2 and SiWx91x.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, updated accordingly.

static void counter_gecko_0_irq_config(void)
{
IRQ_DIRECT_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), STIMER_IRQ_HANDLER, 0);
IRQ_DIRECT_CONNECT(DT_IRQ(DT_RTC, irq), DT_IRQ(DT_RTC, priority),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The responsibility of interrupt configuration between the Timer and Counter drivers needs to be decided, they shouldn't both configure it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using sl_sleeptimer_get_timer_frequency() to identify the driver initialization. By default, it always returns 0 unitl sl_sleeptimer_init() is called. Hope this is okay.

Copy link
Contributor

@asmellby asmellby Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the IRQ_(DIRECT_)CONNECT macro puts things into linker sections, the code doesn't need to execute. So wrapping it in an if statement doesn't prevent it from registering the interrupt. Only one source file should contain the macro at all. IMO either a) the counter driver should depend on the OS timer driver and never touch the interrupt, b) the interrupt registration should be moved to a shared file (soc.c?) guarded by #if defined(counter_sleeptimer) || defined(timer_sleeptimer), or c) the interrupt registration in the counter driver should be guarded by #ifndef timer_sleeptimer. Not sure which option is the best.

Also consider initialization order -- the counter driver is pre-kernel 1 and the timer driver is pre-kernel 2, so the timer driver is never initialized when counter init runs with the current priorities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #ifndef CONFIG_SILABS_SLEEPTIMER_TIMER guard in counter driver. Also, changes the counter driver init priority to POST_KERNEL.

@smalae smalae force-pushed the silabs_siwx91x_counter_driver branch from c5be94f to 5080583 Compare April 29, 2025 06:41
@github-actions github-actions bot added the area: Timer Timer label Apr 29, 2025
@github-actions github-actions bot requested review from andyross and teburd April 29, 2025 06:42
@smalae smalae force-pushed the silabs_siwx91x_counter_driver branch 2 times, most recently from 7687c00 to 0c7525d Compare April 29, 2025 06:52
@smalae smalae requested a review from asmellby April 29, 2025 06:55
@smalae smalae force-pushed the silabs_siwx91x_counter_driver branch from 0c7525d to eada131 Compare April 30, 2025 06:06
Copy link
Contributor

@jerome-pouiller jerome-pouiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine. However, I have to admit I don't understand how interactions between gecko_stimer and sleeptimer_timer are supposed to work. Maybe we should expand the binding documentation.

@smalae
Copy link
Contributor Author

smalae commented May 8, 2025

The code looks fine. However, I have to admit I don't understand how interactions between gecko_stimer and sleeptimer_timer are supposed to work. Maybe we should expand the binding documentation.

will update this

@github-actions github-actions bot added the area: RTC Real Time Clock label May 9, 2025
@github-actions github-actions bot requested a review from bjarki-andreasen May 9, 2025 18:21
@smalae smalae requested a review from jerome-pouiller May 9, 2025 18:21
@smalae smalae force-pushed the silabs_siwx91x_counter_driver branch 2 times, most recently from 7330676 to aae929c Compare May 12, 2025 06:22
smalae added 2 commits May 12, 2025 12:28
Enable sleeptimer counter driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
Add detailed description for silabs,gecko-stimer.yaml
binding.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
@smalae smalae force-pushed the silabs_siwx91x_counter_driver branch from aae929c to 62dd8bf Compare May 12, 2025 07:01
@sonarqubecloud
Copy link

@jhedberg jhedberg self-assigned this May 13, 2025
@kartben kartben merged commit 0bce31b into zephyrproject-rtos:main May 13, 2025
26 checks passed
@smalae smalae deleted the silabs_siwx91x_counter_driver branch August 22, 2025 05:40
@smalae smalae restored the silabs_siwx91x_counter_driver branch August 22, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants