1/dts-v1/;
2
3#include <raspberrypi/rpi_pico/rp2040.dtsi>
4#include "adafruit_macropad_rp2040-pinctrl.dtsi"
5#include <zephyr/dt-bindings/input/input-event-codes.h>
6#include <zephyr/dt-bindings/led/led.h>
7#include <zephyr/dt-bindings/pwm/pwm.h>
8
9
10/ {
11	model = "Adafruit MacroPad RP2040";
12	compatible = "adafruit,macropad-rp2040";
13
14	chosen {
15		zephyr,console = &uart1;
16		zephyr,shell-uart = &uart1;
17		zephyr,sram = &sram0;
18		zephyr,flash = &flash0;
19		zephyr,flash-controller = &ssi;
20		zephyr,code-partition = &code_partition;
21		zephyr,display = &oled;
22	};
23
24	aliases {
25		watchdog0 = &wdt0;
26		led-strip = &ws2812;
27		led0 = &led0;
28	};
29
30	speaker_reg: speaker-reg {
31		compatible = "regulator-fixed";
32		regulator-name = "Speaker";
33		enable-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
34	};
35
36	keys {
37		compatible = "gpio-keys";
38
39		key0: key_0 {
40			gpios = <&gpio0 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
41			zephyr,code = <INPUT_KEY_F1>;
42		};
43
44		key1: key_1 {
45			gpios = <&gpio0 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
46			zephyr,code = <INPUT_KEY_F2>;
47		};
48
49		key2: key_2 {
50			gpios = <&gpio0 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
51			zephyr,code = <INPUT_KEY_F3>;
52		};
53
54		key3: key_3 {
55			gpios = <&gpio0 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
56			zephyr,code = <INPUT_KEY_F4>;
57		};
58
59		key4: key_4 {
60			gpios = <&gpio0 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
61			zephyr,code = <INPUT_KEY_F5>;
62		};
63
64		key5: key_5 {
65			gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
66			zephyr,code = <INPUT_KEY_F6>;
67		};
68
69		key6: key_6 {
70			gpios = <&gpio0 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
71			zephyr,code = <INPUT_KEY_F7>;
72		};
73
74		key7: key_7 {
75			gpios = <&gpio0 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
76			zephyr,code = <INPUT_KEY_F8>;
77		};
78
79		key8: key_8 {
80			gpios = <&gpio0 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
81			zephyr,code = <INPUT_KEY_F9>;
82		};
83
84		key9: key_9 {
85			gpios = <&gpio0 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
86			zephyr,code = <INPUT_KEY_F10>;
87		};
88
89		key10: key_10 {
90			gpios = <&gpio0 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
91			zephyr,code = <INPUT_KEY_F11>;
92		};
93
94		key11: key_11 {
95			gpios = <&gpio0 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
96			zephyr,code = <INPUT_KEY_F12>;
97		};
98
99		encoder_button: encoder_button {
100			gpios = <&gpio0 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
101			zephyr,code = <INPUT_KEY_ENTER>;
102		};
103	};
104
105	leds {
106		compatible = "gpio-leds";
107		led0: led_0 {
108			gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
109			label = "LED 0";
110		};
111	};
112
113	encoder {
114		compatible = "gpio-qdec";
115		gpios = <&gpio0 17 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,
116			<&gpio0 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
117		zephyr,axis = <INPUT_REL_WHEEL>;
118		steps-per-period = <4>;
119		sample-time-us = <2000>;
120		idle-timeout-ms = <200>;
121	};
122
123	stemma_connector: stemma_connector {
124		compatible = "stemma-qt-connector";
125		#gpio-cells = <2>;
126		gpio-map-mask = <0xffffffff 0xffffffc0>;
127		gpio-map-pass-thru = <0 0x3f>;
128		gpio-map = <0 0 &gpio0 21 0>,
129			   <1 0 &gpio0 20 0>;
130	};
131};
132
133&flash0 {
134	reg = <0x10000000 DT_SIZE_M(8)>;
135
136	partitions {
137		compatible = "fixed-partitions";
138		#address-cells = <1>;
139		#size-cells = <1>;
140
141		/* Reserved memory for the second stage bootloader */
142		second_stage_bootloader: partition@0 {
143			label = "second_stage_bootloader";
144			reg = <0x00000000 0x100>;
145			read-only;
146		};
147
148		/*
149		 * Usable flash. Starts at 0x100, after the bootloader. The partition
150		 * size is 8MB minus the 0x100 bytes taken by the bootloader.
151		 */
152		code_partition: partition@100 {
153			label = "code-partition";
154			reg = <0x100 (DT_SIZE_M(8) - 0x100)>;
155			read-only;
156		};
157	};
158};
159
160&uart1 {
161	current-speed = <115200>;
162	status = "okay";
163	pinctrl-0 = <&uart1_default>;
164	pinctrl-names = "default";
165};
166
167/* You need to disable uart1 to use i2c0 */
168&i2c0 {
169	clock-frequency = <400000>;
170	pinctrl-0 = <&i2c0_default>;
171	pinctrl-names = "default";
172};
173
174&spi1 {
175	status = "okay";
176	pinctrl-0 = <&spi1_default>;
177	pinctrl-names = "default";
178	cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
179
180	oled: ssd1306@0 {
181		compatible = "sinowealth,sh1106";
182		reg = <0>;
183		spi-max-frequency = <10000000>;
184		width = <128>;
185		height = <64>;
186		segment-offset = <2>;
187		page-offset = <0>;
188		display-offset = <0>;
189		multiplex-ratio = <63>;
190		prechargep = <0x1F>;
191		segment-remap;
192		com-invdir;
193		inversion-on;
194		reset-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
195		data-cmd-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
196		ready-time-ms = <100>;  /* SH1106G needs 100ms delay after init */
197	};
198};
199
200&gpio0 {
201	status = "okay";
202};
203
204&pwm {
205	pinctrl-0 = <&pwm_ch0a_default>;
206	pinctrl-names = "default";
207	divider-int-0 = <255>;
208};
209
210&wdt0 {
211	status = "okay";
212};
213
214zephyr_udc0: &usbd {
215	status = "okay";
216};
217
218&pio1 {
219	status = "okay";
220
221	pio-ws2812 {
222		compatible = "worldsemi,ws2812-rpi_pico-pio";
223		status = "okay";
224		pinctrl-0 = <&ws2812_pio1_default>;
225		pinctrl-names = "default";
226		bit-waveform = <3>, <3>, <4>;
227
228		ws2812: ws2812 {
229			status = "okay";
230			gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
231			chain-length = <12>;
232			color-mapping = <LED_COLOR_ID_GREEN
233					 LED_COLOR_ID_RED
234					 LED_COLOR_ID_BLUE>;
235			reset-delay = <280>;
236			frequency = <800000>;
237		};
238	};
239};
240