1/*
2 * Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
3 * Copyright (c) 2025 Jakub Novák <jakubnovak.cz@outlook.cz>
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7/dts-v1/;
8
9#include <espressif/esp32/esp32_d0wd_v3.dtsi>
10#include "m5stack_fire-pinctrl.dtsi"
11#include "grove_connectors.dtsi"
12#include "m5stack_mbus_connectors.dtsi"
13#include <zephyr/dt-bindings/display/ili9xxx.h>
14#include <espressif/partitions_0x1000_amp.dtsi>
15#include <zephyr/dt-bindings/input/input-event-codes.h>
16
17/ {
18	model = "M5Stack Fire PROCPU";
19	compatible = "m5stack,fire";
20
21	aliases {
22		uart-0 = &uart0;
23		i2c-0 = &i2c0;
24		watchdog0 = &wdt0;
25		accel0 = &mpu6886;
26		sw0 = &button0;
27		pwm0 = &ledc0;
28		lcd-bg = &lcd_bg;
29	};
30
31	chosen {
32		zephyr,sram = &sram1;
33		zephyr,console = &uart0;
34		zephyr,shell-uart = &uart0;
35		zephyr,flash = &flash0;
36		zephyr,display = &ili9342c;
37		zephyr,code-partition = &slot0_partition;
38		zephyr,bt-hci = &esp32_bt_hci;
39	};
40
41	pwm {
42		compatible = "pwm-leds";
43
44		lcd_bg: lcd_bg {
45			label = "PWM LED0";
46			/* The cycle duration is taken from the ILI9342c spec section 8.3.15 */
47			pwms = <&ledc0 7 PWM_KHZ(16000 / 256) PWM_POLARITY_NORMAL>;
48		};
49
50		speaker: speaker {
51			label = "PWM speaker";
52			pwms = <&ledc0 8 1000 PWM_POLARITY_NORMAL>;
53		};
54	};
55
56	buttons {
57		compatible = "gpio-keys";
58
59		button0: button_0 {
60			gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
61			label = "button left";
62			zephyr,code = <INPUT_KEY_0>;
63		};
64
65		button1: button_1 {
66			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
67			label = "button middle";
68			zephyr,code = <INPUT_KEY_1>;
69		};
70
71		button2: button_2 {
72			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
73			label = "button right";
74			zephyr,code = <INPUT_KEY_2>;
75		};
76
77		button3: button_3 {
78			gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
79			label = "button 2";
80			zephyr,code = <INPUT_KEY_3>;
81		};
82	};
83
84	mipi_dbi {
85		compatible = "zephyr,mipi-dbi-spi";
86		dc-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
87		reset-gpios = <&gpio1 1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
88		spi-dev = <&spi3>;
89		write-only;
90		#address-cells = <1>;
91		#size-cells = <0>;
92
93		ili9342c: ili9342c@0 {
94			status = "okay";
95			compatible = "ilitek,ili9342c";
96			mipi-max-frequency = <30000000>;
97			reg = <0>;
98			pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
99			display-inversion;
100			width = <320>;
101			height = <240>;
102			rotation = <0>;
103		};
104	};
105};
106
107&flash0 {
108	reg = <0x0 DT_SIZE_M(16)>;
109};
110
111&psram0 {
112	size = <DT_SIZE_M(8)>;
113};
114
115&uart0 {
116	status = "okay";
117	current-speed = <115200>;
118	pinctrl-0 = <&uart0_tx_gpio1 &uart0_rx_gpio3>;
119	pinctrl-names = "default";
120};
121
122&uart1 {
123	status = "disabled";
124	current-speed = <115200>;
125	pinctrl-0 = <&uart1_tx_gpio16 &uart1_rx_gpio17>;
126	pinctrl-names = "default";
127};
128
129&gpio0 {
130	status = "okay";
131};
132
133&gpio1 {
134	status = "okay";
135};
136
137&i2c0 {
138	status = "okay";
139	clock-frequency = <I2C_BITRATE_FAST>;
140	sda-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>;
141	scl-gpios = <&gpio0 22 GPIO_OPEN_DRAIN>;
142	pinctrl-0 = <&i2c0_default>;
143	scl-timeout-us = <0>;
144	pinctrl-names = "default";
145
146	mpu6886: mpu6886@68 {
147		status = "okay";
148		compatible = "invensense,mpu6050";
149		reg = <0x68>;
150	};
151};
152
153&spi3 {
154	status = "okay";
155	#address-cells = <1>;
156	#size-cells = <0>;
157	pinctrl-0 = <&spim3_default>;
158	pinctrl-names = "default";
159	dma-enabled;
160	clock-frequency = <20000000>;
161	cs-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>, <&gpio0 4 GPIO_ACTIVE_LOW>;
162
163	sd0: sd@1 {
164		status = "okay";
165		compatible = "zephyr,sdhc-spi-slot";
166		reg = <1>;
167		spi-max-frequency = <20000000>;
168
169		mmc {
170			status = "okay";
171			compatible = "zephyr,sdmmc-disk";
172			disk-name = "SD";
173		};
174	};
175};
176
177&ledc0 {
178	pinctrl-0 = <&ledc0_default>;
179	pinctrl-names = "default";
180	status = "okay";
181	#address-cells = <1>;
182	#size-cells = <0>;
183
184	hispeed0@7 {
185		reg = <0x7>;
186		timer = <0>;
187	};
188
189	hispeed1@8 {
190		reg = <0x8>;
191		timer = <0>;
192	};
193};
194
195&timer0 {
196	status = "okay";
197};
198
199&timer1 {
200	status = "okay";
201};
202
203&timer2 {
204	status = "okay";
205};
206
207&timer3 {
208	status = "okay";
209};
210
211&trng0 {
212	status = "okay";
213};
214
215&esp32_bt_hci {
216	status = "okay";
217};
218
219&wifi {
220	status = "okay";
221};
222