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
286				pinctrl-0 = <&spi_pins>;
287				pinctrl-names = "default";
288
289				cs-gpios = <&qcom_pinmux 20 GPIO_ACTIVE_HIGH>;
290
291				norflash: flash@0 {
292					compatible = "jedec,spi-nor";
293					#address-cells = <1>;
294					#size-cells = <1>;
295					spi-max-frequency = <50000000>;
296					reg = <0>;
297
298					partition@0 {
299						label = "RouterBoot";
300						reg = <0x0 0x40000>;
301					};
302				};
303			};
304		};
305
306		gpio-keys {
307			compatible = "gpio-keys";
308			pinctrl-0 = <&buttons_pins>;
309			pinctrl-names = "default";
310
311			button {
312				label = "reset";
313				linux,code = <KEY_RESTART>;
314				gpios = <&qcom_pinmux 66 GPIO_ACTIVE_LOW>;
315				linux,input-type = <1>;
316				debounce-interval = <60>;
317			};
318		};
319
320		leds {
321			compatible = "gpio-leds";
322			pinctrl-0 = <&leds_pins>;
323			pinctrl-names = "default";
324
325			led-0 {
326				label = "rb3011:green:user";
327				color = <LED_COLOR_ID_GREEN>;
328				gpios = <&qcom_pinmux 33 GPIO_ACTIVE_HIGH>;
329				default-state = "off";
330			};
331		};
332
333	};
334};
335
336&adm_dma {
337	status = "okay";
338};
339
340&gmac0 {
341	status = "okay";
342
343	phy-mode = "rgmii";
344	qcom,id = <0>;
345	phy-handle = <&switch0cpu>;
346
347	fixed-link {
348		speed = <1000>;
349		full-duplex;
350	};
351};
352
353&gmac3 {
354	status = "okay";
355
356	phy-mode = "sgmii";
357	qcom,id = <3>;
358	phy-handle = <&switch1cpu>;
359
360	fixed-link {
361		speed = <1000>;
362		full-duplex;
363	};
364};
365
366&gsbi7 {
367	status = "okay";
368	qcom,mode = <GSBI_PROT_I2C_UART>;
369};
370
371&gsbi7_serial {
372	status = "okay";
373};
374
375&hs_phy_1 {
376	status = "okay";
377};
378
379&nand {
380	status = "okay";
381
382	nand@0 {
383		reg = <0>;
384
385		nand-ecc-strength = <4>;
386		nand-bus-width = <8>;
387		nand-ecc-step-size = <512>;
388
389		partitions {
390			compatible = "fixed-partitions";
391			#address-cells = <1>;
392			#size-cells = <1>;
393
394			boot@0 {
395				label = "RouterBoard NAND 1 Boot";
396				reg = <0x0000000 0x0800000>;
397			};
398
399			main@800000 {
400				label = "RouterBoard NAND 1 Main";
401				reg = <0x0800000 0x7800000>;
402			};
403		};
404	};
405};
406
407&qcom_pinmux {
408	buttons_pins: buttons_pins {
409		mux {
410			pins = "gpio66";
411			drive-strength = <16>;
412			bias-disable;
413		};
414	};
415
416	leds_pins: leds_pins {
417		mux {
418			pins = "gpio33";
419			drive-strength = <16>;
420			bias-disable;
421		};
422	};
423
424	mdio1_pins: mdio1_pins {
425		mux {
426			pins = "gpio10", "gpio11";
427			function = "gpio";
428			drive-strength = <8>;
429			bias-disable;
430		};
431	};
432
433	sw0_reset_pin: sw0_reset_pin {
434		mux {
435			pins = "gpio16";
436			drive-strength = <16>;
437			function = "gpio";
438			bias-disable;
439			input-disable;
440		};
441	};
442
443	sw1_reset_pin: sw1_reset_pin {
444		mux {
445			pins = "gpio17";
446			drive-strength = <16>;
447			function = "gpio";
448			bias-disable;
449			input-disable;
450		};
451	};
452
453	usb1_pwr_en_pins: usb1_pwr_en_pins {
454		mux {
455			pins = "gpio4";
456			function = "gpio";
457			drive-strength = <16>;
458			bias-disable;
459			output-high;
460		};
461	};
462};
463
464&ss_phy_1 {
465	status = "okay";
466};
467
468&usb3_1 {
469	pinctrl-0 = <&usb1_pwr_en_pins>;
470	pinctrl-names = "default";
471
472	status = "okay";
473};
474