1/*
2 * Copyright (c) 2023 Benjamin Cabé <benjamin@zephyrproject.org>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6/dts-v1/;
7
8#include <espressif/esp32s3/esp32s3_fn8.dtsi>
9#include "m5stack_atoms3-pinctrl.dtsi"
10#include "grove_connectors.dtsi"
11#include <zephyr/dt-bindings/input/input-event-codes.h>
12#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
13
14/ {
15	model = "M5Stack AtomS3 PROCPU";
16	compatible = "m5stack,atoms3";
17
18	chosen {
19		zephyr,sram = &sram0;
20		zephyr,console = &usb_serial;
21		zephyr,shell-uart = &usb_serial;
22		zephyr,flash = &flash0;
23		zephyr,code-partition = &slot0_partition;
24		zephyr,display = &st7789v;
25		zephyr,bt-hci = &esp32_bt_hci;
26	};
27
28	aliases {
29		sw0 = &user_button_0;
30		watchdog0 = &wdt0;
31		accel0 = &mpu6886;
32	};
33
34	gpio_keys {
35		compatible = "gpio-keys";
36
37		/* This is the button that's underneath the LCD display  */
38		user_button_0: button_0 {
39			label = "User button 0";
40			gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; // G42
41			zephyr,code = <INPUT_KEY_0>;
42		};
43	};
44
45	/* Regulators */
46	lcd_backlight_en {
47		compatible = "regulator-fixed";
48		regulator-name = "lcd_backlight_enable";
49		enable-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
50		regulator-boot-on;
51	};
52
53	mipi_dbi {
54		compatible = "zephyr,mipi-dbi-spi";
55		spi-dev = <&spi2>;
56		dc-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;	     /* G33 */
57		reset-gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;    /* G34 */
58		write-only;
59		#address-cells = <1>;
60		#size-cells = <0>;
61
62		st7789v: st7789v@0 {
63			compatible = "sitronix,st7789v";
64			reg = <0>;
65			mipi-max-frequency = <27000000>;
66
67			width = <128>;
68			height = <128>;
69			x-offset = <2>;
70			y-offset = <1>;
71
72			vcom = <0x28>;
73			gctrl = <0x35>;
74			vrhs = <0x10>;
75			vdvs = <0x20>;
76			mdac = <0x00>;
77			gamma = <0x01>;
78			colmod = <0x55>;
79			lcm = <0x0c>;
80			porch-param = [0c 0c 00 33 33];
81			cmd2en-param = [5a 69 02 00];
82			pwctrl1-param = [a4 a1];
83			pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17];
84			nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e];
85			ram-param = [00 E0];
86			rgb-param = [40 02 14];
87			mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
88		};
89
90	};
91
92};
93
94&usb_serial {
95	status = "okay";
96};
97
98&uart0 {
99	status = "okay";
100	current-speed = <115200>;
101	pinctrl-0 = <&uart0_default>;
102	pinctrl-names = "default";
103};
104
105&i2c0 {
106	status = "okay";
107	clock-frequency = <I2C_BITRATE_STANDARD>;
108	pinctrl-0 = <&i2c0_default>;
109	pinctrl-names = "default";
110
111	mpu6886: mpu6886@68 {
112		compatible = "invensense,mpu6050";
113		reg = <0x68>;
114		status = "okay";
115	};
116};
117
118&i2c1 {
119	status = "okay";
120	clock-frequency = <I2C_BITRATE_STANDARD>;
121	pinctrl-0 = <&i2c1_default>;
122	pinctrl-names = "default";
123};
124
125&trng0 {
126	status = "okay";
127};
128
129&spi2 {
130	#address-cells = <1>;
131	#size-cells = <0>;
132	status = "okay";
133	pinctrl-0 = <&spim2_default>;
134	pinctrl-names = "default";
135};
136
137&gpio0 {
138	status = "okay";
139};
140
141&gpio1 {
142	status = "okay";
143};
144
145&wdt0 {
146	status = "okay";
147};
148
149&timer0 {
150	status = "okay";
151};
152
153&timer1 {
154	status = "okay";
155};
156
157&flash0 {
158	status = "okay";
159	partitions {
160		compatible = "fixed-partitions";
161		#address-cells = <1>;
162		#size-cells = <1>;
163
164		boot_partition: partition@0 {
165			label = "mcuboot";
166			reg = <0x00000000 0x0000F000>;
167			read-only;
168		};
169
170		slot0_partition: partition@10000 {
171			label = "image-0";
172			reg = <0x00010000 0x00100000>;
173		};
174
175		slot1_partition: partition@110000 {
176			label = "image-1";
177			reg = <0x00110000 0x00100000>;
178		};
179
180		scratch_partition: partition@210000 {
181			label = "image-scratch";
182			reg = <0x00210000 0x00040000>;
183		};
184
185		storage_partition: partition@250000 {
186			label = "storage";
187			reg = <0x00250000 0x00006000>;
188		};
189	};
190};
191
192&esp32_bt_hci {
193	status = "okay";
194};
195