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		iovcc-supply = <&vcc_lcd>;
239		reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>;
240		rotation = <270>;
241		vdd-supply = <&vcc_lcd>;
242
243		port {
244			mipi_in_panel: endpoint {
245				remote-endpoint = <&mipi_out_panel>;
246			};
247		};
248	};
249};
250
251&dsi_dphy {
252	status = "okay";
253};
254
255&gpu {
256	mali-supply = <&vdd_logic>;
257	status = "okay";
258};
259
260&i2c0 {
261	clock-frequency = <400000>;
262	i2c-scl-falling-time-ns = <16>;
263	i2c-scl-rising-time-ns = <280>;
264	status = "okay";
265
266	rk817: pmic@20 {
267		compatible = "rockchip,rk817";
268		reg = <0x20>;
269		interrupt-parent = <&gpio0>;
270		interrupts = <RK_PB2 IRQ_TYPE_LEVEL_LOW>;
271		clock-output-names = "rk808-clkout1", "xin32k";
272		clock-names = "mclk";
273		clocks = <&cru SCLK_I2S1_OUT>;
274		pinctrl-names = "default";
275		pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>;
276		wakeup-source;
277		#clock-cells = <1>;
278		#sound-dai-cells = <0>;
279
280		vcc1-supply = <&vccsys>;
281		vcc2-supply = <&vccsys>;
282		vcc3-supply = <&vccsys>;
283		vcc4-supply = <&vccsys>;
284		vcc5-supply = <&vccsys>;
285		vcc6-supply = <&vccsys>;
286		vcc7-supply = <&vccsys>;
287		vcc8-supply = <&vccsys>;
288
289		regulators {
290			vdd_logic: DCDC_REG1 {
291				regulator-name = "vdd_logic";
292				regulator-min-microvolt = <950000>;
293				regulator-max-microvolt = <1150000>;
294				regulator-ramp-delay = <6001>;
295				regulator-always-on;
296				regulator-boot-on;
297
298				regulator-state-mem {
299					regulator-on-in-suspend;
300					regulator-suspend-microvolt = <950000>;
301				};
302			};
303
304			vdd_arm: DCDC_REG2 {
305				regulator-name = "vdd_arm";
306				regulator-min-microvolt = <950000>;
307				regulator-max-microvolt = <1350000>;
308				regulator-ramp-delay = <6001>;
309				regulator-always-on;
310				regulator-boot-on;
311
312				regulator-state-mem {
313					regulator-off-in-suspend;
314					regulator-suspend-microvolt = <950000>;
315				};
316			};
317
318			vcc_ddr: DCDC_REG3 {
319				regulator-name = "vcc_ddr";
320				regulator-always-on;
321				regulator-boot-on;
322
323				regulator-state-mem {
324					regulator-on-in-suspend;
325				};
326			};
327
328			vcc_3v3: DCDC_REG4 {
329				regulator-name = "vcc_3v3";
330				regulator-min-microvolt = <3300000>;
331				regulator-max-microvolt = <3300000>;
332				regulator-always-on;
333				regulator-boot-on;
334
335				regulator-state-mem {
336					regulator-off-in-suspend;
337					regulator-suspend-microvolt = <3300000>;
338				};
339			};
340
341			vcc_1v8: LDO_REG2 {
342				regulator-name = "vcc_1v8";
343				regulator-min-microvolt = <1800000>;
344				regulator-max-microvolt = <1800000>;
345				regulator-always-on;
346				regulator-boot-on;
347
348				regulator-state-mem {
349					regulator-on-in-suspend;
350					regulator-suspend-microvolt = <1800000>;
351				};
352			};
353
354			vdd_1v0: LDO_REG3 {
355				regulator-name = "vdd_1v0";
356				regulator-min-microvolt = <1000000>;
357				regulator-max-microvolt = <1000000>;
358				regulator-always-on;
359				regulator-boot-on;
360
361				regulator-state-mem {
362					regulator-on-in-suspend;
363					regulator-suspend-microvolt = <1000000>;
364				};
365			};
366
367			vcc3v3_pmu: LDO_REG4 {
368				regulator-name = "vcc3v3_pmu";
369				regulator-min-microvolt = <3300000>;
370				regulator-max-microvolt = <3300000>;
371				regulator-always-on;
372				regulator-boot-on;
373
374				regulator-state-mem {
375					regulator-on-in-suspend;
376					regulator-suspend-microvolt = <3300000>;
377				};
378			};
379
380			vccio_sd: LDO_REG5 {
381				regulator-name = "vccio_sd";
382				regulator-min-microvolt = <1800000>;
383				regulator-max-microvolt = <3300000>;
384				regulator-always-on;
385				regulator-boot-on;
386
387				regulator-state-mem {
388					regulator-on-in-suspend;
389					regulator-suspend-microvolt = <3300000>;
390				};
391			};
392
393			vcc_sd: LDO_REG6 {
394				regulator-name = "vcc_sd";
395				regulator-min-microvolt = <3300000>;
396				regulator-max-microvolt = <3300000>;
397				regulator-boot-on;
398
399				regulator-state-mem {
400					regulator-on-in-suspend;
401					regulator-suspend-microvolt = <3300000>;
402				};
403			};
404
405			vcc_bl: LDO_REG7 {
406				regulator-name = "vcc_bl";
407				regulator-min-microvolt = <3300000>;
408				regulator-max-microvolt = <3300000>;
409
410				regulator-state-mem {
411					regulator-off-in-suspend;
412					regulator-suspend-microvolt = <3300000>;
413				};
414			};
415
416			vcc_lcd: LDO_REG8 {
417				regulator-name = "vcc_lcd";
418				regulator-min-microvolt = <2800000>;
419				regulator-max-microvolt = <2800000>;
420
421				regulator-state-mem {
422					regulator-off-in-suspend;
423					regulator-suspend-microvolt = <2800000>;
424				};
425			};
426
427			LDO_REG9 {
428				/* unused */
429			};
430
431			usb_midu: BOOST {
432				regulator-name = "usb_midu";
433				regulator-min-microvolt = <5000000>;
434				regulator-max-microvolt = <5400000>;
435				regulator-always-on;
436				regulator-boot-on;
437			};
438		};
439
440		rk817_charger: charger {
441			rockchip,resistor-sense-micro-ohms = <10000>;
442			rockchip,sleep-enter-current-microamp = <300000>;
443			rockchip,sleep-filter-current-microamp = <100000>;
444		};
445
446		rk817_codec: codec {
447			rockchip,mic-in-differential;
448		};
449	};
450};
451
452/* EXT Header(P2): 7(SCL:GPIO0.C2), 8(SDA:GPIO0.C3) */
453&i2c1 {
454	clock-frequency = <400000>;
455	status = "okay";
456};
457
458/* I2S 1 Channel Used */
459&i2s1_2ch {
460	status = "okay";
461};
462
463&io_domains {
464	vccio1-supply = <&vcc_3v3>;
465	vccio2-supply = <&vccio_sd>;
466	vccio3-supply = <&vcc_3v3>;
467	vccio4-supply = <&vcc_3v3>;
468	vccio5-supply = <&vcc_3v3>;
469	vccio6-supply = <&vcc_3v3>;
470	status = "okay";
471};
472
473&pmu_io_domains {
474	pmuio1-supply = <&vcc3v3_pmu>;
475	pmuio2-supply = <&vcc3v3_pmu>;
476	status = "okay";
477};
478
479&pwm1 {
480	status = "okay";
481};
482
483&pwm3 {
484	status = "okay";
485};
486
487&saradc {
488	vref-supply = <&vcc_1v8>;
489	status = "okay";
490};
491
492&sdmmc {
493	cap-sd-highspeed;
494	card-detect-delay = <200>;
495	cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/
496	sd-uhs-sdr12;
497	sd-uhs-sdr25;
498	sd-uhs-sdr50;
499	sd-uhs-sdr104;
500	vmmc-supply = <&vcc_sd>;
501	vqmmc-supply = <&vccio_sd>;
502	status = "okay";
503};
504
505&sfc {
506	pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>;
507	pinctrl-names = "default";
508	#address-cells = <1>;
509	#size-cells = <0>;
510	status = "okay";
511
512	flash@0 {
513		compatible = "jedec,spi-nor";
514		reg = <0>;
515		spi-max-frequency = <108000000>;
516		spi-rx-bus-width = <2>;
517		spi-tx-bus-width = <1>;
518	};
519};
520
521&tsadc {
522	status = "okay";
523};
524
525&u2phy {
526	status = "okay";
527
528	u2phy_host: host-port {
529		status = "okay";
530	};
531
532	u2phy_otg: otg-port {
533		status = "disabled";
534	};
535};
536
537&usb20_otg {
538	status = "okay";
539};
540
541/* EXT Header(P2): 2(RXD:GPIO1.C0),3(TXD:.C1),4(CTS:.C2),5(RTS:.C3) */
542&uart1 {
543	pinctrl-names = "default";
544	pinctrl-0 = <&uart1_xfer &uart1_cts>;
545	status = "okay";
546};
547
548&uart2 {
549	pinctrl-names = "default";
550	pinctrl-0 = <&uart2m1_xfer>;
551	status = "okay";
552};
553
554&vopb {
555	status = "okay";
556};
557
558&vopb_mmu {
559	status = "okay";
560};
561
562&pinctrl {
563	btns {
564		btn_pins: btn-pins {
565			rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>,
566					<1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>,
567					<1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>,
568					<1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>,
569					<1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>,
570					<1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>,
571					<1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>,
572					<1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>,
573					<2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>,
574					<2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>,
575					<2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>,
576					<2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>,
577					<2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
578					<2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>,
579					<2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>,
580					<2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>;
581		};
582	};
583
584	headphone {
585		hp_det: hp-det {
586			rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>;
587		};
588	};
589
590	leds {
591		red_led_pin: red-led-pin {
592			rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
593		};
594	};
595
596	pmic {
597		dc_det: dc-det {
598			rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
599		};
600
601		pmic_int: pmic-int {
602			rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>;
603		};
604
605		soc_slppin_gpio: soc_slppin_gpio {
606			rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>;
607		};
608
609		soc_slppin_rst: soc_slppin_rst {
610			rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>;
611		};
612
613		soc_slppin_slp: soc_slppin_slp {
614			rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>;
615		};
616	};
617};
618