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&lpass_codec {
139	status = "okay";
140};
141
142&mdss {
143	status = "okay";
144};
145
146&pm8916_codec {
147	qcom,hphl-jack-type-normally-open;
148	qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
149	qcom,mbhc-vthreshold-high = <75 150 237 450 500>;
150	status = "okay";
151};
152
153&pm8916_gpios {
154	gpio-line-names =
155		"PM_GPIO1",     /* WIFI_GPIO1_PRE */
156		"PM_GPIO2",     /* WIFI_GPIO2_PRE */
157		"PM_GPIO3",
158		"PM_GPIO4";
159};
160
161&sdhc_1 {
162	status = "okay";
163};
164
165&sound {
166	model = "apq8039-square-sndcard";
167	audio-routing = "AMIC2", "MIC BIAS Internal2";
168	pinctrl-names = "default", "sleep";
169	pinctrl-0 = <&cdc_pdm_default>;
170	pinctrl-1 = <&cdc_pdm_sleep>;
171
172	internal-codec-playback-dai-link {
173		link-name = "WCD";
174		cpu {
175			sound-dai = <&lpass MI2S_PRIMARY>;
176		};
177		codec {
178			sound-dai = <&lpass_codec 0>, <&pm8916_codec 0>;
179		};
180	};
181
182	internal-codec-capture-dai-link {
183		link-name = "WCD-Capture";
184		cpu {
185			sound-dai = <&lpass MI2S_TERTIARY>;
186		};
187		codec {
188			sound-dai = <&lpass_codec 1>, <&pm8916_codec 1>;
189		};
190	};
191};
192
193/*
194 * Line names are taken from the schematic of T2, Ver X03.
195 * July 14, 2018. Page 4 in particular.
196 */
197&tlmm {
198	gpio-line-names =
199		"APQ_UART1_TX",		/* GPIO_0 */
200		"APQ_UART1_RX",
201		"APQ_I2C1_SDA",
202		"APQ_I2C1_SCL",
203		"APQ_UART2_TX_1V8",
204		"APQ_UART2_RX_1V8",
205		"APQ_I2C2_SDA",
206		"APQ_I2C2_SCL",
207		"NC",
208		"APQ_LCD_IOVCC_EN",
209		"APQ_I2C3_SDA",		/* GPIO_10 */
210		"APQ_I2C3_SCL",
211		"TOUCH_RST_1V8_L",
212		"NC",
213		"APQ_I2C4_SDA",
214		"APQ_I2C4_SCL",
215		"APQ_ID5",
216		"USB_DISCONNECT",
217		"APQ_I2C5_SDA",
218		"APQ_I2C5_SCL",
219		"APQ_USBC_SPI_MOSI",	/* GPIO_20 */
220		"APQ_USBC_SPI_MISO",
221		"APQ_USBC_SPI_SS_L",
222		"APQ_USBC_SPI_CLK",
223		"APQ_LCD_TE0",
224		"APQ_LCD_RST_L",
225		"NC",
226		"NC",
227		"ACCELEROMETER_INT1",
228		"APQ_CAM_I2C0_SDA",
229		"APQ_CAM_I2C0_SCL",	/* GPIO_30 */
230		"ACCELEROMETER_INT2",
231		"NC",
232		"NC",
233		"NC",
234		"APQ_K21_RST_1V8_L",
235		"NC",
236		"APQ_EDL_1V8",
237		"TP145",
238		"BT_SSBI",
239		"NC",			/* GPIO_40 */
240		"NC",
241		"NC",
242		"NC",
243		"NC",
244		"NC",
245		"NC",
246		"BT_CTRL",
247		"BT_DAT",
248		"PWR_GPIO_IN",
249		"PWR_GPIO_OUT",		/* GPIO_50 */
250		"CARD_DET_MLB_L",
251		"HALL_SENSOR",
252		"TP63",
253		"TP64",
254		"TP65",
255		"NC",
256		"NC",
257		"NC",
258		"NC",
259		"NC",			/* GPIO_60 */
260		"NC",
261		"APQ_K21_GPIO0_1V8",
262		"CDC_PDM_CLK",
263		"CDC_PDM_SYNC",
264		"CDC_PDM_TX",
265		"CDC_PDM_RX0",
266		"CDC_PDM_RX1",
267		"CDC_PDM_RX2",
268		"APQ_K21_GPIO1_1V8",
269		"NC",			/* GPIO_70 */
270		"APQ_HUB_SEL_1V8",
271		"APQ_K21_GPIO2_1V8",
272		"APQ_K21_GPIO3_1V8",
273		"APQ_ID0",
274		"APQ_ID1",
275		"APQ_ID2",
276		"APQ_ID3",
277		"APQ_ID4",
278		"APQ_HUB_SUSP_IND",
279		"BOOT_CONFIG_0",	/* GPIO_80 */
280		"BOOT_CONFIG_1",
281		"BOOT_CONFIG_2",
282		"BOOT_CONFIG_3",
283		"NC",
284		"NC",
285		"APQ_LCD_AVDD_EN",
286		"APQ_LCD_AVEE_EN",
287		"TP70",
288		"NC",
289		"APQ_DEBUG0",		/* GPIO_90 */
290		"APQ_DEBUG1",
291		"APQ_DEBUG2",
292		"APQ_DEBUG3",
293		"TP165",
294		"NC",
295		"APQ_LNA_PWR_EN",
296		"NC",
297		"APQ_LCD_BL_EN",
298		"NC",
299		"APQ_LCD_ID0",		/* GPIO_100 */
300		"APQ_LCD_ID1",
301		"USBC_GPIO5_1V8",
302		"NC",
303		"NC",
304		"NC",
305		"APQ_HUB_RST_1V8_L",
306		"USBC_I2C_IRQ_1V8_L",
307		"SPE_PWR_EN",
308		"NC",
309		"APQ_USB_ID",		/* GPIO_110 */
310		"APQ_EXT_BUCK_VSEL",
311		"APQ_USB_ID_OUT",
312		"NC",
313		"PRNT_RST_L",
314		"APQ_CRQ_I2C_RDY_1V8",
315		"TYPEC_RST_1V8_H",
316		"CHG_BACKPWR_EN",
317		"CHG_PROCHOT_L",
318		"NC",
319		"USBC_GPIO7_1V8",	/* GPIO_120 */
320		"NC";
321
322	pinctrl_backlight: backlight-state {
323		pins = "gpio98";
324		function = "gpio";
325	};
326
327	pinctrl_lcd_avdd_reg: lcd-avdd-reg-state {
328		pins = "gpio86";
329		function = "gpio";
330	};
331
332	pinctrl_lcd_avee_reg: lcd-avee-reg-state {
333		pins = "gpio87";
334		function = "gpio";
335	};
336
337	pinctrl_lcd_iovcc_reg: lcd-iovcc-reg-state {
338		pins = "gpio9";
339		function = "gpio";
340	};
341
342	pinctrl_lcd_rst: lcd-rst-state {
343		pins = "gpio25";
344		function = "gpio";
345	};
346
347	pinctrl_otg_default: otg-default-state {
348		function = "gpio";
349		pins = "gpio17";
350		output-high;
351	};
352
353	pinctrl_otg_device: otg-device-state {
354		function = "gpio";
355		pins = "gpio17";
356		output-low;
357	};
358
359	pinctrl_otg_host: otg-host-state {
360		function = "gpio";
361		pins = "gpio17";
362		output-low;
363	};
364
365	typec_irq: typec-irq-state {
366		function = "gpio";
367		pins = "gpio107";
368		bias-pull-up;
369	};
370};
371
372&usb {
373	pinctrl-names = "default", "host", "device";
374	pinctrl-0 = <&pinctrl_otg_default>;
375	pinctrl-1 = <&pinctrl_otg_host>;
376	pinctrl-2 = <&pinctrl_otg_device>;
377	usb-role-switch;
378	status = "okay";
379
380	port {
381		otg_ep: endpoint {
382			remote-endpoint = <&typec_ep>;
383		};
384	};
385};
386
387&wcnss {
388	status = "okay";
389};
390
391&wcnss_iris {
392	compatible = "qcom,wcn3680";
393};
394