1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 Hardkernel Co., Ltd
4 * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH
5 * Copyright (c) 2022 Maya Matuszczyk <maccraft123mc@gmail.com>
6 */
7
8/dts-v1/;
9#include <dt-bindings/gpio/gpio.h>
10#include <dt-bindings/input/input.h>
11#include <dt-bindings/leds/common.h>
12#include <dt-bindings/pinctrl/rockchip.h>
13#include "rk3326.dtsi"
14
15/ {
16	aliases {
17		mmc0 = &sdmmc;
18	};
19
20	chosen {
21		stdout-path = "serial2:115200n8";
22	};
23
24	backlight: backlight {
25		compatible = "pwm-backlight";
26		power-supply = <&vcc_bl>;
27		pwms = <&pwm1 0 25000 0>;
28	};
29
30	builtin_gamepad: gpio-keys {
31		compatible = "gpio-keys";
32		pinctrl-names = "default";
33		pinctrl-0 = <&btn_pins>;
34
35		button-sw1 {
36			gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>;
37			label = "DPAD-UP";
38			linux,code = <BTN_DPAD_UP>;
39		};
40		button-sw2 {
41			gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>;
42			label = "DPAD-DOWN";
43			linux,code = <BTN_DPAD_DOWN>;
44		};
45		button-sw3 {
46			gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>;
47			label = "DPAD-LEFT";
48			linux,code = <BTN_DPAD_LEFT>;
49		};
50		button-sw4 {
51			gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>;
52			label = "DPAD-RIGHT";
53			linux,code = <BTN_DPAD_RIGHT>;
54		};
55		button-sw5 {
56			gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>;
57			label = "BTN-A";
58			linux,code = <BTN_EAST>;
59		};
60		button-sw6 {
61			gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>;
62			label = "BTN-B";
63			linux,code = <BTN_SOUTH>;
64		};
65		button-sw7 {
66			gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>;
67			label = "BTN-Y";
68			linux,code = <BTN_WEST>;
69		};
70		button-sw8 {
71			gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>;
72			label = "BTN-X";
73			linux,code = <BTN_NORTH>;
74		};
75		btn_f1: button-sw9 {
76			gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>;
77			label = "F1";
78			linux,code = <BTN_TRIGGER_HAPPY1>;
79		};
80		btn_f2: button-sw10 {
81			gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>;
82			label = "F2";
83			linux,code = <BTN_TRIGGER_HAPPY2>;
84		};
85		btn_f3: button-sw11 {
86			gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>;
87			label = "F3";
88			linux,code = <BTN_TRIGGER_HAPPY3>;
89		};
90		btn_f4: button-sw12 {
91			gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>;
92			label = "F4";
93			linux,code = <BTN_TRIGGER_HAPPY4>;
94		};
95		btn_f5: button-sw13 {
96			gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>;
97			label = "F5";
98			linux,code = <BTN_TRIGGER_HAPPY5>;
99		};
100		btn_f6: button-sw14 {
101			gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>;
102			label = "F6";
103			linux,code = <BTN_TRIGGER_HAPPY6>;
104		};
105		button-sw15 {
106			gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>;
107			label = "TOP-LEFT";
108			linux,code = <BTN_TL>;
109		};
110		button-sw16 {
111			gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>;
112			label = "TOP-RIGHT";
113			linux,code = <BTN_TR>;
114		};
115	};
116
117	/* led-1 is wired directly to output of always-on regulator */
118
119	gpio_led: gpio-leds {
120		compatible = "gpio-leds";
121		pinctrl-names = "default";
122		pinctrl-0 = <&red_led_pin>;
123
124		red_led: led-3 {
125			color = <LED_COLOR_ID_RED>;
126			gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>;
127			function = LED_FUNCTION_CHARGING;
128		};
129	};
130
131	pwm_led: led-controller {
132		compatible = "pwm-leds";
133
134		blue_led: led-2 {
135			color = <LED_COLOR_ID_BLUE>;
136			function = LED_FUNCTION_STATUS;
137			linux,default-trigger = "heartbeat";
138			max-brightness = <255>;
139			pwms = <&pwm3 0 25000 0>;
140		};
141	};
142
143	rk817-sound {
144		compatible = "simple-audio-card";
145		simple-audio-card,name = "rk817_int";
146		simple-audio-card,format = "i2s";
147		simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>;
148		simple-audio-card,mclk-fs = <256>;
149		simple-audio-card,widgets =
150			"Microphone", "Mic Jack",
151			"Headphone", "Headphones",
152			"Speaker", "Speaker";
153		simple-audio-card,routing =
154			"MICL", "Mic Jack",
155			"Headphones", "HPOL",
156			"Headphones", "HPOR",
157			"Speaker", "SPKO";
158
159		simple-audio-card,codec {
160			sound-dai = <&rk817>;
161		};
162
163		simple-audio-card,cpu {
164			sound-dai = <&i2s1_2ch>;
165		};
166	};
167
168	vccsys: vccsys {
169		compatible = "regulator-fixed";
170		regulator-name = "vcc3v8_sys";
171		regulator-always-on;
172		regulator-min-microvolt = <3800000>;
173		regulator-max-microvolt = <3800000>;
174	};
175
176	vcc_host: vcc_host {
177		compatible = "regulator-fixed";
178		regulator-name = "vcc_host";
179		regulator-min-microvolt = <5000000>;
180		regulator-max-microvolt = <5000000>;
181
182		gpio = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>;
183		enable-active-high;
184		regulator-always-on;
185		regulator-boot-on;
186		vin-supply = <&usb_midu>;
187	};
188};
189
190&cpu0 {
191	cpu-supply = <&vdd_arm>;
192};
193
194&cpu1 {
195	cpu-supply = <&vdd_arm>;
196};
197
198&cpu2 {
199	cpu-supply = <&vdd_arm>;
200};
201
202&cpu3 {
203	cpu-supply = <&vdd_arm>;
204};
205
206&cru {
207	assigned-clocks = <&cru PLL_NPLL>,
208		<&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>,
209		<&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>,
210		<&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>;
211
212	assigned-clock-rates = <1188000000>,
213		<200000000>, <200000000>,
214		<150000000>, <150000000>,
215		<100000000>, <200000000>;
216};
217
218&display_subsystem {
219	status = "okay";
220};
221
222&dsi {
223	status = "okay";
224
225	ports {
226		mipi_out: port@1 {
227			reg = <1>;
228
229			mipi_out_panel: endpoint {
230				remote-endpoint = <&mipi_in_panel>;
231			};
232		};
233	};
234
235	internal_display: panel@0 {
236		reg = <0>;
237		backlight = <&backlight>;
238		reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
239		rotation = <270>;
240
241		port {
242			mipi_in_panel: endpoint {
243				remote-endpoint = <&mipi_out_panel>;
244			};
245		};
246	};
247};
248
249&dsi_dphy {
250	status = "okay";
251};
252
253&gpu {
254	mali-supply = <&vdd_logic>;
255	status = "okay";
256};
257
258&i2c0 {
259	clock-frequency = <400000>;
260	i2c-scl-falling-time-ns = <16>;
261	i2c-scl-rising-time-ns = <280>;
262	status = "okay";
263
264	rk817: pmic@20 {
265		compatible = "rockchip,rk817";
266		reg = <0x20>;
267		interrupt-parent = <&gpio0>;
268		interrupts = <RK_PB2 IRQ_TYPE_LEVEL_LOW>;
269		clock-output-names = "rk808-clkout1", "xin32k";
270		clock-names = "mclk";
271		clocks = <&cru SCLK_I2S1_OUT>;
272		pinctrl-names = "default";
273		pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>;
274		wakeup-source;
275		#clock-cells = <1>;
276		#sound-dai-cells = <0>;
277
278		vcc1-supply = <&vccsys>;
279		vcc2-supply = <&vccsys>;
280		vcc3-supply = <&vccsys>;
281		vcc4-supply = <&vccsys>;
282		vcc5-supply = <&vccsys>;
283		vcc6-supply = <&vccsys>;
284		vcc7-supply = <&vccsys>;
285		vcc8-supply = <&vccsys>;
286
287		regulators {
288			vdd_logic: DCDC_REG1 {
289				regulator-name = "vdd_logic";
290				regulator-min-microvolt = <950000>;
291				regulator-max-microvolt = <1150000>;
292				regulator-ramp-delay = <6001>;
293				regulator-always-on;
294				regulator-boot-on;
295
296				regulator-state-mem {
297					regulator-on-in-suspend;
298					regulator-suspend-microvolt = <950000>;
299				};
300			};
301
302			vdd_arm: DCDC_REG2 {
303				regulator-name = "vdd_arm";
304				regulator-min-microvolt = <950000>;
305				regulator-max-microvolt = <1350000>;
306				regulator-ramp-delay = <6001>;
307				regulator-always-on;
308				regulator-boot-on;
309
310				regulator-state-mem {
311					regulator-off-in-suspend;
312					regulator-suspend-microvolt = <950000>;
313				};
314			};
315
316			vcc_ddr: DCDC_REG3 {
317				regulator-name = "vcc_ddr";
318				regulator-always-on;
319				regulator-boot-on;
320
321				regulator-state-mem {
322					regulator-on-in-suspend;
323				};
324			};
325
326			vcc_3v3: DCDC_REG4 {
327				regulator-name = "vcc_3v3";
328				regulator-min-microvolt = <3300000>;
329				regulator-max-microvolt = <3300000>;
330				regulator-always-on;
331				regulator-boot-on;
332
333				regulator-state-mem {
334					regulator-off-in-suspend;
335					regulator-suspend-microvolt = <3300000>;
336				};
337			};
338
339			vcc_1v8: LDO_REG2 {
340				regulator-name = "vcc_1v8";
341				regulator-min-microvolt = <1800000>;
342				regulator-max-microvolt = <1800000>;
343				regulator-always-on;
344				regulator-boot-on;
345
346				regulator-state-mem {
347					regulator-on-in-suspend;
348					regulator-suspend-microvolt = <1800000>;
349				};
350			};
351
352			vdd_1v0: LDO_REG3 {
353				regulator-name = "vdd_1v0";
354				regulator-min-microvolt = <1000000>;
355				regulator-max-microvolt = <1000000>;
356				regulator-always-on;
357				regulator-boot-on;
358
359				regulator-state-mem {
360					regulator-on-in-suspend;
361					regulator-suspend-microvolt = <1000000>;
362				};
363			};
364
365			vcc3v3_pmu: LDO_REG4 {
366				regulator-name = "vcc3v3_pmu";
367				regulator-min-microvolt = <3300000>;
368				regulator-max-microvolt = <3300000>;
369				regulator-always-on;
370				regulator-boot-on;
371
372				regulator-state-mem {
373					regulator-on-in-suspend;
374					regulator-suspend-microvolt = <3300000>;
375				};
376			};
377
378			vccio_sd: LDO_REG5 {
379				regulator-name = "vccio_sd";
380				regulator-min-microvolt = <1800000>;
381				regulator-max-microvolt = <3300000>;
382				regulator-always-on;
383				regulator-boot-on;
384
385				regulator-state-mem {
386					regulator-on-in-suspend;
387					regulator-suspend-microvolt = <3300000>;
388				};
389			};
390
391			vcc_sd: LDO_REG6 {
392				regulator-name = "vcc_sd";
393				regulator-min-microvolt = <3300000>;
394				regulator-max-microvolt = <3300000>;
395				regulator-boot-on;
396
397				regulator-state-mem {
398					regulator-on-in-suspend;
399					regulator-suspend-microvolt = <3300000>;
400				};
401			};
402
403			vcc_bl: LDO_REG7 {
404				regulator-name = "vcc_bl";
405				regulator-min-microvolt = <3300000>;
406				regulator-max-microvolt = <3300000>;
407
408				regulator-state-mem {
409					regulator-off-in-suspend;
410					regulator-suspend-microvolt = <3300000>;
411				};
412			};
413
414			vcc_lcd: LDO_REG8 {
415				regulator-name = "vcc_lcd";
416				regulator-min-microvolt = <2800000>;
417				regulator-max-microvolt = <2800000>;
418
419				regulator-state-mem {
420					regulator-off-in-suspend;
421					regulator-suspend-microvolt = <2800000>;
422				};
423			};
424
425			LDO_REG9 {
426				/* unused */
427			};
428
429			usb_midu: BOOST {
430				regulator-name = "usb_midu";
431				regulator-min-microvolt = <5000000>;
432				regulator-max-microvolt = <5400000>;
433				regulator-always-on;
434				regulator-boot-on;
435			};
436		};
437
438		rk817_charger: charger {
439			rockchip,resistor-sense-micro-ohms = <10000>;
440			rockchip,sleep-enter-current-microamp = <300000>;
441			rockchip,sleep-filter-current-microamp = <100000>;
442		};
443
444		rk817_codec: codec {
445			rockchip,mic-in-differential;
446		};
447	};
448};
449
450/* EXT Header(P2): 7(SCL:GPIO0.C2), 8(SDA:GPIO0.C3) */
451&i2c1 {
452	clock-frequency = <400000>;
453	status = "okay";
454};
455
456/* I2S 1 Channel Used */
457&i2s1_2ch {
458	status = "okay";
459};
460
461&io_domains {
462	vccio1-supply = <&vcc_3v3>;
463	vccio2-supply = <&vccio_sd>;
464	vccio3-supply = <&vcc_3v3>;
465	vccio4-supply = <&vcc_3v3>;
466	vccio5-supply = <&vcc_3v3>;
467	vccio6-supply = <&vcc_3v3>;
468	status = "okay";
469};
470
471&pmu_io_domains {
472	pmuio1-supply = <&vcc3v3_pmu>;
473	pmuio2-supply = <&vcc3v3_pmu>;
474	status = "okay";
475};
476
477&pwm1 {
478	status = "okay";
479};
480
481&pwm3 {
482	status = "okay";
483};
484
485&saradc {
486	vref-supply = <&vcc_1v8>;
487	status = "okay";
488};
489
490&sdmmc {
491	cap-sd-highspeed;
492	card-detect-delay = <200>;
493	cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/
494	sd-uhs-sdr12;
495	sd-uhs-sdr25;
496	sd-uhs-sdr50;
497	sd-uhs-sdr104;
498	vmmc-supply = <&vcc_sd>;
499	vqmmc-supply = <&vccio_sd>;
500	status = "okay";
501};
502
503&sfc {
504	pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>;
505	pinctrl-names = "default";
506	#address-cells = <1>;
507	#size-cells = <0>;
508	status = "okay";
509
510	flash@0 {
511		compatible = "jedec,spi-nor";
512		reg = <0>;
513		spi-max-frequency = <108000000>;
514		spi-rx-bus-width = <2>;
515		spi-tx-bus-width = <1>;
516	};
517};
518
519&tsadc {
520	status = "okay";
521};
522
523&u2phy {
524	status = "okay";
525
526	u2phy_host: host-port {
527		status = "okay";
528	};
529
530	u2phy_otg: otg-port {
531		status = "disabled";
532	};
533};
534
535&usb20_otg {
536	status = "okay";
537};
538
539/* EXT Header(P2): 2(RXD:GPIO1.C0),3(TXD:.C1),4(CTS:.C2),5(RTS:.C3) */
540&uart1 {
541	pinctrl-names = "default";
542	pinctrl-0 = <&uart1_xfer &uart1_cts>;
543	status = "okay";
544};
545
546&uart2 {
547	pinctrl-names = "default";
548	pinctrl-0 = <&uart2m1_xfer>;
549	status = "okay";
550};
551
552&vopb {
553	status = "okay";
554};
555
556&vopb_mmu {
557	status = "okay";
558};
559
560&pinctrl {
561	btns {
562		btn_pins: btn-pins {
563			rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>,
564					<1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>,
565					<1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>,
566					<1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>,
567					<1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>,
568					<1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>,
569					<1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>,
570					<1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>,
571					<2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>,
572					<2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>,
573					<2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>,
574					<2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>,
575					<2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
576					<2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>,
577					<2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>,
578					<2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>;
579		};
580	};
581
582	headphone {
583		hp_det: hp-det {
584			rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>;
585		};
586	};
587
588	leds {
589		red_led_pin: red-led-pin {
590			rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
591		};
592	};
593
594	pmic {
595		dc_det: dc-det {
596			rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
597		};
598
599		pmic_int: pmic-int {
600			rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>;
601		};
602
603		soc_slppin_gpio: soc_slppin_gpio {
604			rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>;
605		};
606
607		soc_slppin_rst: soc_slppin_rst {
608			rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>;
609		};
610
611		soc_slppin_slp: soc_slppin_slp {
612			rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>;
613		};
614	};
615};
616