1/*
2 * Copyright (c) 2024 Andrew Featherstone
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/dt-bindings/adc/adc.h>
8#include <zephyr/dt-bindings/gpio/gpio.h>
9#include <zephyr/dt-bindings/clock/rpi_pico_rp2350_clock.h>
10#include <zephyr/dt-bindings/i2c/i2c.h>
11#include <zephyr/dt-bindings/regulator/rpi_pico.h>
12#include <zephyr/dt-bindings/reset/rp2350_reset.h>
13#include <mem.h>
14
15#ifndef RPI_PICO_DEFAULT_IRQ_PRIORITY
16#define RPI_PICO_DEFAULT_IRQ_PRIORITY 7
17#endif
18
19/ {
20	aliases {
21		die-temp0 = &die_temp;
22	};
23
24	cpus {
25		#address-cells = <1>;
26		#size-cells = <0>;
27
28		/* There are two CPU sockets in the RP2350-series SoCs.
29		 * Represent the sockets in the device tree as these two
30		 * partially-defined CPU instances. Use a separate DTSI file to
31		 * define what kind of CPU cores they are.
32		 */
33		cpu0: cpu@0 {
34			reg = <0>;
35		};
36
37		cpu1: cpu@1 {
38			reg = <1>;
39		};
40	};
41
42	clocks {
43		clk_gpout0: clk-gpout0 {
44			compatible = "raspberrypi,pico-clock";
45			clocks = <&pll_sys>;
46			clock-names = "pll_sys";
47			clock-frequency = <150000000>;
48			#clock-cells = <0>;
49			#address-cells = <0>;
50		};
51
52		clk_gpout1: clk-gpout1 {
53			compatible = "raspberrypi,pico-clock";
54			clocks = <&pll_sys>;
55			clock-names = "pll_sys";
56			clock-frequency = <150000000>;
57			#clock-cells = <0>;
58		};
59
60		clk_gpout2: clk-gpout2 {
61			compatible = "raspberrypi,pico-clock";
62			clocks = <&pll_sys>;
63			clock-names = "pll_sys";
64			clock-frequency = <150000000>;
65			#clock-cells = <0>;
66		};
67
68		clk_gpout3: clk-gpout3 {
69			compatible = "raspberrypi,pico-clock";
70			clocks = <&pll_sys>;
71			clock-names = "pll_sys";
72			clock-frequency = <150000000>;
73			#clock-cells = <0>;
74		};
75
76		clk_hstx: clk-hstx {
77			compatible = "raspberrypi,pico-clock";
78			clocks = <&pll_sys>;
79			clock-names = "pll_sys";
80			clock-frequency = <150000000>;
81			#clock-cells = <0>;
82		};
83
84		clk_ref: clk-ref {
85			compatible = "raspberrypi,pico-clock";
86			clocks = <&xosc>;
87			clock-names = "xosc";
88			clock-frequency = <12000000>;
89			#clock-cells = <0>;
90		};
91
92		clk_sys: clk-sys {
93			compatible = "raspberrypi,pico-clock";
94			clocks = <&pll_sys>;
95			clock-names = "pll_sys";
96			clock-frequency = <150000000>;
97			#clock-cells = <0>;
98		};
99
100		clk_usb: clk-usb {
101			compatible = "raspberrypi,pico-clock";
102			clocks = <&pll_usb>;
103			clock-names = "pll_usb";
104			clock-frequency = <48000000>;
105			#clock-cells = <0>;
106		};
107
108		clk_adc: clk-adc {
109			compatible = "raspberrypi,pico-clock";
110			clocks = <&pll_usb>;
111			clock-names = "pll_usb";
112			clock-frequency = <48000000>;
113			#clock-cells = <0>;
114		};
115
116		clk_peri: clk-peri {
117			compatible = "raspberrypi,pico-clock";
118			clocks = <&clk_sys>;
119			clock-names = "clk_sys";
120			clock-frequency = <150000000>;
121			#clock-cells = <0>;
122		};
123
124		pll_sys: pll-sys {
125			compatible = "raspberrypi,pico-pll";
126			clocks = <&xosc>;
127			clock-names = "xosc";
128			clock-div= <1>;
129			fb-div= <125>;
130			post-div1 = <5>;
131			post-div2 = <2>;
132			#clock-cells = <0>;
133		};
134
135		pll_usb: pll-usb {
136			compatible = "raspberrypi,pico-pll";
137			clocks = <&xosc>;
138			clock-names = "xosc";
139			clock-div= <1>;
140			fb-div = <100>;
141			post-div1 = <5>;
142			post-div2 = <5>;
143			#clock-cells = <0>;
144		};
145
146		rosc: rosc {
147			compatible = "raspberrypi,pico-rosc";
148			clock-frequency = <6500000>;
149			range = <RPI_PICO_ROSC_RANGE_RESET>;
150			stage-drive-strength = <0>, <0>, <0>, <0>, <0>, <0>, <0>, <0>;
151			clock-div = <16>;
152			phase = <0>;
153			#clock-cells = <0>;
154		};
155
156		rosc_ph: rosc-ph {
157			compatible = "raspberrypi,pico-clock";
158			clock-frequency = <6500000>;
159			clocks = <&rosc>;
160			clock-names = "rosc";
161			#clock-cells = <0>;
162		};
163
164		xosc: xosc {
165			compatible = "raspberrypi,pico-xosc";
166			clock-frequency = <12000000>;
167			#clock-cells = <0>;
168		};
169
170		gpin0: gpin0 {
171			compatible = "raspberrypi,pico-clock";
172			status = "disabled";
173			clock-frequency = <0>;
174			#clock-cells = <0>;
175		};
176
177		gpin1: gpin1 {
178			compatible = "raspberrypi,pico-clock";
179			status = "disabled";
180			clock-frequency = <0>;
181			#clock-cells = <0>;
182		};
183	};
184
185	soc {
186		compatible = "raspberrypi,rp2350", "simple-bus";
187
188		sram0: memory@20000000 {
189			compatible = "mmio-sram";
190			reg = <0x20000000 DT_SIZE_K(520)>;
191		};
192
193		qmi: flash-controller@400d0000 {
194			compatible = "raspberrypi,pico-flash-controller";
195			reg = <0x400d0000 0xfc>;
196
197			#address-cells = <1>;
198			#size-cells = <1>;
199
200			flash0: flash@10000000 {
201				compatible = "soc-nv-flash";
202				write-block-size = <1>;
203				erase-block-size = <DT_SIZE_K(4)>;
204			};
205			status = "disabled";
206		};
207
208		reset: reset-controller@40020000 {
209			compatible = "raspberrypi,pico-reset";
210			reg = <0x40020000 DT_SIZE_K(4)>;
211			reg-width = <4>;
212			active-low = <0>;
213			#reset-cells = <1>;
214		};
215
216		clocks: clock-controller@40010000 {
217			compatible = "raspberrypi,pico-clock-controller";
218			reg = <0x40010000 DT_SIZE_K(4)
219			       0x40048000 DT_SIZE_K(4)
220			       0x40050000 DT_SIZE_K(4)
221			       0x40058000 DT_SIZE_K(4)
222			       0x400e8000 DT_SIZE_K(4)>;
223			reg-names = "clocks", "xosc", "pll_sys", "pll_usb", "rosc";
224			#clock-cells = <1>;
225			status = "okay";
226			clocks = <&clk_gpout0>, <&clk_gpout1>, <&clk_gpout2>, <&clk_gpout3>,
227				 <&clk_hstx>, <&clk_ref>, <&clk_sys>, <&clk_peri>,
228				 <&clk_usb>, <&clk_adc>,
229				 <&pll_sys>, <&pll_usb>, <&xosc>, <&rosc>, <&rosc_ph>,
230				 <&gpin0>, <&gpin1>;
231			clock-names = "clk_gpout0", "clk_gpout1", "clk_gpout2", "clk_gpout3",
232				 "clk_hstx", "clk_ref", "clk_sys", "clk_peri",
233				 "clk_usb", "clk_adc",
234				 "pll_sys", "pll_usb", "xosc", "rosc", "rosc_ph",
235				 "gpin0", "gpin1";
236		};
237
238		gpio0: gpio@40028000 {
239			compatible = "raspberrypi,pico-gpio";
240			reg = <0x40028000 DT_SIZE_K(4)>;
241			interrupts = <21 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
242			gpio-controller;
243			#gpio-cells = <2>;
244			status = "disabled";
245		};
246
247		uart0: uart@40070000 {
248			compatible = "raspberrypi,pico-uart", "arm,pl011";
249			reg = <0x40070000 DT_SIZE_K(4)>;
250			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
251			resets = <&reset RPI_PICO_RESETS_RESET_UART0>;
252			interrupts = <33 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
253			interrupt-names = "uart0";
254			status = "disabled";
255		};
256
257		uart1: uart@40078000 {
258			compatible = "raspberrypi,pico-uart", "arm,pl011";
259			reg = <0x40078000 DT_SIZE_K(4)>;
260			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
261			resets = <&reset RPI_PICO_RESETS_RESET_UART1>;
262			interrupts = <34 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
263			interrupt-names = "uart1";
264			status = "disabled";
265		};
266
267		spi0: spi@40080000 {
268			compatible = "raspberrypi,pico-spi", "arm,pl022";
269			#address-cells = <1>;
270			#size-cells = <0>;
271			reg = <0x40080000 DT_SIZE_K(4)>;
272			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
273			resets = <&reset RPI_PICO_RESETS_RESET_SPI0>;
274			interrupts = <31 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
275			interrupt-names = "spi0";
276			status = "disabled";
277		};
278
279		spi1: spi@40088000 {
280			compatible = "raspberrypi,pico-spi", "arm,pl022";
281			#address-cells = <1>;
282			#size-cells = <0>;
283			reg = <0x40088000 DT_SIZE_K(4)>;
284			resets = <&reset RPI_PICO_RESETS_RESET_SPI1>;
285			clocks = <&clocks RPI_PICO_CLKID_CLK_PERI>;
286			interrupts = <32 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
287			interrupt-names = "spi1";
288			status = "disabled";
289		};
290
291		i2c0: i2c@40090000 {
292			compatible = "raspberrypi,pico-i2c", "snps,designware-i2c";
293			#address-cells = <1>;
294			#size-cells = <0>;
295			reg = <0x40090000 DT_SIZE_K(4)>;
296			resets = <&reset RPI_PICO_RESETS_RESET_I2C0>;
297			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
298			interrupts = <36 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
299			interrupt-names = "i2c0";
300			status = "disabled";
301		};
302
303		i2c1: i2c@40098000 {
304			compatible = "raspberrypi,pico-i2c", "snps,designware-i2c";
305			#address-cells = <1>;
306			#size-cells = <0>;
307			reg = <0x40098000 DT_SIZE_K(4)>;
308			resets = <&reset RPI_PICO_RESETS_RESET_I2C1>;
309			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
310			interrupts = <37 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
311			interrupt-names = "i2c1";
312			status = "disabled";
313		};
314
315		adc: adc@400a0000 {
316			compatible = "raspberrypi,pico-adc";
317			reg = <0x400a0000 DT_SIZE_K(4)>;
318			resets = <&reset RPI_PICO_RESETS_RESET_ADC>;
319			clocks = <&clocks RPI_PICO_CLKID_CLK_ADC>;
320			interrupts = <35 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
321			interrupt-names = "adc0";
322			status = "disabled";
323			#io-channel-cells = <1>;
324		};
325
326		pwm: pwm@400a8000 {
327			compatible = "raspberrypi,pico-pwm";
328			reg = <0x400a8000 DT_SIZE_K(4)>;
329			resets = <&reset RPI_PICO_RESETS_RESET_PWM>;
330			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
331			interrupts = <8 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
332					<9 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
333			interrupt-names = "PWM_IRQ_WRAP_0",
334						"PWM_IRQ_WRAP_1";
335			status = "disabled";
336			#pwm-cells = <3>;
337		};
338
339		timer0: timer@400b0000 {
340			compatible = "raspberrypi,pico-timer";
341			reg = <0x400b0000 DT_SIZE_K(4)>;
342			resets = <&reset RPI_PICO_RESETS_RESET_TIMER0>;
343			clocks = <&clocks RPI_PICO_CLKID_CLK_REF>;
344			interrupts = <0 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
345				     <1 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
346				     <2 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
347				     <3 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
348			interrupt-names = "TIMER0_IRQ_0",
349					  "TIMER0_IRQ_1",
350					  "TIMER0_IRQ_2",
351					  "TIMER0_IRQ_3";
352			status = "disabled";
353		};
354
355		timer1: timer@400b8000 {
356			compatible = "raspberrypi,pico-timer";
357			reg = <0x400b8000 DT_SIZE_K(4)>;
358			resets = <&reset RPI_PICO_RESETS_RESET_TIMER1>;
359			clocks = <&clocks RPI_PICO_CLKID_CLK_REF>;
360			interrupts = <4 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
361				     <5 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
362				     <6 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
363				     <7 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
364			interrupt-names = "TIMER1_IRQ_0",
365					  "TIMER1_IRQ_1",
366					  "TIMER1_IRQ_2",
367					  "TIMER1_IRQ_3";
368			status = "disabled";
369		};
370
371		wdt0: watchdog@400d8000 {
372			compatible = "raspberrypi,pico-watchdog";
373			reg = <0x400d8000 DT_SIZE_K(4)>;
374			clocks = <&clocks RPI_PICO_CLKID_CLK_REF>;
375			status = "disabled";
376		};
377
378		dma: dma@50000000 {
379			compatible = "raspberrypi,pico-dma";
380			reg = <0x50000000 DT_SIZE_K(64)>;
381			resets = <&reset RPI_PICO_RESETS_RESET_DMA>;
382			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
383			interrupts = <10 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
384				     <11 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
385				     <12 RPI_PICO_DEFAULT_IRQ_PRIORITY>,
386				     <13 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
387			interrupt-names = "dma0", "dma1", "dma2", "dma3";
388			dma-channels = <16>;
389			status = "disabled";
390			#dma-cells = <3>;
391		};
392
393		usbd: usbd@50100000 {
394			compatible = "raspberrypi,pico-usbd";
395			reg = <0x50100000 0x10000>;
396			resets = <&reset RPI_PICO_RESETS_RESET_USBCTRL>;
397			clocks = <&clocks RPI_PICO_CLKID_CLK_USB>;
398			interrupts = <14 RPI_PICO_DEFAULT_IRQ_PRIORITY>;
399			interrupt-names = "usbctrl";
400			num-bidir-endpoints = <16>;
401			status = "disabled";
402		};
403
404		pio0: pio@50200000 {
405			compatible = "raspberrypi,pico-pio";
406			reg = <0x50200000 DT_SIZE_K(4)>;
407			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
408			resets = <&reset RPI_PICO_RESETS_RESET_PIO0>;
409			status = "disabled";
410		};
411
412		pio1: pio@50300000 {
413			compatible = "raspberrypi,pico-pio";
414			reg = <0x50300000 DT_SIZE_K(4)>;
415			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
416			resets = <&reset RPI_PICO_RESETS_RESET_PIO1>;
417			status = "disabled";
418		};
419
420		pio2: pio@50400000 {
421			compatible = "raspberrypi,pico-pio";
422			reg = <0x50400000 DT_SIZE_K(4)>;
423			clocks = <&clocks RPI_PICO_CLKID_CLK_SYS>;
424			resets = <&reset RPI_PICO_RESETS_RESET_PIO2>;
425			status = "disabled";
426		};
427	};
428
429	pinctrl: pin-controller {
430		compatible = "raspberrypi,pico-pinctrl";
431		status = "okay";
432	};
433
434	die_temp: dietemp {
435		compatible = "raspberrypi,pico-temp";
436		status = "disabled";
437	};
438};
439