xref: /freebsd/sys/contrib/device-tree/src/arm64/qcom/msm8916-huawei-g7.dts (revision c7046f76c2c027b00c0e6ba57cfd28f1a78f5e23)
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2021 Stephan Gerhold
3
4/dts-v1/;
5
6#include "msm8916-pm8916.dtsi"
7#include <dt-bindings/gpio/gpio.h>
8#include <dt-bindings/input/input.h>
9#include <dt-bindings/interrupt-controller/irq.h>
10#include <dt-bindings/leds/common.h>
11
12/*
13 * Note: The original firmware from Huawei can only boot 32-bit kernels.
14 * To boot arm64 kernels it is necessary to flash 64-bit TZ/HYP firmware
15 * with EDL, e.g. taken from the DragonBoard 410c. This works because Huawei
16 * forgot to set up (firmware) secure boot for some reason.
17 *
18 * Also note that Huawei no longer provides bootloader unlock codes.
19 * This can be bypassed by patching the bootloader from a custom HYP firmware,
20 * making it think the bootloader is unlocked.
21 *
22 * See: https://wiki.postmarketos.org/wiki/Huawei_Ascend_G7_(huawei-g7)
23 */
24
25/ {
26	model = "Huawei Ascend G7";
27	compatible = "huawei,g7", "qcom,msm8916";
28	chassis-type = "handset";
29
30	aliases {
31		serial0 = &blsp1_uart2;
32	};
33
34	chosen {
35		stdout-path = "serial0";
36	};
37
38	gpio-keys {
39		compatible = "gpio-keys";
40
41		pinctrl-names = "default";
42		pinctrl-0 = <&gpio_keys_default>;
43
44		label = "GPIO Buttons";
45
46		volume-up {
47			label = "Volume Up";
48			gpios = <&msmgpio 107 GPIO_ACTIVE_LOW>;
49			linux,code = <KEY_VOLUMEUP>;
50		};
51	};
52
53	leds {
54		compatible = "gpio-leds";
55
56		pinctrl-names = "default";
57		pinctrl-0 = <&gpio_leds_default>;
58
59		led-0 {
60			gpios = <&msmgpio 8 GPIO_ACTIVE_HIGH>;
61			color = <LED_COLOR_ID_RED>;
62			default-state = "off";
63			function = LED_FUNCTION_INDICATOR;
64		};
65
66		led-1 {
67			gpios = <&msmgpio 9 GPIO_ACTIVE_HIGH>;
68			color = <LED_COLOR_ID_GREEN>;
69			default-state = "off";
70			function = LED_FUNCTION_INDICATOR;
71		};
72
73		led-2 {
74			gpios = <&msmgpio 10 GPIO_ACTIVE_HIGH>;
75			color = <LED_COLOR_ID_BLUE>;
76			default-state = "off";
77			function = LED_FUNCTION_INDICATOR;
78		};
79	};
80
81	usb_id: usb-id {
82		compatible = "linux,extcon-usb-gpio";
83		id-gpio = <&msmgpio 117 GPIO_ACTIVE_HIGH>;
84		pinctrl-names = "default";
85		pinctrl-0 = <&usb_id_default>;
86	};
87};
88
89&blsp_i2c2 {
90	status = "okay";
91
92	magnetometer@c {
93		compatible = "asahi-kasei,ak09911";
94		reg = <0x0c>;
95
96		vdd-supply = <&pm8916_l17>;
97		vid-supply = <&pm8916_l6>;
98
99		reset-gpios = <&msmgpio 36 GPIO_ACTIVE_LOW>;
100
101		pinctrl-names = "default";
102		pinctrl-0 = <&mag_reset_default>;
103	};
104
105	accelerometer@1e {
106		compatible = "kionix,kx023-1025";
107		reg = <0x1e>;
108
109		interrupt-parent = <&msmgpio>;
110		interrupts = <115 IRQ_TYPE_EDGE_RISING>;
111
112		vdd-supply = <&pm8916_l17>;
113		vddio-supply = <&pm8916_l6>;
114
115		pinctrl-names = "default";
116		pinctrl-0 = <&accel_irq_default>;
117
118		mount-matrix = "-1", "0", "0",
119				"0", "1", "0",
120				"0", "0", "1";
121	};
122
123	proximity@39 {
124		compatible = "avago,apds9930";
125		reg = <0x39>;
126
127		interrupt-parent = <&msmgpio>;
128		interrupts = <113 IRQ_TYPE_EDGE_FALLING>;
129
130		vdd-supply = <&pm8916_l17>;
131		vddio-supply = <&pm8916_l6>;
132
133		led-max-microamp = <100000>;
134		amstaos,proximity-diodes = <1>;
135
136		pinctrl-names = "default";
137		pinctrl-0 = <&prox_irq_default>;
138	};
139
140	regulator@3e {
141		compatible = "ti,tps65132";
142		reg = <0x3e>;
143
144		pinctrl-names = "default";
145		pinctrl-0 = <&reg_lcd_en_default>;
146
147		reg_lcd_pos: outp {
148			regulator-name = "outp";
149			regulator-min-microvolt = <5400000>;
150			regulator-max-microvolt = <5400000>;
151			enable-gpios = <&msmgpio 97 GPIO_ACTIVE_HIGH>;
152			regulator-active-discharge = <1>;
153		};
154
155		reg_lcd_neg: outn {
156			regulator-name = "outn";
157			regulator-min-microvolt = <5400000>;
158			regulator-max-microvolt = <5400000>;
159			enable-gpios = <&msmgpio 32 GPIO_ACTIVE_HIGH>;
160			regulator-active-discharge = <1>;
161		};
162	};
163};
164
165&blsp_i2c5 {
166	status = "okay";
167
168	rmi4@70 {
169		compatible = "syna,rmi4-i2c";
170		reg = <0x70>;
171		#address-cells = <1>;
172		#size-cells = <0>;
173
174		interrupt-parent = <&msmgpio>;
175		interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
176
177		vdd-supply = <&pm8916_l17>;
178		vio-supply = <&pm8916_l16>;
179
180		pinctrl-names = "default";
181		pinctrl-0 = <&ts_irq_default>;
182
183		syna,startup-delay-ms = <100>;
184
185		rmi4-f01@1 {
186			reg = <0x1>;
187			syna,nosleep-mode = <1>; /* Allow sleeping */
188		};
189
190		rmi4-f11@11 {
191			reg = <0x11>;
192			syna,sensor-type = <1>; /* Touchscreen */
193		};
194	};
195};
196
197&blsp_i2c6 {
198	status = "okay";
199
200	nfc@28 {
201		compatible = "nxp,pn547", "nxp,nxp-nci-i2c";
202		reg = <0x28>;
203
204		interrupt-parent = <&msmgpio>;
205		interrupts = <21 IRQ_TYPE_EDGE_RISING>;
206
207		enable-gpios = <&msmgpio 20 GPIO_ACTIVE_HIGH>;
208		firmware-gpios = <&msmgpio 2 GPIO_ACTIVE_HIGH>;
209
210		pinctrl-names = "default";
211		pinctrl-0 = <&nfc_default>;
212	};
213};
214
215&blsp1_uart2 {
216	status = "okay";
217};
218
219&pm8916_resin {
220	status = "okay";
221	linux,code = <KEY_VOLUMEDOWN>;
222};
223
224&pm8916_vib {
225	status = "okay";
226};
227
228&pronto {
229	status = "okay";
230};
231
232&sdhc_1 {
233	status = "okay";
234
235	pinctrl-names = "default", "sleep";
236	pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on>;
237	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off>;
238};
239
240&sdhc_2 {
241	status = "okay";
242
243	pinctrl-names = "default", "sleep";
244	pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdhc2_cd_default>;
245	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdhc2_cd_default>;
246
247	/*
248	 * The Huawei device tree sets cd-gpios = <&msmgpio 38 GPIO_ACTIVE_HIGH>.
249	 * However, gpio38 does not change its state when inserting/removing the
250	 * SD card, it's just low all the time. The Huawei kernel seems to use
251	 * polling for SD card detection instead.
252	 *
253	 * However, looking closer at the GPIO debug output it turns out that
254	 * gpio56 switches its state when inserting/removing the SD card.
255	 * It behaves just like gpio38 normally does. Usually GPIO56 is used as
256	 * "UIM2_PRESENT", i.e. to check if a second SIM card is inserted.
257	 * Maybe Huawei decided to replace the second SIM card slot with the
258	 * SD card slot and forgot to re-route to gpio38.
259	 */
260	cd-gpios = <&msmgpio 56 GPIO_ACTIVE_LOW>;
261};
262
263&usb {
264	status = "okay";
265	extcon = <&usb_id>, <&usb_id>;
266};
267
268&usb_hs_phy {
269	extcon = <&usb_id>;
270};
271
272&smd_rpm_regulators {
273	vdd_l1_l2_l3-supply = <&pm8916_s3>;
274	vdd_l4_l5_l6-supply = <&pm8916_s4>;
275	vdd_l7-supply = <&pm8916_s4>;
276
277	s3 {
278		regulator-min-microvolt = <1200000>;
279		regulator-max-microvolt = <1300000>;
280	};
281
282	s4 {
283		regulator-min-microvolt = <1800000>;
284		regulator-max-microvolt = <2100000>;
285	};
286
287	l1 {
288		regulator-min-microvolt = <1225000>;
289		regulator-max-microvolt = <1225000>;
290	};
291
292	l2 {
293		regulator-min-microvolt = <1200000>;
294		regulator-max-microvolt = <1200000>;
295	};
296
297	l4 {
298		regulator-min-microvolt = <2050000>;
299		regulator-max-microvolt = <2050000>;
300	};
301
302	l5 {
303		regulator-min-microvolt = <1800000>;
304		regulator-max-microvolt = <1800000>;
305	};
306
307	l6 {
308		regulator-min-microvolt = <1800000>;
309		regulator-max-microvolt = <1800000>;
310	};
311
312	l7 {
313		regulator-min-microvolt = <1800000>;
314		regulator-max-microvolt = <1800000>;
315	};
316
317	l8 {
318		regulator-min-microvolt = <2950000>;
319		regulator-max-microvolt = <2950000>;
320	};
321
322	l9 {
323		regulator-min-microvolt = <3300000>;
324		regulator-max-microvolt = <3300000>;
325	};
326
327	l10 {
328		regulator-min-microvolt = <2700000>;
329		regulator-max-microvolt = <2800000>;
330	};
331
332	l11 {
333		regulator-min-microvolt = <1800000>;
334		regulator-max-microvolt = <2950000>;
335		regulator-allow-set-load;
336		regulator-system-load = <200000>;
337	};
338
339	l12 {
340		regulator-min-microvolt = <1800000>;
341		regulator-max-microvolt = <2950000>;
342	};
343
344	l13 {
345		regulator-min-microvolt = <3075000>;
346		regulator-max-microvolt = <3075000>;
347	};
348
349	l14 {
350		regulator-min-microvolt = <1800000>;
351		regulator-max-microvolt = <3300000>;
352	};
353
354	l15 {
355		regulator-min-microvolt = <1800000>;
356		regulator-max-microvolt = <3300000>;
357	};
358
359	l16 {
360		regulator-min-microvolt = <1800000>;
361		regulator-max-microvolt = <1800000>;
362	};
363
364	l17 {
365		regulator-min-microvolt = <2850000>;
366		regulator-max-microvolt = <2850000>;
367	};
368
369	l18 {
370		regulator-min-microvolt = <2700000>;
371		regulator-max-microvolt = <2700000>;
372	};
373};
374
375&msmgpio {
376	accel_irq_default: accel-irq-default {
377		pins = "gpio115";
378		function = "gpio";
379
380		drive-strength = <2>;
381		bias-disable;
382	};
383
384	gpio_keys_default: gpio-keys-default {
385		pins = "gpio107";
386		function = "gpio";
387
388		drive-strength = <2>;
389		bias-pull-up;
390	};
391
392	gpio_leds_default: gpio-leds-default {
393		pins = "gpio8", "gpio9", "gpio10";
394		function = "gpio";
395
396		drive-strength = <2>;
397		bias-disable;
398	};
399
400	nfc_default: nfc-default {
401		pins = "gpio2", "gpio20", "gpio21";
402		function = "gpio";
403
404		drive-strength = <2>;
405		bias-disable;
406	};
407
408	mag_reset_default: mag-reset-default {
409		pins = "gpio36";
410		function = "gpio";
411
412		drive-strength = <2>;
413		bias-disable;
414	};
415
416	prox_irq_default: prox-irq-default {
417		pins = "gpio113";
418		function = "gpio";
419
420		drive-strength = <2>;
421		bias-disable;
422	};
423
424	reg_lcd_en_default: reg-lcd-en-default {
425		pins = "gpio32", "gpio97";
426		function = "gpio";
427
428		drive-strength = <2>;
429		bias-disable;
430	};
431
432	sdhc2_cd_default: sdhc2-cd-default {
433		pins = "gpio56";
434		function = "gpio";
435
436		drive-strength = <2>;
437		bias-disable;
438	};
439
440	ts_irq_default: ts-irq-default {
441		pins = "gpio13";
442		function = "gpio";
443
444		drive-strength = <2>;
445		bias-disable;
446	};
447
448	usb_id_default: usb-id-default {
449		pins = "gpio117";
450		function = "gpio";
451
452		drive-strength = <8>;
453		bias-pull-up;
454	};
455};
456