// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2024, Jérôme de Bretagne <jerome.debretagne@gmail.com>
 */

/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/gpio-keys.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>

#include "sc8280xp.dtsi"
#include "sc8280xp-pmics.dtsi"

/ {
	model = "Microsoft Surface Pro 9 5G";
	compatible = "microsoft,arcata", "qcom,sc8280xp";

	aliases {
		serial0 = &uart18;
		serial1 = &uart2;
	};

	wcd938x: audio-codec {
		compatible = "qcom,wcd9380-codec";

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

		reset-gpios = <&tlmm 106 GPIO_ACTIVE_LOW>;

		vdd-buck-supply = <&vreg_s10b>;
		vdd-rxtx-supply = <&vreg_s10b>;
		vdd-io-supply = <&vreg_s10b>;
		vdd-mic-bias-supply = <&vreg_bob>;

		qcom,micbias1-microvolt = <1800000>;
		qcom,micbias2-microvolt = <1800000>;
		qcom,micbias3-microvolt = <1800000>;
		qcom,micbias4-microvolt = <1800000>;
		qcom,mbhc-buttons-vthreshold-microvolt = <75000 150000 237000 500000 500000 500000 500000 500000>;
		qcom,mbhc-headset-vthreshold-microvolt = <1700000>;
		qcom,mbhc-headphone-vthreshold-microvolt = <50000>;
		qcom,rx-device = <&wcd_rx>;
		qcom,tx-device = <&wcd_tx>;

		#sound-dai-cells = <1>;
	};

	backlight: backlight {
		compatible = "pwm-backlight";
		pwms = <&pmc8280c_lpg 3 1000000>;
		enable-gpios = <&pmc8280_1_gpios 8 GPIO_ACTIVE_HIGH>;

		pinctrl-0 = <&edp_bl_en>, <&edp_bl_pwm>;
		pinctrl-names = "default";
	};

	gpio-keys {
		compatible = "gpio-keys";

		pinctrl-0 = <&hall_int_n_default>, <&vol_down_n>, <&vol_up_n>;
		pinctrl-names = "default";

		key-vol-down {
			label = "Volume Down";
			gpios = <&pmc8280_1_gpios 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEDOWN>;
			debounce-interval = <15>;
			linux,can-disable;
			wakeup-source;
		};

		key-vol-up {
			label = "Volume Up";
			gpios = <&pmc8280_1_gpios 9 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEUP>;
			debounce-interval = <15>;
			linux,can-disable;
			wakeup-source;
		};

		switch-lid {
			label = "lid";
			gpios = <&tlmm 180 GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_SW>;
			linux,code = <SW_LID>;
			wakeup-source;
			wakeup-event-action = <EV_ACT_DEASSERTED>;
		};
	};

	pmic-glink {
		compatible = "qcom,sc8280xp-pmic-glink", "qcom,pmic-glink";

		#address-cells = <1>;
		#size-cells = <0>;
		orientation-gpios = <&tlmm 166 GPIO_ACTIVE_HIGH>,
				    <&tlmm 49 GPIO_ACTIVE_HIGH>;

		/* Left-side top port */
		connector@0 {
			compatible = "usb-c-connector";
			reg = <0>;
			power-role = "dual";
			data-role = "dual";

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

				port@0 {
					reg = <0>;

					pmic_glink_con0_hs: endpoint {
						remote-endpoint = <&usb_0_dwc3_hs>;
					};
				};

				port@1 {
					reg = <1>;

					pmic_glink_con0_ss: endpoint {
						remote-endpoint = <&usb_0_qmpphy_out>;
					};
				};

				port@2 {
					reg = <2>;

					pmic_glink_con0_sbu: endpoint {
						remote-endpoint = <&usb0_sbu_mux>;
					};
				};
			};
		};

		/* Left-side bottom port */
		connector@1 {
			compatible = "usb-c-connector";
			reg = <1>;
			power-role = "dual";
			data-role = "dual";

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

				port@0 {
					reg = <0>;

					pmic_glink_con1_hs: endpoint {
						remote-endpoint = <&usb_1_dwc3_hs>;
					};
				};

				port@1 {
					reg = <1>;

					pmic_glink_con1_ss: endpoint {
						remote-endpoint = <&usb_1_qmpphy_out>;
					};
				};

				port@2 {
					reg = <2>;

					pmic_glink_con1_sbu: endpoint {
						remote-endpoint = <&usb1_sbu_mux>;
					};
				};
			};
		};
	};

	vreg_edp_3p3: regulator-edp-3p3 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_EDP_3P3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

		gpio = <&tlmm 36 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_nvme: regulator-nvme {
		compatible = "regulator-fixed";

		regulator-name = "VCC3_SSD";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

		gpio = <&tlmm 135 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_vph_pwr: regulator-vph-pwr {
		compatible = "regulator-fixed";

		regulator-name = "VPH_VCC3R9";
		regulator-min-microvolt = <3900000>;
		regulator-max-microvolt = <3900000>;

		regulator-always-on;
	};

	vreg_wlan: regulator-wlan {
		compatible = "regulator-fixed";

		regulator-name = "VCC_WLAN_3R9";
		regulator-min-microvolt = <3900000>;
		regulator-max-microvolt = <3900000>;

		gpio = <&pmr735a_gpios 1 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_wwan: regulator-wwan {
		compatible = "regulator-fixed";

		regulator-name = "VCC3B_WAN";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

		gpio = <&pmc8280_2_gpios 1 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	reserved-memory {
		linux,cma {
			compatible = "shared-dma-pool";
			size = <0x0 0x8000000>;
			reusable;
			linux,cma-default;
		};
	};

	thermal-zones {
		skin-temp-thermal {
			polling-delay-passive = <250>;

			thermal-sensors = <&pmk8280_adc_tm 5>;

			trips {
				skin_temp_alert0: trip-point0 {
					temperature = <55000>;
					hysteresis = <1000>;
					type = "passive";
				};

				skin_temp_alert1: trip-point1 {
					temperature = <58000>;
					hysteresis = <1000>;
					type = "passive";
				};

				skin-temp-crit {
					temperature = <73000>;
					hysteresis = <1000>;
					type = "critical";
				};
			};

			cooling-maps {
				map0 {
					trip = <&skin_temp_alert0>;
					cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};

				map1 {
					trip = <&skin_temp_alert1>;
					cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
							 <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
				};
			};
		};
	};

	usb0-sbu-mux {
		compatible = "pericom,pi3usb102", "gpio-sbu-mux";

		enable-gpios = <&tlmm 100 GPIO_ACTIVE_LOW>;
		select-gpios = <&tlmm 164 GPIO_ACTIVE_HIGH>;

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

		mode-switch;
		orientation-switch;

		port {
			usb0_sbu_mux: endpoint {
				remote-endpoint = <&pmic_glink_con0_sbu>;
			};
		};
	};

	usb1-sbu-mux {
		compatible = "pericom,pi3usb102", "gpio-sbu-mux";

		enable-gpios = <&tlmm 48 GPIO_ACTIVE_LOW>;
		select-gpios = <&tlmm 47 GPIO_ACTIVE_HIGH>;

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

		mode-switch;
		orientation-switch;

		port {
			usb1_sbu_mux: endpoint {
				remote-endpoint = <&pmic_glink_con1_sbu>;
			};
		};
	};

	wcn6855-pmu {
		compatible = "qcom,wcn6855-pmu";

		pinctrl-0 = <&bt_default>, <&wlan_en>;
		pinctrl-names = "default";

		wlan-enable-gpios = <&tlmm 134 GPIO_ACTIVE_HIGH>;
		bt-enable-gpios = <&tlmm 133 GPIO_ACTIVE_HIGH>;
		swctrl-gpios = <&tlmm 132 GPIO_ACTIVE_HIGH>;

		vddio-supply = <&vreg_s10b>;
		vddaon-supply = <&vreg_s12b>;
		vddpmu-supply = <&vreg_s12b>;
		vddpmumx-supply = <&vreg_s12b>;
		vddpmucx-supply = <&vreg_s12b>;
		vddrfa0p95-supply = <&vreg_s12b>;
		vddrfa1p3-supply = <&vreg_s11b>;
		vddrfa1p9-supply = <&vreg_s1c>;
		vddpcie1p3-supply = <&vreg_s11b>;
		vddpcie1p9-supply = <&vreg_s1c>;

		regulators {
			vreg_pmu_rfa_cmn_0p8: ldo0 {
				regulator-name = "vreg_pmu_rfa_cmn_0p8";
			};

			vreg_pmu_aon_0p8: ldo1 {
				regulator-name = "vreg_pmu_aon_0p8";
			};

			vreg_pmu_wlcx_0p8: ldo2 {
				regulator-name = "vreg_pmu_wlcx_0p8";
			};

			vreg_pmu_wlmx_0p8: ldo3 {
				regulator-name = "vreg_pmu_wlmx_0p8";
			};

			vreg_pmu_btcmx_0p8: ldo4 {
				regulator-name = "vreg_pmu_btcmx_0p8";
			};

			vreg_pmu_pcie_1p8: ldo5 {
				regulator-name = "vreg_pmu_pcie_1p8";
			};

			vreg_pmu_pcie_0p9: ldo6 {
				regulator-name = "vreg_pmu_pcie_0p9";
			};

			vreg_pmu_rfa_0p8: ldo7 {
				regulator-name = "vreg_pmu_rfa_0p8";
			};

			vreg_pmu_rfa_1p2: ldo8 {
				regulator-name = "vreg_pmu_rfa_1p2";
			};

			vreg_pmu_rfa_1p7: ldo9 {
				regulator-name = "vreg_pmu_rfa_1p7";
			};
		};
	};
};

&apps_rsc {
	regulators-0 {
		compatible = "qcom,pm8350-rpmh-regulators";
		qcom,pmic-id = "b";

		vdd-l1-l4-supply = <&vreg_s12b>;
		vdd-l2-l7-supply = <&vreg_bob>;
		vdd-l3-l5-supply = <&vreg_s11b>;
		vdd-l6-l9-l10-supply = <&vreg_s12b>;
		vdd-l8-supply = <&vreg_s12b>;

		vreg_s10b: smps10 {
			regulator-name = "vreg_s10b";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-always-on;
		};

		vreg_s11b: smps11 {
			regulator-name = "vreg_s11b";
			regulator-min-microvolt = <1272000>;
			regulator-max-microvolt = <1272000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_s12b: smps12 {
			regulator-name = "vreg_s12b";
			regulator-min-microvolt = <984000>;
			regulator-max-microvolt = <984000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3b: ldo3 {
			regulator-name = "vreg_l3b";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-boot-on;
		};

		vreg_l4b: ldo4 {
			regulator-name = "vreg_l4b";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6b: ldo6 {
			regulator-name = "vreg_l6b";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <880000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-boot-on;
		};
	};

	regulators-1 {
		compatible = "qcom,pm8350c-rpmh-regulators";
		qcom,pmic-id = "c";

		vdd-bob-supply = <&vreg_vph_pwr>;
		vdd-l1-l12-supply = <&vreg_s1c>;
		vdd-l2-l8-supply = <&vreg_s1c>;
		vdd-l3-l4-l5-l7-l13-supply = <&vreg_bob>;
		vdd-l6-l9-l11-supply = <&vreg_bob>;
		vdd-l10-supply = <&vreg_s11b>;

		vreg_s1c: smps1 {
			regulator-name = "vreg_s1c";
			regulator-min-microvolt = <1880000>;
			regulator-max-microvolt = <1900000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-always-on;
		};

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

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

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

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

	regulators-2 {
		compatible = "qcom,pm8350-rpmh-regulators";
		qcom,pmic-id = "d";

		vdd-l1-l4-supply = <&vreg_s11b>;
		vdd-l2-l7-supply = <&vreg_bob>;
		vdd-l3-l5-supply = <&vreg_s11b>;
		vdd-l6-l9-l10-supply = <&vreg_s12b>;
		vdd-l8-supply = <&vreg_s12b>;

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

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

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

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

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

&dispcc0 {
	status = "okay";
};

&gpi_dma0 {
	dma-channel-mask = <0x3>;
	status = "okay";
};

&gpi_dma1 {
	dma-channel-mask = <0x3>;
	status = "okay";
};

&gpi_dma2 {
	dma-channel-mask = <0x23>;
	status = "okay";
};

&gpu {
	status = "okay";
};

&gpu_zap_shader {
	firmware-name = "qcom/sc8280xp/MICROSOFT/SurfacePro9/qcdxkmsuc8280.mbn";
};

&mdss0 {
	status = "okay";
};

&mdss0_dp0 {
	status = "okay";
};

&mdss0_dp0_out {
	data-lanes = <0 1 2 3>;
	remote-endpoint = <&usb_0_qmpphy_dp_in>;
};

&mdss0_dp1 {
	status = "okay";
};

&mdss0_dp1_out {
	data-lanes = <0 1 2 3>;
	remote-endpoint = <&usb_1_qmpphy_dp_in>;
};

&mdss0_dp3 {
	compatible = "qcom,sc8280xp-edp";
	/delete-property/ #sound-dai-cells;

	data-lanes = <0 1 2 3>;

	status = "okay";

	aux-bus {
		panel {
			compatible = "edp-panel";

			backlight = <&backlight>;
			power-supply = <&vreg_edp_3p3>;

			port {
				edp_panel_in: endpoint {
					remote-endpoint = <&mdss0_dp3_out>;
				};
			};
		};
	};
};

&mdss0_dp3_out {
	remote-endpoint = <&edp_panel_in>;
};

&mdss0_dp3_phy {
	compatible = "qcom,sc8280xp-edp-phy";
	vdda-phy-supply = <&vreg_l6b>;
	vdda-pll-supply = <&vreg_l3b>;

	status = "okay";
};

&pcie2a {
	vddpe-3v3-supply = <&vreg_nvme>;

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

	status = "okay";
};

&pcie2a_phy {
	vdda-phy-supply = <&vreg_l6d>;
	vdda-pll-supply = <&vreg_l4d>;

	status = "okay";
};

&pcie2a_port0 {
	reset-gpios = <&tlmm 143 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 145 GPIO_ACTIVE_LOW>;
};

&pcie3a {
	vddpe-3v3-supply = <&vreg_wwan>;

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

	status = "okay";
};

&pcie3a_phy {
	vdda-phy-supply = <&vreg_l6d>;
	vdda-pll-supply = <&vreg_l4d>;

	status = "okay";
};

&pcie3a_port0 {
	reset-gpios = <&tlmm 151 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 148 GPIO_ACTIVE_LOW>;
};

&pcie4 {
	max-link-speed = <2>;

	vddpe-3v3-supply = <&vreg_wlan>;

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

	status = "okay";
};

&pcie4_port0 {
	reset-gpios = <&tlmm 141 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 139 GPIO_ACTIVE_LOW>;

	wifi@0 {
		compatible = "pci17cb,1103";
		reg = <0x10000 0x0 0x0 0x0 0x0>;

		vddrfacmn-supply = <&vreg_pmu_rfa_cmn_0p8>;
		vddaon-supply = <&vreg_pmu_aon_0p8>;
		vddwlcx-supply = <&vreg_pmu_wlcx_0p8>;
		vddwlmx-supply = <&vreg_pmu_wlmx_0p8>;
		vddpcie1p8-supply = <&vreg_pmu_pcie_1p8>;
		vddpcie0p9-supply = <&vreg_pmu_pcie_0p9>;
		vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>;
		vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>;
		vddrfa1p8-supply = <&vreg_pmu_rfa_1p7>;

		qcom,calibration-variant = "MS_SP9_5G";
	};
};

&pcie4_phy {
	vdda-phy-supply = <&vreg_l6d>;
	vdda-pll-supply = <&vreg_l4d>;

	status = "okay";
};

&pmc8280c_lpg {
	status = "okay";
};

&pmk8280_pon_pwrkey {
	status = "okay";
};

&pmk8280_pon_resin {
	status = "okay";
};

&pmk8280_rtc {
	qcom,uefi-rtc-info;

	status = "okay";
};

&qup0 {
	status = "okay";
};

&qup1 {
	status = "okay";
};

&qup2 {
	status = "okay";
};

&remoteproc_adsp {
	firmware-name = "qcom/sc8280xp/MICROSOFT/SurfacePro9/qcadsp8280.mbn";

	status = "okay";
};

&remoteproc_nsp0 {
	firmware-name = "qcom/sc8280xp/MICROSOFT/SurfacePro9/qccdsp8280.mbn";

	status = "okay";
};

&rxmacro {
	status = "okay";
};

&sound {
	compatible = "qcom,sc8280xp-sndcard";
	model = "SC8280XP-MICROSOFT-SURFACE-PRO-9-5G";
	audio-routing = "SpkrLeft IN", "WSA_SPK1 OUT",
			"SpkrRight IN", "WSA_SPK2 OUT",
			"IN1_HPHL", "HPHL_OUT",
			"IN2_HPHR", "HPHR_OUT",
			"AMIC2", "MIC BIAS2",
			"VA DMIC0", "MIC BIAS1",
			"VA DMIC1", "MIC BIAS1",
			"VA DMIC2", "MIC BIAS3",
			"TX SWR_ADC1", "ADC2_OUTPUT";

	wcd-playback-dai-link {
		link-name = "WCD Playback";

		cpu {
			sound-dai = <&q6apmbedai RX_CODEC_DMA_RX_0>;
		};

		codec {
			sound-dai = <&wcd938x 0>, <&swr1 0>, <&rxmacro 0>;
		};

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

	wcd-capture-dai-link {
		link-name = "WCD Capture";

		cpu {
			sound-dai = <&q6apmbedai TX_CODEC_DMA_TX_3>;
		};

		codec {
			sound-dai = <&wcd938x 1>, <&swr2 0>, <&txmacro 0>;
		};

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

	wsa-dai-link {
		link-name = "WSA Playback";

		cpu {
			sound-dai = <&q6apmbedai WSA_CODEC_DMA_RX_0>;
		};

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

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

	va-dai-link {
		link-name = "VA Capture";

		cpu {
			sound-dai = <&q6apmbedai VA_CODEC_DMA_TX_0>;
		};

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

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

&swr0 {
	status = "okay";
};

&swr1 {
	status = "okay";

	wcd_rx: codec@0,4 {
		compatible = "sdw20217010d00";
		reg = <0 4>;
		qcom,rx-port-mapping = <1 2 3 4 5>;
	};
};

&swr2 {
	status = "okay";

	wcd_tx: codec@0,3 {
		compatible = "sdw20217010d00";
		reg = <0 3>;
		qcom,tx-port-mapping = <1 1 2 3>;
	};
};

&txmacro {
	status = "okay";
};

&uart2 {
	pinctrl-0 = <&uart2_default>;
	pinctrl-names = "default";

	status = "okay";

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

		vddrfacmn-supply = <&vreg_pmu_rfa_cmn_0p8>;
		vddaon-supply = <&vreg_pmu_aon_0p8>;
		vddwlcx-supply = <&vreg_pmu_wlcx_0p8>;
		vddwlmx-supply = <&vreg_pmu_wlmx_0p8>;
		vddbtcmx-supply = <&vreg_pmu_btcmx_0p8>;
		vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>;
		vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>;
		vddrfa1p7-supply = <&vreg_pmu_rfa_1p7>;

		max-speed = <3200000>;
	};
};

&uart18 {
	status = "okay";

	embedded-controller {
		compatible = "microsoft,surface-sam";

		interrupts-extended = <&tlmm 85 IRQ_TYPE_EDGE_RISING>;

		current-speed = <4000000>;

		pinctrl-0 = <&ssam_state>;
		pinctrl-names = "default";
	};
};

&usb_0 {
	status = "okay";
};

&usb_0_dwc3 {
	dr_mode = "host";
};

&usb_0_dwc3_hs {
	remote-endpoint = <&pmic_glink_con0_hs>;
};

&usb_0_hsphy {
	vdda-pll-supply = <&vreg_l9d>;
	vdda18-supply = <&vreg_l1c>;
	vdda33-supply = <&vreg_l7d>;

	status = "okay";
};

&usb_0_qmpphy {
	vdda-phy-supply = <&vreg_l9d>;
	vdda-pll-supply = <&vreg_l4d>;

	mode-switch;
	orientation-switch;

	status = "okay";
};

&usb_0_qmpphy_dp_in {
	remote-endpoint = <&mdss0_dp0_out>;
};

&usb_0_qmpphy_out {
	remote-endpoint = <&pmic_glink_con0_ss>;
};

&usb_1 {
	status = "okay";
};

&usb_1_dwc3 {
	dr_mode = "host";
};

&usb_1_dwc3_hs {
	remote-endpoint = <&pmic_glink_con1_hs>;
};

&usb_1_hsphy {
	vdda-pll-supply = <&vreg_l4b>;
	vdda18-supply = <&vreg_l1c>;
	vdda33-supply = <&vreg_l13c>;

	status = "okay";
};

&usb_1_qmpphy {
	vdda-phy-supply = <&vreg_l4b>;
	vdda-pll-supply = <&vreg_l3b>;

	mode-switch;
	orientation-switch;

	status = "okay";
};

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

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

&vamacro {
	pinctrl-0 = <&dmic01_default>, <&dmic23_default>;
	pinctrl-names = "default";

	vdd-micb-supply = <&vreg_s10b>;

	qcom,dmic-sample-rate = <4800000>;

	status = "okay";
};

&wsamacro {
	status = "okay";
};

&xo_board_clk {
	clock-frequency = <38400000>;
};

/* PINCTRL */

&lpass_tlmm {
	status = "okay";
};

&pmc8280_1_gpios {
	edp_bl_en: edp-bl-en-state {
		pins = "gpio8";
		function = "normal";
	};

	vol_down_n: vol-down-n-state {
		pins = "gpio6";
		function = "normal";
		power-source = <1>;
		input-enable;
		bias-pull-up;
	};

	vol_up_n: vol-up-n-state {
		pins = "gpio9";
		function = "normal";
		power-source = <1>;
		input-enable;
		bias-pull-up;
	};
};

&pmc8280_2_gpios {
	wwan_sw_en: wwan-sw-en-state {
		pins = "gpio1";
		function = "normal";
	};
};

&pmc8280c_gpios {
	edp_bl_pwm: edp-bl-pwm-state {
		pins = "gpio8";
		function = "func1";
	};
};

&pmr735a_gpios {
	hastings_reg_en: hastings-reg-en-state {
		pins = "gpio1";
		function = "normal";
	};
};

&tlmm {
	bt_default: bt-default-state {
		hstp-bt-en-pins {
			pins = "gpio133";
			function = "gpio";
			drive-strength = <16>;
			bias-disable;
		};

		hstp-sw-ctrl-pins {
			pins = "gpio132";
			function = "gpio";
			bias-pull-down;
		};
	};

	edp_reg_en: edp-reg-en-state {
		pins = "gpio36";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	hall_int_n_default: hall-int-n-state {
		pins = "gpio180";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	nvme_reg_en: nvme-reg-en-state {
		pins = "gpio135";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	pcie2a_default: pcie2a-default-state {
		clkreq-n-pins {
			pins = "gpio142";
			function = "pcie2a_clkreq";
			drive-strength = <2>;
			bias-pull-up;
		};

		perst-n-pins {
			pins = "gpio143";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		wake-n-pins {
			pins = "gpio145";
			function = "gpio";
			drive-strength = <2>;
			bias-pull-up;
		};
	};

	pcie3a_default: pcie3a-default-state {
		clkreq-n-pins {
			pins = "gpio150";
			function = "pcie3a_clkreq";
			drive-strength = <2>;
			bias-pull-up;
		};

		perst-n-pins {
			pins = "gpio151";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		wake-n-pins {
			pins = "gpio148";
			function = "gpio";
			drive-strength = <2>;
			bias-pull-up;
		};
	};

	pcie4_default: pcie4-default-state {
		clkreq-n-pins {
			pins = "gpio140";
			function = "pcie4_clkreq";
			drive-strength = <2>;
			bias-pull-up;
		};

		perst-n-pins {
			pins = "gpio141";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		wake-n-pins {
			pins = "gpio139";
			function = "gpio";
			drive-strength = <2>;
			bias-pull-up;
		};
	};


	ssam_state: ssam-state-state {
		pins = "gpio85";
		function = "gpio";
		bias-disable;
	};

	uart2_default: uart2-default-state {
		cts-pins {
			pins = "gpio121";
			function = "qup2";
			bias-bus-hold;
		};

		rts-pins {
			pins = "gpio122";
			function = "qup2";
			drive-strength = <2>;
			bias-disable;
		};

		rx-pins {
			pins = "gpio124";
			function = "qup2";
			bias-pull-up;
		};

		tx-pins {
			pins = "gpio123";
			function = "qup2";
			drive-strength = <2>;
			bias-disable;
		};
	};

	usb0_sbu_default: usb0-sbu-state {
		oe-n-pins {
			pins = "gpio100";
			function = "gpio";
			bias-disable;
			drive-strength = <16>;
			output-high;
		};

		sel-pins {
			pins = "gpio164";
			function = "gpio";
			bias-disable;
			drive-strength = <16>;
		};
	};

	usb1_sbu_default: usb1-sbu-state {
		oe-n-pins {
			pins = "gpio48";
			function = "gpio";
			bias-disable;
			drive-strength = <16>;
			output-high;
		};

		sel-pins {
			pins = "gpio47";
			function = "gpio";
			bias-disable;
			drive-strength = <16>;
		};
	};

	wcd_default: wcd-default-state {
		reset-pins {
			pins = "gpio106";
			function = "gpio";
			bias-disable;
		};
	};

	wlan_en: wlan-en-state {
		pins = "gpio134";
		function = "gpio";
		drive-strength = <8>;
		bias-pull-down;
	};
};