1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 * Copyright (c) 2020-2023, Linaro Ltd.
5 *
6 */
7
8/dts-v1/;
9
10#include "msm8939.dtsi"
11#include "msm8939-pm8916.dtsi"
12#include <dt-bindings/arm/qcom,ids.h>
13#include <dt-bindings/gpio/gpio.h>
14#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
15#include <dt-bindings/sound/apq8016-lpass.h>
16
17/ {
18	model = "Square, Inc. T2 Devkit";
19	compatible = "square,apq8039-t2", "qcom,msm8939";
20
21	qcom,board-id = <0x53 0x54>;
22	qcom,msm-id = <QCOM_ID_APQ8039 0x30000>;
23
24	aliases {
25		mmc0 = &sdhc_1;
26		mmc1 = &sdhc_2;
27		serial0 = &blsp_uart1;
28		serial1 = &blsp_uart2;
29	};
30
31	bl: backlight {
32		compatible = "gpio-backlight";
33		pinctrl-0 = <&pinctrl_backlight>;
34		pinctrl-names = "default";
35		gpios = <&tlmm 98 GPIO_ACTIVE_HIGH>;
36	};
37
38	chosen {
39		stdout-path = "serial1:115200n8";
40	};
41
42	vreg_lcd_avdd_reg: lcd-avdd-regulator {
43		compatible = "regulator-fixed";
44		regulator-name = "lcd_avdd";
45		regulator-min-microvolt = <5600000>;
46		regulator-max-microvolt = <5600000>;
47		pinctrl-0 = <&pinctrl_lcd_avdd_reg>;
48		pinctrl-names = "default";
49		gpio = <&tlmm 86 GPIO_ACTIVE_HIGH>;
50		startup-delay-us = <300>;
51		enable-active-high;
52	};
53
54	vreg_lcd_avee_reg: lcd-avee-regulator {
55		compatible = "regulator-fixed";
56		regulator-name = "lcd_avee";
57		regulator-min-microvolt = <5600000>;
58		regulator-max-microvolt = <5600000>;
59		pinctrl-0 = <&pinctrl_lcd_avee_reg>;
60		pinctrl-names = "default";
61		gpio = <&tlmm 87 GPIO_ACTIVE_HIGH>;
62		startup-delay-us = <300>;
63		enable-active-high;
64	};
65
66	vreg_lcd_iovcc_reg: lcd-iovcc-regulator {
67		compatible = "regulator-fixed";
68		regulator-name = "lcd_iovcc";
69		regulator-min-microvolt = <1800000>;
70		regulator-max-microvolt = <1800000>;
71		pinctrl-0 = <&pinctrl_lcd_iovcc_reg>;
72		pinctrl-names = "default";
73		gpio = <&tlmm 9 GPIO_ACTIVE_HIGH>;
74		startup-delay-us = <300>;
75		enable-active-high;
76	};
77};
78
79&blsp_i2c1 {
80	status = "okay";
81};
82
83&blsp_i2c2 {
84	status = "okay";
85};
86
87&blsp_i2c3 {
88	status = "okay";
89
90	typec_pd: usb-pd@38 {
91		compatible = "ti,tps6598x";
92		reg = <0x38>;
93
94		interrupt-parent = <&tlmm>;
95		interrupts = <107 IRQ_TYPE_LEVEL_LOW>;
96		interrupt-names = "irq";
97
98		pinctrl-names = "default";
99		pinctrl-0 = <&typec_irq>;
100
101		typec_con: connector {
102			compatible = "usb-c-connector";
103			label = "USB-C";
104
105			port {
106				typec_ep: endpoint {
107					remote-endpoint = <&otg_ep>;
108				};
109			};
110		};
111	};
112};
113
114&blsp_i2c5 {
115	status = "okay";
116};
117
118&blsp_uart1 {
119	status = "okay";
120};
121
122&blsp_uart1_default {
123	pins = "gpio0", "gpio1";
124};
125
126&blsp_uart1_sleep {
127	pins = "gpio0", "gpio1";
128};
129
130&blsp_uart2 {
131	status = "okay";
132};
133
134&lpass {
135	status = "okay";
136};
137
138&mdss {
139	status = "okay";
140};
141
142&pm8916_codec {
143	qcom,hphl-jack-type-normally-open;
144	qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
145	qcom,mbhc-vthreshold-high = <75 150 237 450 500>;
146	status = "okay";
147};
148
149&pm8916_gpios {
150	gpio-line-names =
151		"PM_GPIO1",     /* WIFI_GPIO1_PRE */
152		"PM_GPIO2",     /* WIFI_GPIO2_PRE */
153		"PM_GPIO3",
154		"PM_GPIO4";
155};
156
157&smd_rpm_regulators {
158	vdd_l1_l2_l3-supply = <&pm8916_s3>;
159	vdd_l4_l5_l6-supply = <&pm8916_s4>;
160	vdd_l7-supply = <&pm8916_s4>;
161
162	pm8916_s3: s3 {
163		regulator-min-microvolt = <1200000>;
164		regulator-max-microvolt = <1300000>;
165	};
166
167	pm8916_s4: s4 {
168		regulator-min-microvolt = <1800000>;
169		regulator-max-microvolt = <2100000>;
170	};
171
172	/* l1 is fixed to 1225000, but not connected in schematic */
173
174	pm8916_l2: l2 {
175		regulator-min-microvolt = <1200000>;
176		regulator-max-microvolt = <1200000>;
177	};
178
179	pm8916_l4: l4 {
180		regulator-min-microvolt = <2050000>;
181		regulator-max-microvolt = <2050000>;
182	};
183
184	pm8916_l5: l5 {
185		regulator-min-microvolt = <1800000>;
186		regulator-max-microvolt = <1800000>;
187	};
188
189	pm8916_l6: l6 {
190		regulator-min-microvolt = <1800000>;
191		regulator-max-microvolt = <1800000>;
192	};
193
194	pm8916_l7: l7 {
195		regulator-min-microvolt = <1800000>;
196		regulator-max-microvolt = <1800000>;
197	};
198
199	pm8916_l8: l8 {
200		regulator-min-microvolt = <2850000>;
201		regulator-max-microvolt = <2900000>;
202	};
203
204	pm8916_l9: l9 {
205		regulator-min-microvolt = <3300000>;
206		regulator-max-microvolt = <3300000>;
207	};
208
209	pm8916_l10: l10 {
210		regulator-min-microvolt = <3300000>;
211		regulator-max-microvolt = <3300000>;
212	};
213
214	pm8916_l11: l11 {
215		regulator-min-microvolt = <1800000>;
216		regulator-max-microvolt = <2950000>;
217	};
218
219	pm8916_l12: l12 {
220		regulator-min-microvolt = <1800000>;
221		regulator-max-microvolt = <2950000>;
222	};
223
224	pm8916_l13: l13 {
225		regulator-min-microvolt = <3075000>;
226		regulator-max-microvolt = <3075000>;
227	};
228
229	pm8916_l14: l14 {
230		regulator-min-microvolt = <1800000>;
231		regulator-max-microvolt = <3300000>;
232	};
233
234	pm8916_l15: l15 {
235		regulator-min-microvolt = <1800000>;
236		regulator-max-microvolt = <3300000>;
237	};
238
239	pm8916_l16: l16 {
240		regulator-min-microvolt = <1800000>;
241		regulator-max-microvolt = <3300000>;
242	};
243
244	pm8916_l17: l17 {
245		regulator-min-microvolt = <2850000>;
246		regulator-max-microvolt = <2850000>;
247	};
248
249	pm8916_l18: l18 {
250		regulator-min-microvolt = <2700000>;
251		regulator-max-microvolt = <2700000>;
252	};
253};
254
255&sdhc_1 {
256	pinctrl-names = "default", "sleep";
257	pinctrl-0 = <&sdc1_default_state>;
258	pinctrl-1 = <&sdc1_sleep_state>;
259	status = "okay";
260};
261
262&sound {
263	model = "apq8039-square-sndcard";
264	audio-routing = "AMIC2", "MIC BIAS Internal2";
265	pinctrl-names = "default", "sleep";
266	pinctrl-0 = <&cdc_pdm_lines_default>;
267	pinctrl-1 = <&cdc_pdm_lines_sleep>;
268
269	internal-codec-playback-dai-link {
270		link-name = "WCD";
271		cpu {
272			sound-dai = <&lpass MI2S_PRIMARY>;
273		};
274		codec {
275			sound-dai = <&lpass_codec 0>, <&pm8916_codec 0>;
276		};
277	};
278
279	internal-codec-capture-dai-link {
280		link-name = "WCD-Capture";
281		cpu {
282			sound-dai = <&lpass MI2S_TERTIARY>;
283		};
284		codec {
285			sound-dai = <&lpass_codec 1>, <&pm8916_codec 1>;
286		};
287	};
288};
289
290/*
291 * Line names are taken from the schematic of T2, Ver X03.
292 * July 14, 2018. Page 4 in particular.
293 */
294&tlmm {
295	gpio-line-names =
296		"APQ_UART1_TX",		/* GPIO_0 */
297		"APQ_UART1_RX",
298		"APQ_I2C1_SDA",
299		"APQ_I2C1_SCL",
300		"APQ_UART2_TX_1V8",
301		"APQ_UART2_RX_1V8",
302		"APQ_I2C2_SDA",
303		"APQ_I2C2_SCL",
304		"NC",
305		"APQ_LCD_IOVCC_EN",
306		"APQ_I2C3_SDA",		/* GPIO_10 */
307		"APQ_I2C3_SCL",
308		"TOUCH_RST_1V8_L",
309		"NC",
310		"APQ_I2C4_SDA",
311		"APQ_I2C4_SCL",
312		"APQ_ID5",
313		"USB_DISCONNECT",
314		"APQ_I2C5_SDA",
315		"APQ_I2C5_SCL",
316		"APQ_USBC_SPI_MOSI",	/* GPIO_20 */
317		"APQ_USBC_SPI_MISO",
318		"APQ_USBC_SPI_SS_L",
319		"APQ_USBC_SPI_CLK",
320		"APQ_LCD_TE0",
321		"APQ_LCD_RST_L",
322		"NC",
323		"NC",
324		"ACCELEROMETER_INT1",
325		"APQ_CAM_I2C0_SDA",
326		"APQ_CAM_I2C0_SCL",	/* GPIO_30 */
327		"ACCELEROMETER_INT2",
328		"NC",
329		"NC",
330		"NC",
331		"APQ_K21_RST_1V8_L",
332		"NC",
333		"APQ_EDL_1V8",
334		"TP145",
335		"BT_SSBI",
336		"NC",			/* GPIO_40 */
337		"NC",
338		"NC",
339		"NC",
340		"NC",
341		"NC",
342		"NC",
343		"BT_CTRL",
344		"BT_DAT",
345		"PWR_GPIO_IN",
346		"PWR_GPIO_OUT",		/* GPIO_50 */
347		"CARD_DET_MLB_L",
348		"HALL_SENSOR",
349		"TP63",
350		"TP64",
351		"TP65",
352		"NC",
353		"NC",
354		"NC",
355		"NC",
356		"NC",			/* GPIO_60 */
357		"NC",
358		"APQ_K21_GPIO0_1V8",
359		"CDC_PDM_CLK",
360		"CDC_PDM_SYNC",
361		"CDC_PDM_TX",
362		"CDC_PDM_RX0",
363		"CDC_PDM_RX1",
364		"CDC_PDM_RX2",
365		"APQ_K21_GPIO1_1V8",
366		"NC",			/* GPIO_70 */
367		"APQ_HUB_SEL_1V8",
368		"APQ_K21_GPIO2_1V8",
369		"APQ_K21_GPIO3_1V8",
370		"APQ_ID0",
371		"APQ_ID1",
372		"APQ_ID2",
373		"APQ_ID3",
374		"APQ_ID4",
375		"APQ_HUB_SUSP_IND",
376		"BOOT_CONFIG_0",	/* GPIO_80 */
377		"BOOT_CONFIG_1",
378		"BOOT_CONFIG_2",
379		"BOOT_CONFIG_3",
380		"NC",
381		"NC",
382		"APQ_LCD_AVDD_EN",
383		"APQ_LCD_AVEE_EN",
384		"TP70",
385		"NC",
386		"APQ_DEBUG0",		/* GPIO_90 */
387		"APQ_DEBUG1",
388		"APQ_DEBUG2",
389		"APQ_DEBUG3",
390		"TP165",
391		"NC",
392		"APQ_LNA_PWR_EN",
393		"NC",
394		"APQ_LCD_BL_EN",
395		"NC",
396		"APQ_LCD_ID0",		/* GPIO_100 */
397		"APQ_LCD_ID1",
398		"USBC_GPIO5_1V8",
399		"NC",
400		"NC",
401		"NC",
402		"APQ_HUB_RST_1V8_L",
403		"USBC_I2C_IRQ_1V8_L",
404		"SPE_PWR_EN",
405		"NC",
406		"APQ_USB_ID",		/* GPIO_110 */
407		"APQ_EXT_BUCK_VSEL",
408		"APQ_USB_ID_OUT",
409		"NC",
410		"PRNT_RST_L",
411		"APQ_CRQ_I2C_RDY_1V8",
412		"TYPEC_RST_1V8_H",
413		"CHG_BACKPWR_EN",
414		"CHG_PROCHOT_L",
415		"NC",
416		"USBC_GPIO7_1V8",	/* GPIO_120 */
417		"NC";
418
419	pinctrl_backlight: backlight-state {
420		pins = "gpio98";
421		function = "gpio";
422	};
423
424	pinctrl_lcd_avdd_reg: lcd-avdd-reg-state {
425		pins = "gpio86";
426		function = "gpio";
427	};
428
429	pinctrl_lcd_avee_reg: lcd-avee-reg-state {
430		pins = "gpio87";
431		function = "gpio";
432	};
433
434	pinctrl_lcd_iovcc_reg: lcd-iovcc-reg-state {
435		pins = "gpio9";
436		function = "gpio";
437	};
438
439	pinctrl_lcd_rst: lcd-rst-state {
440		pins = "gpio25";
441		function = "gpio";
442	};
443
444	pinctrl_otg_default: otg-default-state {
445		function = "gpio";
446		pins = "gpio17";
447		output-high;
448	};
449
450	pinctrl_otg_device: otg-device-state {
451		function = "gpio";
452		pins = "gpio17";
453		output-low;
454	};
455
456	pinctrl_otg_host: otg-host-state {
457		function = "gpio";
458		pins = "gpio17";
459		output-low;
460	};
461
462	typec_irq: typec-irq-state {
463		function = "gpio";
464		pins = "gpio107";
465		bias-pull-up;
466		input-enable;
467	};
468};
469
470&usb {
471	pinctrl-names = "default", "host", "device";
472	pinctrl-0 = <&pinctrl_otg_default>;
473	pinctrl-1 = <&pinctrl_otg_host>;
474	pinctrl-2 = <&pinctrl_otg_device>;
475	pin-switch-delay-us = <100000>;
476	usb-role-switch;
477	status = "okay";
478
479	port {
480		otg_ep: endpoint {
481			remote-endpoint = <&typec_ep>;
482		};
483	};
484};
485
486&wcnss {
487	status = "okay";
488};
489
490&wcnss_iris {
491	compatible = "qcom,wcn3680";
492};
493