1/*
2 * Copyright (c) 2018 Prevas A/S
3 * Copyright 2024 NXP
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8/dts-v1/;
9
10#include <nxp/nxp_k22fn512.dtsi>
11#include <zephyr/dt-bindings/pwm/pwm.h>
12#include "frdm_k22f-pinctrl.dtsi"
13#include <zephyr/dt-bindings/input/input-event-codes.h>
14
15/ {
16	model = "NXP Freedom MK22F board";
17	compatible = "nxp,mk22f12", "nxp,k22f", "nxp,k2x";
18
19	aliases {
20		led0 = &green_led;
21		led1 = &blue_led;
22		led2 = &red_led;
23		sw0 = &user_button_3;
24		sw1 = &user_button_2;
25		pwm-led0 = &green_pwm_led;
26		green-pwm-led = &green_pwm_led;
27		blue-pwm-led = &blue_pwm_led;
28		red-pwm-led = &red_pwm_led;
29		magn0 = &fxos8700;
30		accel0 = &fxos8700;
31		mcuboot-button0 = &user_button_3;
32	};
33
34	chosen {
35		zephyr,sram = &sram0;
36		zephyr,flash = &flash0;
37		zephyr,code-partition = &slot0_partition;
38		zephyr,uart-mcumgr = &uart1;
39		zephyr,console = &uart1;
40		zephyr,shell-uart = &uart1;
41		zephyr,uart-pipe = &uart1;
42	};
43
44	leds {
45		compatible = "gpio-leds";
46		red_led: led_0 {
47			gpios = <&gpioa 1 0>;
48			label = "User LD1";
49		};
50		green_led: led_1 {
51			gpios = <&gpioa 2 0>;
52			label = "User LD2";
53		};
54		blue_led: led_2 {
55			gpios = <&gpiod 5 0>;
56			label = "User LD3";
57		};
58	};
59
60	pwmleds {
61		compatible = "pwm-leds";
62
63		red_pwm_led: red_pwm_led {
64			label = "red_led";
65			pwms = <&ftm0 6 15625000 PWM_POLARITY_INVERTED>;
66		};
67		green_pwm_led: green_pwm_led {
68			label = "green_led";
69			pwms = <&ftm0 7 15625000 PWM_POLARITY_INVERTED>;
70		};
71		blue_pwm_led: blue_pwm_led {
72			label = "blue_led";
73			pwms = <&ftm0 5 15625000 PWM_POLARITY_INVERTED>;
74		};
75	};
76
77	gpio_keys {
78		compatible = "gpio-keys";
79		user_button_2: button_0 {
80			label = "User SW2";
81			gpios = <&gpioc 1 GPIO_ACTIVE_LOW>;
82			zephyr,code = <INPUT_KEY_0>;
83		};
84		user_button_3: button_1 {
85			label = "User SW3";
86			gpios = <&gpiob 17 GPIO_ACTIVE_LOW>;
87			zephyr,code = <INPUT_KEY_1>;
88		};
89	};
90
91	arduino_header: connector {
92		compatible = "arduino-header-r3";
93		#gpio-cells = <2>;
94		gpio-map-mask = <0xffffffff 0xffffffc0>;
95		gpio-map-pass-thru = <0 0x3f>;
96		gpio-map = <0 0 &gpiob 0 0>,	/* A0 */
97			   <1 0 &gpiob 1 0>,	/* A1 */
98			   <2 0 &gpioc 1 0>,	/* A2 */
99			   <3 0 &gpioc 2 0>,	/* A3 */
100			   <4 0 &gpiob 3 0>,	/* A4 */
101			   <5 0 &gpiob 2 0>,	/* A5 */
102			   <6 0 &gpiod 2 0>,	/* D0 */
103			   <7 0 &gpiod 3 0>,	/* D1 */
104			   <8 0 &gpiob 16 0>,	/* D2 */
105			   <9 0 &gpioa 2 0>,	/* D3 */
106			   <10 0 &gpioa 4 0>,	/* D4 */
107			   <11 0 &gpiob 18 0>,	/* D5 */
108			   <12 0 &gpioc 3 0>,	/* D6 */
109			   <13 0 &gpioc 6 0>,	/* D7 */
110			   <14 0 &gpiob 19 0>,	/* D8 */
111			   <15 0 &gpioa 1 0>,	/* D9 */
112			   <16 0 &gpiod 4 0>,	/* D10 */
113			   <17 0 &gpiod 6 0>,	/* D11 */
114			   <18 0 &gpiod 7 0>,	/* D12 */
115			   <19 0 &gpiod 5 0>,	/* D13 */
116			   <20 0 &gpioe 0 0>,	/* D14 */
117			   <21 0 &gpioe 1 0>;	/* D15 */
118	};
119};
120
121&sim {
122	pllfll-select = <KINETIS_SIM_PLLFLLSEL_MCGPLLCLK>;
123	er32k-select = <KINETIS_SIM_ER32KSEL_RTC>;
124};
125
126&adc0 {
127	status = "okay";
128};
129
130&dac0 {
131	status = "okay";
132	voltage-reference = <2>;
133};
134arduino_i2c: &i2c0 {
135	status = "okay";
136	pinctrl-0 = <&i2c0_default>;
137	pinctrl-names = "default";
138
139	fxos8700: fxos8700@1c {
140		compatible = "nxp,fxos8700";
141		reg = <0x1c>;
142		int1-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;
143		int2-gpios = <&gpiod 1 GPIO_ACTIVE_LOW>;
144	};
145};
146
147
148arduino_spi: &spi0 {
149	status = "okay";
150	pinctrl-0 = <&spi0_default>;
151	pinctrl-names = "default";
152};
153
154&ftm0 {
155	status = "okay";
156	compatible = "nxp,ftm-pwm";
157	#pwm-cells = <3>;
158	pinctrl-0 = <&ftm0_default>;
159	pinctrl-names = "default";
160	clock-source = "fixed";
161};
162
163&uart1 {
164	status = "okay";
165	current-speed = <115200>;
166	pinctrl-0 = <&uart1_default>;
167	pinctrl-names = "default";
168};
169
170&uart2 {
171	pinctrl-0 = <&uart2_default>;
172	pinctrl-names = "default";
173};
174
175zephyr_udc0: &usbotg {
176	compatible = "nxp,kinetis-usbd";
177	status = "okay";
178	num-bidir-endpoints = <8>;
179};
180
181&gpioa {
182	status = "okay";
183};
184
185&gpiob {
186	status = "okay";
187};
188
189&gpioc {
190	status = "okay";
191};
192
193&gpiod {
194	status = "okay";
195};
196
197&gpioe {
198	status = "okay";
199};
200
201&flash0 {
202	partitions {
203		compatible = "fixed-partitions";
204		#address-cells = <1>;
205		#size-cells = <1>;
206
207		boot_partition: partition@0 {
208			label = "mcuboot";
209			reg = <0x00000000 DT_SIZE_K(64)>;
210			read-only;
211		};
212		/* The MCUBoot swap-move algorithm uses the last 3 sectors
213		 * of the primary slot0 for swap status and move.
214		 */
215		slot0_partition: partition@10000 {
216			label = "image-0";
217			reg = <0x00010000 (DT_SIZE_K(180) + DT_SIZE_K(6))>;
218		};
219		slot1_partition: partition@3E800 {
220			label = "image-1";
221			reg = <0x0003E800 DT_SIZE_K(180)>;
222		};
223		storage_partition: partition@6B800 {
224			label = "storage";
225			reg = <0x0006B800 DT_SIZE_K(82)>;
226		};
227
228	};
229};
230