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	reg = <0x3f800000 DT_SIZE_M(8)>;
91	status = "disabled";
92};
93
94&uart0 {
95	status = "okay";
96	current-speed = <115200>;
97	pinctrl-0 = <&uart0_tx_gpio1 &uart0_rx_gpio3>;
98	pinctrl-names = "default";
99};
100
101&uart1 {
102	status = "disabled";
103	current-speed = <115200>;
104	pinctrl-0 = <&uart1_rx_gpio33 &uart1_tx_gpio32>;
105	pinctrl-names = "default";
106};
107
108&gpio0 {
109	status = "okay";
110};
111
112&gpio1 {
113	status = "okay";
114};
115
116&i2c0 {
117	status = "okay";
118	clock-frequency = <I2C_BITRATE_FAST>;
119	sda-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>;
120	scl-gpios = <&gpio0 22 GPIO_OPEN_DRAIN>;
121	pinctrl-0 = <&i2c0_default>;
122	scl-timeout-us = <0>;
123	pinctrl-names = "default";
124
125	pfc8563_rtc: pfc8563@51 {
126		compatible = "nxp,pcf8563";
127		reg = <0x51>;
128		status = "okay";
129	};
130
131	axp192_pmic: axp192@34 {
132		compatible = "x-powers,axp192";
133		reg = <0x34>;
134		status = "okay";
135
136		axp192_regulator: axp192_regulator {
137			compatible = "x-powers,axp192-regulator";
138			status = "okay";
139
140			vdd_mcu: DCDC1 {
141				regulator-init-microvolt = <3350000>;
142				regulator-min-microvolt = <3200000>;
143				regulator-max-microvolt = <3400000>;
144				regulator-initial-mode = <AXP192_DCDC_MODE_AUTO>;
145				regulator-boot-on;
146				regulator-always-on;
147			};
148
149			lcd_bg: DCDC3 {
150				regulator-init-microvolt = <2800000>;
151				regulator-min-microvolt = <2500000>;
152				regulator-max-microvolt = <3300000>;
153				regulator-boot-on;
154			};
155
156			v_peri: LDO2 {
157				regulator-init-microvolt = <3300000>;
158				regulator-min-microvolt = <3200000>;
159				regulator-max-microvolt = <3300000>;
160				regulator-boot-on;
161			};
162
163			vib_motor: LDO3 {
164				regulator-init-microvolt = <2800000>;
165			};
166		};
167
168		axp192_gpio: axp192_gpio {
169			compatible = "x-powers,axp192-gpio";
170			gpio-controller;
171			#gpio-cells = <2>;
172			ngpios = <6>;
173			status = "okay";
174
175			pwr_led: axp192_gpio1 {
176				gpio-hog;
177				gpios = <1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
178				output-high;
179				line-name = "pwr-led";
180			};
181
182			bus_pwr_en: axp192_gpio0 {
183				gpio-hog;
184				gpios = <0 0>;
185				output-high;
186				line-name = "bus_pwr_en";
187			};
188		};
189	};
190
191	ft5336_touch: ft5336@38 {
192		compatible = "focaltech,ft5336";
193		reg = <0x38>;
194		int-gpios = <&gpio1 7 0>;
195	};
196};
197
198&i2c1 {
199	status = "disabled";
200	clock-frequency = <I2C_BITRATE_STANDARD>;
201	sda-gpios = <&gpio1 0 GPIO_OPEN_DRAIN>;
202	scl-gpios = <&gpio1 1 GPIO_OPEN_DRAIN>;
203	pinctrl-0 = <&i2c1_default>;
204	pinctrl-names = "default";
205};
206
207&spi3 {
208	#address-cells = <1>;
209	#size-cells = <0>;
210	status = "okay";
211	pinctrl-0 = <&spim3_default>;
212	pinctrl-names = "default";
213	dma-enabled;
214	clock-frequency = <20000000>;
215	cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>,
216			   <&gpio0 4 GPIO_ACTIVE_LOW>;
217
218	sd0: sd@1 {
219		compatible = "zephyr,sdhc-spi-slot";
220		reg = <1>;
221		status = "okay";
222		spi-max-frequency = <20000000>;
223		mmc {
224			compatible = "zephyr,sdmmc-disk";
225			disk-name = "SD";
226			status = "okay";
227		};
228
229	};
230};
231
232
233&timer0 {
234	status = "okay";
235};
236
237&timer1 {
238	status = "okay";
239};
240
241&timer2 {
242	status = "okay";
243};
244
245&timer3 {
246	status = "okay";
247};
248
249&trng0 {
250	status = "okay";
251};
252
253&esp32_bt_hci {
254	status = "okay";
255};
256