1// SPDX-License-Identifier: BSD-3-Clause
2/*
3 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2020-2023, Linaro Limited
5 */
6
7/dts-v1/;
8
9#include <dt-bindings/firmware/qcom,scm.h>
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/input/gpio-keys.h>
12#include <dt-bindings/input/input.h>
13#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
14#include "sc8180x.dtsi"
15#include "sc8180x-pmics.dtsi"
16
17/ {
18	model = "Lenovo Flex 5G";
19	compatible = "lenovo,flex-5g", "qcom,sc8180x";
20
21	aliases {
22		serial0 = &uart13;
23	};
24
25	backlight: backlight {
26		compatible = "pwm-backlight";
27		pwms = <&pmc8180c_lpg 4 1000000>;
28		enable-gpios = <&pmc8180c_gpios 8 GPIO_ACTIVE_HIGH>;
29
30		pinctrl-0 = <&bl_pwm_default>;
31		pinctrl-names = "default";
32	};
33
34	gpio-keys {
35		compatible = "gpio-keys";
36
37		pinctrl-0 = <&hall_int_active_state>;
38		pinctrl-names = "default";
39
40		lid-switch {
41			gpios = <&tlmm 121 GPIO_ACTIVE_LOW>;
42			linux,input-type = <EV_SW>;
43			linux,code = <SW_LID>;
44			wakeup-source;
45			wakeup-event-action = <EV_ACT_DEASSERTED>;
46		};
47	};
48
49	pmic-glink {
50		compatible = "qcom,sc8180x-pmic-glink", "qcom,pmic-glink";
51
52		#address-cells = <1>;
53		#size-cells = <0>;
54		orientation-gpios = <&tlmm 38 GPIO_ACTIVE_HIGH>,
55				    <&tlmm 58 GPIO_ACTIVE_HIGH>;
56
57		connector@0 {
58			compatible = "usb-c-connector";
59			reg = <0>;
60			power-role = "dual";
61			data-role = "dual";
62
63			ports {
64				#address-cells = <1>;
65				#size-cells = <0>;
66
67				port@0 {
68					reg = <0>;
69
70					pmic_glink_con0_hs: endpoint {
71						remote-endpoint = <&usb_prim_dwc3_hs>;
72					};
73				};
74
75				port@1 {
76					reg = <1>;
77
78					pmic_glink_con0_ss: endpoint {
79						remote-endpoint = <&usb_prim_qmpphy_out>;
80					};
81				};
82
83				port@2 {
84					reg = <2>;
85
86					pmic_glink_con0_sbu: endpoint {
87						remote-endpoint = <&usbprim_sbu_mux>;
88					};
89				};
90			};
91		};
92
93		connector@1 {
94			compatible = "usb-c-connector";
95			reg = <1>;
96			power-role = "dual";
97			data-role = "dual";
98
99			ports {
100				#address-cells = <1>;
101				#size-cells = <0>;
102				port@0 {
103					reg = <0>;
104
105					pmic_glink_con1_hs: endpoint {
106						remote-endpoint = <&usb_sec_dwc3_hs>;
107					};
108				};
109
110				port@1 {
111					reg = <1>;
112
113					pmic_glink_con1_ss: endpoint {
114						remote-endpoint = <&usb_sec_qmpphy_out>;
115					};
116				};
117
118				port@2 {
119					reg = <2>;
120
121					pmic_glink_con1_sbu: endpoint {
122						remote-endpoint = <&usbsec_sbu_mux>;
123					};
124				};
125			};
126		};
127	};
128
129	reserved-memory {
130		rmtfs_mem: rmtfs-region@85500000 {
131			compatible = "qcom,rmtfs-mem";
132			reg = <0x0 0x85500000 0x0 0x200000>;
133			no-map;
134
135			qcom,client-id = <1>;
136			qcom,vmid = <QCOM_SCM_VMID_MSS_MSA>;
137		};
138
139		wlan_mem: wlan-region@8bc00000 {
140			reg = <0x0 0x8bc00000 0x0 0x180000>;
141			no-map;
142		};
143
144		mpss_mem: mpss-region@8d800000 {
145			reg = <0x0 0x8d800000 0x0 0x3000000>;
146			no-map;
147		};
148
149		adsp_mem: adsp-region@90800000 {
150			reg = <0x0 0x90800000 0x0 0x1c00000>;
151			no-map;
152		};
153
154		gpu_mem: gpu-region@98715000 {
155			reg = <0x0 0x98715000 0x0 0x2000>;
156			no-map;
157		};
158
159		cdsp_mem: cdsp-region@98900000 {
160			reg = <0x0 0x98900000 0x0 0x1400000>;
161			no-map;
162		};
163	};
164
165	vph_pwr: vph-pwr-regulator {
166		compatible = "regulator-fixed";
167		regulator-name = "vph_pwr";
168		regulator-min-microvolt = <3700000>;
169		regulator-max-microvolt = <3700000>;
170	};
171
172	vreg_s4a_1p8: pm8150-s4-regulator {
173		compatible = "regulator-fixed";
174		regulator-name = "vreg_s4a_1p8";
175
176		regulator-min-microvolt = <1800000>;
177		regulator-max-microvolt = <1800000>;
178
179		regulator-always-on;
180		regulator-boot-on;
181
182		vin-supply = <&vph_pwr>;
183	};
184
185	usbprim-sbu-mux {
186		compatible = "pericom,pi3usb102", "gpio-sbu-mux";
187
188		enable-gpios = <&tlmm 152 GPIO_ACTIVE_LOW>;
189		select-gpios = <&tlmm 100 GPIO_ACTIVE_HIGH>;
190
191		pinctrl-names = "default";
192		pinctrl-0 = <&usbprim_sbu_default>;
193
194		mode-switch;
195		orientation-switch;
196
197		port {
198			usbprim_sbu_mux: endpoint {
199				remote-endpoint = <&pmic_glink_con0_sbu>;
200			};
201		};
202	};
203
204	usbsec-sbu-mux {
205		compatible = "pericom,pi3usb102", "gpio-sbu-mux";
206
207		enable-gpios = <&tlmm 188 GPIO_ACTIVE_LOW>;
208		select-gpios = <&tlmm 187 GPIO_ACTIVE_HIGH>;
209
210		pinctrl-names = "default";
211		pinctrl-0 = <&usbsec_sbu_default>;
212
213		mode-switch;
214		orientation-switch;
215
216		port {
217			usbsec_sbu_mux: endpoint {
218				remote-endpoint = <&pmic_glink_con1_sbu>;
219			};
220		};
221	};
222};
223
224&apps_rsc {
225	regulators-0 {
226		compatible = "qcom,pmc8180-rpmh-regulators";
227		qcom,pmic-id = "a";
228
229		vdd-s5-supply = <&vph_pwr>;
230		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_2p0>;
231
232		vreg_s5a_2p0: smps5 {
233			regulator-min-microvolt = <2040000>;
234			regulator-max-microvolt = <2100000>;
235		};
236
237		vreg_l7a_1p8: ldo7 {
238			regulator-min-microvolt = <1800000>;
239			regulator-max-microvolt = <1800000>;
240			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
241		};
242
243		vreg_l9a_1p3: ldo9 {
244			regulator-min-microvolt = <1296000>;
245			regulator-max-microvolt = <1304000>;
246			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
247		};
248
249		vreg_l12a_1p8: ldo12 {
250			regulator-min-microvolt = <1800000>;
251			regulator-max-microvolt = <1800000>;
252			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
253		};
254	};
255
256	regulators-1 {
257		compatible = "qcom,pmc8180c-rpmh-regulators";
258		qcom,pmic-id = "c";
259
260		vdd-s6-supply = <&vph_pwr>;
261		vdd-l2-l3-supply = <&vreg_s6c_1p35>;
262		vdd-bob-supply = <&vph_pwr>;
263
264		vreg_s6c_1p35: smps6 {
265			regulator-min-microvolt = <1350000>;
266			regulator-max-microvolt = <1372000>;
267			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
268		};
269
270		vreg_l3c_1p2: ldo3 {
271			regulator-min-microvolt = <1200000>;
272			regulator-max-microvolt = <1200000>;
273			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
274		};
275
276		vreg_l10c_3p3: ldo10 {
277			regulator-min-microvolt = <3000000>;
278			regulator-max-microvolt = <3312000>;
279			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
280		};
281
282		vreg_l11c_3p3: ldo11 {
283			regulator-min-microvolt = <3296000>;
284			regulator-max-microvolt = <3304000>;
285			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
286		};
287
288		vreg_bob: bob {
289			regulator-min-microvolt = <3296000>;
290			regulator-max-microvolt = <3350000>;
291			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
292		};
293	};
294
295	regulators-2 {
296		compatible = "qcom,pmc8180-rpmh-regulators";
297		qcom,pmic-id = "e";
298
299		vdd-s4-supply = <&vph_pwr>;
300		vdd-s5-supply = <&vph_pwr>;
301		vdd-l2-l10-supply = <&vreg_bob>;
302		vdd-l3-l4-l5-l18-supply = <&vreg_s4e_0p98>;
303		vdd-l7-l12-l14-l15-supply = <&vreg_s5e_2p05>;
304		vdd-l13-l16-l17-supply = <&vreg_bob>;
305
306		vreg_s4e_0p98: smps4 {
307			regulator-min-microvolt = <992000>;
308			regulator-max-microvolt = <992000>;
309			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
310		};
311
312		vreg_s5e_2p05: smps5 {
313			regulator-min-microvolt = <2040000>;
314			regulator-max-microvolt = <2040000>;
315			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
316		};
317
318		vreg_l1e_0p75: ldo1 {
319			regulator-min-microvolt = <752000>;
320			regulator-max-microvolt = <752000>;
321			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
322		};
323
324		vreg_l5e_0p88: ldo5 {
325			regulator-min-microvolt = <880000>;
326			regulator-max-microvolt = <880000>;
327			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
328		};
329
330		vreg_l7e_1p8: ldo7 {
331			regulator-min-microvolt = <1800000>;
332			regulator-max-microvolt = <1800000>;
333			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
334			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
335						   RPMH_REGULATOR_MODE_HPM>;
336			regulator-allow-set-load;
337		};
338
339		vreg_l10e_2p9: ldo10 {
340			regulator-min-microvolt = <2904000>;
341			regulator-max-microvolt = <2904000>;
342			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
343			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
344						   RPMH_REGULATOR_MODE_HPM>;
345			regulator-allow-set-load;
346		};
347
348		vreg_l16e_3p0: ldo16 {
349			regulator-min-microvolt = <3072000>;
350			regulator-max-microvolt = <3072000>;
351			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
352		};
353	};
354};
355
356&gpu {
357	status = "okay";
358
359	zap-shader {
360		memory-region = <&gpu_mem>;
361		firmware-name = "qcom/sc8180x/LENOVO/82AK/qcdxkmsuc8180.mbn";
362	};
363};
364
365&i2c1 {
366	clock-frequency = <100000>;
367
368	pinctrl-0 = <&i2c1_active>;
369	pinctrl-names = "default";
370
371	status = "okay";
372
373	touchscreen@10 {
374		compatible = "hid-over-i2c";
375		reg = <0x10>;
376		hid-descr-addr = <0x1>;
377
378		interrupts-extended = <&tlmm 122 IRQ_TYPE_LEVEL_LOW>;
379
380		pinctrl-0 = <&ts_int_default>;
381		pinctrl-names = "default";
382	};
383};
384
385&i2c7 {
386	clock-frequency = <1000000>;
387
388	pinctrl-0 = <&i2c7_active>;
389	pinctrl-names = "default";
390
391	status = "okay";
392
393	keyboard@5 {
394		compatible = "hid-over-i2c";
395		reg = <0x5>;
396		hid-descr-addr = <0x20>;
397
398		interrupts-extended = <&tlmm 37 IRQ_TYPE_LEVEL_LOW>;
399
400		pinctrl-0 = <&kb_int_default>;
401		pinctrl-names = "default";
402	};
403
404	touchpad@2c {
405		compatible = "hid-over-i2c";
406		reg = <0x2c>;
407		hid-descr-addr = <0x20>;
408
409		interrupts-extended = <&tlmm 24 IRQ_TYPE_LEVEL_LOW>;
410
411		pinctrl-0 = <&tp_int_default>;
412		pinctrl-names = "default";
413	};
414};
415
416&mdss {
417	status = "okay";
418};
419
420&mdss_dp0 {
421	status = "okay";
422};
423
424&mdss_dp0_out {
425	data-lanes = <0 1>;
426	remote-endpoint = <&usb_prim_qmpphy_dp_in>;
427};
428
429&mdss_dp1 {
430	status = "okay";
431};
432
433&mdss_dp1_out {
434	data-lanes = <0 1>;
435	remote-endpoint = <&usb_sec_qmpphy_dp_in>;
436};
437
438&mdss_edp {
439	data-lanes = <0 1 2 3>;
440
441	pinctrl-0 = <&edp_hpd_active>;
442	pinctrl-names = "default";
443
444	status = "okay";
445
446	aux-bus {
447		panel {
448			compatible = "edp-panel";
449			no-hpd;
450
451			backlight = <&backlight>;
452
453			port {
454				auo_b140han06_in: endpoint {
455					remote-endpoint = <&mdss_edp_out>;
456				};
457			};
458		};
459	};
460
461	ports {
462		port@1 {
463			reg = <1>;
464			mdss_edp_out: endpoint {
465				remote-endpoint = <&auo_b140han06_in>;
466			};
467		};
468	};
469};
470
471&pcie3 {
472	perst-gpios = <&tlmm 178 GPIO_ACTIVE_LOW>;
473	wake-gpios = <&tlmm 180 GPIO_ACTIVE_HIGH>;
474	pinctrl-0 = <&pcie3_default_state>;
475	pinctrl-names = "default";
476
477	status = "okay";
478};
479
480&pcie3_phy {
481	vdda-phy-supply = <&vreg_l5e_0p88>;
482	vdda-pll-supply = <&vreg_l3c_1p2>;
483
484	status = "okay";
485};
486
487&pmc8180_pwrkey {
488	status = "okay";
489};
490
491&pmc8180c_lpg {
492	status = "okay";
493};
494
495&qupv3_id_0 {
496	status = "okay";
497};
498
499&qupv3_id_1 {
500	status = "okay";
501};
502
503&qupv3_id_2 {
504	status = "okay";
505};
506
507&remoteproc_adsp {
508	memory-region = <&adsp_mem>;
509	firmware-name = "qcom/sc8180x/LENOVO/82AK/qcadsp8180.mbn";
510
511	status = "okay";
512};
513
514&remoteproc_cdsp {
515	memory-region = <&cdsp_mem>;
516	firmware-name = "qcom/sc8180x/LENOVO/82AK/qccdsp8180.mbn";
517
518	status = "okay";
519};
520
521&remoteproc_mpss {
522	memory-region = <&mpss_mem>;
523	firmware-name = "qcom/sc8180x/LENOVO/82AK/qcmpss8180_nm.mbn";
524
525	status = "okay";
526};
527
528&uart13 {
529	pinctrl-0 = <&uart13_state>;
530	pinctrl-names = "default";
531
532	status = "okay";
533
534	bluetooth {
535		compatible = "qcom,wcn3998-bt";
536
537		vddio-supply = <&vreg_s4a_1p8>;
538		vddxo-supply = <&vreg_l7a_1p8>;
539		vddrf-supply = <&vreg_l9a_1p3>;
540		vddch0-supply = <&vreg_l11c_3p3>;
541		max-speed = <3200000>;
542	};
543};
544
545&ufs_mem_hc {
546	reset-gpios = <&tlmm 190 GPIO_ACTIVE_LOW>;
547
548	vcc-supply = <&vreg_l10e_2p9>;
549	vcc-max-microamp = <155000>;
550
551	vccq2-supply = <&vreg_l7e_1p8>;
552	vccq2-max-microamp = <425000>;
553
554	status = "okay";
555};
556
557&ufs_mem_phy {
558	vdda-phy-supply = <&vreg_l5e_0p88>;
559	vdda-pll-supply = <&vreg_l3c_1p2>;
560
561	status = "okay";
562};
563
564&usb_mp {
565	status = "okay";
566};
567
568&usb_mp_hsphy0 {
569	vdda-pll-supply = <&vreg_l5e_0p88>;
570	vdda18-supply = <&vreg_l12a_1p8>;
571	vdda33-supply = <&vreg_l16e_3p0>;
572
573	status = "okay";
574};
575
576&usb_mp_hsphy1 {
577	vdda-pll-supply = <&vreg_l5e_0p88>;
578	vdda18-supply = <&vreg_l12a_1p8>;
579	vdda33-supply = <&vreg_l16e_3p0>;
580
581	status = "okay";
582};
583
584&usb_mp_qmpphy0 {
585	vdda-phy-supply = <&vreg_l3c_1p2>;
586	vdda-pll-supply = <&vreg_l5e_0p88>;
587
588	status = "okay";
589};
590
591&usb_mp_qmpphy1 {
592	vdda-phy-supply = <&vreg_l3c_1p2>;
593	vdda-pll-supply = <&vreg_l5e_0p88>;
594
595	status = "okay";
596};
597
598&usb_prim_hsphy {
599	vdda-pll-supply = <&vreg_l5e_0p88>;
600	vdda18-supply = <&vreg_l12a_1p8>;
601	vdda33-supply = <&vreg_l16e_3p0>;
602
603	status = "okay";
604};
605
606&usb_prim_qmpphy {
607	vdda-phy-supply = <&vreg_l3c_1p2>;
608	vdda-pll-supply = <&vreg_l5e_0p88>;
609
610	orientation-switch;
611
612	status = "okay";
613};
614
615&usb_prim {
616	status = "okay";
617};
618
619&usb_prim_dwc3 {
620	dr_mode = "host";
621};
622
623&usb_prim_dwc3_hs {
624	remote-endpoint = <&pmic_glink_con0_hs>;
625};
626
627&usb_prim_qmpphy_dp_in {
628	remote-endpoint = <&mdss_dp0_out>;
629};
630
631&usb_prim_qmpphy_out {
632	remote-endpoint = <&pmic_glink_con0_ss>;
633};
634
635&usb_sec_dwc3_hs {
636	remote-endpoint = <&pmic_glink_con1_hs>;
637};
638
639&usb_sec_hsphy {
640	vdda-pll-supply = <&vreg_l5e_0p88>;
641	vdda18-supply = <&vreg_l12a_1p8>;
642	vdda33-supply = <&vreg_l16e_3p0>;
643
644	status = "okay";
645};
646
647&usb_sec_qmpphy {
648	vdda-phy-supply = <&vreg_l3c_1p2>;
649	vdda-pll-supply = <&vreg_l5e_0p88>;
650
651	orientation-switch;
652
653	status = "okay";
654};
655
656&usb_sec_qmpphy_dp_in {
657	remote-endpoint = <&mdss_dp1_out>;
658};
659
660&usb_sec_qmpphy_out {
661	remote-endpoint = <&pmic_glink_con1_ss>;
662};
663
664&usb_sec {
665	status = "okay";
666};
667
668&usb_sec_dwc3 {
669	dr_mode = "host";
670};
671
672&wifi {
673	memory-region = <&wlan_mem>;
674
675	vdd-0.8-cx-mx-supply = <&vreg_l1e_0p75>;
676	vdd-1.8-xo-supply = <&vreg_l7a_1p8>;
677	vdd-1.3-rfa-supply = <&vreg_l9a_1p3>;
678	vdd-3.3-ch0-supply = <&vreg_l11c_3p3>;
679	vdd-3.3-ch1-supply = <&vreg_l10c_3p3>;
680
681	status = "okay";
682};
683
684/* PINCTRL */
685
686&pmc8180c_gpios {
687	bl_pwm_default: bl-pwm-default-state {
688		en-pins {
689			pins = "gpio8";
690			function = "normal";
691		};
692
693		pwm-pins {
694			pins = "gpio10";
695			function = "func1";
696		};
697	};
698};
699
700&tlmm {
701	gpio-reserved-ranges = <0 4>, <47 4>, <126 4>;
702
703	edp_hpd_active: epd-hpd-active-state {
704		pins = "gpio10";
705		function = "edp_hot";
706	};
707
708	hall_int_active_state: hall-int-active-state {
709		pins = "gpio121";
710		function = "gpio";
711
712		bias-disable;
713	};
714
715	i2c1_active: i2c1-active-state {
716		pins = "gpio114", "gpio115";
717		function = "qup1";
718
719		bias-pull-up = <1>;
720		drive-strength = <2>;
721	};
722
723	i2c7_active: i2c7-active-state {
724		pins = "gpio98", "gpio99";
725		function = "qup7";
726
727		bias-pull-up;
728		drive-strength = <2>;
729	};
730
731	kb_int_default: kb-int-default-state {
732		pins = "gpio37";
733		function = "gpio";
734
735		bias-pull-up;
736		drive-strength = <2>;
737	};
738
739	pcie3_default_state: pcie3-default-state {
740		clkreq-pins {
741			pins = "gpio179";
742			function = "pci_e3";
743			bias-pull-up;
744		};
745
746		reset-n-pins {
747			pins = "gpio178";
748			function = "gpio";
749
750			drive-strength = <2>;
751			output-low;
752			bias-pull-down;
753		};
754
755		wake-n-pins {
756			pins = "gpio180";
757			function = "gpio";
758
759			drive-strength = <2>;
760			bias-pull-up;
761		};
762	};
763
764	tp_int_default: tp-int-default-state {
765		pins = "gpio24";
766		function = "gpio";
767
768		bias-pull-up;
769		drive-strength = <2>;
770	};
771
772	ts_int_default: ts-int-default-state {
773		pins = "gpio122";
774		function = "gpio";
775
776		bias-pull-up;
777		drive-strength = <2>;
778	};
779
780	usbprim_sbu_default: usbprim-sbu-state {
781		oe-n-pins {
782			pins = "gpio152";
783			function = "gpio";
784			bias-disable;
785			drive-strength = <16>;
786			output-high;
787		};
788
789		sel-pins {
790			pins = "gpio100";
791			function = "gpio";
792			bias-disable;
793			drive-strength = <16>;
794		};
795	};
796
797	usbsec_sbu_default: usbsec-sbu-state {
798		oe-n-pins {
799			pins = "gpio188";
800			function = "gpio";
801			bias-disable;
802			drive-strength = <16>;
803			output-high;
804		};
805
806		sel-pins {
807			pins = "gpio187";
808			function = "gpio";
809			bias-disable;
810			drive-strength = <16>;
811		};
812	};
813
814	uart13_state: uart13-state {
815		cts-pins {
816			pins = "gpio43";
817			function = "qup13";
818			bias-pull-down;
819		};
820
821		rts-tx-pins {
822			pins = "gpio44", "gpio45";
823			function = "qup13";
824			drive-strength = <2>;
825			bias-disable;
826		};
827
828		rx-pins {
829			pins = "gpio46";
830			function = "qup13";
831			bias-pull-up;
832		};
833	};
834};
835