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