1/*
2 * Copyright (c) 2021 Yonatan Schachter
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <arm/armv6-m.dtsi>
8#include <zephyr/dt-bindings/adc/adc.h>
9#include <zephyr/dt-bindings/gpio/gpio.h>
10#include <zephyr/dt-bindings/clock/rpi_pico_clock.h>
11#include <zephyr/dt-bindings/i2c/i2c.h>
12#include <zephyr/dt-bindings/regulator/rpi_pico.h>
13#include <mem.h>
14
15#include "rpi_pico_common.dtsi"
16
17/ {
18	aliases {
19		die-temp0 = &die_temp;
20	};
21
22	cpus {
23		#address-cells = <1>;
24		#size-cells = <0>;
25
26		cpu0: cpu@0 {
27			compatible = "arm,cortex-m0+";
28			reg = <0>;
29		};
30
31		cpu1: cpu@1 {
32			compatible = "arm,cortex-m0+";
33			reg = <1>;
34		};
35	};
36
37	clocks {
38		clk_gpout0: clk-gpout0 {
39			compatible = "raspberrypi,pico-clock";
40			clocks = <&pll_sys>;
41			clock-names = "pll_sys";
42			clock-frequency = <125000000>;
43			#clock-cells = <0>;
44			#address-cells = <0>;
45		};
46
47		clk_gpout1: clk-gpout1 {
48			compatible = "raspberrypi,pico-clock";
49			clocks = <&pll_sys>;
50			clock-names = "pll_sys";
51			clock-frequency = <125000000>;
52			#clock-cells = <0>;
53		};
54
55		clk_gpout2: clk-gpout2 {
56			compatible = "raspberrypi,pico-clock";
57			clocks = <&pll_sys>;
58			clock-names = "pll_sys";
59			clock-frequency = <125000000>;
60			#clock-cells = <0>;
61		};
62
63		clk_gpout3: clk-gpout3 {
64			compatible = "raspberrypi,pico-clock";
65			clocks = <&pll_sys>;
66			clock-names = "pll_sys";
67			clock-frequency = <125000000>;
68			#clock-cells = <0>;
69		};
70
71		clk_ref: clk-ref {
72			compatible = "raspberrypi,pico-clock";
73			clocks = <&xosc>;
74			clock-names = "xosc";
75			clock-frequency = <12000000>;
76			#clock-cells = <0>;
77		};
78
79		clk_sys: clk-sys {
80			compatible = "raspberrypi,pico-clock";
81			clocks = <&pll_sys>;
82			clock-names = "pll_sys";
83			clock-frequency = <125000000>;
84			#clock-cells = <0>;
85		};
86
87		clk_usb: clk-usb {
88			compatible = "raspberrypi,pico-clock";
89			clocks = <&pll_usb>;
90			clock-names = "pll_usb";
91			clock-frequency = <48000000>;
92			#clock-cells = <0>;
93		};
94
95		clk_adc: clk-adc {
96			compatible = "raspberrypi,pico-clock";
97			clocks = <&pll_usb>;
98			clock-names = "pll_usb";
99			clock-frequency = <48000000>;
100			#clock-cells = <0>;
101		};
102
103		clk_rtc: clk-rtc {
104			compatible = "raspberrypi,pico-clock";
105			clocks = <&pll_usb>;
106			clock-names = "pll_usb";
107			clock-frequency = <46875>;
108			#clock-cells = <0>;
109		};
110
111		clk_peri: clk-peri {
112			compatible = "raspberrypi,pico-clock";
113			clocks = <&clk_sys>;
114			clock-names = "clk_sys";
115			clock-frequency = <125000000>;
116			#clock-cells = <0>;
117		};
118
119		pll_sys: pll-sys {
120			compatible = "raspberrypi,pico-pll";
121			clocks = <&xosc>;
122			clock-names = "xosc";
123			clock-div= <1>;
124			fb-div= <125>;
125			post-div1 = <6>;
126			post-div2 = <2>;
127			#clock-cells = <0>;
128		};
129
130		pll_usb: pll-usb {
131			compatible = "raspberrypi,pico-pll";
132			clocks = <&xosc>;
133			clock-names = "xosc";
134			clock-div= <1>;
135			fb-div = <100>;
136			post-div1 = <5>;
137			post-div2 = <5>;
138			#clock-cells = <0>;
139		};
140
141		rosc: rosc {
142			compatible = "raspberrypi,pico-rosc";
143			clock-frequency = <6500000>;
144			range = <RPI_PICO_ROSC_RANGE_RESET>;
145			stage-drive-strength = <0>, <0>, <0>, <0>, <0>, <0>, <0>, <0>;
146			clock-div = <16>;
147			phase = <0>;
148			#clock-cells = <0>;
149		};
150
151		rosc_ph: rosc-ph {
152			compatible = "raspberrypi,pico-clock";
153			clock-frequency = <6500000>;
154			clocks = <&rosc>;
155			clock-names = "rosc";
156			#clock-cells = <0>;
157		};
158
159		xosc: xosc {
160			compatible = "raspberrypi,pico-clock";
161			clock-frequency = <12000000>;
162			#clock-cells = <0>;
163		};
164
165		gpin0: gpin0 {
166			compatible = "raspberrypi,pico-clock";
167			status = "disabled";
168			clock-frequency = <0>;
169			#clock-cells = <0>;
170		};
171
172		gpin1: gpin1 {
173			compatible = "raspberrypi,pico-clock";
174			status = "disabled";
175			clock-frequency = <0>;
176			#clock-cells = <0>;
177		};
178	};
179
180	soc {
181		compatible = "raspberrypi,rp2040", "simple-bus";
182
183		sram0: memory@20000000 {
184			compatible = "mmio-sram";
185			reg = <0x20000000 DT_SIZE_K(264)>;
186		};
187
188		ssi: flash-controller@18000000 {
189			compatible = "raspberrypi,pico-flash-controller";
190			reg = <0x18000000 0xfc>;
191
192			#address-cells = <1>;
193			#size-cells = <1>;
194
195			flash0: flash@10000000 {
196				compatible = "soc-nv-flash";
197				write-block-size = <1>;
198				erase-block-size = <DT_SIZE_K(4)>;
199			};
200		};
201
202		reset: reset-controller@4000c000 {
203			compatible = "raspberrypi,pico-reset";
204			reg = <0x4000c000 DT_SIZE_K(4)>;
205			reg-width = <4>;
206			active-low = <0>;
207			#reset-cells = <1>;
208		};
209
210		clocks: clock-controller@40008000 {
211			compatible = "raspberrypi,pico-clock-controller";
212			reg = <0x40008000 DT_SIZE_K(4)
213			       0x40024000 DT_SIZE_K(4)
214			       0x40028000 DT_SIZE_K(4)
215			       0x4002c000 DT_SIZE_K(4)
216			       0x40060000 DT_SIZE_K(4)>;
217			reg-names = "clocks", "xosc", "pll_sys", "pll_usb", "rosc";
218			#clock-cells = <1>;
219			status = "okay";
220			clocks = <&clk_gpout0>, <&clk_gpout1>, <&clk_gpout2>, <&clk_gpout3>,
221				 <&clk_ref>, <&clk_sys>, <&clk_peri>,
222				 <&clk_usb>, <&clk_adc>, <&clk_rtc>,
223				 <&pll_sys>, <&pll_usb>, <&xosc>, <&rosc>, <&rosc_ph>,
224				 <&gpin0>, <&gpin1>;
225			clock-names = "clk_gpout0", "clk_gpout1", "clk_gpout2", "clk_gpout3",
226				 "clk_ref", "clk_sys", "clk_peri",
227				 "clk_usb", "clk_adc", "clk_rtc",
228				 "pll_sys", "pll_usb", "xosc", "rosc", "rosc_ph",
229				 "gpin0", "gpin1";
230		};
231
232		gpio0: gpio@40014000 {
233			compatible = "raspberrypi,pico-gpio";
234			reg = <0x40014000 DT_SIZE_K(4)>;
235			interrupts = <13 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
236			gpio-controller;
237			#gpio-cells = <2>;
238			status = "disabled";
239			ngpios = <30>;
240		};
241
242		uart0: uart@40034000 {
243			compatible = "raspberrypi,pico-uart", "arm,pl011";
244			reg = <0x40034000 DT_SIZE_K(4)>;
245			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
246			resets = <&reset RPI_PICO_RESETS_RESET_UART0>;
247			interrupts = <20 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
248			interrupt-names = "uart0";
249			status = "disabled";
250		};
251
252		uart1: uart@40038000 {
253			compatible = "raspberrypi,pico-uart", "arm,pl011";
254			reg = <0x40038000 DT_SIZE_K(4)>;
255			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
256			resets = <&reset RPI_PICO_RESETS_RESET_UART1>;
257			interrupts = <21 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
258			interrupt-names = "uart1";
259			status = "disabled";
260		};
261
262		spi0: spi@4003c000 {
263			compatible = "raspberrypi,pico-spi", "arm,pl022";
264			#address-cells = <1>;
265			#size-cells = <0>;
266			reg = <0x4003c000 DT_SIZE_K(4)>;
267			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
268			resets = <&reset RPI_PICO_RESETS_RESET_SPI0>;
269			interrupts = <18 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
270			interrupt-names = "spi0";
271			status = "disabled";
272		};
273
274		spi1: spi@40040000 {
275			compatible = "raspberrypi,pico-spi", "arm,pl022";
276			#address-cells = <1>;
277			#size-cells = <0>;
278			reg = <0x40040000 DT_SIZE_K(4)>;
279			resets = <&reset RPI_PICO_RESETS_RESET_SPI1>;
280			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
281			interrupts = <19 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
282			interrupt-names = "spi1";
283			status = "disabled";
284		};
285
286		adc: adc@4004c000 {
287			compatible = "raspberrypi,pico-adc";
288			reg = <0x4004c000 DT_SIZE_K(4)>;
289			resets = <&reset RPI_PICO_RESETS_RESET_ADC>;
290			clocks = <&clocks RPI_PICO_CLKID_CLK_ADC>;
291			interrupts = <22 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
292			interrupt-names = "adc0";
293			status = "disabled";
294			#io-channel-cells = <1>;
295		};
296
297		i2c0: i2c@40044000 {
298			compatible = "raspberrypi,pico-i2c", "snps,designware-i2c";
299			#address-cells = <1>;
300			#size-cells = <0>;
301			reg = <0x40044000 DT_SIZE_K(4)>;
302			resets = <&reset RPI_PICO_RESETS_RESET_I2C0>;
303			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
304			interrupts = <23 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
305			interrupt-names = "i2c0";
306			status = "disabled";
307		};
308
309		i2c1: i2c@40048000 {
310			compatible = "raspberrypi,pico-i2c", "snps,designware-i2c";
311			#address-cells = <1>;
312			#size-cells = <0>;
313			reg = <0x40048000 DT_SIZE_K(4)>;
314			resets = <&reset RPI_PICO_RESETS_RESET_I2C1>;
315			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
316			interrupts = <24 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
317			interrupt-names = "i2c1";
318			status = "disabled";
319		};
320
321		wdt0: watchdog@40058000 {
322			compatible = "raspberrypi,pico-watchdog";
323			reg = <0x40058000 DT_SIZE_K(4)>;
324			clocks = <&clocks RPI_PICO_CLKID_CLK_REF>;
325			status = "disabled";
326		};
327
328		usbd: usbd@50100000 {
329			compatible = "raspberrypi,pico-usbd";
330			reg = <0x50100000 0x10000>;
331			resets = <&reset RPI_PICO_RESETS_RESET_USBCTRL>;
332			clocks = <&clocks RPI_PICO_CLKID_CLK_USB>;
333			interrupts = <5 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
334			interrupt-names = "usbctrl";
335			num-bidir-endpoints = <16>;
336			status = "disabled";
337		};
338
339		pwm: pwm@40050000 {
340			compatible = "raspberrypi,pico-pwm";
341			reg = <0x40050000 DT_SIZE_K(4)>;
342			resets = <&reset RPI_PICO_RESETS_RESET_PWM>;
343			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
344			interrupts = <4 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
345			interrupt-names = "PWM_IRQ_WRAP";
346			status = "disabled";
347			#pwm-cells = <3>;
348		};
349
350		timer: timer@40054000 {
351			compatible = "raspberrypi,pico-timer";
352			reg = <0x40054000 DT_SIZE_K(4)>;
353			resets = <&reset RPI_PICO_RESETS_RESET_TIMER>;
354			clocks = <&clocks RPI_PICO_CLKID_CLK_REF>;
355			interrupts = <0 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
356				     <1 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
357				     <2 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
358				     <3 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
359			interrupt-names = "TIMER_IRQ_0",
360					  "TIMER_IRQ_1",
361					  "TIMER_IRQ_2",
362					  "TIMER_IRQ_3";
363			status = "disabled";
364		};
365
366		dma: dma@50000000 {
367			compatible = "raspberrypi,pico-dma";
368			reg = <0x50000000 DT_SIZE_K(64)>;
369			resets = <&reset RPI_PICO_RESETS_RESET_DMA>;
370			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
371			interrupts = <11 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
372				     <12 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
373			interrupt-names = "dma0", "dma1";
374			dma-channels = <12>;
375			status = "disabled";
376			#dma-cells = <3>;
377		};
378
379		vreg: vreg@40064000 {
380			compatible = "raspberrypi,core-supply-regulator";
381			reg = <0x40064000 1>;
382			status = "okay";
383			raspberrypi,brown-out-detection;
384			raspberrypi,brown-out-threshold = <860000>;
385		};
386
387		pio0: pio@50200000 {
388			compatible = "raspberrypi,pico-pio";
389			reg = <0x50200000 DT_SIZE_K(4)>;
390			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
391			resets = <&reset RPI_PICO_RESETS_RESET_PIO0>;
392			status = "disabled";
393		};
394
395		pio1: pio@50300000 {
396			compatible = "raspberrypi,pico-pio";
397			reg = <0x50300000 DT_SIZE_K(4)>;
398			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
399			resets = <&reset RPI_PICO_RESETS_RESET_PIO1>;
400			status = "disabled";
401		};
402
403		rtc: rtc@4005c000 {
404			compatible = "raspberrypi,pico-rtc";
405			reg = <0x4005c000 DT_SIZE_K(4)>;
406			interrupts = <25 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
407			interrupt-names = "rtc";
408			resets = <&reset RPI_PICO_RESETS_RESET_RTC>;
409			alarms-count = <1>;
410			status = "disabled";
411		};
412	};
413
414	pinctrl: pin-controller {
415		compatible = "raspberrypi,pico-pinctrl";
416	};
417
418	die_temp: dietemp {
419		compatible = "raspberrypi,pico-temp";
420		io-channels = <&adc 4>;
421		status = "disabled";
422	};
423};
424
425&nvic {
426	arm,num-irq-priority-bits = <2>;
427};
428