1// SPDX-License-Identifier: GPL-2.0
2#include "qcom-ipq8064.dtsi"
3#include <dt-bindings/input/input.h>
4#include <dt-bindings/leds/common.h>
5
6/ {
7	model = "MikroTik RB3011UiAS-RM";
8	compatible = "mikrotik,rb3011", "qcom,ipq8064";
9
10	aliases {
11		serial0 = &gsbi7_serial;
12		ethernet0 = &gmac0;
13		ethernet1 = &gmac3;
14		mdio-gpio0 = &mdio0;
15		mdio-gpio1 = &mdio1;
16	};
17
18	chosen {
19		bootargs = "loglevel=8 console=ttyMSM0,115200";
20		stdout-path = "serial0:115200n8";
21	};
22
23	memory@42000000 {
24		reg = <0x42000000 0x3e000000>;
25		device_type = "memory";
26	};
27
28	mdio0: mdio-0 {
29		status = "okay";
30		compatible = "virtual,mdio-gpio";
31		gpios = <&qcom_pinmux 1 GPIO_ACTIVE_HIGH>,
32			<&qcom_pinmux 0 GPIO_ACTIVE_HIGH>;
33		#address-cells = <1>;
34		#size-cells = <0>;
35
36		pinctrl-0 = <&mdio0_pins>;
37		pinctrl-names = "default";
38
39		switch0: switch@10 {
40			compatible = "qca,qca8337";
41
42			dsa,member = <0 0>;
43
44			pinctrl-0 = <&sw0_reset_pin>;
45			pinctrl-names = "default";
46
47			reset-gpios = <&qcom_pinmux 16 GPIO_ACTIVE_LOW>;
48			reg = <0x10>;
49
50			ports {
51				#address-cells = <1>;
52				#size-cells = <0>;
53
54				switch0cpu: port@0 {
55					reg = <0>;
56					label = "cpu";
57					ethernet = <&gmac0>;
58					phy-mode = "rgmii-id";
59					fixed-link {
60						speed = <1000>;
61						full-duplex;
62					};
63				};
64
65				port@1 {
66					reg = <1>;
67					label = "sw1";
68
69					leds {
70						#address-cells = <1>;
71						#size-cells = <0>;
72
73						led@0 {
74							reg = <0>;
75							color = <LED_COLOR_ID_GREEN>;
76							function = LED_FUNCTION_LAN;
77							default-state = "keep";
78						};
79					};
80				};
81
82				port@2 {
83					reg = <2>;
84					label = "sw2";
85
86					leds {
87						#address-cells = <1>;
88						#size-cells = <0>;
89
90						led@0 {
91							reg = <0>;
92							color = <LED_COLOR_ID_GREEN>;
93							function = LED_FUNCTION_LAN;
94							default-state = "keep";
95						};
96					};
97				};
98
99				port@3 {
100					reg = <3>;
101					label = "sw3";
102
103					leds {
104						#address-cells = <1>;
105						#size-cells = <0>;
106
107						led@0 {
108							reg = <0>;
109							color = <LED_COLOR_ID_GREEN>;
110							function = LED_FUNCTION_LAN;
111							default-state = "keep";
112						};
113					};
114				};
115
116				port@4 {
117					reg = <4>;
118					label = "sw4";
119
120					leds {
121						#address-cells = <1>;
122						#size-cells = <0>;
123
124						led@0 {
125							reg = <0>;
126							color = <LED_COLOR_ID_GREEN>;
127							function = LED_FUNCTION_LAN;
128							default-state = "keep";
129						};
130					};
131				};
132
133				port@5 {
134					reg = <5>;
135					label = "sw5";
136
137					leds {
138						#address-cells = <1>;
139						#size-cells = <0>;
140
141						led@0 {
142							reg = <0>;
143							color = <LED_COLOR_ID_GREEN>;
144							function = LED_FUNCTION_LAN;
145							default-state = "keep";
146						};
147					};
148				};
149			};
150		};
151	};
152
153	mdio1: mdio-1 {
154		status = "okay";
155		compatible = "virtual,mdio-gpio";
156		gpios = <&qcom_pinmux 11 GPIO_ACTIVE_HIGH>,
157			<&qcom_pinmux 10 GPIO_ACTIVE_HIGH>;
158		#address-cells = <1>;
159		#size-cells = <0>;
160
161		pinctrl-0 = <&mdio1_pins>;
162		pinctrl-names = "default";
163
164		switch1: switch@14 {
165			compatible = "qca,qca8337";
166
167			dsa,member = <1 0>;
168
169			pinctrl-0 = <&sw1_reset_pin>;
170			pinctrl-names = "default";
171
172			reset-gpios = <&qcom_pinmux 17 GPIO_ACTIVE_LOW>;
173			reg = <0x10>;
174
175			ports {
176				#address-cells = <1>;
177				#size-cells = <0>;
178
179				switch1cpu: port@0 {
180					reg = <0>;
181					label = "cpu";
182					ethernet = <&gmac3>;
183					phy-mode = "sgmii";
184					fixed-link {
185						speed = <1000>;
186						full-duplex;
187					};
188				};
189
190				port@1 {
191					reg = <1>;
192					label = "sw6";
193
194					leds {
195						#address-cells = <1>;
196						#size-cells = <0>;
197
198						led@0 {
199							reg = <0>;
200							color = <LED_COLOR_ID_GREEN>;
201							function = LED_FUNCTION_LAN;
202							default-state = "keep";
203						};
204					};
205				};
206
207				port@2 {
208					reg = <2>;
209					label = "sw7";
210
211					leds {
212						#address-cells = <1>;
213						#size-cells = <0>;
214
215						led@0 {
216							reg = <0>;
217							color = <LED_COLOR_ID_GREEN>;
218							function = LED_FUNCTION_LAN;
219							default-state = "keep";
220						};
221					};
222				};
223
224				port@3 {
225					reg = <3>;
226					label = "sw8";
227
228					leds {
229						#address-cells = <1>;
230						#size-cells = <0>;
231
232						led@0 {
233							reg = <0>;
234							color = <LED_COLOR_ID_GREEN>;
235							function = LED_FUNCTION_LAN;
236							default-state = "keep";
237						};
238					};
239				};
240
241				port@4 {
242					reg = <4>;
243					label = "sw9";
244
245					leds {
246						#address-cells = <1>;
247						#size-cells = <0>;
248
249						led@0 {
250							reg = <0>;
251							color = <LED_COLOR_ID_GREEN>;
252							function = LED_FUNCTION_LAN;
253							default-state = "keep";
254						};
255					};
256				};
257
258				port@5 {
259					reg = <5>;
260					label = "sw10";
261
262					leds {
263						#address-cells = <1>;
264						#size-cells = <0>;
265
266						led@0 {
267							reg = <0>;
268							color = <LED_COLOR_ID_GREEN>;
269							function = LED_FUNCTION_LAN;
270							default-state = "keep";
271						};
272					};
273				};
274			};
275		};
276	};
277
278	soc {
279		gsbi5: gsbi@1a200000 {
280			qcom,mode = <GSBI_PROT_SPI>;
281			status = "okay";
282
283			spi4: spi@1a280000 {
284				status = "okay";
285				spi-max-frequency = <50000000>;
286
287				pinctrl-0 = <&spi_pins>;
288				pinctrl-names = "default";
289
290				cs-gpios = <&qcom_pinmux 20 GPIO_ACTIVE_HIGH>;
291
292				norflash: flash@0 {
293					compatible = "jedec,spi-nor";
294					#address-cells = <1>;
295					#size-cells = <1>;
296					spi-max-frequency = <50000000>;
297					reg = <0>;
298
299					partition@0 {
300						label = "RouterBoot";
301						reg = <0x0 0x40000>;
302					};
303				};
304			};
305		};
306
307		gpio-keys {
308			compatible = "gpio-keys";
309			pinctrl-0 = <&buttons_pins>;
310			pinctrl-names = "default";
311
312			button {
313				label = "reset";
314				linux,code = <KEY_RESTART>;
315				gpios = <&qcom_pinmux 66 GPIO_ACTIVE_LOW>;
316				linux,input-type = <1>;
317				debounce-interval = <60>;
318			};
319		};
320
321		leds {
322			compatible = "gpio-leds";
323			pinctrl-0 = <&leds_pins>;
324			pinctrl-names = "default";
325
326			led-0 {
327				label = "rb3011:green:user";
328				color = <LED_COLOR_ID_GREEN>;
329				gpios = <&qcom_pinmux 33 GPIO_ACTIVE_HIGH>;
330				default-state = "off";
331			};
332		};
333
334	};
335};
336
337&adm_dma {
338	status = "okay";
339};
340
341&gmac0 {
342	status = "okay";
343
344	phy-mode = "rgmii";
345	qcom,id = <0>;
346	phy-handle = <&switch0cpu>;
347
348	fixed-link {
349		speed = <1000>;
350		full-duplex;
351	};
352};
353
354&gmac3 {
355	status = "okay";
356
357	phy-mode = "sgmii";
358	qcom,id = <3>;
359	phy-handle = <&switch1cpu>;
360
361	fixed-link {
362		speed = <1000>;
363		full-duplex;
364	};
365};
366
367&gsbi7 {
368	status = "okay";
369	qcom,mode = <GSBI_PROT_I2C_UART>;
370};
371
372&gsbi7_serial {
373	status = "okay";
374};
375
376&hs_phy_1 {
377	status = "okay";
378};
379
380&nand {
381	status = "okay";
382
383	nand@0 {
384		reg = <0>;
385
386		nand-ecc-strength = <4>;
387		nand-bus-width = <8>;
388		nand-ecc-step-size = <512>;
389
390		partitions {
391			compatible = "fixed-partitions";
392			#address-cells = <1>;
393			#size-cells = <1>;
394
395			boot@0 {
396				label = "RouterBoard NAND 1 Boot";
397				reg = <0x0000000 0x0800000>;
398			};
399
400			main@800000 {
401				label = "RouterBoard NAND 1 Main";
402				reg = <0x0800000 0x7800000>;
403			};
404		};
405	};
406};
407
408&qcom_pinmux {
409	buttons_pins: buttons_pins {
410		mux {
411			pins = "gpio66";
412			drive-strength = <16>;
413			bias-disable;
414		};
415	};
416
417	leds_pins: leds_pins {
418		mux {
419			pins = "gpio33";
420			drive-strength = <16>;
421			bias-disable;
422		};
423	};
424
425	mdio1_pins: mdio1_pins {
426		mux {
427			pins = "gpio10", "gpio11";
428			function = "gpio";
429			drive-strength = <8>;
430			bias-disable;
431		};
432	};
433
434	sw0_reset_pin: sw0_reset_pin {
435		mux {
436			pins = "gpio16";
437			drive-strength = <16>;
438			function = "gpio";
439			bias-disable;
440			input-disable;
441		};
442	};
443
444	sw1_reset_pin: sw1_reset_pin {
445		mux {
446			pins = "gpio17";
447			drive-strength = <16>;
448			function = "gpio";
449			bias-disable;
450			input-disable;
451		};
452	};
453
454	usb1_pwr_en_pins: usb1_pwr_en_pins {
455		mux {
456			pins = "gpio4";
457			function = "gpio";
458			drive-strength = <16>;
459			bias-disable;
460			output-high;
461		};
462	};
463};
464
465&ss_phy_1 {
466	status = "okay";
467};
468
469&usb3_1 {
470	pinctrl-0 = <&usb1_pwr_en_pins>;
471	pinctrl-names = "default";
472
473	status = "okay";
474};
475