1/*
2 * Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6/dts-v1/;
7
8#include <espressif/esp32/esp32_d0wd_v3.dtsi>
9#include "m5stack_core2-pinctrl.dtsi"
10#include "grove_connectors.dtsi"
11#include "m5stack_mbus_connectors.dtsi"
12#include <zephyr/dt-bindings/display/ili9xxx.h>
13#include <zephyr/dt-bindings/regulator/axp192.h>
14#include <espressif/partitions_0x1000_amp.dtsi>
15
16/ {
17	model = "M5Stack Core2 PROCPU";
18	compatible = "m5stack,core2";
19
20	aliases {
21		pwr-led = &pwr_led;
22		uart-0 = &uart0;
23		i2c-0 = &i2c0;
24		watchdog0 = &wdt0;
25		rtc = &pfc8563_rtc;
26		led0 = &led_pwr;
27		sdhc0 = &sd0;
28	};
29
30	chosen {
31		zephyr,sram = &sram1;
32		zephyr,console = &uart0;
33		zephyr,shell-uart = &uart0;
34		zephyr,flash = &flash0;
35		zephyr,display = &ili9342c;
36		zephyr,code-partition = &slot0_partition;
37		zephyr,rtc = &pfc8563_rtc;
38		zephyr,bt-hci = &esp32_bt_hci;
39		zephyr,touch = &ft5336_touch;
40	};
41
42	leds {
43		compatible = "gpio-leds";
44		led_pwr: led_pwr {
45			gpios = <&axp192_gpio 1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
46			label = "Power LED";
47		};
48	};
49
50	lvgl_pointer {
51		compatible = "zephyr,lvgl-pointer-input";
52		input = <&ft5336_touch>;
53		swap-xy;
54	};
55
56	mipi_dbi {
57		compatible = "zephyr,mipi-dbi-spi";
58		dc-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
59		reset-gpios = <&axp192_gpio 4 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
60		spi-dev = <&spi3>;
61		write-only;
62		#address-cells = <1>;
63		#size-cells = <0>;
64
65		ili9342c: ili9342c@0 {
66			compatible = "ilitek,ili9342c";
67			mipi-max-frequency = <30000000>;
68			reg = <0>;
69			vin-supply = <&lcd_bg>;
70			pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
71			display-inversion;
72			width = <320>;
73			height = <240>;
74			rotation = <0>;
75		};
76	};
77
78	bus_5v: bus_5v {
79		compatible = "regulator-fixed";
80		regulator-name = "bus_5v";
81		enable-gpios = <&axp192_gpio 5 GPIO_ACTIVE_HIGH>;
82	};
83};
84
85&flash0 {
86	reg = <0x0 DT_SIZE_M(16)>;
87};
88
89&psram0 {
90	size = <DT_SIZE_M(8)>;
91};
92
93&uart0 {
94	status = "okay";
95	current-speed = <115200>;
96	pinctrl-0 = <&uart0_tx_gpio1 &uart0_rx_gpio3>;
97	pinctrl-names = "default";
98};
99
100&uart1 {
101	status = "disabled";
102	current-speed = <115200>;
103	pinctrl-0 = <&uart1_rx_gpio33 &uart1_tx_gpio32>;
104	pinctrl-names = "default";
105};
106
107&gpio0 {
108	status = "okay";
109};
110
111&gpio1 {
112	status = "okay";
113};
114
115&i2c0 {
116	status = "okay";
117	clock-frequency = <I2C_BITRATE_FAST>;
118	sda-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>;
119	scl-gpios = <&gpio0 22 GPIO_OPEN_DRAIN>;
120	pinctrl-0 = <&i2c0_default>;
121	scl-timeout-us = <0>;
122	pinctrl-names = "default";
123
124	pfc8563_rtc: pfc8563@51 {
125		compatible = "nxp,pcf8563";
126		reg = <0x51>;
127		status = "okay";
128	};
129
130	axp192_pmic: axp192@34 {
131		compatible = "x-powers,axp192";
132		reg = <0x34>;
133		status = "okay";
134
135		axp192_regulator: axp192_regulator {
136			compatible = "x-powers,axp192-regulator";
137			status = "okay";
138
139			vdd_mcu: DCDC1 {
140				regulator-init-microvolt = <3350000>;
141				regulator-min-microvolt = <3200000>;
142				regulator-max-microvolt = <3400000>;
143				regulator-initial-mode = <AXP192_DCDC_MODE_AUTO>;
144				regulator-boot-on;
145				regulator-always-on;
146			};
147
148			lcd_bg: DCDC3 {
149				regulator-init-microvolt = <2800000>;
150				regulator-min-microvolt = <2500000>;
151				regulator-max-microvolt = <3300000>;
152				regulator-boot-on;
153			};
154
155			v_peri: LDO2 {
156				regulator-init-microvolt = <3300000>;
157				regulator-min-microvolt = <3200000>;
158				regulator-max-microvolt = <3300000>;
159				regulator-boot-on;
160			};
161
162			vib_motor: LDO3 {
163				regulator-init-microvolt = <2800000>;
164			};
165		};
166
167		axp192_gpio: axp192_gpio {
168			compatible = "x-powers,axp192-gpio";
169			gpio-controller;
170			#gpio-cells = <2>;
171			ngpios = <6>;
172			status = "okay";
173
174			pwr_led: axp192_gpio1 {
175				gpio-hog;
176				gpios = <1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
177				output-high;
178				line-name = "pwr-led";
179			};
180
181			bus_pwr_en: axp192_gpio0 {
182				gpio-hog;
183				gpios = <0 0>;
184				output-high;
185				line-name = "bus_pwr_en";
186			};
187		};
188	};
189
190	ft5336_touch: ft5336@38 {
191		compatible = "focaltech,ft5336";
192		reg = <0x38>;
193		int-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
194	};
195};
196
197&i2c1 {
198	status = "disabled";
199	clock-frequency = <I2C_BITRATE_STANDARD>;
200	sda-gpios = <&gpio1 0 GPIO_OPEN_DRAIN>;
201	scl-gpios = <&gpio1 1 GPIO_OPEN_DRAIN>;
202	pinctrl-0 = <&i2c1_default>;
203	pinctrl-names = "default";
204};
205
206&spi3 {
207	#address-cells = <1>;
208	#size-cells = <0>;
209	status = "okay";
210	pinctrl-0 = <&spim3_default>;
211	pinctrl-names = "default";
212	dma-enabled;
213	clock-frequency = <20000000>;
214	cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>,
215			   <&gpio0 4 GPIO_ACTIVE_LOW>;
216
217	sd0: sd@1 {
218		compatible = "zephyr,sdhc-spi-slot";
219		reg = <1>;
220		status = "okay";
221		spi-max-frequency = <20000000>;
222		mmc {
223			compatible = "zephyr,sdmmc-disk";
224			disk-name = "SD";
225			status = "okay";
226		};
227
228	};
229};
230
231
232&timer0 {
233	status = "okay";
234};
235
236&timer1 {
237	status = "okay";
238};
239
240&timer2 {
241	status = "okay";
242};
243
244&timer3 {
245	status = "okay";
246};
247
248&trng0 {
249	status = "okay";
250};
251
252&esp32_bt_hci {
253	status = "okay";
254};
255