Skip to content

Commit fb60799

Browse files
nandojvekartben
authored andcommitted
dts: rtc: sam0: Add clock properties
Add properties to differentiate the timer counter operating modes. This properties are necessary to spetialize the driver to be used as a normal 16/32-bit counter or to provide the clock/calendar functions. Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent 50a044a commit fb60799

File tree

6 files changed

+134
-7
lines changed

6 files changed

+134
-7
lines changed

drivers/timer/Kconfig.sam0_rtc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Copyright (c) 2014-2015 Wind River Systems, Inc.
22
# Copyright (c) 2016 Cadence Design Systems, Inc.
33
# Copyright (c) 2019 Intel Corp.
4+
# Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
45
# SPDX-License-Identifier: Apache-2.0
56

67
config SAM0_RTC_TIMER
78
bool "Atmel SAM0 series RTC timer"
89
default y
9-
depends on DT_HAS_ATMEL_SAM0_RTC_ENABLED
10+
depends on DT_HAS_ATMEL_SAM0_RTC_ENABLED \
11+
&& $(dt_nodelabel_bool_prop,rtc,systimer)
1012
select PINCTRL
1113
select TICKLESS_CAPABLE
1214
help

dts/arm/atmel/samc2x.dtsi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2022 Kamil Serwus
3-
* Copyright (c) 2024 Gerson Fernando Budke <[email protected]>
3+
* Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -20,6 +20,8 @@
2020
port-b = &portb;
2121
port-c = &portc;
2222

23+
rtc = &rtc;
24+
2325
sercom-0 = &sercom0;
2426
sercom-1 = &sercom1;
2527
sercom-2 = &sercom2;
@@ -274,6 +276,9 @@
274276
atmel,assigned-clocks = <&osc32kctrl 0>;
275277
atmel,assigned-clock-names = "OSC32KCTRL";
276278
status = "disabled";
279+
280+
alarms-count = <1>;
281+
cal-constant = <(4096 * 240)>;
277282
};
278283
};
279284
};

dts/arm/atmel/samd2x.dtsi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2017 Google LLC.
3-
* Copyright (c) 2024 Gerson Fernando Budke <[email protected]>
3+
* Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -19,6 +19,8 @@
1919
port-a = &porta;
2020
port-b = &portb;
2121

22+
rtc = &rtc;
23+
2224
sercom-0 = &sercom0;
2325
sercom-1 = &sercom1;
2426
sercom-2 = &sercom2;
@@ -189,7 +191,12 @@
189191
compatible = "atmel,sam0-rtc";
190192
reg = <0x40001400 0x1C>;
191193
interrupts = <3 0>;
194+
clocks = <&gclk 4 4>, <&pm 0x18 5>;
195+
clock-names = "GCLK", "PM";
192196
status = "disabled";
197+
198+
alarms-count = <1>;
199+
cal-constant = <(1024 * 976)>;
193200
};
194201

195202
adc: adc@42004000 {

dts/arm/atmel/samd5x.dtsi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2019 ML!PA Consulting GmbH
3-
* Copyright (c) 2024 Gerson Fernando Budke <[email protected]>
3+
* Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -21,6 +21,8 @@
2121
port-c = &portc;
2222
port-d = &portd;
2323

24+
rtc = &rtc;
25+
2426
sercom-0 = &sercom0;
2527
sercom-1 = &sercom1;
2628
sercom-2 = &sercom2;
@@ -45,6 +47,7 @@
4547
};
4648

4749
chosen {
50+
zephyr,flash-controller = &nvmctrl;
4851
zephyr,entropy = &trng;
4952
zephyr,flash-controller = &nvmctrl;
5053
};
@@ -331,6 +334,9 @@
331334
atmel,assigned-clocks = <&osc32kctrl 0>;
332335
atmel,assigned-clock-names = "OSC32KCTRL";
333336
status = "disabled";
337+
338+
alarms-count = <2>;
339+
cal-constant = <(8192 * 128)>;
334340
};
335341

336342
adc0: adc@43001c00 {

dts/arm/atmel/saml2x.dtsi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2021 Argentum Systems Ltd.
3-
* Copyright (c) 2024 Gerson Fernando Budke <[email protected]>
3+
* Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -26,6 +26,8 @@
2626
sercom-4 = &sercom4;
2727
sercom-5 = &sercom5;
2828

29+
rtc = &rtc;
30+
2931
tc-4 = &tc4;
3032

3133
watchdog0 = &wdog;
@@ -203,6 +205,9 @@
203205
atmel,assigned-clocks = <&osc32kctrl 0>;
204206
atmel,assigned-clock-names = "OSC32KCTRL";
205207
status = "disabled";
208+
209+
alarms-count = <1>;
210+
cal-constant = <(8192 * 128)>;
206211
};
207212

208213
adc: adc@43000c00 {

dts/bindings/rtc/atmel,sam0-rtc.yaml

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Copyright (c) 2018 omSquare s.r.o.
2-
# Copyright (c) 2024 Gerson Fernando Budke <[email protected]>
2+
# Copyright (c) 2024-2025 Gerson Fernando Budke <[email protected]>
33
# SPDX-License-Identifier: Apache-2.0
44

55
description: Atmel SAM0 RTC
66

77
compatible: "atmel,sam0-rtc"
88

99
include:
10-
- name: rtc.yaml
10+
- name: rtc-device.yaml
1111
- name: pinctrl-device.yaml
1212
- name: atmel,assigned-clocks.yaml
1313

@@ -26,3 +26,105 @@ properties:
2626

2727
atmel,assigned-clock-names:
2828
required: true
29+
30+
systimer:
31+
type: boolean
32+
description: |
33+
Selects RTC peripheral to be used as a system timer and replace
34+
the ARM systick. When this option is selected the normal RTC
35+
functionality is in exclusive mode and the normal RTC functions
36+
will not be available.
37+
38+
The systimer exclusive functionality can be enabled using the
39+
following devicetree entry:
40+
41+
&rtc {
42+
status = "okay";
43+
systimer;
44+
};
45+
46+
cal-constant:
47+
type: int
48+
required: true
49+
description: |
50+
Define the constant used to calculate the calibration. More
51+
information can be found in the datasheet of each SoC series
52+
at RTC Frequency Correction topic.
53+
54+
Example:
55+
Correction in ppm = (FREQCORR.VALUE * 1e6 ppm) / (8192 * 128)
56+
57+
&rtc {
58+
cal-constant = <8192 * 128>;
59+
};
60+
61+
counter-mode:
62+
type: string
63+
enum:
64+
- "count-32"
65+
- "count-16"
66+
- "clock"
67+
description: |
68+
Configure the RTC counter operating mode. In mode 0, the counter
69+
register is configured as a 32-bit counter. In mode 1, simmilar
70+
to mode 0, the counter register is only 16-bit counter. In mode
71+
2 the counter register is configured as a clock/calendar.
72+
73+
&rtc {
74+
status = "okay";
75+
counter-mode = "clock";
76+
prescaler = <1024>;
77+
};
78+
79+
prescaler:
80+
type: int
81+
enum:
82+
- 1
83+
- 2
84+
- 4
85+
- 8
86+
- 16
87+
- 32
88+
- 64
89+
- 128
90+
- 256
91+
- 512
92+
- 1024
93+
description: |
94+
Enable CLKOUT at given frequency. When disabled, CLKOUT pin is LOW.
95+
The default is 0 and corresponds to the disable the CLKOUT signal.
96+
97+
&rtc {
98+
status = "okay";
99+
counter-mode = "clock";
100+
prescaler = <1024>;
101+
};
102+
103+
event-control-msk:
104+
type: int
105+
default: 0
106+
description: |
107+
Enable peripheral event sources by bitmask. By default all the channels
108+
are always disabled.
109+
110+
Event Table:
111+
112+
bit Event Source
113+
0 Periodic Interval 0 Event Output
114+
1 Periodic Interval 1 Event Output
115+
2 Periodic Interval 2 Event Output
116+
3 Periodic Interval 3 Event Output
117+
4 Periodic Interval 4 Event Output
118+
5 Periodic Interval 5 Event Output
119+
6 Periodic Interval 6 Event Output
120+
7 Periodic Interval 7 Event Output
121+
8 Compare/Alarm 0 Event Output
122+
9 Compare/Alarm 1 Event Output
123+
14 Tamper Event Output
124+
15 Overflow Event Output
125+
16 Tamper Event Input
126+
127+
Example how to enable Compare/Alarm 0 Event Output:
128+
&rtc {
129+
event-control-msk = <100>;
130+
};

0 commit comments

Comments
 (0)