1/*
2 * Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem)
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6/dts-v1/;
7
8#include <espressif/esp32/esp32_pico_d4.dtsi>
9#include "m5stickc_plus-pinctrl.dtsi"
10#include <zephyr/dt-bindings/input/input-event-codes.h>
11#include <zephyr/dt-bindings/regulator/axp192.h>
12#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
13#include <espressif/partitions_0x1000_amp.dtsi>
14
15/ {
16	model = "M5StickC Plus PROCPU";
17	compatible = "m5stack,m5stickc-plus";
18
19	aliases {
20		led0 = &red_led;
21		sw0 = &user_button_0;
22		sw1 = &user_button_1;
23		uart-0 = &uart0;
24		i2c-0 = &i2c0;
25		watchdog0 = &wdt0;
26		accel0 = &mpu6886;
27		rtc = &bm8563;
28	};
29
30	chosen {
31		zephyr,sram = &sram1;
32		zephyr,console = &uart0;
33		zephyr,shell-uart = &uart0;
34		zephyr,flash = &flash0;
35		zephyr,code-partition = &slot0_partition;
36		zephyr,rtc = &bm8563;
37		zephyr,display = &st7789v;
38		zephyr,bt-hci = &esp32_bt_hci;
39	};
40
41	leds {
42		compatible = "gpio-leds";
43
44		red_led: led_0 {
45			gpios =  <&gpio0 10 GPIO_ACTIVE_HIGH>;
46			label = "Red - LED0";
47		};
48	};
49
50	gpio_keys {
51		compatible = "gpio-keys";
52
53		user_button_0: button_0 {
54			label = "User button 0";
55			gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
56			zephyr,code = <INPUT_KEY_0>;
57		};
58		user_button_1: button_1 {
59			label = "User button 1";
60			gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
61			zephyr,code = <INPUT_KEY_1>;
62		};
63	};
64
65	mipi_dbi {
66		compatible = "zephyr,mipi-dbi-spi";
67		spi-dev = <&spi3>;
68		dc-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
69		reset-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
70		write-only;
71		#address-cells = <1>;
72		#size-cells = <0>;
73
74		st7789v: st7789v@0 {
75			compatible = "sitronix,st7789v";
76			reg = <0>;
77			mipi-max-frequency = <20000000>;
78
79			width = <135>;
80			height = <240>;
81			x-offset = <53>;
82			y-offset = <40>;
83
84			vcom = <0x28>;
85			gctrl = <0x35>;
86			vrhs = <0x10>;
87			vdvs = <0x20>;
88			mdac = <0x00>;
89			gamma = <0x01>;
90			colmod = <0x55>;
91			lcm = <0x2c>;
92			porch-param = [0c 0c 00 33 33];
93			cmd2en-param = [5a 69 02 00];
94			pwctrl1-param = [a4 a1];
95			pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17];
96			nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e];
97			ram-param = [00 F0];
98			rgb-param = [40 02 14];
99			mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
100		};
101	};
102};
103
104&uart0 {
105	status = "okay";
106	current-speed = <115200>;
107	pinctrl-0 = <&uart0_tx_gpio1 &uart0_rx_gpio3>;
108	pinctrl-names = "default";
109};
110
111&gpio0 {
112	status = "okay";
113};
114
115&gpio1 {
116	status = "okay";
117};
118
119/* IMU MPU-6886, RTC BM8563, PMU AXP192 */
120&i2c0 {
121	status = "okay";
122	clock-frequency = <I2C_BITRATE_FAST>;
123	sda-gpios = <&gpio0 21 GPIO_OPEN_DRAIN>;
124	scl-gpios = <&gpio0 22 GPIO_OPEN_DRAIN>;
125	pinctrl-0 = <&i2c0_default>;
126	scl-timeout-us = <0>;
127	pinctrl-names = "default";
128
129	axp192_pmic: axp192@34 {
130		compatible = "x-powers,axp192";
131		reg = <0x34>;
132		status = "okay";
133
134		axp192_regulator: axp192_regulator {
135			compatible = "x-powers,axp192-regulator";
136			status = "okay";
137
138			vdd_mcu: DCDC1 {
139				regulator-init-microvolt = <3350000>;
140				regulator-min-microvolt = <3200000>;
141				regulator-max-microvolt = <3400000>;
142				regulator-initial-mode = <AXP192_DCDC_MODE_AUTO>;
143				regulator-boot-on;
144				regulator-always-on;
145			};
146
147			lcd_bl: LDO2 {
148				regulator-init-microvolt = <2800000>;
149				regulator-min-microvolt = <1800000>;
150				regulator-max-microvolt = <3000000>;
151				regulator-boot-on;
152			};
153
154			lcd_logic: LDO3 {
155				regulator-init-microvolt = <3000000>;
156			};
157		};
158		axp192_gpio: axp192_gpio {
159			compatible = "x-powers,axp192-gpio";
160			gpio-controller;
161			#gpio-cells = <2>;
162			ngpios = <6>;
163			status = "okay";
164		};
165	};
166
167	mpu6886: mpu6886@68 {
168		status = "okay";
169		compatible = "invensense,mpu6050";
170		reg = <0x68>;
171	};
172
173	bm8563: bm8563@51 {
174		compatible = "nxp,pcf8563";
175		reg = <0x51>;
176		status = "okay";
177	};
178};
179
180&spi2 {
181	#address-cells = <1>;
182	#size-cells = <0>;
183	status = "okay";
184	pinctrl-0 = <&spim2_miso_gpio12 &spim2_mosi_gpio11
185				&spim2_sclk_gpio14 &spim2_csel_gpio16>;
186	pinctrl-names = "default";
187};
188
189/* LCD TFT 1.14", 135x240 px, ST7789v2 */
190&spi3 {
191	#address-cells = <1>;
192	#size-cells = <0>;
193	status = "okay";
194	pinctrl-0 = <&spim3_default>;
195	pinctrl-names = "default";
196};
197
198&timer0 {
199	status = "okay";
200};
201
202&timer1 {
203	status = "okay";
204};
205
206&timer2 {
207	status = "okay";
208};
209
210&timer3 {
211	status = "okay";
212};
213
214&trng0 {
215	status = "okay";
216};
217
218&esp32_bt_hci {
219	status = "okay";
220};
221