-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: rtc: STM32 rtc scalers #89313
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
base: main
Are you sure you want to change the base?
drivers: rtc: STM32 rtc scalers #89313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some doubts about the motivation behind this change and if it is actually required.
Please clarify and see comments to make the usage of these new properties fully clear to user.
Also, this compatible is STM32 generic so please remove STM32U5 from the title and provide a more detailled description about the usefulness of this change
5e3f372
to
2db263e
Compare
Allow RTC prescalers to be configurable via dts Signed-off-by: Jake Greaves <[email protected]>
2db263e
to
d09764a
Compare
Ready for re-review. This was needed to make the most use out of the RTC sub second register, giving our RTC timestamping accuracy of up to 30.5us |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for this part.
However (and it seems you're bound to hit all the corner cases in our drivers):
- There's already a
prescaler
part ofst,stm32-rtc
binding inherited fromrtc.yaml
. No impact from what I could see but worse to be cross-checked - This binding also applies to
drivers/counter/counter_ll_stm32_rtc.c
driver, which implements these prescalers in a different way and we're not supposed to make properties specific to a driver ("compatible is supposed to describe hardware"). So you'd need to align also counter rtc driver to make use of those (which is a more consequent clean up I'm affraid)
I cross checked the existing prescaler and I also don't see a conflict. I've refactored the rtc counter driver to include the new prescaler override options |
85ccb70
to
57d6954
Compare
57d6954
to
5388d4d
Compare
cce5cbf
to
9a45464
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greavesinator85, could you move all changes related to coding style into a dedicated commit?
Commit "drivers: counter: STM32 rtc counter" header line should be rephrased IMHO, to something like drivers: counter: stm32: config RTC prescaler from DT
.
defined(CONFIG_SOC_SERIES_STM32L0X) || defined(CONFIG_SOC_SERIES_STM32L1X) || \ | ||
defined(CONFIG_SOC_SERIES_STM32L5X) || defined(CONFIG_SOC_SERIES_STM32H7X) || \ | ||
defined(CONFIG_SOC_SERIES_STM32H5X) || defined(CONFIG_SOC_SERIES_STM32WLX) | ||
#define RTC_EXTI_LINE LL_EXTI_LINE_17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change? I would suggest to discard it.
Ditto for changes on tick_t
type definition and added space char to #endif
directive line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
static int rtc_stm32_start(const struct device *dev) | ||
{ | ||
#if defined(CONFIG_SOC_SERIES_STM32WBAX) || defined(CONFIG_SOC_SERIES_STM32U5X) | ||
const struct device *const clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE); | ||
const struct rtc_stm32_config *cfg = dev->config; | ||
|
||
/* Enable RTC bus clock */ | ||
if (clock_control_on(clk, (clock_control_subsys_t) &cfg->pclken[0]) != 0) { | ||
if (clock_control_on(clk, (clock_control_subsys_t)&cfg->pclken[0]) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be in favor of such a change. However I think it deserved a specific commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed formatting changes from this PR
dts/bindings/rtc/st,stm32-rtc.yaml
Outdated
when HSE is selected as the source clock. | ||
RTC HSE prescaler value. Optional, if not set defaulted in code to: | ||
- not used if source clock is LSE/LSI | ||
- value calculated based on HSE clock frequency if RTC source clock is HSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest another phrasing:
RTC HSE prescaler value. Applies only when RTC source clock is HSE.
Optional, defaulting to the value calculated based on HSE clock frequency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to reflect this
9284f8e
to
fe2a86e
Compare
Handle RTC prescaler options inside RTC counter driver Signed-off-by: Jake Greaves <[email protected]>
fe2a86e
to
8bf4e52
Compare
|
Allow RTC prescalers to be configurable via dts.
Prescalers can now be adjusted to give more accurate RTC readings, up to 30.5us on LSI/LSE