Skip to content

Commit e0a915a

Browse files
sylvioalveskartben
authored andcommitted
soc: espressif: convert rtc peripheral to clock subsystem
Current ESP32 clock system is mixed with RTC labeling/registers, but it doesn't implement a real-time clock (RTC) driver. To avoid confusion and allow adding a proper RTC driver later, this commit renames the existing RTC interface to CLOCK and make it as a subsystem without any peripheral attached to it. This better reflects its actual purpose as a general clock controller. Signed-off-by: Sylvio Alves <[email protected]>
1 parent c42cd2d commit e0a915a

File tree

21 files changed

+191
-202
lines changed

21 files changed

+191
-202
lines changed

drivers/clock_control/Kconfig.esp32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
config CLOCK_CONTROL_ESP32
77
bool "ESP32 Clock driver"
88
default y
9-
depends on DT_HAS_ESPRESSIF_ESP32_RTC_ENABLED
9+
depends on DT_HAS_ESPRESSIF_ESP32_CLOCK_ENABLED
1010
help
1111
Enable support for ESP32 clock driver.

drivers/clock_control/clock_control_esp32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: Apache-2.0
66
*/
77

8-
#define DT_DRV_COMPAT espressif_esp32_rtc
8+
#define DT_DRV_COMPAT espressif_esp32_clock
99

1010
#define CPU_RESET_REASON RTC_SW_CPU_RESET
1111

@@ -812,16 +812,16 @@ static const struct esp32_cpu_clock_config esp32_cpu_clock_config0 = {
812812
};
813813

814814
static const struct esp32_rtc_clock_config esp32_rtc_clock_config0 = {
815-
.rtc_fast_clock_src = DT_PROP(DT_INST(0, espressif_esp32_rtc), fast_clk_src),
816-
.rtc_slow_clock_src = DT_PROP(DT_INST(0, espressif_esp32_rtc), slow_clk_src),
815+
.rtc_fast_clock_src = DT_PROP(DT_INST(0, espressif_esp32_clock), fast_clk_src),
816+
.rtc_slow_clock_src = DT_PROP(DT_INST(0, espressif_esp32_clock), slow_clk_src),
817817
};
818818

819819
static const struct esp32_clock_config esp32_clock_config0 = {
820820
.cpu = esp32_cpu_clock_config0,
821821
.rtc = esp32_rtc_clock_config0
822822
};
823823

824-
DEVICE_DT_DEFINE(DT_NODELABEL(rtc),
824+
DEVICE_DT_DEFINE(DT_NODELABEL(clock),
825825
clock_control_esp32_init,
826826
NULL,
827827
NULL,

drivers/watchdog/xt_wdt_esp32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ DEVICE_DT_DEFINE(DT_NODELABEL(xt_wdt),
168168
defined(CONFIG_SOC_SERIES_ESP32C3))
169169
#error "XT WDT is not supported"
170170
#else
171-
BUILD_ASSERT((DT_PROP(DT_INST(0, espressif_esp32_rtc), slow_clk_src) ==
171+
BUILD_ASSERT((DT_PROP(DT_INST(0, espressif_esp32_clock), slow_clk_src) ==
172172
ESP32_RTC_SLOW_CLK_SRC_XTAL32K) ||
173-
(DT_PROP(DT_INST(0, espressif_esp32_rtc), slow_clk_src) ==
173+
(DT_PROP(DT_INST(0, espressif_esp32_clock), slow_clk_src) ==
174174
ESP32_RTC_SLOW_CLK_32K_EXT_OSC),
175175
"XT WDT is only supported with XTAL32K or 32K_EXT_OSC as slow clock source");
176176
#endif

dts/bindings/clock/espressif,esp32-rtc.yaml renamed to dts/bindings/clock/espressif,esp32-clock.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# Copyright (c) 2020, Mohamed ElShahawi
22
# SPDX-License-Identifier: Apache-2.0
33

4-
description: ESP32 RTC (Power & Clock Controller Module) Module
4+
description: ESP32 Clock (Power & Clock Controller Module) Module
55

6-
compatible: "espressif,esp32-rtc"
6+
compatible: "espressif,esp32-clock"
77

8-
include: [clock-controller.yaml, base.yaml]
8+
include: [clock-controller.yaml]
99

1010
properties:
11-
reg:
12-
required: true
13-
1411
fast-clk-src:
1512
type: int
1613
required: true

dts/riscv/espressif/esp32c2/esp32c2_common.dtsi

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050
status = "disabled";
5151
};
5252

53+
clock: clock {
54+
compatible = "espressif,esp32-clock";
55+
fast-clk-src = <ESP32_RTC_FAST_CLK_SRC_RC_FAST>;
56+
slow-clk-src = <ESP32_RTC_SLOW_CLK_SRC_RC_SLOW>;
57+
#clock-cells = <1>;
58+
status = "okay";
59+
};
60+
5361
soc {
5462
#address-cells = <1>;
5563
#size-cells = <1>;
@@ -85,19 +93,10 @@
8593
status = "okay";
8694
};
8795

88-
rtc: rtc@60008000 {
89-
compatible = "espressif,esp32-rtc";
90-
reg = <0x60008000 0x1000>;
91-
fast-clk-src = <ESP32_RTC_FAST_CLK_SRC_RC_FAST>;
92-
slow-clk-src = <ESP32_RTC_SLOW_CLK_SRC_RC_SLOW>;
93-
#clock-cells = <1>;
94-
status = "okay";
95-
};
96-
9796
rtc_timer: rtc_timer@60008004 {
9897
reg = <0x60008004 0xC>;
99-
compatible = "espressif,esp32-rtc-timer";
100-
clocks = <&rtc ESP32_MODULE_MAX>;
98+
compatible = "espressif,esp32-rtc_timer";
99+
clocks = <&clock ESP32_MODULE_MAX>;
101100
interrupts = <RTC_CORE_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
102101
interrupt-parent = <&intc>;
103102
status = "disabled";
@@ -140,7 +139,7 @@
140139
reg = <0x60013000 0x1000>;
141140
interrupts = <I2C_EXT0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
142141
interrupt-parent = <&intc>;
143-
clocks = <&rtc ESP32_I2C0_MODULE>;
142+
clocks = <&clock ESP32_I2C0_MODULE>;
144143
status = "disabled";
145144
};
146145

@@ -150,7 +149,7 @@
150149
status = "disabled";
151150
interrupts = <UART0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
152151
interrupt-parent = <&intc>;
153-
clocks = <&rtc ESP32_UART0_MODULE>;
152+
clocks = <&clock ESP32_UART0_MODULE>;
154153
};
155154

156155
uart1: uart@60010000 {
@@ -159,7 +158,7 @@
159158
status = "disabled";
160159
interrupts = <UART1_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
161160
interrupt-parent = <&intc>;
162-
clocks = <&rtc ESP32_UART1_MODULE>;
161+
clocks = <&clock ESP32_UART1_MODULE>;
163162
current-speed = <115200>;
164163
};
165164

@@ -168,14 +167,14 @@
168167
pwm-controller;
169168
#pwm-cells = <3>;
170169
reg = <0x60019000 0x1000>;
171-
clocks = <&rtc ESP32_LEDC_MODULE>;
170+
clocks = <&clock ESP32_LEDC_MODULE>;
172171
status = "disabled";
173172
};
174173

175174
timer0: counter@6001f000 {
176175
compatible = "espressif,esp32-timer";
177176
reg = <0x6001F000 DT_SIZE_K(4)>;
178-
clocks = <&rtc ESP32_TIMG0_MODULE>;
177+
clocks = <&clock ESP32_TIMG0_MODULE>;
179178
group = <0>;
180179
index = <0>;
181180
interrupts = <TG0_T0_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
@@ -199,7 +198,7 @@
199198
reg = <0x60024000 DT_SIZE_K(4)>;
200199
interrupts = <SPI2_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
201200
interrupt-parent = <&intc>;
202-
clocks = <&rtc ESP32_SPI2_MODULE>;
201+
clocks = <&clock ESP32_SPI2_MODULE>;
203202
dma-clk = <ESP32_GDMA_MODULE>;
204203
dma-host = <0>;
205204
status = "disabled";
@@ -210,7 +209,7 @@
210209
reg = <0x6001f048 0x20>;
211210
interrupts = <TG0_WDT_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
212211
interrupt-parent = <&intc>;
213-
clocks = <&rtc ESP32_TIMG0_MODULE>;
212+
clocks = <&clock ESP32_TIMG0_MODULE>;
214213
status = "disabled";
215214
};
216215

@@ -224,7 +223,7 @@
224223
adc0: adc@60040000 {
225224
compatible = "espressif,esp32-adc";
226225
reg = <0x60040000 4>;
227-
clocks = <&rtc ESP32_SARADC_MODULE>;
226+
clocks = <&clock ESP32_SARADC_MODULE>;
228227
unit = <1>;
229228
channel-count = <5>;
230229
#io-channel-cells = <1>;

dts/riscv/espressif/esp32c3/esp32c3_common.dtsi

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
status = "disabled";
7575
};
7676

77+
clock: clock {
78+
compatible = "espressif,esp32-clock";
79+
fast-clk-src = <ESP32_RTC_FAST_CLK_SRC_RC_FAST>;
80+
slow-clk-src = <ESP32_RTC_SLOW_CLK_SRC_RC_SLOW>;
81+
#clock-cells = <1>;
82+
status = "okay";
83+
};
84+
7785
soc {
7886
#address-cells = <1>;
7987
#size-cells = <1>;
@@ -109,28 +117,19 @@
109117
status = "okay";
110118
};
111119

112-
rtc: rtc@60008000 {
113-
compatible = "espressif,esp32-rtc";
114-
reg = <0x60008000 0x1000>;
115-
fast-clk-src = <ESP32_RTC_FAST_CLK_SRC_RC_FAST>;
116-
slow-clk-src = <ESP32_RTC_SLOW_CLK_SRC_RC_SLOW>;
117-
#clock-cells = <1>;
118-
status = "okay";
119-
};
120-
121120
xt_wdt: xt_wdt@60008004 {
122121
compatible = "espressif,esp32-xt-wdt";
123122
reg = <0x60008004 0x4>;
124-
clocks = <&rtc ESP32_MODULE_MAX>;
123+
clocks = <&clock ESP32_MODULE_MAX>;
125124
interrupts = <RTC_CORE_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
126125
interrupt-parent = <&intc>;
127126
status = "disabled";
128127
};
129128

130129
rtc_timer: rtc_timer@60008004 {
131130
reg = <0x60008004 0xC>;
132-
compatible = "espressif,esp32-rtc-timer";
133-
clocks = <&rtc ESP32_MODULE_MAX>;
131+
compatible = "espressif,esp32-rtc_timer";
132+
clocks = <&clock ESP32_MODULE_MAX>;
134133
interrupts = <RTC_CORE_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
135134
interrupt-parent = <&intc>;
136135
status = "okay";
@@ -173,7 +172,7 @@
173172
reg = <0x60013000 0x1000>;
174173
interrupts = <I2C_EXT0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
175174
interrupt-parent = <&intc>;
176-
clocks = <&rtc ESP32_I2C0_MODULE>;
175+
clocks = <&clock ESP32_I2C0_MODULE>;
177176
status = "disabled";
178177
};
179178

@@ -184,7 +183,7 @@
184183
reg = <0x6002d000 0x1000>;
185184
interrupts = <I2S1_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
186185
interrupt-parent = <&intc>;
187-
clocks = <&rtc ESP32_I2S1_MODULE>;
186+
clocks = <&clock ESP32_I2S1_MODULE>;
188187
dmas = <&dma 2>, <&dma 3>;
189188
dma-names = "rx", "tx";
190189
unit = <0>;
@@ -197,7 +196,7 @@
197196
status = "disabled";
198197
interrupts = <UART0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
199198
interrupt-parent = <&intc>;
200-
clocks = <&rtc ESP32_UART0_MODULE>;
199+
clocks = <&clock ESP32_UART0_MODULE>;
201200
};
202201

203202
uart1: uart@60010000 {
@@ -206,7 +205,7 @@
206205
status = "disabled";
207206
interrupts = <UART1_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
208207
interrupt-parent = <&intc>;
209-
clocks = <&rtc ESP32_UART1_MODULE>;
208+
clocks = <&clock ESP32_UART1_MODULE>;
210209
current-speed = <115200>;
211210
};
212211

@@ -215,7 +214,7 @@
215214
pwm-controller;
216215
#pwm-cells = <3>;
217216
reg = <0x60019000 0x1000>;
218-
clocks = <&rtc ESP32_LEDC_MODULE>;
217+
clocks = <&clock ESP32_LEDC_MODULE>;
219218
status = "disabled";
220219
};
221220

@@ -225,13 +224,13 @@
225224
status = "disabled";
226225
interrupts = <USB_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
227226
interrupt-parent = <&intc>;
228-
clocks = <&rtc ESP32_USB_MODULE>;
227+
clocks = <&clock ESP32_USB_MODULE>;
229228
};
230229

231230
timer0: counter@6001f000 {
232231
compatible = "espressif,esp32-timer";
233232
reg = <0x6001F000 DT_SIZE_K(4)>;
234-
clocks = <&rtc ESP32_TIMG0_MODULE>;
233+
clocks = <&clock ESP32_TIMG0_MODULE>;
235234
group = <0>;
236235
index = <0>;
237236
interrupts = <TG0_T0_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
@@ -247,7 +246,7 @@
247246
timer1: counter@60020000 {
248247
compatible = "espressif,esp32-timer";
249248
reg = <0x60020000 DT_SIZE_K(4)>;
250-
clocks = <&rtc ESP32_TIMG1_MODULE>;
249+
clocks = <&clock ESP32_TIMG1_MODULE>;
251250
group = <1>;
252251
index = <0>;
253252
interrupts = <TG1_T0_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
@@ -271,7 +270,7 @@
271270
reg = <0x6002b000 DT_SIZE_K(4)>;
272271
interrupts = <TWAI_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
273272
interrupt-parent = <&intc>;
274-
clocks = <&rtc ESP32_TWAI_MODULE>;
273+
clocks = <&clock ESP32_TWAI_MODULE>;
275274
status = "disabled";
276275
};
277276

@@ -280,7 +279,7 @@
280279
reg = <0x60024000 DT_SIZE_K(4)>;
281280
interrupts = <SPI2_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
282281
interrupt-parent = <&intc>;
283-
clocks = <&rtc ESP32_SPI2_MODULE>;
282+
clocks = <&clock ESP32_SPI2_MODULE>;
284283
dma-clk = <ESP32_GDMA_MODULE>;
285284
dma-host = <0>;
286285
status = "disabled";
@@ -291,7 +290,7 @@
291290
reg = <0x6001f048 0x20>;
292291
interrupts = <TG0_WDT_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
293292
interrupt-parent = <&intc>;
294-
clocks = <&rtc ESP32_TIMG0_MODULE>;
293+
clocks = <&clock ESP32_TIMG0_MODULE>;
295294
status = "disabled";
296295
};
297296

@@ -300,7 +299,7 @@
300299
reg = <0x60020048 0x20>;
301300
interrupts = <TG1_WDT_LEVEL_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
302301
interrupt-parent = <&intc>;
303-
clocks = <&rtc ESP32_TIMG1_MODULE>;
302+
clocks = <&clock ESP32_TIMG1_MODULE>;
304303
status = "disabled";
305304
};
306305

@@ -314,7 +313,7 @@
314313
adc0: adc@60040000 {
315314
compatible = "espressif,esp32-adc";
316315
reg = <0x60040000 4>;
317-
clocks = <&rtc ESP32_SARADC_MODULE>;
316+
clocks = <&clock ESP32_SARADC_MODULE>;
318317
unit = <1>;
319318
channel-count = <5>;
320319
#io-channel-cells = <1>;
@@ -330,7 +329,7 @@
330329
<DMA_CH1_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>,
331330
<DMA_CH2_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
332331
interrupt-parent = <&intc>;
333-
clocks = <&rtc ESP32_GDMA_MODULE>;
332+
clocks = <&clock ESP32_GDMA_MODULE>;
334333
dma-channels = <6>;
335334
dma-buf-addr-alignment = <4>;
336335
status = "disabled";

0 commit comments

Comments
 (0)