1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#include "thingy53_nrf5340_common-pinctrl.dtsi"
7#include <zephyr/dt-bindings/input/input-event-codes.h>
8#include <zephyr/dt-bindings/battery/battery.h>
9
10/ {
11	chosen {
12		zephyr,bt-hci-ipc = &ipc0;
13		zephyr,bt-hci = &bt_hci_ipc0;
14		nordic,802154-spinel-ipc = &ipc0;
15		zephyr,ieee802154 = &ieee802154;
16	};
17
18	buttons {
19		compatible = "gpio-keys";
20		button0: button_0 {
21			gpios = <&gpio1 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
22			label = "Push button 1";
23			zephyr,code = <INPUT_KEY_0>;
24		};
25		button1: button_1 {
26			gpios = <&gpio1 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
27			label = "Push button 2";
28			zephyr,code = <INPUT_KEY_1>;
29		};
30	};
31
32	leds {
33		compatible = "gpio-leds";
34		red_led: led_1 {
35			gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
36			label = "RGB red LED";
37		};
38		green_led: led_2 {
39			gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
40			label = "RGB green LED";
41		};
42		blue_led: led_3 {
43			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
44			label = "RGB blue LED";
45		};
46	};
47
48	pwmleds {
49		compatible = "pwm-leds";
50		red_led_pwm: led_pwm_0 {
51			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
52			label = "Red PWM LED";
53		};
54
55		green_led_pwm: led_pwm_1 {
56			pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
57			label = "Green PWM LED";
58		};
59
60		blue_led_pwm: led_pwm_2 {
61			pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
62			label = "Blue PWM LED";
63		};
64	};
65
66	edge_connector: connector {
67		compatible = "nordic-thingy53-edge-connector";
68		#gpio-cells = <2>;
69		gpio-map-mask = <0xffffffff 0xffffffc0>;
70		gpio-map-pass-thru = <0 0x3f>;
71		gpio-map = <8 0 &gpio0 5 0>,	/* P8, P0.05/AIN1 */
72			   <9 0 &gpio0 4 0>,	/* P9, P0.04/AIN0 */
73			   <15 0 &gpio0 8 0>,	/* P15, P0.08/TRACEDATA3 */
74			   <16 0 &gpio0 9 0>,	/* P16, P0.09/TRACEDATA2 */
75			   <17 0 &gpio0 10 0>,	/* P17, P0.10/TRACEDATA1 */
76			   <18 0 &gpio0 11 0>,	/* P18, P0.11/TRACEDATA0 */
77			   <19 0 &gpio0 12 0>;	/* P19, P0.12/TRACECLK */
78	};
79
80	npm1100_force_pwm_mode: npm1100_force_pwm_mode {
81		compatible = "regulator-fixed";
82		regulator-name = "npm1100_force_pwm_mode";
83		enable-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
84		status = "disabled";
85		regulator-boot-on;
86	};
87
88	vbatt: vbatt {
89		compatible = "voltage-divider";
90		io-channels = <&adc 2>;
91		output-ohms = <180000>;
92		full-ohms = <(1500000 + 180000)>;
93		power-gpios = <&gpio0 16 0>;
94	};
95
96	fuel_gauge: fuel_gauge {
97		compatible = "zephyr,fuel-gauge-composite";
98		battery-voltage = <&vbatt>;
99		device-chemistry = "lithium-ion-polymer";
100		ocv-capacity-table-0 = <BATTERY_OCV_CURVE_LITHIUM_ION_POLYMER_DEFAULT>;
101		charge-full-design-microamp-hours = <1350000>;
102	};
103
104	regulator_3v3: regulator-3v3-ctrl {
105		compatible = "regulator-fixed";
106		regulator-name = "ncp114";
107		enable-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
108		regulator-boot-on;
109	};
110
111	sensor_pwr_ctrl: sensor-pwr-ctrl {
112		compatible = "regulator-fixed";
113		regulator-name = "tck106ag";
114		enable-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
115		regulator-boot-on;
116	};
117
118	gpio_fwd: nrf-gpio-forwarder {
119		compatible = "nordic,nrf-gpio-forwarder";
120		status = "okay";
121		fem-gpio-if {
122			gpios = <&gpio1 11 0>,
123				<&gpio1 12 0>,
124				<&gpio1 10 0>,
125				<&gpio0 30 0>;
126		};
127	};
128
129	/* Disabled by default as SPI lines are shared with peripherals on application core */
130	spi_fwd: nrf-spi-forwarder {
131		compatible = "nordic,nrf-gpio-forwarder";
132		status = "disabled";
133		fem-spi-if {
134			gpios = <&gpio0 24 0>,
135				<&gpio0 29 0>,
136				<&gpio0 27 0>,
137				<&gpio0 28 0>;
138		};
139	};
140
141	aliases {
142		sw0 = &button0;
143		sw1 = &button1;
144		led0 = &red_led;
145		led1 = &green_led;
146		led2 = &blue_led;
147		pwm-led0 = &red_led_pwm;
148		pwm-led1 = &green_led_pwm;
149		pwm-led2 = &blue_led_pwm;
150		magn0 = &bmm150;
151		watchdog0 = &wdt0;
152		accel0 = &adxl362;
153		mcuboot-button0 = &button1;
154		mcuboot-led0 = &blue_led;
155	};
156};
157
158/* RGB LED control */
159&pwm0 {
160	status = "okay";
161	pinctrl-0 = <&pwm0_default>;
162	pinctrl-1 = <&pwm0_sleep>;
163	pinctrl-names = "default", "sleep";
164};
165
166/* Buzzer control */
167&pwm1 {
168	status = "okay";
169	pinctrl-0 = <&pwm1_default>;
170	pinctrl-1 = <&pwm1_sleep>;
171	pinctrl-names = "default", "sleep";
172};
173
174&adc {
175	#address-cells = <1>;
176	#size-cells = <0>;
177	status = "okay";
178
179	channel@2 {
180		reg = <2>;
181		zephyr,gain = "ADC_GAIN_1";
182		zephyr,reference = "ADC_REF_INTERNAL";
183		zephyr,vref-mv = <600>;
184		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
185		zephyr,resolution = <12>;
186		zephyr,input-positive = <NRF_SAADC_AIN2>;
187	};
188};
189
190&gpiote {
191	status = "okay";
192};
193
194&gpio0 {
195	status = "okay";
196};
197
198&gpio1 {
199	status = "okay";
200};
201
202&i2c1 {
203	compatible = "nordic,nrf-twim";
204	status = "okay";
205	clock-frequency = <I2C_BITRATE_FAST>;
206
207	pinctrl-0 = <&i2c1_default>;
208	pinctrl-1 = <&i2c1_sleep>;
209	pinctrl-names = "default", "sleep";
210	bmm150: bmm150@10 {
211		compatible = "bosch,bmm150";
212		reg = <0x10>;
213	};
214
215	bh1749: bh1749@38 {
216		compatible = "rohm,bh1749";
217		reg = <0x38>;
218		int-gpios = <&gpio1 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
219	};
220
221	bme688: bme688@76 {
222		compatible = "bosch,bme680";
223		reg = <0x76>;
224	};
225};
226
227&spi3 {
228	compatible = "nordic,nrf-spim";
229	status = "okay";
230	cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>,
231		   <&gpio1 4  GPIO_ACTIVE_LOW>,
232		   <&gpio0 24 GPIO_ACTIVE_LOW>;
233
234	pinctrl-0 = <&spi3_default>;
235	pinctrl-1 = <&spi3_sleep>;
236	pinctrl-names = "default", "sleep";
237	adxl362: spi-dev-adxl362@0 {
238		compatible = "adi,adxl362";
239		spi-max-frequency = <8000000>;
240		reg = <0>;
241		int1-gpios = <&gpio0 19 0>;
242	};
243
244	bmi270: spi-dev-bmi270@1 {
245		compatible = "bosch,bmi270";
246		status = "disabled";
247		spi-max-frequency = <8000000>;
248		reg = <1>;
249	};
250
251	nrf_radio_fem_spi: fem_spi@2 {
252		compatible = "nordic,nrf21540-fem-spi";
253		status = "disabled";
254		reg = <2>;
255		spi-max-frequency = <8000000>;
256	};
257};
258
259/* UART0 GPIOs can be configured for other use-cases */
260&uart0 {
261	/* Disabled by default */
262	current-speed = <115200>;
263	status = "disabled";
264	pinctrl-0 = <&uart0_default>;
265	pinctrl-1 = <&uart0_sleep>;
266	pinctrl-names = "default", "sleep";
267};
268
269&qspi {
270	status = "okay";
271	pinctrl-0 = <&qspi_default>;
272	pinctrl-1 = <&qspi_sleep>;
273	pinctrl-names = "default", "sleep";
274	mx25r64: mx25r6435f@0 {
275		compatible = "nordic,qspi-nor";
276		reg = <0>;
277		/* MX25R64 supports only pp and pp4io */
278		/* Thingy:53 supports only pp and pp2o options */
279		writeoc = "pp";
280		/* MX25R64 supports all readoc options */
281		/* Thingy:53 supports only fastread and read2io options */
282		readoc = "read2io";
283		sck-frequency = <8000000>;
284		jedec-id = [c2 28 17];
285		sfdp-bfp = [
286			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
287			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
288			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
289			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
290		];
291		size = <67108864>;
292		has-dpd;
293		t-enter-dpd = <10000>;
294		t-exit-dpd = <35000>;
295	};
296};
297
298edge_connector_spi: &spi4 {
299	compatible = "nordic,nrf-spim";
300	status = "okay";
301	cs-gpios = <&edge_connector 18 GPIO_ACTIVE_LOW>;
302	pinctrl-0 = <&spi4_default>;
303	pinctrl-1 = <&spi4_sleep>;
304	pinctrl-names = "default", "sleep";
305};
306
307&ieee802154 {
308	status = "okay";
309};
310
311zephyr_udc0: &usbd {
312	compatible = "nordic,nrf-usbd";
313	status = "okay";
314};
315
316/* Include default memory partition configuration file */
317#include <common/nordic/nrf5340_cpuapp_partition.dtsi>
318