Skip to content

Commit 5e3f372

Browse files
drivers: rtc: STM32U5XX rtc scalers
Allow RTC prescalers to be configurable via dts Signed-off-by: Jake Greaves <jake.greaves@analog.com>
1 parent fb1d078 commit 5e3f372

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/rtc/rtc_ll_stm32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,12 +1114,12 @@ BUILD_ASSERT(DT_INST_CLOCKS_HAS_IDX(0, 1), "RTC source clock not defined in the
11141114
static const struct rtc_stm32_config rtc_config = {
11151115
#if DT_INST_CLOCKS_CELL_BY_IDX(0, 1, bus) == STM32_SRC_LSI
11161116
/* prescaler values for LSI @ 32 KHz */
1117-
.async_prescaler = 0x7F,
1118-
.sync_prescaler = 0x00F9,
1117+
.async_prescaler = DT_INST_PROP_OR(0, async_prescaler, 0x7F),
1118+
.sync_prescaler = DT_INST_PROP_OR(0, sync_prescaler, 0x00FF),
11191119
#elif DT_INST_CLOCKS_CELL_BY_IDX(0, 1, bus) == STM32_SRC_LSE
11201120
/* prescaler values for LSE @ 32768 Hz */
1121-
.async_prescaler = 0x7F,
1122-
.sync_prescaler = 0x00FF,
1121+
.async_prescaler = DT_INST_PROP_OR(0, async_prescaler, 0x7F),
1122+
.sync_prescaler = DT_INST_PROP_OR(0, sync_prescaler, 0x00FF),
11231123
#elif DT_INST_CLOCKS_CELL_BY_IDX(0, 1, bus) == STM32_SRC_HSE
11241124
/* prescaler values for HSE */
11251125
.async_prescaler = RTC_HSE_ASYNC_PRESCALER - 1,

dts/bindings/rtc/st,stm32-rtc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ properties:
1414
reg:
1515
required: true
1616

17+
sync-prescaler:
18+
type: int
19+
description: |
20+
RTC synchronous prescaler value. Optional, defaulting to set values
21+
depending on source clock.
22+
23+
async-prescaler:
24+
type: int
25+
description: |
26+
RTC asynchronous prescaler value. Optional, defaulting to set values
27+
depending on source clock.
28+
1729
calib-out-freq:
1830
type: int
1931
description: |

0 commit comments

Comments
 (0)