// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
 */

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

#include "hamoa.dtsi"
#include "hamoa-pmics.dtsi"

/ {
	aliases {
		serial0 = &uart2;
		i2c0 = &i2c0;
		i2c3 = &i2c3;
		i2c4 = &i2c4;
		i2c5 = &i2c5;
		i2c7 = &i2c7;
	};

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

		reset-gpios = <&tlmm 191 GPIO_ACTIVE_LOW>;

		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>;


		vdd-buck-supply = <&vreg_l15b>;
		vdd-rxtx-supply = <&vreg_l15b>;
		vdd-io-supply = <&vreg_l15b>;
		vdd-mic-bias-supply = <&vreg_bob1>;

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

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

	backlight: backlight {
		compatible = "pwm-backlight";
		pwms = <&pmk8550_pwm 0 5000000>;
		enable-gpios = <&pmc8380_3_gpios 4 GPIO_ACTIVE_HIGH>;
		/* TODO: power-supply? */

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

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

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

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

	leds {
		compatible = "gpio-leds";

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

		led-camera-indicator {
			label = "white:camera-indicator";
			function = LED_FUNCTION_INDICATOR;
			color = <LED_COLOR_ID_WHITE>;
			gpios = <&tlmm 225 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "none";
			default-state = "off";
			/* Reuse as a panic indicator until we get a "camera on" trigger */
			panic-indicator;
		};
	};

	pmic-glink {
		compatible = "qcom,x1e80100-pmic-glink",
			     "qcom,sm8550-pmic-glink",
			     "qcom,pmic-glink";
		#address-cells = <1>;
		#size-cells = <0>;
		orientation-gpios = <&tlmm 121 GPIO_ACTIVE_HIGH>,
				    <&tlmm 123 GPIO_ACTIVE_HIGH>;

		/* Left-side rear 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_ss0_hs_in: endpoint {
						remote-endpoint = <&usb_1_ss0_dwc3_hs>;
					};
				};

				port@1 {
					reg = <1>;

					pmic_glink_ss0_ss_in: endpoint {
						remote-endpoint = <&retimer_ss0_ss_out>;
					};
				};

				port@2 {
					reg = <2>;

					pmic_glink_ss0_con_sbu_in: endpoint {
						remote-endpoint = <&retimer_ss0_con_sbu_out>;
					};
				};
			};
		};

		/* Left-side front 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_ss1_hs_in: endpoint {
						remote-endpoint = <&usb_1_ss1_dwc3_hs>;
					};
				};

				port@1 {
					reg = <1>;

					pmic_glink_ss1_ss_in: endpoint {
						remote-endpoint = <&retimer_ss1_ss_out>;
					};
				};

				port@2 {
					reg = <2>;

					pmic_glink_ss1_con_sbu_in: endpoint {
						remote-endpoint = <&retimer_ss1_con_sbu_out>;
					};
				};
			};
		};
	};

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

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

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

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

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

		regulator-boot-on;
	};

	vreg_rtmr0_1p15: regulator-rtmr0-1p15 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR0_1P15";

		regulator-min-microvolt = <1150000>;
		regulator-max-microvolt = <1150000>;

		gpio = <&pmc8380_5_gpios 8 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_rtmr0_1p8: regulator-rtmr0-1p8 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR0_1P8";

		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;

		gpio = <&pm8550ve_9_gpios 8 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_rtmr0_3p3: regulator-rtmr0-3p3 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR0_3P3";

		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

		gpio = <&pm8550_gpios 11 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

		regulator-boot-on;
	};

	vreg_rtmr1_1p15: regulator-rtmr1-1p15 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR1_1P15";

		regulator-min-microvolt = <1150000>;
		regulator-max-microvolt = <1150000>;

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

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

		regulator-boot-on;
	};

	vreg_rtmr1_1p8: regulator-rtmr1-1p8 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR1_1P8";

		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;

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

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

		regulator-boot-on;
	};

	vreg_rtmr1_3p3: regulator-rtmr1-3p3 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_RTMR1_3P3";

		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

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

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

		regulator-boot-on;
	};


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

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

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

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

		regulator-boot-on;
	};

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

		regulator-name = "vph_pwr";
		regulator-min-microvolt = <3700000>;
		regulator-max-microvolt = <3700000>;

		regulator-always-on;
		regulator-boot-on;
	};

	vreg_wcn_0p95: regulator-wcn-0p95 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_WCN_0P95";
		regulator-min-microvolt = <950000>;
		regulator-max-microvolt = <950000>;

		vin-supply = <&vreg_wcn_3p3>;
	};

	vreg_wcn_1p9: regulator-wcn-1p9 {
		compatible = "regulator-fixed";

		regulator-name = "VREG_WCN_1P9";
		regulator-min-microvolt = <1900000>;
		regulator-max-microvolt = <1900000>;

		vin-supply = <&vreg_wcn_3p3>;
	};

	vreg_wcn_3p3: regulator-wcn-3p3 {
		compatible = "regulator-fixed";

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

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

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

		regulator-boot-on;
	};

	sound {
		compatible = "qcom,x1e80100-sndcard";
		model = "X1E80100-Romulus";
		audio-routing = "SpkrLeft IN", "WSA WSA_SPK1 OUT",
				"SpkrRight IN", "WSA WSA_SPK2 OUT",
				"IN1_HPHL", "HPHL_OUT",
				"IN2_HPHR", "HPHR_OUT",
				"AMIC2", "MIC BIAS2",
				"VA DMIC0", "MIC BIAS3",
				"VA DMIC1", "MIC BIAS3",
				"VA DMIC0", "VA MIC BIAS3",
				"VA DMIC1", "VA MIC BIAS3",
				"TX SWR_INPUT1", "ADC2_OUTPUT";

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

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

			codec {
				sound-dai = <&lpass_vamacro 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 1>, <&lpass_txmacro 0>;
			};

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

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

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

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

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

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

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

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

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

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

		vdd-supply = <&vreg_wcn_0p95>;
		vddio-supply = <&vreg_l15b>;
		vddaon-supply = <&vreg_wcn_0p95>;
		vdddig-supply = <&vreg_wcn_0p95>;
		vddrfa1p2-supply = <&vreg_wcn_1p9>;
		vddrfa1p8-supply = <&vreg_wcn_1p9>;

		wlan-enable-gpios = <&tlmm 117 GPIO_ACTIVE_HIGH>;
		bt-enable-gpios = <&tlmm 116 GPIO_ACTIVE_HIGH>;

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

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

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

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

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

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

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

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

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

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

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

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

		vdd-bob1-supply = <&vph_pwr>;
		vdd-bob2-supply = <&vph_pwr>;
		vdd-l1-l4-l10-supply = <&vreg_s4c>;
		vdd-l2-l13-l14-supply = <&vreg_bob1>;
		vdd-l5-l16-supply = <&vreg_bob1>;
		vdd-l6-l7-supply = <&vreg_bob2>;
		vdd-l8-l9-supply = <&vreg_bob1>;
		vdd-l12-supply = <&vreg_s5j>;
		vdd-l15-supply = <&vreg_s4c>;
		vdd-l17-supply = <&vreg_bob2>;

		vreg_bob1: bob1 {
			regulator-name = "vreg_bob1";
			regulator-min-microvolt = <3008000>;
			regulator-max-microvolt = <3960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_bob2: bob2 {
			regulator-name = "vreg_bob2";
			regulator-min-microvolt = <2504000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

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

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

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

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

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

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

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

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

		vreg_l12b: ldo12 {
			regulator-name = "vreg_l12b";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-always-on;
		};

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

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

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

		vreg_l16b: ldo16 {
			regulator-name = "vreg_l16b";
			regulator-min-microvolt = <2912000>;
			regulator-max-microvolt = <2912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l17b: ldo17 {
			regulator-name = "vreg_l17b";
			regulator-min-microvolt = <2504000>;
			regulator-max-microvolt = <2504000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

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

		vdd-l1-supply = <&vreg_s5j>;
		vdd-l2-supply = <&vreg_s1f>;
		vdd-l3-supply = <&vreg_s1f>;
		vdd-s4-supply = <&vph_pwr>;

		vreg_s4c: smps4 {
			regulator-name = "vreg_s4c";
			regulator-min-microvolt = <1856000>;
			regulator-max-microvolt = <2000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

		vreg_l2c: ldo2 {
			regulator-name = "vreg_l2c";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3c: ldo3 {
			regulator-name = "vreg_l3c";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

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

		vdd-l1-supply = <&vreg_s1f>;
		vdd-l2-supply = <&vreg_s1f>;
		vdd-l3-supply = <&vreg_s4c>;
		vdd-s1-supply = <&vph_pwr>;

		vreg_l1d: ldo1 {
			regulator-name = "vreg_l1d";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l2d: ldo2 {
			regulator-name = "vreg_l2d";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

	regulators-3 {
		compatible = "qcom,pmc8380-rpmh-regulators";
		qcom,pmic-id = "e";

		vdd-l2-supply = <&vreg_s1f>;
		vdd-l3-supply = <&vreg_s5j>;

		vreg_l2e: ldo2 {
			regulator-name = "vreg_l2e";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

	regulators-4 {
		compatible = "qcom,pmc8380-rpmh-regulators";
		qcom,pmic-id = "f";

		vdd-l1-supply = <&vreg_s5j>;
		vdd-l2-supply = <&vreg_s5j>;
		vdd-l3-supply = <&vreg_s5j>;
		vdd-s1-supply = <&vph_pwr>;

		vreg_s1f: smps1 {
			regulator-name = "vreg_s1f";
			regulator-min-microvolt = <700000>;
			regulator-max-microvolt = <1100000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

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

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

	regulators-6 {
		compatible = "qcom,pm8550ve-rpmh-regulators";
		qcom,pmic-id = "i";

		vdd-l1-supply = <&vreg_s4c>;
		vdd-l2-supply = <&vreg_s5j>;
		vdd-l3-supply = <&vreg_s1f>;
		vdd-s1-supply = <&vph_pwr>;
		vdd-s2-supply = <&vph_pwr>;

		vreg_s1i: smps1 {
			regulator-name = "vreg_s1i";
			regulator-min-microvolt = <900000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_s2i: smps2 {
			regulator-name = "vreg_s2i";
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1100000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

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

		vreg_l3i: ldo3 {
			regulator-name = "vreg_l3i";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-7 {
		compatible = "qcom,pm8550ve-rpmh-regulators";
		qcom,pmic-id = "j";

		vdd-l1-supply = <&vreg_s1f>;
		vdd-l2-supply = <&vreg_s5j>;
		vdd-l3-supply = <&vreg_s1f>;
		vdd-s5-supply = <&vph_pwr>;

		vreg_s5j: smps5 {
			regulator-name = "vreg_s5j";
			regulator-min-microvolt = <1256000>;
			regulator-max-microvolt = <1304000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l1j: ldo1 {
			regulator-name = "vreg_l1j";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

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

		vreg_l3j: ldo3 {
			regulator-name = "vreg_l3j";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};
};

&gpu {
	status = "okay";
};

&gpu_zap_shader {
	firmware-name = "qcom/x1e80100/microsoft/qcdxkmsuc8380.mbn";
};

&i2c0 {
	clock-frequency = <100000>;

	status = "okay";

	/* Something @39, @3e, @44 */
};

&i2c3 {
	clock-frequency = <400000>;

	status = "okay";

	/* Left-side rear port */
	typec-mux@8 {
		compatible = "parade,ps8830";
		reg = <0x8>;

		reset-gpios = <&pm8550_gpios 10 GPIO_ACTIVE_LOW>;

		clocks = <&rpmhcc RPMH_RF_CLK3>;

		vdd-supply = <&vreg_rtmr0_1p15>;
		vdd33-supply = <&vreg_rtmr0_3p3>;
		vdd33-cap-supply = <&vreg_rtmr0_3p3>;
		vddar-supply = <&vreg_rtmr0_1p15>;
		vddat-supply = <&vreg_rtmr0_1p15>;
		vddio-supply = <&vreg_rtmr0_1p8>;

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

		retimer-switch;
		orientation-switch;

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

			port@0 {
				reg = <0>;

				retimer_ss0_ss_out: endpoint {
					remote-endpoint = <&pmic_glink_ss0_ss_in>;
				};
			};

			port@1 {
				reg = <1>;

				retimer_ss0_ss_in: endpoint {
					remote-endpoint = <&usb_1_ss0_qmpphy_out>;
				};
			};

			port@2 {
				reg = <2>;

				retimer_ss0_con_sbu_out: endpoint {
					remote-endpoint = <&pmic_glink_ss0_con_sbu_in>;
				};
			};
		};
	};

};

&i2c4 {
	clock-frequency = <400000>;

	status = "okay";

	/* Something @18, @2c, @2e */
};

&i2c5 {
	clock-frequency = <400000>;

	status = "okay";

	ptn3222: redriver@4f {
		compatible = "nxp,ptn3222";
		reg = <0x4f>;

		reset-gpios = <&tlmm 7 GPIO_ACTIVE_LOW>;

		vdd3v3-supply = <&vreg_l13b>;
		vdd1v8-supply = <&vreg_l4b>;

		#phy-cells = <0>;
	};
};

&i2c7 {
	clock-frequency = <400000>;

	status = "okay";

	/* Left-side front port */
	typec-mux@8 {
		compatible = "parade,ps8830";
		reg = <0x8>;

		reset-gpios = <&tlmm 176 GPIO_ACTIVE_LOW>;

		clocks = <&rpmhcc RPMH_RF_CLK4>;

		vdd-supply = <&vreg_rtmr1_1p15>;
		vdd33-supply = <&vreg_rtmr1_3p3>;
		vdd33-cap-supply = <&vreg_rtmr1_3p3>;
		vddar-supply = <&vreg_rtmr1_1p15>;
		vddat-supply = <&vreg_rtmr1_1p15>;
		vddio-supply = <&vreg_rtmr1_1p8>;

		retimer-switch;
		orientation-switch;

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

			port@0 {
				reg = <0>;

				retimer_ss1_ss_out: endpoint {
					remote-endpoint = <&pmic_glink_ss1_ss_in>;
				};
			};

			port@1 {
				reg = <1>;

				retimer_ss1_ss_in: endpoint {
					remote-endpoint = <&usb_1_ss1_qmpphy_out>;
				};
			};

			port@2 {
				reg = <2>;

				retimer_ss1_con_sbu_out: endpoint {
					remote-endpoint = <&pmic_glink_ss1_con_sbu_in>;
				};
			};
		};
	};
};

&lpass_tlmm {
	spkr_01_sd_n_active: spkr-01-sd-n-active-state {
		pins = "gpio12";
		function = "gpio";
		drive-strength = <16>;
		bias-disable;
		output-low;
	};
};

&lpass_vamacro {
	qcom,dmic-sample-rate = <4800000>;

	vdd-micb-supply = <&vreg_l1b>;

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

&mdss {
	status = "okay";
};

&mdss_dp0 {
	status = "okay";
};

&mdss_dp0_out {
	link-frequencies = /bits/ 64 <1620000000 2700000000 5400000000 8100000000>;
};

&mdss_dp1 {
	status = "okay";
};

&mdss_dp1_out {
	link-frequencies = /bits/ 64 <1620000000 2700000000 5400000000 8100000000>;
};

&mdss_dp3 {
	/delete-property/ #sound-dai-cells;

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

	status = "okay";

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

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

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

&mdss_dp3_out {
	data-lanes = <0 1 2 3>;
	link-frequencies = /bits/ 64 <1620000000 2700000000 5400000000 8100000000>;

	remote-endpoint = <&edp_panel_in>;
};

&mdss_dp3_phy {
	vdda-phy-supply = <&vreg_l3j>;
	vdda-pll-supply = <&vreg_l2j>;

	status = "okay";
};

&pcie3 {
	pinctrl-0 = <&pcie3_default>;
	pinctrl-names = "default";

	/* The RTS5261 chip on the other side only does Gen1x1 anyway */
	max-link-speed = <1>;
	status = "okay";
};

&pcie3_phy {
	vdda-phy-supply = <&vreg_l3c>;
	vdda-pll-supply = <&vreg_l3e>;

	status = "okay";
};

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

&pcie4 {
	status = "okay";
};

&pcie4_phy {
	vdda-phy-supply = <&vreg_l3i>;
	vdda-pll-supply = <&vreg_l3e>;

	status = "okay";
};

&pcie4_port0 {
	reset-gpios = <&tlmm 146 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 148 GPIO_ACTIVE_LOW>;

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

		vddaon-supply = <&vreg_pmu_aon_0p59>;
		vddwlcx-supply = <&vreg_pmu_wlcx_0p8>;
		vddwlmx-supply = <&vreg_pmu_wlmx_0p85>;
		vddrfacmn-supply = <&vreg_pmu_rfa_cmn>;
		vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>;
		vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>;
		vddrfa1p8-supply = <&vreg_pmu_rfa_1p8>;
		vddpcie0p9-supply = <&vreg_pmu_pcie_0p9>;
		vddpcie1p8-supply = <&vreg_pmu_pcie_1p8>;
	};
};

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

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

	status = "okay";
};

&pcie6a_phy {
	vdda-phy-supply = <&vreg_l1d>;
	vdda-pll-supply = <&vreg_l2j>;

	status = "okay";
};

&pcie6a_port0 {
	reset-gpios = <&tlmm 152 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 154 GPIO_ACTIVE_LOW>;
};

&pm8550_gpios {
	rtmr0_default: rtmr0-reset-n-active-state {
		pins = "gpio10";
		function = "normal";
		power-source = <1>; /* 1.8V */
	};

	rtmr0_3p3_reg_en: rtmr0-3p3-reg-en-state {
		pins = "gpio11";
		function = "normal";
		power-source = <1>; /* 1.8V */
	};
};

&pm8550ve_9_gpios {
	rtmr0_1p8_reg_en: rtmr0-1p8-reg-en-state {
		pins = "gpio8";
		function = "normal";
		power-source = <1>; /* 1.8V */
	};
};

&pmc8380_3_gpios {
	edp_bl_en: edp-bl-en-state {
		pins = "gpio4";
		function = "normal";
		power-source = <1>; /* 1.8V */
		input-disable;
		output-enable;
	};
};

&pmc8380_5_gpios {
	rtmr0_1p15_reg_en: rtmr0-1p15-reg-en-state {
		pins = "gpio8";
		function = "normal";
		power-source = <1>; /* 1.8V */
	};
};

&pmk8550_pwm {
	status = "okay";
};

&pmk8550_gpios {
	edp_bl_pwm: edp-bl-pwm-state {
		pins = "gpio5";
		function = "func3";
	};
};

&qupv3_0 {
	status = "okay";
};

&qupv3_1 {
	status = "okay";
};

&qupv3_2 {
	status = "okay";
};

&remoteproc_adsp {
	firmware-name = "qcom/x1e80100/microsoft/Romulus/qcadsp8380.mbn",
			"qcom/x1e80100/microsoft/Romulus/adsp_dtbs.elf";

	status = "okay";
};

&remoteproc_cdsp {
	firmware-name = "qcom/x1e80100/microsoft/Romulus/qccdsp8380.mbn",
			"qcom/x1e80100/microsoft/Romulus/cdsp_dtbs.elf";

	status = "okay";
};

&smb2360_0 {
	status = "okay";
};

&smb2360_0_eusb2_repeater {
	vdd18-supply = <&vreg_l3d>;
	vdd3-supply = <&vreg_l2b>;
};

&smb2360_1 {
	status = "okay";
};

&smb2360_1_eusb2_repeater {
	vdd18-supply = <&vreg_l3d>;
	vdd3-supply = <&vreg_l14b>;
};

&smb2360_2 {
	status = "okay";
};

&smb2360_2_eusb2_repeater {
	vdd18-supply = <&vreg_l3d>;
	vdd3-supply = <&vreg_l8b>;
};

&swr0 {
	pinctrl-0 = <&wsa_swr_active>, <&spkr_01_sd_n_active>;
	pinctrl-names = "default";

	status = "okay";

	/* WSA8845, Left speaker */
	left_spkr: speaker@0,0 {
		compatible = "sdw20217020400";
		reg = <0 0>;
		reset-gpios = <&lpass_tlmm 12 GPIO_ACTIVE_LOW>;
		#sound-dai-cells = <0>;
		sound-name-prefix = "SpkrLeft";
		vdd-1p8-supply = <&vreg_l15b>;
		vdd-io-supply = <&vreg_l12b>;
		qcom,port-mapping = <1 2 3 7 10 13>;
	};

	/* WSA8845, Right speaker */
	right_spkr: speaker@0,1 {
		compatible = "sdw20217020400";
		reg = <0 1>;
		reset-gpios = <&lpass_tlmm 12 GPIO_ACTIVE_LOW>;
		#sound-dai-cells = <0>;
		sound-name-prefix = "SpkrRight";
		vdd-1p8-supply = <&vreg_l15b>;
		vdd-io-supply = <&vreg_l12b>;
		qcom,port-mapping = <4 5 6 7 11 13>;
	};
};

&swr1 {
	status = "okay";

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

&swr2 {
	status = "okay";

	/* WCD9385 TX */
	wcd_tx: codec@0,3 {
		compatible = "sdw20217010d00";
		reg = <0 3>;
		qcom,tx-port-mapping = <2 2 3 4>;
	};
};

&tcsr {
	vdda-qrefrpt0-0p9-supply = <&vreg_l3c>;
	vdda-qrefrpt1-0p9-supply = <&vreg_l3i>;
	vdda-qrefrpt2-0p9-supply = <&vreg_l3i>;
	vdda-qrefrpt3-0p9-supply = <&vreg_l3j>;
	vdda-qrefrpt4-0p9-supply = <&vreg_l1d>;
	vdda-qrefrx0-0p9-supply = <&vreg_l3c>;
	vdda-qrefrx1-0p9-supply = <&vreg_l3i>;
	vdda-qrefrx2-0p9-supply = <&vreg_l3i>;
	vdda-qrefrx3-0p9-supply = <&vreg_l3j>;
	vdda-qrefrx4-0p9-supply = <&vreg_l1d>;
	vdda-qreftx0-0p9-supply = <&vreg_l3j>;
	vdda-qreftx0-1p2-supply = <&vreg_l2j>;
	vdda-qreftx1-0p9-supply = <&vreg_l3j>;
	vdda-qreftx1-1p2-supply = <&vreg_l3e>;
	vdda-refgen0-0p9-supply = <&vreg_l3i>;
	vdda-refgen0-1p2-supply = <&vreg_l3e>;
	vdda-refgen2-0p9-supply = <&vreg_l3j>;
	vdda-refgen2-1p2-supply = <&vreg_l2j>;
};

&tlmm {
	gpio-reserved-ranges = <44 4>, /* SPI (TPM) */
			       <238 1>; /* UFS Reset */

	hall_int_n_default: hall-int-n-state {
		pins = "gpio2";
		function = "gpio";
		bias-disable;
	};

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

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

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

	wcn_wlan_bt_en: wcn-wlan-bt-en-state {
		pins = "gpio116", "gpio117";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	pcie3_default: pcie3-default-state {
		perst-n-pins {
			pins = "gpio143";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		clkreq-n-pins {
			pins = "gpio144";
			function = "pcie3_clk";
			drive-strength = <2>;
			bias-pull-up;
		};

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

	pcie6a_default: pcie6a-default-state {
		perst-n-pins {
			pins = "gpio152";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		clkreq-n-pins {
			pins = "gpio153";
			function = "pcie6a_clk";
			drive-strength = <2>;
			bias-pull-up;
		};

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

	rtmr1_1p8_reg_en: rtmr1-1p8-reg-en-state {
		pins = "gpio175";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	rtmr1_3p3_reg_en: rtmr1-3p3-reg-en-state {
		pins = "gpio186";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	rtmr1_1p15_reg_en: rtmr1-1p15-reg-en-state {
		pins = "gpio188";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	wcd_default: wcd-reset-n-active-state {
		pins = "gpio191";
		function = "gpio";
		drive-strength = <16>;
		bias-disable;
		output-low;
	};

	wcn_sw_en: wcn-sw-en-state {
		pins = "gpio214";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	cam_indicator_en: cam-indicator-en-state {
		pins = "gpio225";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};
};

&uart2 {
	status = "okay";

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

		interrupts-extended = <&tlmm 91 IRQ_TYPE_EDGE_RISING>;

		current-speed = <4000000>;

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

&uart14 {
	status = "okay";

	bluetooth {
		compatible = "qcom,wcn7850-bt";
		max-speed = <3200000>;

		vddaon-supply = <&vreg_pmu_aon_0p59>;
		vddwlcx-supply = <&vreg_pmu_wlcx_0p8>;
		vddwlmx-supply = <&vreg_pmu_wlmx_0p85>;
		vddrfacmn-supply = <&vreg_pmu_rfa_cmn>;
		vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>;
		vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>;
		vddrfa1p8-supply = <&vreg_pmu_rfa_1p8>;
	};
};

&usb_1_ss0_hsphy {
	vdd-supply = <&vreg_l3j>;
	vdda12-supply = <&vreg_l2j>;

	phys = <&smb2360_0_eusb2_repeater>;

	status = "okay";
};

&usb_1_ss0_qmpphy {
	vdda-phy-supply = <&vreg_l1j>;
	vdda-pll-supply = <&vreg_l2j>;

	status = "okay";
};

&usb_1_ss0 {
	dr_mode = "host";

	status = "okay";
};

&usb_1_ss0_dwc3_hs {
	remote-endpoint = <&pmic_glink_ss0_hs_in>;
};

&usb_1_ss0_qmpphy_out {
	remote-endpoint = <&retimer_ss0_ss_in>;
};

&usb_1_ss1_hsphy {
	vdd-supply = <&vreg_l3j>;
	vdda12-supply = <&vreg_l2j>;

	phys = <&smb2360_1_eusb2_repeater>;

	status = "okay";
};

&usb_1_ss1_qmpphy {
	vdda-phy-supply = <&vreg_l2d>;
	vdda-pll-supply = <&vreg_l2j>;

	status = "okay";
};

&usb_1_ss1 {
	dr_mode = "host";

	status = "okay";
};

&usb_1_ss1_dwc3_hs {
	remote-endpoint = <&pmic_glink_ss1_hs_in>;
};

&usb_1_ss1_qmpphy_out {
	remote-endpoint = <&retimer_ss1_ss_in>;
};

/* MP0 goes to the Surface Connector, MP1 goes to the USB-A port */
&usb_mp {
	status = "okay";
};

&usb_mp_hsphy0 {
	vdd-supply = <&vreg_l2e>;
	vdda12-supply = <&vreg_l2j>;

	phys = <&smb2360_2_eusb2_repeater>;

	status = "okay";
};

&usb_mp_hsphy1 {
	vdd-supply = <&vreg_l2e>;
	vdda12-supply = <&vreg_l2j>;

	phys = <&ptn3222>;

	status = "okay";
};

&usb_mp_qmpphy0 {
	vdda-phy-supply = <&vreg_l3c>;
	vdda-pll-supply = <&vreg_l3e>;

	status = "okay";
};

&usb_mp_qmpphy1 {
	vdda-phy-supply = <&vreg_l3c>;
	vdda-pll-supply = <&vreg_l3e>;

	status = "okay";
};