drivers: rtc: Add support for RTC for stm32n6 series#106527
drivers: rtc: Add support for RTC for stm32n6 series#106527aescolar merged 1 commit intozephyrproject-rtos:mainfrom
Conversation
| #ifdef CONFIG_SOC_SERIES_STM32N6X | ||
| /* STM32N6 series need RTC enabled in Sleep mode to count during idle thread */ | ||
| LL_RCC_EnableRTC_LP(); | ||
| #endif /* CONFIG_SOC_SERIES_STM32N6X */ |
There was a problem hiding this comment.
@basilegrunersmile Is that strictly required ?
Can't this just eb enabled via a call to clock_control_on?
Also note that clock_control_on on N6 always enable LP clock:
zephyr/drivers/clock_control/clock_stm32_ll_n6.c
Lines 210 to 212 in 6182bc0
There was a problem hiding this comment.
clock_control_on\ is called here by rtc_stm32_init` :
zephyr/drivers/rtc/rtc_stm32.c
Lines 488 to 492 in 6182bc0
After further investigation, it appears that this call does not affect RCC_APB4LLPENR register (rm0486) because access to backup domain is disabled.
If I modify rtc_stm32_init like this, it works for nucleo n657x0 Q :
stm32_backup_domain_enable_access();
/* Enable RTC bus clock */
if (clock_control_on(clk, (clock_control_subsys_t)&cfg->pclken[0]) != 0) {
LOG_ERR("clock op failed\n");
return -EIO;
}
But I don't know how it can affect other boards.
Registers values before moving stm32_backup_domain_enable_access :
(gdb) x/1xw 0x56028274
0x56028274: 0x00038000
(gdb) x/1xw 0x560282B4
0x560282b4: 0x00000000
Registers values after moving stm32_backup_domain_enable_access :
(gdb) x/1xw 0x56028274
0x56028274: 0x00038000
(gdb) x/1xw 0x560282B4
0x560282b4: 0x00010000
There was a problem hiding this comment.
You can put it under a series specific #ifdef. Or it won't probably hurt other series anyway.
0999a55 to
df4fa83
Compare
|
Force pushed to solve merge conflict. |
There was a problem hiding this comment.
LGTM.
To get the full RTC be tested by default on these boards, could you also at in boards/st/{nucleo_n657x0_q|stm32n6570_dk}/Kconfig.defconfig:
endif # VIDEO
+if RTC_STM32
+
+configdefault RTC_ALARM
+ default y
+
+configdefault RTC_CALIBRATION
+ default y
+
+endif # RTC_STM32
+
endif # BOARD_STM32N6570_DKon the model of #107342?
| #if defined(CONFIG_SOC_SERIES_STM32N6X) | ||
| /* STM32N6 needs backup domain access before configuring RTC clock */ | ||
| stm32_backup_domain_enable_access(); | ||
| #endif /* CONFIG_SOC_SERIES_STM32N6X */ |
There was a problem hiding this comment.
For sake of simplicity of the code, it would be worth to always enable backup domain here, before RTC clock is enabled, IMHO. Not a blocking comment.
6c8b123 to
2cb6720
Compare
etienne-lms
left a comment
There was a problem hiding this comment.
Could you add in the commit log someething like Enable by default RTC alarm and calibration on Nucleo-N657x0-Q and STM32N6570-DK when STM32 RTC is enabled?
Otherwise LGTM.
2cb6720 to
bbab766
Compare
bbab766 to
1c8d835
Compare
etienne-lms
left a comment
There was a problem hiding this comment.
Could you also add rtc to the supported tags in boards/st/stm32n6570_dk/twister.yaml and boards/st/nucleo_n657x0_q/twister.yaml?
Add rtc node on stm32n6 DT. Enable backup domain access before RTC clock configuration and not after. Add rtc to the supported tags Signed-off-by: Basile GRUNER <basile.gruner@smile.fr>
1c8d835 to
131649f
Compare
|
etienne-lms
left a comment
There was a problem hiding this comment.
LGTM.
I wonder if it would be better to be split in to 2 commits: one for changes in drivers/rtc/...+dts/... and one for thoses in boards/.... Non-blocking.
|
|
||
| int err = 0; | ||
|
|
||
| stm32_backup_domain_enable_access(); |
There was a problem hiding this comment.
I would strongly recommend adding a comment explaining why this must go before clock_control_on() to ensure this isn't moved again by accident. (Even to me right now, I'm not sure I understand the rationale...)



This PR aims to add support for RTC on stm32n6 series.
Related Feature Request : #100667
It also provides an overlay for RTC sample for Nucleo n657x0 Q