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