1/*
2 * Copyright (c) 2021, Electromaticus LLC, 2022 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8
9#include <nxp/nxp_k66.dtsi>
10#include <zephyr/dt-bindings/pwm/pwm.h>
11#include "rddrone_fmuk66-pinctrl.dtsi"
12#include <freq.h>
13
14/ {
15	model = "NXP RDDRONE FMUK66 board";
16	compatible = "nxp,mk66f18", "nxp,k66f", "nxp,k6x";
17
18	aliases {
19		led0 = &amber_led;
20		led1 = &green_led;
21		pwm-led0 = &red_pwm_led;
22		pwm-led1 = &green_pwm_led;
23		pwm-led2 = &blue_pwm_led;
24		magn0 = &bmm150;
25		red-pwm-led = &red_pwm_led;
26		green-pwm-led = &green_pwm_led;
27		blue-pwm-led = &blue_pwm_led;
28	};
29
30	chosen {
31		/*
32		 * Note: when using DMA, the SRAM region must be set to
33		 * a memory region that is not cached by the chip. If the chosen
34		 * sram region is changed and DMA is in use, you will
35		 * encounter issues!
36		 */
37		zephyr,sram = &sram0;
38		zephyr,flash = &flash0;
39		zephyr,code-partition = &slot0_partition;
40		zephyr,uart-mcumgr = &lpuart0;
41		zephyr,console = &lpuart0;
42		zephyr,shell-uart = &lpuart0;
43		zephyr,uart-pipe = &lpuart0;
44		zephyr,canbus = &flexcan0;
45	};
46
47	leds {
48		compatible = "gpio-leds";
49		amber_led: led_0 {
50			gpios = <&gpiod 13 GPIO_ACTIVE_LOW>;
51			label = "LED_AMB";
52		};
53		green_led: led_1 {
54			gpios = <&gpiod 14 GPIO_ACTIVE_LOW>;
55			label = "LED_GRN";
56		};
57	};
58
59	pwmleds {
60		compatible = "pwm-leds";
61
62		red_pwm_led: red_pwm_led {
63			pwms = <&ftm3 1 15625000 PWM_POLARITY_INVERTED>;
64		};
65		blue_pwm_led: blue_pwm_led {
66			pwms = <&ftm3 4 15625000 PWM_POLARITY_INVERTED>;
67		};
68		green_pwm_led: green_pwm_led {
69			pwms = <&ftm3 5 15625000 PWM_POLARITY_INVERTED>;
70		};
71	};
72
73	transceiver0: can-phy0 {
74		compatible = "nxp,tja1042", "can-transceiver-gpio";
75		max-bitrate = <5000000>;
76		standby-gpios = <&gpioc 19 GPIO_ACTIVE_HIGH>;
77		#phy-cells = <0>;
78	};
79
80	transceiver1: can-phy1 {
81		compatible = "nxp,tja1042", "can-transceiver-gpio";
82		max-bitrate = <5000000>;
83		standby-gpios = <&gpioc 18 GPIO_ACTIVE_HIGH>;
84		#phy-cells = <0>;
85	};
86
87	/* This regulator enables the 3V3_S line, which powers sensors on-board. */
88	reg-3v3-s {
89		compatible = "regulator-fixed";
90		regulator-name = "reg-3v3-s";
91		enable-gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>;
92		startup-delay-us = <2000>;
93		regulator-always-on;
94		status = "okay";
95	};
96
97	/* This regulator enables the onboard Ethernet PHY */
98	reg-3v3-neth {
99		compatible = "regulator-fixed";
100		regulator-name = "reg-3v3-neth";
101		enable-gpios = <&gpiob 3 GPIO_ACTIVE_LOW>;
102		regulator-always-on;
103		status = "okay";
104	};
105
106	/* This regulator enables the onboard SD card support */
107	reg-3v3-sd {
108		compatible = "regulator-fixed";
109		regulator-name = "reg-3v3-sd";
110		enable-gpios = <&gpiod 6 GPIO_ACTIVE_HIGH>;
111		regulator-always-on;
112		status = "okay";
113	};
114};
115
116&sim {
117	pllfll-select = <KINETIS_SIM_PLLFLLSEL_MCGPLLCLK>;
118	er32k-select = <KINETIS_SIM_ER32KSEL_RTC>;
119};
120
121&cpu0 {
122	clock-frequency = <160000000>;
123};
124
125&adc0 {
126	status = "okay";
127};
128
129&adc1 {
130	status = "okay";
131};
132
133&temp1 {
134	status = "okay";
135};
136
137&dac0 {
138	status = "okay";
139	voltage-reference = <2>;
140};
141
142/* PWM header is powered by FlexTimer 0 for channels 1 to 4 */
143&ftm0 {
144	status = "okay";
145	compatible = "nxp,ftm-pwm";
146	#pwm-cells = <3>;
147	pinctrl-0 = <&ftm0_default>;
148	pinctrl-names = "default";
149	clock-source = "fixed";
150};
151
152
153/* RGB LED powered by FlexTimer 3, and PWM headers for channel 5 and 6 */
154&ftm3 {
155	status = "okay";
156	compatible = "nxp,ftm-pwm";
157	#pwm-cells = <3>;
158	pinctrl-0 = <&ftm3_default>;
159	pinctrl-names = "default";
160	clock-source = "fixed";
161};
162
163/* LPUART connected to debug header */
164&lpuart0 {
165	status = "okay";
166	current-speed = <115200>;
167	pinctrl-0 = <&lpuart0_default>;
168	pinctrl-names = "default";
169};
170
171zephyr_udc0: &usbotg {
172	compatible = "nxp,kinetis-usbd";
173	status = "okay";
174	num-bidir-endpoints = <8>;
175};
176
177&uart0 {
178	status = "okay";
179	current-speed = <115200>;
180	pinctrl-0 = <&uart0_default>;
181	pinctrl-names = "default";
182};
183
184&uart1 {
185	status = "okay";
186	current-speed = <115200>;
187	pinctrl-0 = <&uart1_default>;
188	pinctrl-names = "default";
189};
190
191&uart2 {
192	status = "okay";
193	current-speed = <115200>;
194	pinctrl-0 = <&uart2_default>;
195	pinctrl-names = "default";
196};
197
198&uart4 {
199	status = "okay";
200	current-speed = <115200>;
201	pinctrl-0 = <&uart4_default>;
202	pinctrl-names = "default";
203};
204
205&usbotg {
206	compatible = "nxp,kinetis-usbd";
207	status = "okay";
208	num-bidir-endpoints = <8>;
209};
210
211&gpioa {
212	status = "okay";
213};
214
215&gpiob {
216	status = "okay";
217};
218
219&gpioc {
220	status = "okay";
221};
222
223&gpiod {
224	status = "okay";
225};
226
227&gpioe {
228	status = "okay";
229};
230
231&flash0 {
232
233	partitions {
234		compatible = "fixed-partitions";
235		#address-cells = <1>;
236		#size-cells = <1>;
237
238		boot_partition: partition@0 {
239			label = "mcuboot";
240			reg = <0x00000000 DT_SIZE_K(64)>;
241			read-only;
242		};
243		/* The MCUBoot swap-move algorithm uses the last 3 sectors
244		 * of the primary slot0 for swap status and move.
245		 */
246		slot0_partition: partition@10000 {
247			label = "image-0";
248			reg = <0x00010000 (DT_SIZE_K(928) + DT_SIZE_K(12))>;
249		};
250		slot1_partition: partition@FB000 {
251			label = "image-1";
252			reg = <0x000FB000 DT_SIZE_K(928)>;
253		};
254		storage_partition: partition@1E3000 {
255			label = "storage";
256			reg = <0x001E3000 DT_SIZE_K(116)>;
257		};
258	};
259};
260
261&enet_mac {
262	status = "okay";
263	pinctrl-0 = <&enet_default>;
264	pinctrl-names = "default";
265	phy-connection-type = "rmii";
266	phy-handle = <&phy>;
267	zephyr,random-mac-address;
268};
269
270&enet_mdio {
271	status = "okay";
272	pinctrl-0 = <&mdio_default>;
273	pinctrl-names = "default";
274	phy: phy@0 {
275		compatible = "ethernet-phy";
276		reg = <0>;
277		status = "okay";
278	};
279};
280
281&flexcan0 {
282	status = "okay";
283	pinctrl-0 = <&flexcan0_default>;
284	pinctrl-names = "default";
285	phys = <&transceiver0>;
286};
287
288&flexcan1 {
289	status = "okay";
290	pinctrl-0 = <&flexcan1_default>;
291	pinctrl-names = "default";
292	phys = <&transceiver1>;
293};
294
295/* external i2c port */
296&i2c0 {
297	status = "okay";
298	pinctrl-0 = <&i2c0_default>;
299	pinctrl-names = "default";
300};
301
302/* magnetometer (bmm150), barometer (bmp280), pressure (mpl3115),
303 * secure element (a7102ch) i2c bus
304 */
305&i2c1 {
306	status = "okay";
307	pinctrl-0 = <&i2c1_default>;
308	pinctrl-names = "default";
309
310	/*
311	 * This board does not have a BME280, it has a BMP280.
312	 * The two parts are incredibly similar, so the BME280 driver works for
313	 * BMP280 as well.
314	 */
315	bme280@76 {
316		compatible = "bosch,bme280";
317		status = "okay";
318		reg = <0x76>;
319	};
320
321	bmm150: bmm150@10 {
322		compatible = "bosch,bmm150";
323		status = "okay";
324		reg = <0x10>;
325	};
326};
327
328/* f-ram spi port */
329&spi0 {
330	status = "okay";
331	pinctrl-0 = <&spi0_default>;
332	pinctrl-names = "default";
333};
334
335/* flash (w25x40), accel, magneto (fxos8700), gyro (fxas2100) */
336&spi1 {
337	status = "okay";
338	pinctrl-0 = <&spi1_default>;
339	pinctrl-names = "default";
340	/*
341	 * cs-gpios needs to be populated as per the schematics
342	 * fxos8700  - CS#0
343	 * fxas21002 - CS#1
344	 */
345	cs-gpios = <&gpiob 10 GPIO_ACTIVE_LOW>,
346		   <&gpiob 9 GPIO_ACTIVE_LOW>;
347	clock-frequency = <DT_FREQ_M(1)>;
348
349
350	fxos8700@0 {
351		compatible = "nxp,fxos8700";
352		reg = <0>;
353		spi-max-frequency = <DT_FREQ_M(1)>;
354		reset-gpios = <&gpioa 25 GPIO_ACTIVE_HIGH>;
355		int1-gpios = <&gpioe 9 GPIO_ACTIVE_LOW>;
356		int2-gpios = <&gpioe 10 GPIO_ACTIVE_LOW>;
357		status = "okay";
358	};
359
360	fxas21002@1 {
361		compatible = "nxp,fxas21002";
362		reg = <1>;
363		spi-max-frequency = <DT_FREQ_M(1)>;
364		reset-gpios = <&gpiod 12 GPIO_ACTIVE_LOW>;
365		int1-gpios = <&gpioe 7 GPIO_ACTIVE_LOW>;
366		int2-gpios = <&gpioe 6 GPIO_ACTIVE_LOW>;
367		status = "okay";
368	};
369
370};
371
372/* external spi */
373&spi2 {
374	status = "okay";
375	pinctrl-0 = <&spi2_default>;
376	pinctrl-names = "default";
377};
378
379&edma0 {
380	status = "okay";
381};
382
383&pit0 {
384	status = "okay";
385};
386