1/*
2 * Copyright (c) 2021 Yonatan Schachter
3 * Copyright (c) 2023 Seeed Studio inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8/dts-v1/;
9
10#include <raspberrypi/rpi_pico/rp2040.dtsi>
11#include "xiao_rp2040-pinctrl.dtsi"
12#include "seeed_xiao_connector.dtsi"
13#include <freq.h>
14#include <zephyr/dt-bindings/led/led.h>
15#include <zephyr/dt-bindings/pwm/pwm.h>
16
17/ {
18	chosen {
19		zephyr,sram = &sram0;
20		zephyr,flash = &flash0;
21		zephyr,flash-controller = &ssi;
22		zephyr,console = &uart0;
23		zephyr,shell-uart = &uart0;
24		zephyr,code-partition = &code_partition;
25	};
26
27	aliases {
28		watchdog0 = &wdt0;
29		led-strip = &ws2812;
30		pwm-led0 = &pwm_led0;
31		led0 = &blue_led;
32		led1 = &green_led;
33		led2 = &red_led;
34	};
35
36	pwm_leds {
37		compatible = "pwm-leds";
38		status = "disabled";
39		pwm_led0: pwm_led_0 {
40			pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
41			label = "PWM_LED";
42		};
43	};
44
45	leds {
46		compatible = "gpio-leds";
47
48		blue_led: blue_led {
49			gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
50			label = "BLUE_LED";
51		};
52
53		green_led: green_led {
54			gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
55			label = "GREEN_LED";
56		};
57
58		red_led: red_led {
59			gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
60			label = "RED_LED";
61		};
62	};
63};
64
65&pwm {
66	pinctrl-0 = <&pwm_ch4b_default>;
67	pinctrl-names = "default";
68	divider-int-0 = <255>;
69};
70
71&flash0 {
72	/*
73	 * 2MB of flash minus the 0x100 used for the second stage bootloader
74	 */
75	reg = <0x10000000 DT_SIZE_M(2)>;
76
77	partitions {
78		compatible = "fixed-partitions";
79		#address-cells = <1>;
80		#size-cells = <1>;
81		code_partition: partition@100 {
82			label = "code";
83			reg = <0x100 (DT_SIZE_M(2) - 0x100)>;
84			read-only;
85		};
86	};
87};
88
89&timer {
90	status = "okay";
91};
92
93&uart0 {
94	current-speed = <115200>;
95	status = "okay";
96	pinctrl-0 = <&uart0_default>;
97	pinctrl-names = "default";
98};
99
100&i2c1 {
101	status = "okay";
102	pinctrl-0 = <&i2c1_default>;
103	pinctrl-names = "default";
104	clock-frequency = <I2C_BITRATE_FAST>;
105};
106
107&spi0 {
108	status = "okay";
109	pinctrl-0 = <&spi0_default>;
110	pinctrl-names = "default";
111	clock-frequency = <DT_FREQ_M(8)>;
112};
113
114&gpio0 {
115	status = "okay";
116
117	/*
118	 * The neopixel on this board has its positive side hooked up to a GPIO pin
119	 * rather than a positive voltage rail to save on power. This will enable
120	 * the LED on board initialization.
121	 */
122	neopixel-power-enable {
123		gpio-hog;
124		gpios = <11 GPIO_ACTIVE_HIGH>;
125		output-high;
126	};
127};
128
129&wdt0 {
130	status = "okay";
131};
132
133&adc {
134	status = "okay";
135	pinctrl-0 = <&adc_default>;
136	pinctrl-names = "default";
137};
138
139&pio0 {
140	status = "okay";
141
142	pio-ws2812 {
143		compatible = "worldsemi,ws2812-rpi_pico-pio";
144		status = "okay";
145		pinctrl-0 = <&ws2812_pio0_default>;
146		pinctrl-names = "default";
147		bit-waveform = <3>, <3>, <4>;
148
149		ws2812: ws2812 {
150			status = "okay";
151			gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
152			chain-length = <1>;
153			color-mapping = <LED_COLOR_ID_GREEN
154					LED_COLOR_ID_RED
155					LED_COLOR_ID_BLUE>;
156			reset-delay = <280>;
157			frequency = <800000>;
158		};
159	};
160};
161
162zephyr_udc0: &usbd {
163	status = "okay";
164};
165
166&vreg {
167	regulator-always-on;
168	regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
169};
170
171&xosc {
172	startup-delay-multiplier = <64>;
173};
174