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