1/*
2 * Copyright (c) 2021 Yonatan Schachter
3 * Copyright (c) 2023 Ian Wakely
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8/dts-v1/;
9
10#include <freq.h>
11
12#include <rpi_pico/rp2040.dtsi>
13#include "w5500_evb_pico-pinctrl.dtsi"
14#include <zephyr/dt-bindings/pwm/pwm.h>
15
16#include <zephyr/dt-bindings/i2c/i2c.h>
17
18/ {
19	chosen {
20		zephyr,sram = &sram0;
21		zephyr,flash = &flash0;
22		zephyr,flash-controller = &ssi;
23		zephyr,console = &uart0;
24		zephyr,shell-uart = &uart0;
25		zephyr,code-partition = &code_partition;
26	};
27
28	pico_header: connector {
29		compatible = "raspberrypi,pico-header";
30		#gpio-cells = <2>;
31		gpio-map-mask = <0xffffffff 0xffffffc0>;
32		gpio-map-pass-thru = <0 0x3f>;
33		gpio-map = <0 0 &gpio0 0 0>,	/* GP0 */
34			<1 0 &gpio0 1 0>,	/* GP1 */
35			<2 0 &gpio0 2 0>,	/* GP2 */
36			<3 0 &gpio0 3 0>,	/* GP3 */
37			<4 0 &gpio0 4 0>,	/* GP4 */
38			<5 0 &gpio0 5 0>,	/* GP5 */
39			<6 0 &gpio0 6 0>,	/* GP6 */
40			<7 0 &gpio0 7 0>,	/* GP7 */
41			<8 0 &gpio0 8 0>,	/* GP8 */
42			<9 0 &gpio0 9 0>,	/* GP9 */
43			<10 0 &gpio0 10 0>,	/* GP10 */
44			<11 0 &gpio0 11 0>,	/* GP11 */
45			<12 0 &gpio0 12 0>,	/* GP12 */
46			<13 0 &gpio0 13 0>,	/* GP13 */
47			<14 0 &gpio0 14 0>,	/* GP14 */
48			<15 0 &gpio0 15 0>,	/* GP15 */
49			<16 0 &gpio0 16 0>,	/* GP16 */
50			<17 0 &gpio0 17 0>,	/* GP17 */
51			<18 0 &gpio0 18 0>,	/* GP18 */
52			<19 0 &gpio0 19 0>,	/* GP19 */
53			<20 0 &gpio0 20 0>,	/* GP20 */
54			<21 0 &gpio0 21 0>,	/* GP21 */
55			<22 0 &gpio0 22 0>,	/* GP22 */
56			<26 0 &gpio0 26 0>,	/* GP26 */
57			<27 0 &gpio0 27 0>,	/* GP27 */
58			<28 0 &gpio0 28 0>;	/* GP28 */
59	};
60
61	leds {
62		compatible = "gpio-leds";
63		led0: led_0 {
64			gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
65			label = "LED";
66		};
67	};
68
69	pwm_leds {
70		compatible = "pwm-leds";
71		status = "disabled";
72		pwm_led0: pwm_led_0 {
73			pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
74			label = "PWM_LED";
75		};
76	};
77
78	aliases {
79		led0 = &led0;
80		pwm-led0 = &pwm_led0;
81		watchdog0 = &wdt0;
82	};
83};
84
85&flash0 {
86	/* 16MB of flash minus the 0x100 used for
87	 * the second stage bootloader
88	 */
89	reg = <0x10000000 DT_SIZE_M(16)>;
90
91	partitions {
92		compatible = "fixed-partitions";
93		#address-cells = <1>;
94		#size-cells = <1>;
95
96		/* Reserved memory for the second stage bootloader */
97		second_stage_bootloader: partition@0 {
98			label = "second_stage_bootloader";
99			reg = <0x00000000 0x100>;
100			read-only;
101		};
102
103		/*
104		 * Usable flash. Starts at 0x100, after the bootloader. The partition
105		 * size is 16MB minus the 0x100 bytes taken by the bootloader.
106		 */
107		code_partition: partition@100 {
108			label = "code-partition";
109			reg = <0x100 (DT_SIZE_M(16) - 0x100)>;
110			read-only;
111		};
112	};
113};
114
115&clocks {
116	pinctrl-0 = <&clocks_default>;
117	pinctrl-names = "default";
118};
119
120&uart0 {
121	current-speed = <115200>;
122	status = "okay";
123	pinctrl-0 = <&uart0_default>;
124	pinctrl-names = "default";
125};
126
127&gpio0 {
128	status = "okay";
129};
130
131&i2c0 {
132	clock-frequency = <I2C_BITRATE_STANDARD>;
133	status = "okay";
134	pinctrl-0 = <&i2c0_default>;
135	pinctrl-names = "default";
136};
137
138&i2c1 {
139	pinctrl-0 = <&i2c1_default>;
140	pinctrl-names = "default";
141	status = "disabled";
142	clock-frequency = <I2C_BITRATE_FAST>;
143};
144
145&spi0 {
146	clock-frequency = <DT_FREQ_M(8)>;
147	status = "okay";
148	pinctrl-0 = <&spi0_default>;
149	pinctrl-names = "default";
150	cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
151
152	ethernet: w5500@0 {
153		compatible = "wiznet,w5500";
154		reg = <0x0>;
155		spi-max-frequency = <50000000>;
156		int-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
157		reset-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
158		local-mac-address = [00 00 00 01 02 03];
159		status = "okay";
160	};
161};
162
163&timer {
164	status = "okay";
165};
166
167&wdt0 {
168	status = "okay";
169};
170
171&adc {
172	status = "okay";
173	pinctrl-0 = <&adc_default>;
174	pinctrl-names = "default";
175};
176
177zephyr_udc0: &usbd {
178	status = "okay";
179};
180
181&pwm {
182	pinctrl-0 = <&pwm_ch4b_default>;
183	pinctrl-names = "default";
184	divider-int-0 = <255>;
185};
186
187&vreg {
188	regulator-always-on;
189	regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
190};
191
192pico_spi: &spi0 {};
193pico_i2c0: &i2c0 {};
194pico_i2c1: &i2c1 {};
195