Skip to content

Commit d09764a

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 d09764a

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

drivers/rtc/rtc_ll_stm32.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,17 +1114,17 @@ 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, 0x00F9),
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 */
1125-
.async_prescaler = RTC_HSE_ASYNC_PRESCALER - 1,
1126-
.sync_prescaler = RTC_HSE_SYNC_PRESCALER - 1,
1127-
.hse_prescaler = RTC_HSE_PRESCALER,
1125+
.async_prescaler = DT_INST_PROP_OR(0, async_prescaler, RTC_HSE_ASYNC_PRESCALER - 1),
1126+
.sync_prescaler = DT_INST_PROP_OR(0, sync_prescaler, RTC_HSE_SYNC_PRESCALER - 1),
1127+
.hse_prescaler = DT_INST_PROP_OR(0, hse_prescaler, RTC_HSE_PRESCALER),
11281128
#else
11291129
#error Invalid RTC SRC
11301130
#endif

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ 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+
29+
hse-prescaler:
30+
type: int
31+
description: |
32+
RTC HSE prescaler value. Optional, defaulting to set values
33+
when HSE is selected as the source clock.
34+
1735
calib-out-freq:
1836
type: int
1937
description: |

0 commit comments

Comments
 (0)