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