1/*
2 * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#include <mem.h>
7#include <xtensa/xtensa.dtsi>
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/clock/esp32s2_clock.h>
12#include <zephyr/dt-bindings/interrupt-controller/esp32s2-xtensa-intmux.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,canbus = &twai;
25		zephyr,entropy = &trng0;
26		zephyr,flash-controller = &flash;
27	};
28
29	cpus {
30		#address-cells = <1>;
31		#size-cells = <0>;
32
33		cpu0: cpu@0 {
34			device_type = "cpu";
35			compatible = "cdns,tensilica-xtensa-lx7";
36			reg = <0>;
37			cpu-power-states = <&light_sleep &deep_sleep>;
38		};
39
40		power-states {
41			light_sleep: light_sleep {
42				compatible = "zephyr,power-state";
43				power-state-name = "standby";
44				min-residency-us = <200>;
45				exit-latency-us = <60>;
46			};
47
48			deep_sleep: deep_sleep {
49				compatible = "zephyr,power-state";
50				power-state-name = "soft-off";
51				min-residency-us = <2000>;
52				exit-latency-us = <212>;
53			};
54		};
55	};
56
57	wifi: wifi {
58		compatible = "espressif,esp32-wifi";
59		status = "disabled";
60	};
61
62	pinctrl: pin-controller {
63		compatible = "espressif,esp32-pinctrl";
64		status = "okay";
65	};
66
67	soc {
68		#address-cells = <1>;
69		#size-cells = <1>;
70		compatible = "simple-bus";
71		ranges;
72
73		sram0: memory@3ffb0000 {
74			compatible = "mmio-sram";
75			reg = <0x3ffb0000 0x50000>;
76		};
77
78		intc: interrupt-controller@3f4c2000 {
79			#interrupt-cells = <1>;
80			compatible = "espressif,esp32-intc";
81			interrupt-controller;
82			reg = <0x3f4c2000 0x114>;
83			status = "okay";
84		};
85
86		rtc: rtc@3f408000 {
87			compatible = "espressif,esp32-rtc";
88			reg = <0x3f408000 0x0D8>;
89			xtal-freq = <ESP32_CLK_XTAL_40M>;
90			#clock-cells = <1>;
91			status = "okay";
92
93			rtc_timer: rtc_timer {
94				compatible = "espressif,esp32-rtc-timer";
95				slow-clk-freq = <ESP32_RTC_SLOW_CLK_FREQ_90K>;
96				interrupts = <RTC_CORE_INTR_SOURCE>;
97				interrupt-parent = <&intc>;
98				status = "okay";
99			};
100		};
101
102		flash: flash-controller@3f402000 {
103			compatible = "espressif,esp32-flash-controller";
104			reg = <0x3f402000 0x1000>;
105
106			#address-cells = <1>;
107			#size-cells = <1>;
108
109			flash0: flash@0 {
110				compatible = "soc-nv-flash";
111				erase-block-size = <4096>;
112				write-block-size = <4>;
113				/* Flash size is specified in SOC/SIP dtsi */
114			};
115		};
116
117		psram0: psram@3f500000 {
118			device_type = "memory";
119			compatible = "mmio-sram";
120			/* PSRAM size is specified in SOC/SIP dtsi */
121			reg = <0x3f500000 DT_SIZE_M(2)>;
122			status = "disabled";
123		};
124
125		uart0: uart@3f400000 {
126			compatible = "espressif,esp32-uart";
127			reg = <0x3f400000 0x400>;
128			status = "disabled";
129			interrupts = <UART0_INTR_SOURCE>;
130			interrupt-parent = <&intc>;
131			clocks = <&rtc ESP32_UART0_MODULE>;
132		};
133
134		uart1: uart@3f410000 {
135			compatible = "espressif,esp32-uart";
136			reg = <0x3f410000 0x400>;
137			status = "disabled";
138			interrupts = <UART1_INTR_SOURCE>;
139			interrupt-parent = <&intc>;
140			clocks = <&rtc ESP32_UART1_MODULE>;
141			current-speed = <115200>;
142		};
143
144		pcnt: pcnt@3f417000 {
145			compatible = "espressif,esp32-pcnt";
146			reg = <0x3f417000 0x1000>;
147			interrupts = <PCNT_INTR_SOURCE>;
148			interrupt-parent = <&intc>;
149			clocks = <&rtc ESP32_PCNT_MODULE>;
150			status = "disabled";
151		};
152
153		ledc0: ledc@3f419000 {
154			compatible = "espressif,esp32-ledc";
155			pwm-controller;
156			#pwm-cells = <3>;
157			reg = <0x3f419000 0x1000>;
158			clocks = <&rtc ESP32_LEDC_MODULE>;
159			status = "disabled";
160		};
161
162		gpio0: gpio@3f404000 {
163			compatible = "espressif,esp32-gpio";
164			gpio-controller;
165			#gpio-cells = <2>;
166			reg = <0x3f404000 0x800>;
167			interrupts = <GPIO_INTR_SOURCE>;
168			interrupt-parent = <&intc>;
169			/* Maximum available pins (per port)
170			 * Actual occupied pins are specified
171			 * on part number dtsi level, using
172			 * the `gpio-reserved-ranges` property.
173			 */
174			ngpios = <32>;   /* 0..31 */
175		};
176
177		gpio1: gpio@3f404800 {
178			compatible = "espressif,esp32-gpio";
179			gpio-controller;
180			#gpio-cells = <2>;
181			reg = <0x3f404800 0x800>;
182			interrupts = <GPIO_INTR_SOURCE>;
183			interrupt-parent = <&intc>;
184			ngpios = <22>;   /* 32..53 */
185		};
186
187		touch: touch@3f40885c {
188			compatible = "espressif,esp32-touch";
189			reg = <0x3f40885c 0xc0 0x3f408104 0x18>;
190			interrupts = <RTC_CORE_INTR_SOURCE>;
191			interrupt-parent = <&intc>;
192			status = "disabled";
193		};
194
195		i2c0: i2c@3f413000 {
196			compatible = "espressif,esp32-i2c";
197			#address-cells = <1>;
198			#size-cells = <0>;
199			reg = <0x3f413000 0x1000>;
200			interrupts = <I2C_EXT0_INTR_SOURCE>;
201			interrupt-parent = <&intc>;
202			clocks = <&rtc ESP32_I2C0_MODULE>;
203			status = "disabled";
204		};
205
206		i2c1: i2c@3f427000 {
207			compatible = "espressif,esp32-i2c";
208			#address-cells = <1>;
209			#size-cells = <0>;
210			reg = <0x3f427000 0x1000>;
211			interrupts = <I2C_EXT1_INTR_SOURCE>;
212			interrupt-parent = <&intc>;
213			clocks = <&rtc ESP32_I2C1_MODULE>;
214			status = "disabled";
215		};
216
217		timer0: counter@3f41f000 {
218			compatible = "espressif,esp32-timer";
219			reg = <0x3f41f000 DT_SIZE_K(4)>;
220			group = <0>;
221			index = <0>;
222			interrupts = <TG0_T0_LEVEL_INTR_SOURCE>;
223			interrupt-parent = <&intc>;
224			status = "disabled";
225		};
226
227		timer1: counter@3f41f024 {
228			compatible = "espressif,esp32-timer";
229			reg = <0x3f41f024 DT_SIZE_K(4)>;
230			group = <0>;
231			index = <1>;
232			interrupts = <TG0_T1_LEVEL_INTR_SOURCE>;
233			interrupt-parent = <&intc>;
234			status = "disabled";
235		};
236
237		timer2: counter@3f420000 {
238			compatible = "espressif,esp32-timer";
239			reg = <0x3f420000 DT_SIZE_K(4)>;
240			group = <1>;
241			index = <0>;
242			interrupts = <TG1_T0_LEVEL_INTR_SOURCE>;
243			interrupt-parent = <&intc>;
244			status = "disabled";
245		};
246
247		timer3: counter@3f420024 {
248			compatible = "espressif,esp32-timer";
249			reg = <0x3f420024 DT_SIZE_K(4)>;
250			group = <1>;
251			index = <1>;
252			interrupts = <TG1_T1_LEVEL_INTR_SOURCE>;
253			interrupt-parent = <&intc>;
254		};
255
256		trng0: trng@3f435110 {
257			compatible = "espressif,esp32-trng";
258			reg = <0x3f435110 0x4>;
259			status = "disabled";
260		};
261
262		spi2: spi@3f424000 {
263			compatible = "espressif,esp32-spi";
264			reg = <0x3f424000 DT_SIZE_K(4)>;
265			interrupts = <SPI2_INTR_SOURCE>;
266			interrupt-parent = <&intc>;
267			clocks = <&rtc ESP32_FSPI_MODULE>;
268			dma-clk = <ESP32_SPI2_DMA_MODULE>;
269			dma-host = <0>;
270			status = "disabled";
271		};
272
273		spi3: spi@3f425000 {
274			compatible = "espressif,esp32-spi";
275			reg = <0x3f425000 DT_SIZE_K(4)>;
276			interrupts = <SPI3_INTR_SOURCE>;
277			interrupt-parent = <&intc>;
278			clocks = <&rtc ESP32_HSPI_MODULE>;
279			dma-clk = <ESP32_SPI3_DMA_MODULE>;
280			dma-host = <1>;
281			status = "disabled";
282		};
283
284		wdt0: watchdog@3f41f048 {
285			compatible = "espressif,esp32-watchdog";
286			reg = <0x3f41f048 0x20>;
287			interrupts = <TG0_WDT_LEVEL_INTR_SOURCE>;
288			interrupt-parent = <&intc>;
289			clocks = <&rtc ESP32_TIMG0_MODULE>;
290			status = "disabled";
291		};
292
293		wdt1: watchdog@3f42f048 {
294			compatible = "espressif,esp32-watchdog";
295			reg = <0x3f42f048 0x20>;
296			interrupts = <TG1_WDT_LEVEL_INTR_SOURCE>;
297			interrupt-parent = <&intc>;
298			clocks = <&rtc ESP32_TIMG1_MODULE>;
299			status = "disabled";
300		};
301
302		dac: dac@3f408800 {
303			compatible = "espressif,esp32-dac";
304			reg = <0x3f408800 0x100>;
305			interrupts = <RTC_CORE_INTR_SOURCE>;
306			interrupt-parent = <&intc>;
307			clocks = <&rtc ESP32_PERIPH_SARADC_MODULE>;
308			#io-channel-cells = <1>;
309		};
310
311		coretemp: coretemp@3f408800 {
312			compatible = "espressif,esp32-temp";
313			friendly-name = "coretemp";
314			reg = <0x3f408800 0x4>;
315			status = "disabled";
316		};
317
318		adc0: adc@3f440018 {
319			compatible = "espressif,esp32-adc";
320			reg = <0x3f440018 100>;
321			unit = <1>;
322			channel-count = <10>;
323			#io-channel-cells = <1>;
324			status = "disabled";
325		};
326
327		adc1: adc@3f440028 {
328			compatible = "espressif,esp32-adc";
329			reg = <0x3f440028 100>;
330			unit = <2>;
331			channel-count = <10>;
332			#io-channel-cells = <1>;
333			status = "disabled";
334		};
335
336		twai: can@3f42b000 {
337			compatible = "espressif,esp32-twai";
338			reg = <0x3f42b000 DT_SIZE_K(4)>;
339			interrupts = <TWAI_INTR_SOURCE>;
340			interrupt-parent = <&intc>;
341			clocks = <&rtc ESP32_TWAI_MODULE>;
342			sample-point = <875>;
343			status = "disabled";
344		};
345	};
346
347};
348