// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2020, Linaro Ltd.
 */

/dts-v1/;

#include <dt-bindings/leds/common.h>
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
#include <dt-bindings/sound/qcom,q6afe.h>
#include <dt-bindings/sound/qcom,q6asm.h>
#include <dt-bindings/usb/pd.h>
#include "sm8250.dtsi"
#include "pm8150.dtsi"
#include "pm8150b.dtsi"
#include "pm8150l.dtsi"

/ {
	model = "Qualcomm Technologies, Inc. Robotics RB5";
	compatible = "qcom,qrb5165-rb5", "qcom,sm8250";
	qcom,msm-id = <455 0x20001>;
	qcom,board-id = <11 3>;

	aliases {
		serial0 = &uart12;
		serial1 = &uart6;
		sdhc2 = &sdhc_2;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	/* Fixed crystal oscillator dedicated to MCP2518FD */
	clk40M: can-clock {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <40000000>;
	};

	dc12v: dc12v-regulator {
		compatible = "regulator-fixed";
		regulator-name = "DC12V";
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
		regulator-always-on;
	};

	hdmi-out {
		compatible = "hdmi-connector";
		type = "a";

		port {
			hdmi_con: endpoint {
				remote-endpoint = <&lt9611_out>;
			};
		};
	};

	leds {
		compatible = "gpio-leds";

		led-user4 {
			label = "green:user4";
			function = LED_FUNCTION_INDICATOR;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&pm8150_gpios 10 GPIO_ACTIVE_HIGH>;
			default-state = "off";
			panic-indicator;
		};

		led-wlan {
			label = "yellow:wlan";
			function = LED_FUNCTION_WLAN;
			color = <LED_COLOR_ID_YELLOW>;
			gpios = <&pm8150_gpios 9 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "phy0tx";
			default-state = "off";
		};

		led-bt {
			label = "blue:bt";
			function = LED_FUNCTION_BLUETOOTH;
			color = <LED_COLOR_ID_BLUE>;
			gpios = <&pm8150_gpios 7 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "bluetooth-power";
			default-state = "off";
		};
	};

	lt9611_1v2: lt9611-vdd12-regulator {
		compatible = "regulator-fixed";
		regulator-name = "LT9611_1V2";

		vin-supply = <&vdc_3v3>;
		regulator-min-microvolt = <1200000>;
		regulator-max-microvolt = <1200000>;
	};

	lt9611_3v3: lt9611-3v3 {
		compatible = "regulator-fixed";
		regulator-name = "LT9611_3V3";

		vin-supply = <&vdc_3v3>;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
	};

	thermal-zones {
		conn-thermal {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8150b_adc_tm 0>;

			trips {
				active-config0 {
					temperature = <125000>;
					hysteresis = <1000>;
					type = "critical";
				};
			};
		};

		pm8150l-pcb-thermal {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8150l_adc_tm 1>;

			trips {
				active-config0 {
					temperature = <50000>;
					hysteresis = <4000>;
					type = "passive";
				};
			};
		};

		skin-msm-thermal {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8150l_adc_tm 0>;

			trips {
				active-config0 {
					temperature = <50000>;
					hysteresis = <4000>;
					type = "passive";
				};
			};
		};

		wifi-thermal {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8150_adc_tm 1>;

			trips {
				active-config0 {
					temperature = <52000>;
					hysteresis = <4000>;
					type = "passive";
				};
			};
		};

		xo-thermal {
			polling-delay-passive = <0>;
			polling-delay = <0>;
			thermal-sensors = <&pm8150_adc_tm 0>;

			trips {
				active-config0 {
					temperature = <50000>;
					hysteresis = <4000>;
					type = "passive";
				};
			};
		};
	};

	vbat: vbat-regulator {
		compatible = "regulator-fixed";
		regulator-name = "VBAT";
		vin-supply = <&vreg_l11c_3p3>;
		regulator-min-microvolt = <4200000>;
		regulator-max-microvolt = <4200000>;
		regulator-always-on;
	};

	vbat_som: vbat-som-regulator {
		compatible = "regulator-fixed";
		regulator-name = "VBAT_SOM";
		vin-supply = <&dc12v>;
		regulator-min-microvolt = <4200000>;
		regulator-max-microvolt = <4200000>;
		regulator-always-on;
	};

	vdc_3v3: vdc-3v3-regulator {
		compatible = "regulator-fixed";
		regulator-name = "VDC_3V3";
		vin-supply = <&vreg_l11c_3p3>;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};

	vdc_5v: vdc-5v-regulator {
		compatible = "regulator-fixed";
		regulator-name = "VDC_5V";

		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-always-on;
		vin-supply = <&vreg_l11c_3p3>;
	};

	vph_pwr: vph-pwr-regulator {
		compatible = "regulator-fixed";
		regulator-name = "vph_pwr";
		regulator-min-microvolt = <3700000>;
		regulator-max-microvolt = <3700000>;
		regulator-always-on;
	};

	vreg_s4a_1p8: vreg-s4a-1p8 {
		compatible = "regulator-fixed";
		regulator-name = "vreg_s4a_1p8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-always-on;
	};
};

&adsp {
	status = "okay";
	firmware-name = "qcom/sm8250/adsp.mbn";
};

&apps_rsc {
	regulators-0 {
		compatible = "qcom,pm8009-1-rpmh-regulators";
		qcom,pmic-id = "f";

		vdd-s1-supply = <&vph_pwr>;
		vdd-s2-supply = <&vph_pwr>;
		vdd-l2-supply = <&vreg_s8c_1p3>;
		vdd-l5-l6-supply = <&vreg_bob>;
		vdd-l7-supply = <&vreg_s4a_1p8>;

		vreg_s2f_0p95: smps2 {
			regulator-name = "vreg_s2f_0p95";
			regulator-min-microvolt = <900000>;
			regulator-max-microvolt = <952000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
		};

		vreg_l1f_1p1: ldo1 {
			regulator-name = "vreg_l1f_1p1";
			regulator-min-microvolt = <1104000>;
			regulator-max-microvolt = <1104000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l2f_1p2: ldo2 {
			regulator-name = "vreg_l2f_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6f_2p8: ldo6 {
			regulator-name = "vreg_l6f_2p8";
			regulator-min-microvolt = <2800000>;
			regulator-max-microvolt = <2800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l7f_1p8: ldo7 {
			regulator-name = "vreg_l7f_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-1 {
		compatible = "qcom,pm8150-rpmh-regulators";
		qcom,pmic-id = "a";

		vdd-s1-supply = <&vph_pwr>;
		vdd-s2-supply = <&vph_pwr>;
		vdd-s3-supply = <&vph_pwr>;
		vdd-s4-supply = <&vph_pwr>;
		vdd-s5-supply = <&vph_pwr>;
		vdd-s6-supply = <&vph_pwr>;
		vdd-s7-supply = <&vph_pwr>;
		vdd-s8-supply = <&vph_pwr>;
		vdd-s9-supply = <&vph_pwr>;
		vdd-s10-supply = <&vph_pwr>;
		vdd-l2-l10-supply = <&vreg_bob>;
		vdd-l3-l4-l5-l18-supply = <&vreg_s6a_0p95>;
		vdd-l6-l9-supply = <&vreg_s8c_1p3>;
		vdd-l7-l12-l14-l15-supply = <&vreg_s5a_1p9>;
		vdd-l13-l16-l17-supply = <&vreg_bob>;

		vreg_l2a_3p1: ldo2 {
			regulator-name = "vreg_l2a_3p1";
			regulator-min-microvolt = <3072000>;
			regulator-max-microvolt = <3072000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3a_0p9: ldo3 {
			regulator-name = "vreg_l3a_0p9";
			regulator-min-microvolt = <928000>;
			regulator-max-microvolt = <932000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l5a_0p88: ldo5 {
			regulator-name = "vreg_l5a_0p88";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <880000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6a_1p2: ldo6 {
			regulator-name = "vreg_l6a_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l7a_1p7: ldo7 {
			regulator-name = "vreg_l7a_1p7";
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l9a_1p2: ldo9 {
			regulator-name = "vreg_l9a_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l10a_1p8: ldo10 {
			regulator-name = "vreg_l10a_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l12a_1p8: ldo12 {
			regulator-name = "vreg_l12a_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l13a_ts_3p0: ldo13 {
			regulator-name = "vreg_l13a_ts_3p0";
			regulator-min-microvolt = <3008000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l14a_1p8: ldo14 {
			regulator-name = "vreg_l14a_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1880000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l15a_1p8: ldo15 {
			regulator-name = "vreg_l15a_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l16a_2p7: ldo16 {
			regulator-name = "vreg_l16a_2p7";
			regulator-min-microvolt = <2704000>;
			regulator-max-microvolt = <2960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l17a_3p0: ldo17 {
			regulator-name = "vreg_l17a_3p0";
			regulator-min-microvolt = <2856000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l18a_0p92: ldo18 {
			regulator-name = "vreg_l18a_0p92";
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_s5a_1p9: smps5 {
			regulator-name = "vreg_s5a_1p9";
			regulator-min-microvolt = <1904000>;
			regulator-max-microvolt = <2000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_s6a_0p95: smps6 {
			regulator-name = "vreg_s6a_0p95";
			regulator-min-microvolt = <920000>;
			regulator-max-microvolt = <1128000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-2 {
		compatible = "qcom,pm8150l-rpmh-regulators";
		qcom,pmic-id = "c";

		vdd-s1-supply = <&vph_pwr>;
		vdd-s2-supply = <&vph_pwr>;
		vdd-s3-supply = <&vph_pwr>;
		vdd-s4-supply = <&vph_pwr>;
		vdd-s5-supply = <&vph_pwr>;
		vdd-s6-supply = <&vph_pwr>;
		vdd-s7-supply = <&vph_pwr>;
		vdd-s8-supply = <&vph_pwr>;
		vdd-l1-l8-supply = <&vreg_s4a_1p8>;
		vdd-l2-l3-supply = <&vreg_s8c_1p3>;
		vdd-l4-l5-l6-supply = <&vreg_bob>;
		vdd-l7-l11-supply = <&vreg_bob>;
		vdd-l9-l10-supply = <&vreg_bob>;
		vdd-bob-supply = <&vph_pwr>;

		vreg_bob: bob {
			regulator-name = "vreg_bob";
			regulator-min-microvolt = <3008000>;
			regulator-max-microvolt = <4000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
		};

		vreg_l1c_1p8: ldo1 {
			regulator-name = "vreg_l1c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l2c_1p2: ldo2 {
			regulator-name = "vreg_l2c_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3c_0p8: ldo3 {
			regulator-name = "vreg_l3c_0p8";
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l4c_1p7: ldo4 {
			regulator-name = "vreg_l4c_1p7";
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <2928000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l5c_1p8: ldo5 {
			regulator-name = "vreg_l5c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2928000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6c_2p96: ldo6 {
			regulator-name = "vreg_l6c_2p96";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l7c_cam_vcm0_2p85: ldo7 {
			regulator-name = "vreg_l7c_cam_vcm0_2p85";
			regulator-min-microvolt = <2856000>;
			regulator-max-microvolt = <3104000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l8c_1p8: ldo8 {
			regulator-name = "vreg_l8c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l9c_2p96: ldo9 {
			regulator-name = "vreg_l9c_2p96";
			regulator-min-microvolt = <2704000>;
			regulator-max-microvolt = <2960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l10c_3p0: ldo10 {
			regulator-name = "vreg_l10c_3p0";
			regulator-min-microvolt = <3000000>;
			regulator-max-microvolt = <3000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l11c_3p3: ldo11 {
			regulator-name = "vreg_l11c_3p3";
			regulator-min-microvolt = <3296000>;
			regulator-max-microvolt = <3296000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-always-on;
		};

		vreg_s8c_1p3: smps8 {
			regulator-name = "vreg_s8c_1p3";
			regulator-min-microvolt = <1352000>;
			regulator-max-microvolt = <1352000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};
};

&cdsp {
	status = "okay";
	firmware-name = "qcom/sm8250/cdsp.mbn";
};

&gmu {
	status = "okay";
};

&gpu {
	status = "okay";

	zap-shader {
		memory-region = <&gpu_mem>;
		firmware-name = "qcom/sm8250/a650_zap.mbn";
	};
};

/* LS-I2C0 */
&i2c4 {
	status = "okay";
};

&i2c5 {
	status = "okay";
	clock-frequency = <400000>;

	lt9611_codec: hdmi-bridge@2b {
		compatible = "lontium,lt9611uxc";
		reg = <0x2b>;
		#sound-dai-cells = <1>;

		interrupts-extended = <&tlmm 63 IRQ_TYPE_EDGE_FALLING>;

		reset-gpios = <&pm8150l_gpios 5 GPIO_ACTIVE_HIGH>;

		vdd-supply = <&lt9611_1v2>;
		vcc-supply = <&lt9611_3v3>;

		pinctrl-names = "default";
		pinctrl-0 = <&lt9611_irq_pin &lt9611_rst_pin>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				lt9611_a: endpoint {
					remote-endpoint = <&mdss_dsi0_out>;
				};
			};

#if 0
			port@1 {
				reg = <1>;

				lt9611_b: endpoint {
					remote-endpoint = <&mdss_dsi1_out>;
				};
			};
#endif

			port@2 {
				reg = <2>;

				lt9611_out: endpoint {
					remote-endpoint = <&hdmi_con>;
				};
			};

		};
	};
};

/* LS-I2C1 */
&i2c15 {
	status = "okay";

	typec-mux@1c {
		compatible = "onnn,nb7vpq904m";
		reg = <0x1c>;

		vcc-supply = <&vreg_s4a_1p8>;

		retimer-switch;
		orientation-switch;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;

				redriver_usb_con_ss: endpoint {
					remote-endpoint = <&pm8150b_typec_mux_in>;
				};
			};

			port@1 {
				reg = <1>;

				redriver_phy_con_ss: endpoint {
					remote-endpoint = <&usb_1_qmpphy_out>;
					data-lanes = <0 1 2 3>;
				};
			};

			port@2 {
				reg = <2>;

				redriver_usb_con_sbu: endpoint {
					remote-endpoint = <&pm8150b_typec_sbu_out>;
				};
			};
		};
	};
};

&mdss {
	status = "okay";
};

&mdss_dp {
	status = "okay";
};

&mdss_dp_out {
	data-lanes = <0 1>;
	remote-endpoint = <&usb_1_qmpphy_dp_in>;
};

&mdss_dsi0 {
	status = "okay";
	vdda-supply = <&vreg_l9a_1p2>;

#if 0
	qcom,dual-dsi-mode;
	qcom,master-dsi;
#endif

	ports {
		port@1 {
			endpoint {
				remote-endpoint = <&lt9611_a>;
				data-lanes = <0 1 2 3>;
			};
		};
	};
};

&mdss_dsi0_phy {
	status = "okay";
	vdds-supply = <&vreg_l5a_0p88>;
};

&pm8150_adc {
	channel@4c {
		reg = <ADC5_XO_THERM_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		label = "xo_therm";
	};

	channel@4e {
		reg = <ADC5_AMUX_THM2_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		label = "wifi_therm";
	};
};

&pm8150_adc_tm {
	status = "okay";

	xo-therm@0 {
		reg = <0>;
		io-channels = <&pm8150_adc ADC5_XO_THERM_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time-us = <200>;
	};

	wifi-therm@1 {
		reg = <1>;
		io-channels = <&pm8150_adc ADC5_AMUX_THM2_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time-us = <200>;
	};
};

&pcie0 {
	status = "okay";
};

&pcie0_phy {
	status = "okay";
	vdda-phy-supply = <&vreg_l5a_0p88>;
	vdda-pll-supply = <&vreg_l9a_1p2>;
};

&pcie1 {
	status = "okay";
};

&pcie1_phy {
	status = "okay";
	vdda-phy-supply = <&vreg_l5a_0p88>;
	vdda-pll-supply = <&vreg_l9a_1p2>;
};

&pcie2 {
	status = "okay";
};

&pcie2_phy {
	status = "okay";
	vdda-phy-supply = <&vreg_l5a_0p88>;
	vdda-pll-supply = <&vreg_l9a_1p2>;
};

&pm8150_gpios {
	gpio-reserved-ranges = <1 1>, <3 2>, <7 1>;
	gpio-line-names =
		"NC",
		"OPTION2",
		"PM_GPIO-F",
		"PM_SLP_CLK_IN",
		"OPTION1",
		"VOL_UP_N",
		"PM8250_GPIO7", /* Blue LED */
		"SP_ARI_PWR_ALARM",
		"GPIO_9_P", /* Yellow LED */
		"GPIO_10_P"; /* Green LED */
};

&pm8150b_adc {
	channel@4f {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		label = "conn_therm";
	};
};

&pm8150b_adc_tm {
	status = "okay";

	conn-therm@0 {
		reg = <0>;
		io-channels = <&pm8150b_adc ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time-us = <200>;
	};
};

&pm8150b_gpios {
	gpio-line-names =
		"NC",
		"NC",
		"NC",
		"NC",
		"HAP_BOOST_EN", /* SOM */
		"SMB_STAT", /* SOM */
		"NC",
		"NC",
		"SDM_FORCE_USB_BOOT",
		"NC",
		"NC",
		"NC";
};

&pm8150l_adc {
	channel@4e {
		reg = <ADC5_AMUX_THM2_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		label = "skin_msm_therm";
	};

	channel@4f {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		label = "pm8150l_therm";
	};
};

&pm8150l_adc_tm {
	status = "okay";

	skin-msm-therm@0 {
		reg = <0>;
		io-channels = <&pm8150l_adc ADC5_AMUX_THM2_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time-us = <200>;
	};

	pm8150l-therm@1 {
		reg = <1>;
		io-channels = <&pm8150l_adc ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time-us = <200>;
	};
};

&pm8150l_gpios {
	gpio-line-names =
		"NC",
		"PM3003A_EN",
		"NC",
		"NC",
		"PM_GPIO5", /* HDMI RST_N */
		"PM_GPIO-A", /* PWM */
		"PM_GPIO7",
		"NC",
		"NC",
		"PM_GPIO-B",
		"NC",
		"PM3003A_MODE";

	lt9611_rst_pin: lt9611-rst-state {
		pins = "gpio5";
		function = "normal";

		output-high;
		input-disable;
		power-source = <0>;
	};
};

&pm8150l_lpg {
	status = "okay";

	#address-cells = <1>;
	#size-cells = <0>;

	led@1 {
		reg = <1>;
		color = <LED_COLOR_ID_GREEN>;
		function = LED_FUNCTION_HEARTBEAT;
		function-enumerator = <3>;

		linux,default-trigger = "heartbeat";
		default-state = "on";
	};

	led@2 {
		reg = <2>;
		color = <LED_COLOR_ID_GREEN>;
		function = LED_FUNCTION_INDICATOR;
		function-enumerator = <2>;
		default-state = "on";
	};

	led@3 {
		reg = <3>;
		color = <LED_COLOR_ID_GREEN>;
		function = LED_FUNCTION_INDICATOR;
		function-enumerator = <1>;
	};
};

&pon_pwrkey {
	status = "okay";
};

&pon_resin {
	status = "okay";

	linux,code = <KEY_VOLUMEDOWN>;
};

&qupv3_id_0 {
	status = "okay";
};

&qupv3_id_1 {
	status = "okay";
};

&qupv3_id_2 {
	status = "okay";
};

&q6afedai {
	dai@16 {
		reg = <PRIMARY_MI2S_RX>;
		qcom,sd-lines = <0 1 2 3>;
	};
};

/* TERT I2S Uses 1 I2S SD Lines for audio on LT9611 HDMI Bridge */
&q6afedai {
	dai@20 {
		reg = <TERTIARY_MI2S_RX>;
		qcom,sd-lines = <0>;
	};
};

&q6asmdai {
	dai@0 {
		reg = <0>;
	};

	dai@1 {
		reg = <1>;
	};

	dai@2 {
		reg = <2>;
	};
};

&sdhc_2 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&sdc2_default_state &sdc2_card_det_n>;
	vmmc-supply = <&vreg_l9c_2p96>;
	vqmmc-supply = <&vreg_l6c_2p96>;
	cd-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>;
	bus-width = <4>;
	no-sdio;
	no-mmc;
};

&sound {
	compatible = "qcom,qrb5165-rb5-sndcard";
	pinctrl-0 = <&tert_mi2s_active>;
	pinctrl-names = "default";
	model = "Qualcomm-RB5-WSA8815-Speakers-DMIC0";
	audio-routing =
		"SpkrLeft IN", "WSA_SPK1 OUT",
		"SpkrRight IN", "WSA_SPK2 OUT",
		"VA DMIC0", "vdd-micb",
		"VA DMIC1", "vdd-micb",
		"MM_DL1",  "MultiMedia1 Playback",
		"MM_DL2",  "MultiMedia2 Playback",
		"MultiMedia3 Capture", "MM_UL3";

	mm1-dai-link {
		link-name = "MultiMedia1";
		cpu {
			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA1>;
		};
	};

	mm2-dai-link {
		link-name = "MultiMedia2";
		cpu {
			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA2>;
		};
	};

	mm3-dai-link {
		link-name = "MultiMedia3";
		cpu {
			sound-dai = <&q6asmdai  MSM_FRONTEND_DAI_MULTIMEDIA3>;
		};
	};

	hdmi-dai-link {
		link-name = "HDMI Playback";
		cpu {
			sound-dai = <&q6afedai TERTIARY_MI2S_RX>;
		};

		platform {
			sound-dai = <&q6routing>;
		};

		codec {
			sound-dai = <&lt9611_codec 0>;
		};
	};

	dma-dai-link {
		link-name = "WSA Playback";
		cpu {
			sound-dai = <&q6afedai WSA_CODEC_DMA_RX_0>;
		};

		platform {
			sound-dai = <&q6routing>;
		};

		codec {
			sound-dai = <&left_spkr>, <&right_spkr>, <&swr0 0>, <&wsamacro 0>;
		};
	};

	va-dai-link {
		link-name = "VA Capture";
		cpu {
			sound-dai = <&q6afedai VA_CODEC_DMA_TX_0>;
		};

		platform {
			sound-dai = <&q6routing>;
		};

		codec {
			sound-dai = <&vamacro 0>;
		};
	};
};

/* CAN */
&spi0 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&qup_spi0_data_clk>, <&qup_spi0_cs_gpio>;
	cs-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;

	can@0 {
		compatible = "microchip,mcp2518fd";
		reg = <0>;
		clocks = <&clk40M>;
		interrupts-extended = <&tlmm 15 IRQ_TYPE_LEVEL_LOW>;
		spi-max-frequency = <10000000>;
		vdd-supply = <&vdc_5v>;
		xceiver-supply = <&vdc_5v>;
	};
};

&swr0 {
	status = "okay";

	left_spkr: speaker@0,3 {
		compatible = "sdw10217211000";
		reg = <0 3>;
		powerdown-gpios = <&tlmm 130 GPIO_ACTIVE_LOW>;
		#thermal-sensor-cells = <0>;
		sound-name-prefix = "SpkrLeft";
		#sound-dai-cells = <0>;
	};

	right_spkr: speaker@0,4 {
		compatible = "sdw10217211000";
		reg = <0 4>;
		powerdown-gpios = <&tlmm 130 GPIO_ACTIVE_LOW>;
		#thermal-sensor-cells = <0>;
		sound-name-prefix = "SpkrRight";
		#sound-dai-cells = <0>;
	};
};

&tlmm {
	gpio-reserved-ranges = <40 4>;
	gpio-line-names =
		"GPIO-MM",
		"GPIO-NN",
		"GPIO-OO",
		"GPIO-PP",
		"GPIO-A",
		"GPIO-C",
		"GPIO-E",
		"GPIO-D",
		"I2C0-SDA",
		"I2C0-SCL",
		"GPIO-TT", /* GPIO_10 */
		"NC",
		"GPIO_12_I2C_SDA",
		"GPIO_13_I2C_SCL",
		"GPIO-X",
		"GPIO_15_RGMII_INT",
		"HST_BT_UART_CTS",
		"HST_BT_UART_RFR",
		"HST_BT_UART_TX",
		"HST_BT_UART_RX",
		"HST_WLAN_EN", /* GPIO_20 */
		"HST_BT_EN",
		"GPIO-AAA",
		"GPIO-BBB",
		"GPIO-CCC",
		"GPIO-Z",
		"GPIO-DDD",
		"GPIO-BB",
		"GPIO_28_CAN_SPI_MISO",
		"GPIO_29_CAN_SPI_MOSI",
		"GPIO_30_CAN_SPI_CLK", /* GPIO_30 */
		"GPIO_31_CAN_SPI_CS",
		"GPIO-UU",
		"NC",
		"UART1_TXD_SOM",
		"UART1_RXD_SOM",
		"UART0_CTS",
		"UART0_RTS",
		"UART0_TXD",
		"UART0_RXD",
		"SPI1_MISO", /* GPIO_40 */
		"SPI1_MOSI",
		"SPI1_CLK",
		"SPI1_CS",
		"I2C1_SDA",
		"I2C1_SCL",
		"GPIO-F",
		"GPIO-JJ",
		"Board_ID1",
		"Board_ID2",
		"NC", /* GPIO_50 */
		"NC",
		"SPI0_MISO",
		"SPI0_MOSI",
		"SPI0_SCLK",
		"SPI0_CS",
		"GPIO-QQ",
		"GPIO-RR",
		"USB2LAN_RESET",
		"USB2LAN_EXTWAKE",
		"NC", /* GPIO_60 */
		"NC",
		"NC",
		"LT9611_INT",
		"GPIO-AA",
		"USB_CC_DIR",
		"GPIO-G",
		"GPIO-LL",
		"USB_DP_HPD_1P8",
		"NC",
		"NC", /* GPIO_70 */
		"SD_CMD",
		"SD_DAT3",
		"SD_SCLK",
		"SD_DAT2",
		"SD_DAT1",
		"SD_DAT0", /* BOOT_CFG3 */
		"SD_UFS_CARD_DET_N",
		"GPIO-II",
		"PCIE0_RST_N",
		"PCIE0_CLK_REQ_N", /* GPIO_80 */
		"PCIE0_WAKE_N",
		"GPIO-CC",
		"GPIO-DD",
		"GPIO-EE",
		"GPIO-FF",
		"GPIO-GG",
		"GPIO-HH",
		"GPIO-VV",
		"GPIO-WW",
		"NC", /* GPIO_90 */
		"NC",
		"GPIO-K",
		"GPIO-I",
		"CSI0_MCLK",
		"CSI1_MCLK",
		"CSI2_MCLK",
		"CSI3_MCLK",
		"GPIO-AA", /* CSI4_MCLK */
		"GPIO-BB", /* CSI5_MCLK */
		"GPIO-KK", /* GPIO_100 */
		"CCI_I2C_SDA0",
		"CCI_I2C_SCL0",
		"CCI_I2C_SDA1",
		"CCI_I2C_SCL1",
		"CCI_I2C_SDA2",
		"CCI_I2C_SCL2",
		"CCI_I2C_SDA3",
		"CCI_I2C_SCL3",
		"GPIO-L",
		"NC", /* GPIO_110 */
		"NC",
		"ACCEL_INT",
		"GYRO_INT",
		"GPIO-J",
		"GPIO-YY",
		"GPIO-H",
		"GPIO-ZZ",
		"NC",
		"NC",
		"NC", /* GPIO_120 */
		"NC",
		"MAG_INT",
		"MAG_DRDY_INT",
		"HST_SW_CTRL",
		"GPIO-M",
		"GPIO-N",
		"GPIO-O",
		"GPIO-P",
		"PS_INT",
		"WSA1_EN", /* GPIO_130 */
		"USB_HUB_RESET",
		"SDM_FORCE_USB_BOOT",
		"I2S1_CLK_HDMI",
		"I2S1_DATA0_HDMI",
		"I2S1_WS_HDMI",
		"GPIO-B",
		"GPIO_137", /* To LT9611_I2S_MCLK_3V3 */
		"PCM_CLK",
		"PCM_DI",
		"PCM_DO", /* GPIO_140 */
		"PCM_FS",
		"HST_SLIM_CLK",
		"HST_SLIM_DATA",
		"GPIO-U",
		"GPIO-Y",
		"GPIO-R",
		"GPIO-Q",
		"GPIO-S",
		"GPIO-T",
		"GPIO-V", /* GPIO_150 */
		"GPIO-W",
		"DMIC_CLK1",
		"DMIC_DATA1",
		"DMIC_CLK2",
		"DMIC_DATA2",
		"WSA_SWR_CLK",
		"WSA_SWR_DATA",
		"DMIC_CLK3",
		"DMIC_DATA3",
		"I2C4_SDA", /* GPIO_160 */
		"I2C4_SCL",
		"SPI3_CS1",
		"SPI3_CS2",
		"SPI2_MISO_LS3",
		"SPI2_MOSI_LS3",
		"SPI2_CLK_LS3",
		"SPI2_ACCEL_CS_LS3",
		"SPI2_CS1",
		"NC",
		"GPIO-SS", /* GPIO_170 */
		"GPIO-XX",
		"SPI3_MISO",
		"SPI3_MOSI",
		"SPI3_CLK",
		"SPI3_CS",
		"HST_BLE_SNS_UART_TX",
		"HST_BLE_SNS_UART_RX",
		"HST_WLAN_UART_TX",
		"HST_WLAN_UART_RX";

	bt_en_state: bt-default-state {
		pins = "gpio21";
		function = "gpio";
		drive-strength = <16>;
		output-low;
		bias-pull-up;
	};

	lt9611_irq_pin: lt9611-irq-state {
		pins = "gpio63";
		function = "gpio";
		bias-disable;
	};

	sdc2_default_state: sdc2-default-state {
		clk-pins {
			pins = "sdc2_clk";
			bias-disable;
			drive-strength = <16>;
		};

		cmd-pins {
			pins = "sdc2_cmd";
			bias-pull-up;
			drive-strength = <10>;
		};

		data-pins {
			pins = "sdc2_data";
			bias-pull-up;
			drive-strength = <10>;
		};
	};

	sdc2_card_det_n: sd-card-det-n-state {
		pins = "gpio77";
		function = "gpio";
		bias-pull-up;
	};
};

&uart6 {
	status = "okay";

	bluetooth {
		compatible = "qcom,qca6390-bt";

		pinctrl-names = "default";
		pinctrl-0 = <&bt_en_state>;

		enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>;

		vddio-supply = <&vreg_s4a_1p8>;
		vddpmu-supply = <&vreg_s2f_0p95>;
		vddaon-supply = <&vreg_s6a_0p95>;
		vddrfa0p9-supply = <&vreg_s2f_0p95>;
		vddrfa1p3-supply = <&vreg_s8c_1p3>;
		vddrfa1p9-supply = <&vreg_s5a_1p9>;
	};
};

&uart12 {
	status = "okay";
};

&ufs_mem_hc {
	status = "okay";

	vcc-supply = <&vreg_l17a_3p0>;
	vcc-max-microamp = <800000>;
	vccq-supply = <&vreg_l6a_1p2>;
	vccq-max-microamp = <800000>;
	vccq2-supply = <&vreg_s4a_1p8>;
	vccq2-max-microamp = <800000>;
};

&ufs_mem_phy {
	status = "okay";

	vdda-phy-supply = <&vreg_l5a_0p88>;
	vdda-pll-supply = <&vreg_l9a_1p2>;
};

&usb_1 {
	status = "okay";
};

&usb_1_dwc3 {
	dr_mode = "otg";
	usb-role-switch;
};

&usb_1_role_switch_out {
	remote-endpoint = <&pm8150b_role_switch_in>;
};

&usb_1_hsphy {
	status = "okay";

	vdda-pll-supply = <&vreg_l5a_0p88>;
	vdda33-supply = <&vreg_l2a_3p1>;
	vdda18-supply = <&vreg_l12a_1p8>;
};

&usb_1_qmpphy {
	status = "okay";

	vdda-phy-supply = <&vreg_l9a_1p2>;
	vdda-pll-supply = <&vreg_l18a_0p92>;
	orientation-switch;
};

&usb_1_qmpphy_out {
	remote-endpoint = <&redriver_phy_con_ss>;
};

&usb_2 {
	status = "okay";
};

&usb_2_dwc3 {
	dr_mode = "host";
};

&usb_2_hsphy {
	status = "okay";

	vdda-pll-supply = <&vreg_l5a_0p88>;
	vdda33-supply = <&vreg_l2a_3p1>;
	vdda18-supply = <&vreg_l12a_1p8>;
};

&usb_2_qmpphy {
	status = "okay";

	vdda-phy-supply = <&vreg_l9a_1p2>;
	vdda-pll-supply = <&vreg_l18a_0p92>;
};

&vamacro {
	pinctrl-0 = <&dmic01_active>;
	pinctrl-names = "default";
	vdd-micb-supply = <&vreg_s4a_1p8>;
	qcom,dmic-sample-rate = <600000>;
};

&venus {
	status = "okay";
};

&wsamacro {
	status = "okay";
};

/* PINCTRL - additions to nodes defined in sm8250.dtsi */
&qup_spi0_cs_gpio {
	drive-strength = <6>;
	bias-disable;
};

&qup_spi0_data_clk {
	drive-strength = <6>;
	bias-disable;
};

&pm8150b_vbus {
	regulator-min-microamp = <500000>;
	regulator-max-microamp = <3000000>;
	status = "okay";
};

&pm8150b_typec {
	status = "okay";

	vdd-pdphy-supply = <&vreg_l2a_3p1>;

	connector {
		compatible = "usb-c-connector";

		power-role = "source";
		data-role = "dual";
		self-powered;

		source-pdos = <PDO_FIXED(5000, 3000,
					 PDO_FIXED_DUAL_ROLE |
					 PDO_FIXED_USB_COMM |
					 PDO_FIXED_DATA_SWAP)>;

		altmodes {
			displayport {
				svid = /bits/ 16 <0xff01>;
				vdo = <0x00001c46>;
			};
		};

		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;
				pm8150b_role_switch_in: endpoint {
					remote-endpoint = <&usb_1_role_switch_out>;
				};
			};

			port@1 {
				reg = <1>;
				pm8150b_typec_mux_in: endpoint {
					remote-endpoint = <&redriver_usb_con_ss>;
				};
			};

			port@2 {
				reg = <2>;

				pm8150b_typec_sbu_out: endpoint {
					remote-endpoint = <&redriver_usb_con_sbu>;
				};
			};
		};
	};
};

&usb_1_qmpphy_dp_in {
	remote-endpoint = <&mdss_dp_out>;
};
