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