1/*
2 * Copyright (c) 2021 Yonatan Schachter
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <freq.h>
8
9#include <rpi_pico/rp2040.dtsi>
10#include "rpi_pico-pinctrl.dtsi"
11#include <zephyr/dt-bindings/pwm/pwm.h>
12
13#include <zephyr/dt-bindings/i2c/i2c.h>
14
15
16/ {
17	chosen {
18		zephyr,sram = &sram0;
19		zephyr,flash = &flash0;
20		zephyr,flash-controller = &ssi;
21		zephyr,console = &uart0;
22		zephyr,shell-uart = &uart0;
23		zephyr,code-partition = &code_partition;
24	};
25
26	xtal_clk: xtal-clk {
27		compatible = "fixed-clock";
28		clock-frequency = <12000000>;
29		#clock-cells = <0>;
30	};
31
32	aliases {
33		watchdog0 = &wdt0;
34	};
35
36	pico_header: connector {
37		compatible = "raspberrypi,pico-header";
38		#gpio-cells = <2>;
39		gpio-map-mask = <0xffffffff 0xffffffc0>;
40		gpio-map-pass-thru = <0 0x3f>;
41		gpio-map = <0 0 &gpio0 0 0>,	/* GP0 */
42			<1 0 &gpio0 1 0>,	/* GP1 */
43			<2 0 &gpio0 2 0>,	/* GP2 */
44			<3 0 &gpio0 3 0>,	/* GP3 */
45			<4 0 &gpio0 4 0>,	/* GP4 */
46			<5 0 &gpio0 5 0>,	/* GP5 */
47			<6 0 &gpio0 6 0>,	/* GP6 */
48			<7 0 &gpio0 7 0>,	/* GP7 */
49			<8 0 &gpio0 8 0>,	/* GP8 */
50			<9 0 &gpio0 9 0>,	/* GP9 */
51			<10 0 &gpio0 10 0>,	/* GP10 */
52			<11 0 &gpio0 11 0>,	/* GP11 */
53			<12 0 &gpio0 12 0>,	/* GP12 */
54			<13 0 &gpio0 13 0>,	/* GP13 */
55			<14 0 &gpio0 14 0>,	/* GP14 */
56			<15 0 &gpio0 15 0>,	/* GP15 */
57			<16 0 &gpio0 16 0>,	/* GP16 */
58			<17 0 &gpio0 17 0>,	/* GP17 */
59			<18 0 &gpio0 18 0>,	/* GP18 */
60			<19 0 &gpio0 19 0>,	/* GP19 */
61			<20 0 &gpio0 20 0>,	/* GP20 */
62			<21 0 &gpio0 21 0>,	/* GP21 */
63			<22 0 &gpio0 22 0>,	/* GP22 */
64			<26 0 &gpio0 26 0>,	/* GP26 */
65			<27 0 &gpio0 27 0>,	/* GP27 */
66			<28 0 &gpio0 28 0>;	/* GP28 */
67	};
68};
69
70&flash0 {
71	reg = <0x10000000 DT_SIZE_M(2)>;
72
73	partitions {
74		compatible = "fixed-partitions";
75		#address-cells = <1>;
76		#size-cells = <1>;
77
78		/* Reserved memory for the second stage bootloader */
79		second_stage_bootloader: partition@0 {
80			label = "second_stage_bootloader";
81			reg = <0x00000000 0x100>;
82			read-only;
83		};
84
85		/*
86		 * Usable flash. Starts at 0x100, after the bootloader. The partition
87		 * size is 2MB minus the 0x100 bytes taken by the bootloader.
88		 */
89		code_partition: partition@100 {
90			label = "code-partition";
91			reg = <0x100 (DT_SIZE_M(2) - 0x100)>;
92			read-only;
93		};
94	};
95};
96
97&uart0 {
98	current-speed = <115200>;
99	status = "okay";
100	pinctrl-0 = <&uart0_default>;
101	pinctrl-names = "default";
102};
103
104&gpio0 {
105	status = "okay";
106};
107
108&i2c0 {
109	clock-frequency = <I2C_BITRATE_STANDARD>;
110	status = "okay";
111	pinctrl-0 = <&i2c0_default>;
112	pinctrl-names = "default";
113};
114
115&spi0 {
116	clock-frequency = <DT_FREQ_M(8)>;
117	status = "okay";
118	pinctrl-0 = <&spi0_default>;
119	pinctrl-names = "default";
120};
121
122&timer {
123	status = "okay";
124};
125
126&wdt0 {
127	status = "okay";
128};
129
130&adc {
131	status = "okay";
132	pinctrl-0 = <&adc_default>;
133	pinctrl-names = "default";
134};
135
136zephyr_udc0: &usbd {
137	status = "okay";
138};
139
140&pwm {
141	pinctrl-0 = <&pwm_ch4b_default>;
142	pinctrl-names = "default";
143	divider-int-0 = <255>;
144};
145
146&vreg {
147	regulator-always-on;
148	regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>;
149};
150
151pico_spi: &spi0 {};
152