1/*
2 * Copyright (c) 2024 Andrew Featherstone
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <freq.h>
8
9#include <zephyr/dt-bindings/i2c/i2c.h>
10#include <zephyr/dt-bindings/pwm/pwm.h>
11
12#include "rpi_pico2-pinctrl.dtsi"
13#include "../common/rpi_pico-led.dtsi"
14
15/ {
16	chosen {
17		zephyr,sram = &sram0;
18		zephyr,flash = &flash0;
19		zephyr,console = &uart0;
20		zephyr,shell-uart = &uart0;
21		zephyr,code-partition = &code_partition;
22	};
23
24	aliases {
25		watchdog0 = &wdt0;
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
62&flash0 {
63	reg = <0x10000000 DT_SIZE_M(4)>;
64
65	partitions {
66		compatible = "fixed-partitions";
67		#address-cells = <1>;
68		#size-cells = <1>;
69
70		/* Reserved memory for an image definition block. The block is much
71		 * smaller than 256 bytes, but in practice the linker places the vector
72		 * table at a much larger alignment offset.
73		 */
74		image_def: partition@0 {
75			label = "image_def";
76			reg = <0x00000000 0x100>;
77			read-only;
78		};
79
80		/*
81		 * Usable flash. Starts at 0x100, after the image definition block.
82		 * The partition size is 4MB minus the 0x100 bytes taken by the
83		 * image definition.
84		 */
85		code_partition: partition@100 {
86			label = "code-partition";
87			reg = <0x100 (DT_SIZE_M(4) - 0x100)>;
88			read-only;
89		};
90	};
91};
92
93&uart0 {
94	current-speed = <115200>;
95	status = "okay";
96	pinctrl-0 = <&uart0_default>;
97	pinctrl-names = "default";
98};
99
100&gpio0 {
101	status = "okay";
102};
103
104&spi0 {
105	clock-frequency = <DT_FREQ_M(8)>;
106	pinctrl-0 = <&spi0_default>;
107	pinctrl-names = "default";
108};
109
110&i2c0 {
111	clock-frequency = <I2C_BITRATE_STANDARD>;
112	pinctrl-0 = <&i2c0_default>;
113	pinctrl-names = "default";
114	status = "okay";
115};
116
117&i2c1 {
118	clock-frequency = <I2C_BITRATE_STANDARD>;
119	pinctrl-0 = <&i2c1_default>;
120	pinctrl-names = "default";
121	status = "okay";
122};
123
124&adc {
125	pinctrl-0 = <&adc_default>;
126	pinctrl-names = "default";
127	status = "okay";
128};
129
130&pwm {
131	pinctrl-0 = <&pwm_ch4b_default>;
132	pinctrl-names = "default";
133	divider-int-0 = <255>;
134};
135
136&timer0 {
137	status = "okay";
138};
139
140zephyr_udc0: &usbd {
141	status = "okay";
142};
143
144pico_serial: &uart0 {};
145