1/*
2 * Copyright (c) 2020 Stephane Dorre <stephane.dorre@gmail.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * DTS for Pine64 PineTime DevKit-0 board
7 * Further info: https://wiki.pine64.org/index.php/PineTime
8 *
9 */
10
11/dts-v1/;
12#include <nordic/nrf52832_qfaa.dtsi>
13#include "pinetime_devkit0-pinctrl.dtsi"
14#include <zephyr/dt-bindings/input/input-event-codes.h>
15#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
16
17/ {
18	model = "Pine64 PineTime DevKit0";
19	compatible = "pine64,pinetime-devkit0";
20
21	chosen {
22		zephyr,console = &uart0;
23		zephyr,shell-uart = &uart0;
24		zephyr,bt-mon-uart = &uart0;
25		zephyr,bt-c2h-uart = &uart0;
26		zephyr,sram = &sram0;
27		zephyr,flash = &flash0;
28		zephyr,code-partition = &slot0_partition;
29		zephyr,display = &st7789v;
30		zephyr,touch = &cst816s;
31	};
32
33	aliases {
34		led0 = &blled0;	/* backlight low */
35		led1 = &blled1;	/* backlight mid */
36		led2 = &blled2;	/* backlight high */
37		led3 = &statusled;	/* status led, may be not populated */
38		sw0 = &key_in;  /* key in */
39		watchdog0 = &wdt0;
40	};
41
42	leds {
43		compatible = "gpio-leds";
44		blled0: bl_led_0 {
45			gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
46			label = "Backlight Low";
47		};
48		blled1: bl_led_1 {
49			gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
50			label = "Backlight Medium";
51		};
52		blled2: bl_led_2 {
53			gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
54			label = "Backlight High";
55		};
56		statusled: led_3 {
57			gpios = <&gpio0 27 GPIO_ACTIVE_LOW>;
58			label = "Status Led";
59		};
60	};
61
62	buttons {
63		compatible = "gpio-keys";
64		key_in: button_0 {
65			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
66			label = "Key in";
67			zephyr,code = <INPUT_KEY_0>;
68		};
69	};
70
71	lvgl_pointer {
72		compatible = "zephyr,lvgl-pointer-input";
73		input = <&cst816s>;
74	};
75
76	vbatt {
77		compatible = "voltage-divider";
78		io-channels = <&adc 7>;
79		output-ohms = <1000000>;
80		full-ohms = <(1000000 + 1000000)>;
81	};
82
83	mipi_dbi {
84		compatible = "zephyr,mipi-dbi-spi";
85		spi-dev = <&spi1>;
86		dc-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>;	/* DET */
87		reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;	/* RESX reset */
88		write-only;
89		#address-cells = <1>;
90		#size-cells = <0>;
91		/* Sitronix ST7789V LCD */
92		st7789v: st7789v@1 {
93			compatible = "sitronix,st7789v";
94			reg = <1>;
95			mipi-max-frequency = <8000000>; /* 8MHz */
96			width = <240>;
97			height = <240>;
98			x-offset = <0>;
99			y-offset = <0>;
100			vcom = <0x19>;
101			gctrl = <0x35>;
102			vrhs = <0x12>;
103			vdvs = <0x20>;
104			mdac = <0x00>;
105			gamma = <0x01>;
106			colmod = <0x05>;
107			lcm = <0x2c>;
108			porch-param = [0c 0c 00 33 33];
109			cmd2en-param = [5a 69 02 01];
110			pwctrl1-param = [a4 a1];
111			pvgam-param = [D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23];
112			nvgam-param = [D0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23];
113			ram-param = [00 F0];
114			rgb-param = [CD 08 14];
115			mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
116		};
117	};
118};
119
120&adc {
121	status = "okay";
122};
123
124&uicr {
125	gpio-as-nreset;
126};
127
128&gpiote {
129	status = "okay";
130};
131
132&uicr {
133	nfct-pins-as-gpios;
134};
135
136&gpio0 {
137	status = "okay";
138
139	key-out {
140		gpio-hog;
141		gpios = <15 GPIO_ACTIVE_HIGH>;
142		output-high;
143	};
144};
145
146&uart0 {
147	compatible = "nordic,nrf-uart";
148	current-speed = <115200>;
149	status = "okay";
150	pinctrl-0 = <&uart0_default>;
151	pinctrl-1 = <&uart0_sleep>;
152	pinctrl-names = "default", "sleep";
153};
154
155&i2c0 {
156	compatible = "nordic,nrf-twim";
157	status = "okay";
158	clock-frequency = <I2C_BITRATE_FAST>; /* 400KHz */
159
160	/* BOSCH BMA421 Triaxial Acceleration Sensor (1000KHz) */
161	pinctrl-0 = <&i2c0_default>;
162	pinctrl-1 = <&i2c0_sleep>;
163	pinctrl-names = "default", "sleep";
164	bma421: bma421@18 {
165		compatible = "bosch,bma4xx";
166		reg = <0x18>;
167		int1-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
168	};
169
170	/* TianYiHeXin HRS3300 PPG Hear Rate Sensor (800KHz) */
171	hrs3300: hrs3300@44 {
172		compatible = "tian-yi-he-xin-hrs3300";
173		reg = <0x44>;
174	};
175
176	/* Hynitron CST816S Capacitive Touch Controller (400KHz) */
177	cst816s: cst816s@15 {
178		compatible = "hynitron,cst816s";
179		reg = <0x15>;
180		irq-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
181		rst-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
182	};
183};
184
185&spi1 {
186	compatible = "nordic,nrf-spi";
187	status = "okay";
188
189	cs-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>, <&gpio0 25 GPIO_ACTIVE_LOW>;
190
191	pinctrl-0 = <&spi1_default>;
192	pinctrl-1 = <&spi1_sleep>;
193	pinctrl-names = "default", "sleep";
194	xt25fb32: xt25fb32@0 {
195		compatible = "jedec,spi-nor";
196		reg = <0>;
197		spi-max-frequency = <8000000>; /* 8MHz */
198		jedec-id = [0b 40 16];
199		size = <DT_SIZE_M(32)>;
200
201		partitions {
202			compatible = "fixed-partitions";
203			#address-cells = <1>;
204			#size-cells = <1>;
205
206			/* next firmware update */
207			slot1_partition: partition@0 {
208				label = "image-1";
209				reg = <0x00000000 0x74000>;
210			};
211
212			/* to be used in firmware */
213			storage_partition: partition@300000 {
214				label = "storage";
215				reg = <0x00300000 0x00100000>;
216			};
217		};
218	};
219};
220
221&flash0 {
222	partitions {
223		compatible = "fixed-partitions";
224		#address-cells = <1>;
225		#size-cells = <1>;
226
227		/* MCUboot bootloader */
228		boot_partition: partition@0 {
229			label = "mcuboot";
230			reg = <0x00000000 0xc000>;
231		};
232
233		/* main firmware partition */
234		slot0_partition: partition@c000 {
235			label = "image-0";
236			reg = <0x0000C000 0x74000>;
237		};
238	};
239};
240