1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 */
5
6#include "msm8916.dtsi"
7#include "pm8916.dtsi"
8#include "apq8016-sbc-soc-pins.dtsi"
9#include "apq8016-sbc-pmic-pins.dtsi"
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/input/input.h>
12#include <dt-bindings/sound/apq8016-lpass.h>
13
14/*
15 * GPIO name legend: proper name = the GPIO line is used as GPIO
16 *         NC = not connected (pin out but not routed from the chip to
17 *              anything the board)
18 *         "[PER]" = pin is muxed for [peripheral] (not GPIO)
19 *         LSEC = Low Speed External Connector
20 *         HSEC = High Speed External Connector
21 *
22 * Line names are taken from the schematic "DragonBoard410c"
23 * dated monday, august 31, 2015. Page 5 in particular.
24 *
25 * For the lines routed to the external connectors the
26 * lines are named after the 96Boards CE Specification 1.0,
27 * Appendix "Expansion Connector Signal Description".
28 *
29 * When the 96Board naming of a line and the schematic name of
30 * the same line are in conflict, the 96Board specification
31 * takes precedence, which means that the external UART on the
32 * LSEC is named UART0 while the schematic and SoC names this
33 * UART3. This is only for the informational lines i.e. "[FOO]",
34 * the GPIO named lines "GPIO-A" thru "GPIO-L" are the only
35 * ones actually used for GPIO.
36 */
37
38/ {
39	aliases {
40		serial0 = &blsp1_uart2;
41		serial1 = &blsp1_uart1;
42		usid0 = &pm8916_0;
43		i2c0	= &blsp_i2c2;
44		i2c1	= &blsp_i2c6;
45		i2c3	= &blsp_i2c4;
46		spi0	= &blsp_spi5;
47		spi1	= &blsp_spi3;
48	};
49
50	chosen {
51		stdout-path = "serial0";
52	};
53
54	reserved-memory {
55		ramoops@bff00000{
56			compatible = "ramoops";
57			reg = <0x0 0xbff00000 0x0 0x100000>;
58
59			record-size = <0x20000>;
60			console-size = <0x20000>;
61			ftrace-size = <0x20000>;
62		};
63	};
64
65	soc {
66		pinctrl@1000000 {
67			gpio-line-names =
68				"[UART0_TX]", /* GPIO_0, LSEC pin 5 */
69				"[UART0_RX]", /* GPIO_1, LSEC pin 7 */
70				"[UART0_CTS_N]", /* GPIO_2, LSEC pin 3 */
71				"[UART0_RTS_N]", /* GPIO_3, LSEC pin 9 */
72				"[UART1_TX]", /* GPIO_4, LSEC pin 11 */
73				"[UART1_RX]", /* GPIO_5, LSEC pin 13 */
74				"[I2C0_SDA]", /* GPIO_8, LSEC pin 17 */
75				"[I2C0_SCL]", /* GPIO_7, LSEC pin 15 */
76				"[SPI1_DOUT]", /* SPI1_MOSI, HSEC pin 1 */
77				"[SPI1_DIN]", /* SPI1_MISO, HSEC pin 11 */
78				"[SPI1_CS]", /* SPI1_CS_N, HSEC pin 7 */
79				"[SPI1_SCLK]", /* SPI1_CLK, HSEC pin 9 */
80				"GPIO-B", /* LS_EXP_GPIO_B, LSEC pin 24 */
81				"GPIO-C", /* LS_EXP_GPIO_C, LSEC pin 25 */
82				"[I2C3_SDA]", /* HSEC pin 38 */
83				"[I2C3_SCL]", /* HSEC pin 36 */
84				"[SPI0_MOSI]", /* LSEC pin 14 */
85				"[SPI0_MISO]", /* LSEC pin 10 */
86				"[SPI0_CS_N]", /* LSEC pin 12 */
87				"[SPI0_CLK]", /* LSEC pin 8 */
88				"HDMI_HPD_N", /* GPIO 20 */
89				"USR_LED_1_CTRL",
90				"[I2C1_SDA]", /* GPIO_22, LSEC pin 21 */
91				"[I2C1_SCL]", /* GPIO_23, LSEC pin 19 */
92				"GPIO-G", /* LS_EXP_GPIO_G, LSEC pin 29 */
93				"GPIO-H", /* LS_EXP_GPIO_H, LSEC pin 30 */
94				"[CSI0_MCLK]", /* HSEC pin 15 */
95				"[CSI1_MCLK]", /* HSEC pin 17 */
96				"GPIO-K", /* LS_EXP_GPIO_K, LSEC pin 33 */
97				"[I2C2_SDA]", /* HSEC pin 34 */
98				"[I2C2_SCL]", /* HSEC pin 32 */
99				"DSI2HDMI_INT_N",
100				"DSI_SW_SEL_APQ",
101				"GPIO-L", /* LS_EXP_GPIO_L, LSEC pin 34 */
102				"GPIO-J", /* LS_EXP_GPIO_J, LSEC pin 32 */
103				"GPIO-I", /* LS_EXP_GPIO_I, LSEC pin 31 */
104				"GPIO-A", /* LS_EXP_GPIO_A, LSEC pin 23 */
105				"FORCED_USB_BOOT",
106				"SD_CARD_DET_N",
107				"[WCSS_BT_SSBI]",
108				"[WCSS_WLAN_DATA_2]", /* GPIO 40 */
109				"[WCSS_WLAN_DATA_1]",
110				"[WCSS_WLAN_DATA_0]",
111				"[WCSS_WLAN_SET]",
112				"[WCSS_WLAN_CLK]",
113				"[WCSS_FM_SSBI]",
114				"[WCSS_FM_SDI]",
115				"[WCSS_BT_DAT_CTL]",
116				"[WCSS_BT_DAT_STB]",
117				"NC",
118				"NC", /* GPIO 50 */
119				"NC",
120				"NC",
121				"NC",
122				"NC",
123				"NC",
124				"NC",
125				"NC",
126				"NC",
127				"NC",
128				"NC", /* GPIO 60 */
129				"NC",
130				"NC",
131				"[CDC_PDM0_CLK]",
132				"[CDC_PDM0_SYNC]",
133				"[CDC_PDM0_TX0]",
134				"[CDC_PDM0_RX0]",
135				"[CDC_PDM0_RX1]",
136				"[CDC_PDM0_RX2]",
137				"GPIO-D", /* LS_EXP_GPIO_D, LSEC pin 26 */
138				"NC", /* GPIO 70 */
139				"NC",
140				"NC",
141				"NC",
142				"NC", /* GPIO 74 */
143				"NC",
144				"NC",
145				"NC",
146				"NC",
147				"NC",
148				"BOOT_CONFIG_0", /* GPIO 80 */
149				"BOOT_CONFIG_1",
150				"BOOT_CONFIG_2",
151				"BOOT_CONFIG_3",
152				"NC",
153				"NC",
154				"BOOT_CONFIG_5",
155				"NC",
156				"NC",
157				"NC",
158				"NC", /* GPIO 90 */
159				"NC",
160				"NC",
161				"NC",
162				"NC",
163				"NC",
164				"NC",
165				"NC",
166				"NC",
167				"NC",
168				"NC", /* GPIO 100 */
169				"NC",
170				"NC",
171				"NC",
172				"SSBI_GPS",
173				"NC",
174				"NC",
175				"KEY_VOLP_N",
176				"NC",
177				"NC",
178				"[LS_EXP_MI2S_WS]", /* GPIO 110 */
179				"NC",
180				"NC",
181				"[LS_EXP_MI2S_SCK]",
182				"[LS_EXP_MI2S_DATA0]",
183				"GPIO-E", /* LS_EXP_GPIO_E, LSEC pin 27 */
184				"NC",
185				"[DSI2HDMI_MI2S_WS]",
186				"[DSI2HDMI_MI2S_SCK]",
187				"[DSI2HDMI_MI2S_DATA0]",
188				"USR_LED_2_CTRL", /* GPIO 120 */
189				"SB_HS_ID";
190		};
191
192		dma@7884000 {
193			status = "okay";
194		};
195
196		serial@78af000 {
197			label = "LS-UART0";
198			status = "okay";
199			pinctrl-names = "default", "sleep";
200			pinctrl-0 = <&blsp1_uart1_default>;
201			pinctrl-1 = <&blsp1_uart1_sleep>;
202		};
203
204		serial@78b0000 {
205			label = "LS-UART1";
206			status = "okay";
207			pinctrl-names = "default", "sleep";
208			pinctrl-0 = <&blsp1_uart2_default>;
209			pinctrl-1 = <&blsp1_uart2_sleep>;
210		};
211
212		i2c@78b6000 {
213		/* On Low speed expansion */
214			label = "LS-I2C0";
215			status = "okay";
216		};
217
218		i2c@78b8000 {
219		/* On High speed expansion */
220			label = "HS-I2C2";
221			status = "okay";
222
223			adv_bridge: bridge@39 {
224				status = "okay";
225
226				compatible = "adi,adv7533";
227				reg = <0x39>;
228
229				interrupt-parent = <&msmgpio>;
230				interrupts = <31 2>;
231
232				adi,dsi-lanes = <4>;
233				clocks = <&rpmcc RPM_SMD_BB_CLK2>;
234				clock-names = "cec";
235
236				pd-gpios = <&msmgpio 32 0>;
237
238				avdd-supply = <&pm8916_l6>;
239				v1p2-supply = <&pm8916_l6>;
240				v3p3-supply = <&pm8916_l17>;
241
242				pinctrl-names = "default","sleep";
243				pinctrl-0 = <&adv7533_int_active &adv7533_switch_active>;
244				pinctrl-1 = <&adv7533_int_suspend &adv7533_switch_suspend>;
245				#sound-dai-cells = <1>;
246
247				ports {
248					#address-cells = <1>;
249					#size-cells = <0>;
250
251					port@0 {
252						reg = <0>;
253						adv7533_in: endpoint {
254							remote-endpoint = <&dsi0_out>;
255						};
256					};
257
258					port@1 {
259						reg = <1>;
260						adv7533_out: endpoint {
261							remote-endpoint = <&hdmi_con>;
262						};
263					};
264				};
265			};
266		};
267
268		i2c@78ba000 {
269		/* On Low speed expansion */
270			label = "LS-I2C1";
271			status = "okay";
272		};
273
274		spi@78b7000 {
275		/* On High speed expansion */
276			label = "HS-SPI1";
277			status = "okay";
278		};
279
280		spi@78b9000 {
281		/* On Low speed expansion */
282			label = "LS-SPI0";
283			status = "okay";
284		};
285
286		leds {
287			pinctrl-names = "default";
288			pinctrl-0 = <&msmgpio_leds>,
289				    <&pm8916_gpios_leds>,
290				    <&pm8916_mpps_leds>;
291
292			compatible = "gpio-leds";
293
294			led@1 {
295				label = "apq8016-sbc:green:user1";
296				gpios = <&msmgpio 21 GPIO_ACTIVE_HIGH>;
297				linux,default-trigger = "heartbeat";
298				default-state = "off";
299			};
300
301			led@2 {
302				label = "apq8016-sbc:green:user2";
303				gpios = <&msmgpio 120 GPIO_ACTIVE_HIGH>;
304				linux,default-trigger = "mmc0";
305				default-state = "off";
306			};
307
308			led@3 {
309				label = "apq8016-sbc:green:user3";
310				gpios = <&pm8916_gpios 1 GPIO_ACTIVE_HIGH>;
311				linux,default-trigger = "mmc1";
312				default-state = "off";
313			};
314
315			led@4 {
316				label = "apq8016-sbc:green:user4";
317				gpios = <&pm8916_gpios 2 GPIO_ACTIVE_HIGH>;
318				linux,default-trigger = "none";
319				panic-indicator;
320				default-state = "off";
321			};
322
323			led@5 {
324				label = "apq8016-sbc:yellow:wlan";
325				gpios = <&pm8916_mpps 2 GPIO_ACTIVE_HIGH>;
326				linux,default-trigger = "phy0tx";
327				default-state = "off";
328			};
329
330			led@6 {
331				label = "apq8016-sbc:blue:bt";
332				gpios = <&pm8916_mpps 3 GPIO_ACTIVE_HIGH>;
333				linux,default-trigger = "bluetooth-power";
334				default-state = "off";
335			};
336		};
337
338		sdhci@7824000 {
339			vmmc-supply = <&pm8916_l8>;
340			vqmmc-supply = <&pm8916_l5>;
341
342			pinctrl-names = "default", "sleep";
343			pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on>;
344			pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off>;
345			status = "okay";
346		};
347
348		sdhci@7864000 {
349			vmmc-supply = <&pm8916_l11>;
350			vqmmc-supply = <&pm8916_l12>;
351
352			pinctrl-names = "default", "sleep";
353			pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
354			pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
355
356			cd-gpios = <&msmgpio 38 0x1>;
357			status = "okay";
358		};
359
360		usb@78d9000 {
361			extcon = <&usb_id>;
362			status = "okay";
363			adp-disable;
364			hnp-disable;
365			srp-disable;
366			dr_mode = "host";
367			pinctrl-names = "default";
368			pinctrl-0 = <&usb_sw_sel_pm>;
369			ulpi {
370				phy {
371					v1p8-supply = <&pm8916_l7>;
372					v3p3-supply = <&pm8916_l13>;
373					extcon = <&usb_id>;
374				};
375			};
376		};
377
378		lpass@7708000 {
379			status = "okay";
380		};
381
382		mdss@1a00000 {
383			status = "okay";
384
385			mdp@1a01000 {
386				status = "okay";
387			};
388
389			dsi@1a98000 {
390				status = "okay";
391
392				vdda-supply = <&pm8916_l2>;
393				vddio-supply = <&pm8916_l6>;
394
395				ports {
396					port@1 {
397						endpoint {
398							remote-endpoint = <&adv7533_in>;
399							data-lanes = <0 1 2 3>;
400						};
401					};
402				};
403			};
404
405			dsi-phy@1a98300 {
406				status = "okay";
407
408				vddio-supply = <&pm8916_l6>;
409			};
410		};
411
412		lpass_codec: codec{
413			status = "okay";
414		};
415
416		/*
417		Internal Codec
418			playback - Primary MI2S
419			capture - Ter MI2S
420
421		External Primary:
422			playback - secondary MI2S
423			capture - Quat MI2S
424
425		External Secondary:
426			playback - Quat MI2S
427			capture - Quat MI2S
428
429		*/
430
431                sound: sound {
432                        compatible = "qcom,apq8016-sbc-sndcard";
433                        reg = <0x07702000 0x4>, <0x07702004 0x4>;
434                        reg-names = "mic-iomux", "spkr-iomux";
435
436                        status = "okay";
437                        pinctrl-0 = <&cdc_pdm_lines_act &ext_sec_tlmm_lines_act &ext_mclk_tlmm_lines_act>;
438                        pinctrl-1 = <&cdc_pdm_lines_sus &ext_sec_tlmm_lines_sus &ext_mclk_tlmm_lines_sus>;
439                        pinctrl-names = "default", "sleep";
440                        qcom,model = "DB410c";
441                        qcom,audio-routing =
442                                "AMIC2", "MIC BIAS Internal2",
443                                "AMIC3", "MIC BIAS External1";
444			external-dai-link@0 {
445				link-name = "ADV7533";
446				cpu { /* QUAT */
447					sound-dai = <&lpass MI2S_QUATERNARY>;
448				};
449				codec {
450					sound-dai = <&adv_bridge 0>;
451				};
452			};
453
454                        internal-codec-playback-dai-link@0 {            /* I2S - Internal codec */
455                                link-name = "WCD";
456                                cpu { /* PRIMARY */
457                                        sound-dai = <&lpass MI2S_PRIMARY>;
458                                };
459                                codec {
460                                        sound-dai = <&lpass_codec 0>, <&wcd_codec 0>;
461                                };
462                        };
463
464                        internal-codec-capture-dai-link@0 {             /* I2S - Internal codec */
465                                link-name = "WCD-Capture";
466                                cpu { /* PRIMARY */
467                                        sound-dai = <&lpass MI2S_TERTIARY>;
468                                };
469                                codec {
470                                        sound-dai = <&lpass_codec 1>, <&wcd_codec 1>;
471                                };
472                        };
473                };
474
475		spmi@200f000 {
476			pm8916@0 {
477				gpios@c000 {
478					gpio-line-names =
479						"USR_LED_3_CTRL",
480						"USR_LED_4_CTRL",
481						"USB_HUB_RESET_N_PM",
482						"USB_SW_SEL_PM";
483				};
484				mpps@a000 {
485					gpio-line-names =
486						"VDD_PX_BIAS",
487						"WLAN_LED_CTRL",
488						"BT_LED_CTRL",
489						"GPIO-F"; /* LS_EXP_GPIO_F, LSEC pin 28 */
490				};
491			};
492		};
493
494		wcnss@a21b000 {
495			status = "okay";
496		};
497	};
498
499	usb2513 {
500		compatible = "smsc,usb3503";
501		reset-gpios = <&pm8916_gpios 3 GPIO_ACTIVE_LOW>;
502		initial-mode = <1>;
503	};
504
505	usb_id: usb-id {
506		compatible = "linux,extcon-usb-gpio";
507		vbus-gpio = <&msmgpio 121 GPIO_ACTIVE_HIGH>;
508		pinctrl-names = "default";
509		pinctrl-0 = <&usb_id_default>;
510	};
511
512	hdmi-out {
513		compatible = "hdmi-connector";
514		type = "a";
515
516		port {
517			hdmi_con: endpoint {
518				remote-endpoint = <&adv7533_out>;
519			};
520		};
521	};
522
523	gpio_keys {
524		compatible = "gpio-keys";
525		#address-cells = <1>;
526		#size-cells = <0>;
527		autorepeat;
528
529		pinctrl-names = "default";
530		pinctrl-0 = <&msm_key_volp_n_default>;
531
532		button@0 {
533			label = "Volume Up";
534			linux,code = <KEY_VOLUMEUP>;
535			gpios = <&msmgpio 107 GPIO_ACTIVE_LOW>;
536		};
537	};
538};
539
540&spmi_bus {
541	pm8916_0: pm8916@0 {
542		pon@800 {
543			resin {
544				compatible = "qcom,pm8941-resin";
545				interrupts = <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>;
546				debounce = <15625>;
547				bias-pull-up;
548				linux,code = <KEY_VOLUMEDOWN>;
549			};
550		};
551	};
552};
553
554&wcd_codec {
555        status = "okay";
556        clocks = <&gcc GCC_CODEC_DIGCODEC_CLK>;
557        clock-names = "mclk";
558	qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
559	qcom,mbhc-vthreshold-high = <75 150 237 450 500>;
560};
561
562&smd_rpm_regulators {
563	vdd_l1_l2_l3-supply = <&pm8916_s3>;
564	vdd_l5-supply = <&pm8916_s3>;
565	vdd_l4_l5_l6-supply = <&pm8916_s4>;
566	vdd_l7-supply = <&pm8916_s4>;
567
568	s1 {
569		regulator-min-microvolt = <375000>;
570		regulator-max-microvolt = <1562000>;
571	};
572
573	s3 {
574		regulator-min-microvolt = <375000>;
575		regulator-max-microvolt = <1562000>;
576	};
577
578	s4 {
579		regulator-min-microvolt = <1800000>;
580		regulator-max-microvolt = <1800000>;
581
582		regulator-always-on;
583		regulator-boot-on;
584	};
585
586	l1 {
587		regulator-min-microvolt = <375000>;
588		regulator-max-microvolt = <1525000>;
589	};
590
591	l2 {
592		regulator-min-microvolt = <1200000>;
593		regulator-max-microvolt = <1200000>;
594	};
595
596	l3 {
597		regulator-min-microvolt = <375000>;
598		regulator-max-microvolt = <1525000>;
599	};
600
601	l4 {
602		regulator-min-microvolt = <1750000>;
603		regulator-max-microvolt = <3337000>;
604	};
605
606	l5 {
607		regulator-min-microvolt = <1750000>;
608		regulator-max-microvolt = <3337000>;
609	};
610
611	l6 {
612		regulator-min-microvolt = <1800000>;
613		regulator-max-microvolt = <1800000>;
614	};
615
616	l7 {
617		regulator-min-microvolt = <1750000>;
618		regulator-max-microvolt = <3337000>;
619	};
620
621	l8 {
622		regulator-min-microvolt = <1750000>;
623		regulator-max-microvolt = <3337000>;
624	};
625
626	l9 {
627		regulator-min-microvolt = <1750000>;
628		regulator-max-microvolt = <3337000>;
629	};
630
631	l10 {
632		regulator-min-microvolt = <1750000>;
633		regulator-max-microvolt = <3337000>;
634	};
635
636	l11 {
637		regulator-min-microvolt = <1750000>;
638		regulator-max-microvolt = <3337000>;
639		regulator-allow-set-load;
640		regulator-system-load = <200000>;
641	};
642
643	l12 {
644		regulator-min-microvolt = <1750000>;
645		regulator-max-microvolt = <3337000>;
646	};
647
648	l13 {
649		regulator-min-microvolt = <1750000>;
650		regulator-max-microvolt = <3337000>;
651	};
652
653	l14 {
654		regulator-min-microvolt = <1750000>;
655		regulator-max-microvolt = <3337000>;
656	};
657
658	/**
659	 * 1.8v required on LS expansion
660	 * for mezzanine boards
661	 */
662	l15 {
663		regulator-min-microvolt = <1750000>;
664		regulator-max-microvolt = <3337000>;
665		regulator-always-on;
666	};
667
668	l16 {
669		regulator-min-microvolt = <1750000>;
670		regulator-max-microvolt = <3337000>;
671	};
672
673	l17 {
674		regulator-min-microvolt = <3300000>;
675		regulator-max-microvolt = <3300000>;
676	};
677
678	l18 {
679		regulator-min-microvolt = <1750000>;
680		regulator-max-microvolt = <3337000>;
681	};
682};
683