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
45		led_pwr: led_pwr {
46			gpios = <&axp192_gpio 1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
47			label = "Power LED";
48		};
49	};
50
51	mipi_dbi {
52		compatible = "zephyr,mipi-dbi-spi";
53		dc-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
54		reset-gpios = <&axp192_gpio 4 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
55		spi-dev = <&spi3>;
56		write-only;
57		#address-cells = <1>;
58		#size-cells = <0>;
59
60		ili9342c: ili9342c@0 {
61			compatible = "ilitek,ili9342c";
62			mipi-max-frequency = <30000000>;
63			reg = <0>;
64			vin-supply = <&lcd_bg>;
65			pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
66			display-inversion;
67			width = <320>;
68			height = <240>;
69			rotation = <0>;
70		};
71	};
72
73	bus_5v: bus_5v {
74		compatible = "regulator-fixed";
75		regulator-name = "bus_5v";
76		enable-gpios = <&axp192_gpio 5 GPIO_ACTIVE_HIGH>;
77	};
78};
79
80&flash0 {
81	reg = <0x0 DT_SIZE_M(16)>;
82};
83
84&psram0 {
85	size = <DT_SIZE_M(8)>;
86};
87
88&uart0 {
89	status = "okay";
90	current-speed = <115200>;
91	pinctrl-0 = <&uart0_tx_gpio1 &uart0_rx_gpio3>;
92	pinctrl-names = "default";
93};
94
95&uart1 {
96	status = "disabled";
97	current-speed = <115200>;
98	pinctrl-0 = <&uart1_rx_gpio33 &uart1_tx_gpio32>;
99	pinctrl-names = "default";
100};
101
102&gpio0 {
103	status = "okay";
104};
105
106&gpio1 {
107	status = "okay";
108};
109
110&i2c0 {
111	status = "okay";
112	clock-frequency = <I2C_BITRATE_FAST>;
113	sda-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>;
114	scl-gpios = <&gpio0 22 GPIO_OPEN_DRAIN>;
115	pinctrl-0 = <&i2c0_default>;
116	scl-timeout-us = <0>;
117	pinctrl-names = "default";
118
119	pfc8563_rtc: pfc8563@51 {
120		compatible = "nxp,pcf8563";
121		reg = <0x51>;
122		status = "okay";
123	};
124
125	axp192_pmic: axp192@34 {
126		compatible = "x-powers,axp192";
127		reg = <0x34>;
128		status = "okay";
129
130		axp192_regulator: axp192_regulator {
131			compatible = "x-powers,axp192-regulator";
132			status = "okay";
133
134			vdd_mcu: DCDC1 {
135				regulator-init-microvolt = <3350000>;
136				regulator-min-microvolt = <3200000>;
137				regulator-max-microvolt = <3400000>;
138				regulator-initial-mode = <AXP192_DCDC_MODE_AUTO>;
139				regulator-boot-on;
140				regulator-always-on;
141			};
142
143			lcd_bg: DCDC3 {
144				regulator-init-microvolt = <2800000>;
145				regulator-min-microvolt = <2500000>;
146				regulator-max-microvolt = <3300000>;
147				regulator-boot-on;
148			};
149
150			v_peri: LDO2 {
151				regulator-init-microvolt = <3300000>;
152				regulator-min-microvolt = <3200000>;
153				regulator-max-microvolt = <3300000>;
154				regulator-boot-on;
155			};
156
157			vib_motor: LDO3 {
158				regulator-init-microvolt = <2800000>;
159			};
160		};
161
162		axp192_gpio: axp192_gpio {
163			compatible = "x-powers,axp192-gpio";
164			gpio-controller;
165			#gpio-cells = <2>;
166			ngpios = <6>;
167			status = "okay";
168
169			pwr_led: axp192_gpio1 {
170				gpio-hog;
171				gpios = <1 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
172				output-high;
173				line-name = "pwr-led";
174			};
175
176			bus_pwr_en: axp192_gpio0 {
177				gpio-hog;
178				gpios = <0 0>;
179				output-high;
180				line-name = "bus_pwr_en";
181			};
182		};
183	};
184
185	ft5336_touch: ft5336@38 {
186		compatible = "focaltech,ft5336";
187		reg = <0x38>;
188		int-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
189		swapped-x-y;
190		screen-width = <320>;
191		screen-height = <240>;
192	};
193};
194
195&i2c1 {
196	status = "disabled";
197	clock-frequency = <I2C_BITRATE_STANDARD>;
198	sda-gpios = <&gpio1 0 GPIO_OPEN_DRAIN>;
199	scl-gpios = <&gpio1 1 GPIO_OPEN_DRAIN>;
200	pinctrl-0 = <&i2c1_default>;
201	pinctrl-names = "default";
202};
203
204&spi3 {
205	#address-cells = <1>;
206	#size-cells = <0>;
207	status = "okay";
208	pinctrl-0 = <&spim3_default>;
209	pinctrl-names = "default";
210	dma-enabled;
211	clock-frequency = <20000000>;
212	cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>,
213		   <&gpio0 4 GPIO_ACTIVE_LOW>;
214
215	sd0: sd@1 {
216		compatible = "zephyr,sdhc-spi-slot";
217		reg = <1>;
218		status = "okay";
219		spi-max-frequency = <20000000>;
220
221		mmc {
222			compatible = "zephyr,sdmmc-disk";
223			disk-name = "SD";
224			status = "okay";
225		};
226	};
227};
228
229&timer0 {
230	status = "okay";
231};
232
233&timer1 {
234	status = "okay";
235};
236
237&timer2 {
238	status = "okay";
239};
240
241&timer3 {
242	status = "okay";
243};
244
245&trng0 {
246	status = "okay";
247};
248
249&esp32_bt_hci {
250	status = "okay";
251};
252
253&wifi {
254	status = "okay";
255};
256