Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver: sleeptimer: siwx917: Add siwx91x Sleeptimer driver #87603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fimohame
Copy link

This commit enables the Sleeptimer driver support for the siwx917 device.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Mar 25, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_silabs zephyrproject-rtos/hal_silabs@9d32354 (main) zephyrproject-rtos/hal_silabs#93 zephyrproject-rtos/hal_silabs#93/files

DNM label due to: 1 project with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_silabs DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Mar 25, 2025
@fimohame fimohame force-pushed the siwx91x-sleeptimer branch from 349e9e6 to 4a67912 Compare March 25, 2025 06:20
@fimohame fimohame marked this pull request as ready for review March 25, 2025 08:01
@jhedberg
Copy link
Member

@fimohame how is this different from #87550? Why did you close that one?

@fimohame
Copy link
Author

I was not able to checkout to that branch... ran into some issues. Wasn't able to access it. Thus created an another branch resolving the compliance issue

@jhedberg
Copy link
Member

I was not able to checkout to that branch... ran into some issues. Wasn't able to access it. Thus created an another branch resolving the compliance issue

You shouldn't need to create a new branch or PR to fix such issues, rather you should be able to just git push --force to the original branch.

@fimohame
Copy link
Author

Noted.

reg = <0x24048c00 0x78>;
interrupts = <22 0>;
interrupt-parent = <&nvic>;
interrupt-names = "irq022";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide a meaningful name for the user?

Copy link
Author

Choose a reason for hiding this comment

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

IRQ_CONNECT(DT_IRQ(DT_RTC, irq), DT_IRQ(DT_RTC, priority),
CONCAT(DT_STRING_UPPER_TOKEN_BY_IDX(DT_RTC, interrupt_names, 0), _IRQHandler),
0, 0);
for 917 it requires to be _Handler instead...
dtsi we could keep it as systrc & in dts we could name it as irq022.. @jerome-pouiller what's your say on it?

Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above: if the upstream is okay, we solve the issue by defining an alias to IRQ022_Handler.

interrupts = <22 0>;
interrupt-parent = <&nvic>;
interrupt-names = "irq022";
clock-frequency = <32768>;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use <DT_FREQ_K(32)>

Copy link
Author

Choose a reason for hiding this comment

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

Use will take it up.. will be addressed

compatible = "silabs,gecko-stimer";
reg = <0x24048c00 0x78>;
interrupts = <22 0>;
interrupt-parent = <&nvic>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it required? Until now, we didn't specified the interrupt controller.

Copy link
Author

@fimohame fimohame Mar 25, 2025

Choose a reason for hiding this comment

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

I have updated the changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree with jérome, actually in the dtsi of other board, we do not used interrupt-parent, why it is needed ?

default n if SILABS_SLEEPTIMER_TIMER

configdefault SYS_CLOCK_TICKS_PER_SEC
default 1024 if SILABS_SLEEPTIMER_TIMER
Copy link
Contributor

Choose a reason for hiding this comment

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

@asmellby has found 1024 was not enough to pass Zephyr timer tests. Maybe:

configdefault SYS_CLOCK_TICKS_PER_SEC
	default 128 if !TICKLESS_KERNEL && SILABS_SLEEPTIMER_TIMER
	default 32768 if SILABS_SLEEPTIMER_TIMER

Copy link
Author

Choose a reason for hiding this comment

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

When checked zephyr timer fails with the above configurations, where with 1024 it passes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

which zephyr timer test have you done ?

Copy link
Author

Choose a reason for hiding this comment

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

behaviour_timer test app

Copy link
Contributor

Choose a reason for hiding this comment

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

32768 makes sense on EFR32, since that's what is used in SiSDK. Wiseconnect uses 1024 in FreeRTOS, though, so IMO it makes sense to keep it the same here.

@@ -3,6 +3,15 @@

if SOC_FAMILY_SILABS_SIWX91X

configdefault SILABS_SLEEPTIMER_TIMER
default y
Copy link
Contributor

Choose a reason for hiding this comment

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

SLEEPTIMER has some drawbacks. Maybe default y if PM?

@@ -151,5 +152,32 @@ if(CONFIG_WISECONNECT_NETWORK_STACK)
)
endif() # CONFIG_WISECONNECT_NETWORK_STACK

# Sleeptimer for 917 devices
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment only repeats the code. Drop it.

bool
select CODE_DATA_RELOCATION
help
Set if the Sleeptimer HAL module is used for SIWX91X.
Copy link
Contributor

Choose a reason for hiding this comment

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

Bad indentation

@@ -121,9 +121,15 @@ static int sleeptimer_init(void)
sl_status_t status = SL_STATUS_OK;
struct sleeptimer_timer_data *timer = &g_sleeptimer_timer_data;

#ifdef CONFIG_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 am annoyed with that. A driver should be independent of the underlying SoC.

Copy link
Author

Choose a reason for hiding this comment

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

IRQ_CONNECT(DT_IRQ(DT_RTC, irq), DT_IRQ(DT_RTC, priority),
	    CONCAT(DT_STRING_UPPER_TOKEN_BY_IDX(DT_RTC, interrupt_names, 0), _IRQHandler),
	    0, 0); 
for efr it's been concat with _IRQHandler so I have defined with way for 91x.. 

Is there any other ways we could handle it?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems wiseconnect define some aliases for compliance with cmsis:

#define UDMA0_IRQHandler       IRQ033_Handler
#define UDMA1_IRQHandler       IRQ010_Handler
#define I2S0_IRQHandler        IRQ064_Handler
#define I2S1_IRQHandler        IRQ014_Handler
#define I2C0_IRQHandler        IRQ042_Handler
#define I2C1_IRQHandler        IRQ061_Handler
#define I2C2_IRQHandler        IRQ013_Handler
#define WDT_IRQHandler         IRQ020_Handler

Do you think the upstream would be okay to add an alias for IRQ022?

Copy link
Author

Choose a reason for hiding this comment

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

I'm certainly not sure, @asmellby could you please provide your thoughts

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that if we can put such a define in an appropriate header, that would make it cleaner. It would honestly be even better if the function name for the ISR was part of the sleeptimer interface, but that's not the case.
I suggest putting the alias in soc/silabs/silabs_siwx91x/siwg917/soc.h for now.

@@ -16,6 +16,7 @@ zephyr_compile_definitions(
SLI_SI91X_MCU_INTERFACE
SLI_SI917
SLI_SI917B0
SLI_SI91X_ENABLE_OS
Copy link
Contributor

Choose a reason for hiding this comment

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

I have not been able to find documentation for this symbols. What it is doing?

Copy link
Author

Choose a reason for hiding this comment

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

In sl_sleeptimer_hal_si91x_sysrtc.c as part of sleeptimer_hal_init_timer
#ifdef SLI_SI91X_ENABLE_OS
//Giving higher priority to SYSRTC to service wakeup
NVIC_SetPriority(NPSS_TO_MCU_SYRTC_INTR_IRQn, SYSRTC_IRQ_PRIORITY);
#endif

To enable OS --> Add SLI_SI91X_ENABLE_OS in preprocessor */

Copy link
Contributor

Choose a reason for hiding this comment

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

Interrupts are normally managed by Zephyr. Typically, we have to apply the priority defined in the DT (interrupts = <22 0>).

SL_CODE_COMPONENT_SLEEPTIMER=sleeptimer
SL_CODE_COMPONENT_HAL_SYSRTC=hal_sysrtc
)
endif() # CONFIG_SOC_SILABS_SLEEPTIMER
Copy link
Contributor

Choose a reason for hiding this comment

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

This section is redundant with modules/hal_silabs/simplicity_sdk/CMakeLists.txt. Maybe we should split the SOC_SILABS_SLEEPTIMER symbol in smaller parts:

config SOC_SILABS_SLEEPTIMER
        depends on SOC_SILABS_SIWX91X_SYSRTC || SOC_SILABS_S2_SYSRTC

@asmellby what is your opinion here?

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to clean up the HAL level Kconfig symbols in general. Symbols are being mixed between the GSDK and SiSDK HALs, and the scope of symbols is often tied to their use in Zephyr, rather than the feature they provide from the HAL. We should redo all the SiSDK symbols to properly map to SiSDK drivers, which will make them more easily composable and reusable for SiWx91x. But that should be a separate PR from this one.

@fimohame fimohame force-pushed the siwx91x-sleeptimer branch from 4a67912 to 0116259 Compare March 25, 2025 16:01
This commit enables the Sleeptimer driver support for the siwx917 device.

Signed-off-by: S Mohamed Fiaz <fiaz.mohamed@silabs.com>
@fimohame fimohame force-pushed the siwx91x-sleeptimer branch from 0116259 to 1e31504 Compare March 26, 2025 11:15
if SOC_FAMILY_SILABS_SIWX91X
source "soc/silabs/silabs_siwx91x/Kconfig"
endif

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this addition is redundant with rsource "*/Kconfig" above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Timer Timer DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-hal_silabs platform: Silabs Silicon Labs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants