Skip to content

Commit fad55d1

Browse files
Raffael Rostagnonashif
authored andcommitted
soc: esp32c2: Add support to ESP32C2 and ESP8684
Files for SoC support: ESP32C2 and ESP8684 (same core). Basic device tree configuration. Signed-off-by: Raffael Rostagno <[email protected]>
1 parent b4b4d7c commit fad55d1

25 files changed

+1971
-6
lines changed

dts/bindings/cpu/espressif,riscv.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ properties:
2828
type: int
2929
description: Value of the external XTAL connected to ESP32. This is typically 40 MHz.
3030
enum:
31-
- 40000000
31+
- 26000000
3232
- 32000000
33+
- 40000000
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp32c2_common.dtsi"
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <mem.h>
7+
#include <freq.h>
8+
#include <zephyr/dt-bindings/adc/adc.h>
9+
#include <zephyr/dt-bindings/gpio/gpio.h>
10+
#include <zephyr/dt-bindings/i2c/i2c.h>
11+
#include <zephyr/dt-bindings/interrupt-controller/esp-esp32c2-intmux.h>
12+
#include <zephyr/dt-bindings/clock/esp32c2_clock.h>
13+
#include <dt-bindings/pinctrl/esp32-pinctrl.h>
14+
15+
/ {
16+
#address-cells = <1>;
17+
#size-cells = <1>;
18+
19+
aliases {
20+
die-temp0 = &coretemp;
21+
};
22+
23+
chosen {
24+
zephyr,entropy = &trng0;
25+
zephyr,flash-controller = &flash;
26+
};
27+
28+
cpus {
29+
#address-cells = <1>;
30+
#size-cells = <0>;
31+
32+
cpu0: cpu@0 {
33+
device_type = "cpu";
34+
compatible = "espressif,riscv", "riscv";
35+
riscv,isa = "rv32imc_zicsr";
36+
reg = <0>;
37+
clock-source = <ESP32_CPU_CLK_SRC_PLL>;
38+
clock-frequency = <DT_FREQ_M(120)>;
39+
xtal-freq = <DT_FREQ_M(26)>;
40+
};
41+
};
42+
43+
pinctrl: pin-controller {
44+
compatible = "espressif,esp32-pinctrl";
45+
status = "okay";
46+
};
47+
48+
soc {
49+
#address-cells = <1>;
50+
#size-cells = <1>;
51+
compatible = "simple-bus";
52+
ranges;
53+
54+
sram0: memory@3fc7c000 {
55+
compatible = "mmio-sram";
56+
reg = <0x3fc7c000 0x50000>;
57+
};
58+
59+
intc: interrupt-controller@600c2000 {
60+
compatible = "espressif,esp32-intc";
61+
#address-cells = <0>;
62+
#interrupt-cells = <1>;
63+
interrupt-controller;
64+
reg = <0x600c2000 0x198>;
65+
status = "okay";
66+
};
67+
68+
systimer0: systimer@60023000 {
69+
compatible = "espressif,esp32-systimer";
70+
reg = <0x60023000 0x80>;
71+
interrupts = <SYSTIMER_TARGET0_EDGE_INTR_SOURCE>;
72+
interrupt-parent = <&intc>;
73+
status = "okay";
74+
};
75+
76+
rtc: rtc@60008000 {
77+
compatible = "espressif,esp32-rtc";
78+
reg = <0x60008000 0x1000>;
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+
85+
rtc_timer: rtc_timer@60008004 {
86+
reg = <0x60008004 0xC>;
87+
compatible = "espressif,esp32-rtc-timer";
88+
clocks = <&rtc ESP32_MODULE_MAX>;
89+
interrupts = <RTC_CORE_INTR_SOURCE>;
90+
interrupt-parent = <&intc>;
91+
status = "disabled";
92+
};
93+
94+
flash: flash-controller@60002000 {
95+
compatible = "espressif,esp32-flash-controller";
96+
reg = <0x60002000 0x1000>;
97+
98+
#address-cells = <1>;
99+
#size-cells = <1>;
100+
101+
flash0: flash@0 {
102+
compatible = "soc-nv-flash";
103+
reg = <0 0x400000>;
104+
erase-block-size = <4096>;
105+
write-block-size = <4>;
106+
};
107+
};
108+
109+
gpio0: gpio@60004000 {
110+
compatible = "espressif,esp32-gpio";
111+
gpio-controller;
112+
#gpio-cells = <2>;
113+
reg = <0x60004000 0x800>;
114+
interrupts = <GPIO_INTR_SOURCE>;
115+
interrupt-parent = <&intc>;
116+
/* Maximum available pins (per port)
117+
* Actual occupied pins are specified
118+
* on part number dtsi level, using
119+
* the `gpio-reserved-ranges` property.
120+
*/
121+
ngpios = <20>; /* 0..20 */
122+
};
123+
124+
i2c0: i2c@60013000 {
125+
compatible = "espressif,esp32-i2c";
126+
#address-cells = <1>;
127+
#size-cells = <0>;
128+
reg = <0x60013000 0x1000>;
129+
interrupts = <I2C_EXT0_INTR_SOURCE>;
130+
interrupt-parent = <&intc>;
131+
clocks = <&rtc ESP32_I2C0_MODULE>;
132+
status = "disabled";
133+
};
134+
135+
uart0: uart@60000000 {
136+
compatible = "espressif,esp32-uart";
137+
reg = <0x60000000 0x400>;
138+
status = "disabled";
139+
interrupts = <UART0_INTR_SOURCE>;
140+
interrupt-parent = <&intc>;
141+
clocks = <&rtc ESP32_UART0_MODULE>;
142+
};
143+
144+
uart1: uart@60010000 {
145+
compatible = "espressif,esp32-uart";
146+
reg = <0x60010000 0x400>;
147+
status = "disabled";
148+
interrupts = <UART1_INTR_SOURCE>;
149+
interrupt-parent = <&intc>;
150+
clocks = <&rtc ESP32_UART1_MODULE>;
151+
current-speed = <115200>;
152+
};
153+
154+
ledc0: ledc@60019000 {
155+
compatible = "espressif,esp32-ledc";
156+
pwm-controller;
157+
#pwm-cells = <3>;
158+
reg = <0x60019000 0x1000>;
159+
clocks = <&rtc ESP32_LEDC_MODULE>;
160+
status = "disabled";
161+
};
162+
163+
timer0: counter@6001f000 {
164+
compatible = "espressif,esp32-timer";
165+
reg = <0x6001F000 DT_SIZE_K(4)>;
166+
group = <0>;
167+
index = <0>;
168+
interrupts = <TG0_T0_LEVEL_INTR_SOURCE>;
169+
interrupt-parent = <&intc>;
170+
status = "disabled";
171+
};
172+
173+
trng0: trng@3ff700b0 {
174+
compatible = "espressif,esp32-trng";
175+
reg = <0x3FF700B0 0x4>;
176+
status = "disabled";
177+
};
178+
179+
spi2: spi@60024000 {
180+
compatible = "espressif,esp32-spi";
181+
reg = <0x60024000 DT_SIZE_K(4)>;
182+
interrupts = <SPI2_INTR_SOURCE>;
183+
interrupt-parent = <&intc>;
184+
clocks = <&rtc ESP32_SPI2_MODULE>;
185+
dma-clk = <ESP32_GDMA_MODULE>;
186+
dma-host = <0>;
187+
status = "disabled";
188+
};
189+
190+
wdt0: watchdog@6001f048 {
191+
compatible = "espressif,esp32-watchdog";
192+
reg = <0x6001f048 0x20>;
193+
interrupts = <TG0_WDT_LEVEL_INTR_SOURCE>;
194+
interrupt-parent = <&intc>;
195+
clocks = <&rtc ESP32_TIMG0_MODULE>;
196+
status = "disabled";
197+
};
198+
199+
coretemp: coretemp@60040058 {
200+
compatible = "espressif,esp32-temp";
201+
friendly-name = "coretemp";
202+
reg = <0x60040058 0x4>;
203+
status = "disabled";
204+
};
205+
};
206+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp32c2_common.dtsi"
8+
9+
/* 2MB flash */
10+
&flash0 {
11+
reg = <0x0 DT_SIZE_M(2)>;
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp32c2_common.dtsi"
8+
9+
/* 4MB flash */
10+
&flash0 {
11+
reg = <0x0 DT_SIZE_M(4)>;
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp32c2_common.dtsi"
8+
9+
/* 2MB flash */
10+
&flash0 {
11+
reg = <0x0 DT_SIZE_M(2)>;
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "esp32c2_common.dtsi"
8+
9+
/* 4MB flash */
10+
&flash0 {
11+
reg = <0x0 DT_SIZE_M(4)>;
12+
};

soc/espressif/common/Kconfig.defconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
1+
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
if SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6
4+
if SOC_SERIES_ESP32C2 || SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6
55

66
config GEN_ISR_TABLES
77
default y
@@ -22,7 +22,8 @@ config ATOMIC_OPERATIONS_C
2222
default y
2323

2424
config SYS_CLOCK_HW_CYCLES_PER_SEC
25-
default 16000000
25+
default 12000000 if SOC_SERIES_ESP32C2
26+
default 16000000 if SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6
2627

2728
config SYS_CLOCK_TICKS_PER_SEC
2829
default 1000
@@ -49,7 +50,7 @@ config ROM_START_OFFSET
4950

5051
endif # BOOTLOADER_MCUBOOT
5152

52-
endif # SOC_SERIES_ESP32C3
53+
endif # SOC_SERIES_ESP32C2 || SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6
5354

5455
if SOC_SERIES_ESP32 || SOC_SERIES_ESP32S2 || SOC_SERIES_ESP32S3
5556

soc/espressif/common/Kconfig.esptool

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ config ESPTOOLPY_FLASHMODE
8181
choice ESPTOOLPY_FLASHFREQ
8282
prompt "Flash SPI speed"
8383
default ESPTOOLPY_FLASHFREQ_40M if SOC_SERIES_ESP32
84+
default ESPTOOLPY_FLASHFREQ_60M if SOC_SERIES_ESP32C2
8485
default ESPTOOLPY_FLASHFREQ_80M if ESPTOOLPY_FLASHFREQ_80M_DEFAULT
8586

8687
config ESPTOOLPY_FLASHFREQ_120M
@@ -99,6 +100,8 @@ config ESPTOOLPY_FLASHFREQ_120M
99100

100101
config ESPTOOLPY_FLASHFREQ_80M
101102
bool "80 MHz"
103+
config ESPTOOLPY_FLASHFREQ_60M
104+
bool "60 MHz"
102105
config ESPTOOLPY_FLASHFREQ_40M
103106
bool "40 MHz"
104107
config ESPTOOLPY_FLASHFREQ_26M
@@ -121,6 +124,7 @@ config ESPTOOLPY_FLASHFREQ
121124
# We currently define this to `80m`.
122125
default '80m' if ESPTOOLPY_FLASHFREQ_120M
123126
default '80m' if ESPTOOLPY_FLASHFREQ_80M
127+
default '60m' if ESPTOOLPY_FLASHFREQ_60M
124128
default '40m' if ESPTOOLPY_FLASHFREQ_40M
125129
default '26m' if ESPTOOLPY_FLASHFREQ_26M
126130
default '20m' if ESPTOOLPY_FLASHFREQ_20M

soc/espressif/common/Kconfig.flash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ config BOOTLOADER_FLASH_XMC_SUPPORT
9494
choice BOOTLOADER_VDDSDIO_BOOST
9595
bool "VDDSDIO LDO voltage"
9696
default BOOTLOADER_VDDSDIO_BOOST_1_9V
97-
depends on !SOC_SERIES_ESP32C3 && !SOC_SERIES_ESP32C6
97+
depends on !SOC_SERIES_ESP32C2 && !SOC_SERIES_ESP32C3 && !SOC_SERIES_ESP32C6
9898
help
9999
If this option is enabled, and VDDSDIO LDO is set to 1.8V (using eFuse
100100
or MTDI bootstrapping pin), bootloader will change LDO settings to

0 commit comments

Comments
 (0)