#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/iio/qcom,spmi-vadc.h>
#include <dt-bindings/input/input.h>
#include "bengal-thermal-overlay.dtsi"
#include "camera/khaje-camera-sensor-qrd.dtsi"
#include "bengal-audio-overlay.dtsi"
#include "khaje-sde-display.dtsi"

&pm6125_gpios {
	key_vol_up {
		key_vol_up_default: key_vol_up_default {
			pins = "gpio5";
			function = "normal";
			input-enable;
			bias-pull-up;
			power-source = <0>;
		};
	};

	eldo9_pin {
		usb_eldo9:gpio@c000 {
			pins = "gpio1";
			function = "normal";
			qcom,drive-strength = <2>;
			power-source = <0>;
			bias-disable;
			output-high;
		};
	};
};

&soc {
	gpio_keys {
		compatible = "gpio-keys";
		label = "gpio-keys";

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

		vol_up {
			label = "volume_up";
			gpios = <&pm6125_gpios 5 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEUP>;
			linux,can-disable;
			debounce-interval = <15>;
			gpio-key,wakeup;
		};
	};

	vdda_usb_ss_dp_core: vdda_usb_ss_dp_core {
		compatible = "regulator-fixed";
		regulator-name = "vdd_supply";
		regulator-min-microvolt = <880000>;
		regulator-max-microvolt = <880000>;
		enable-active-high;
		gpio = <&pm6125_gpios 1 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&usb_eldo9>;
	};
};

&usb_qmp_dp_phy {
	vdd-supply = <&vdda_usb_ss_dp_core>;
};

&qupv3_se1_i2c {
	awinic@64 {
		compatible = "awinic,aw2016_led";
		reg = <0x64>;

		awinic,red {
			awinic,name = "red";
			awinic,id = <0>;
			awinic,imax = <2>;
			awinic,led-current = <3>;
			awinic,max-brightness = <255>;
			awinic,rise-time-ms = <6>;
			awinic,hold-time-ms = <0>;
			awinic,fall-time-ms = <6>;
			awinic,off-time-ms = <4>;
		};

		awinic,green {
			awinic,name = "green";
			awinic,id = <1>;
			awinic,imax = <2>;
			awinic,led-current = <3>;
			awinic,max-brightness = <255>;
			awinic,rise-time-ms = <6>;
			awinic,hold-time-ms = <0>;
			awinic,fall-time-ms = <6>;
			awinic,off-time-ms = <4>;
		};

		awinic,blue {
			awinic,name = "blue";
			awinic,id = <2>;
			awinic,imax = <2>;
			awinic,led-current = <3>;
			awinic,max-brightness = <255>;
			awinic,rise-time-ms = <6>;
			awinic,hold-time-ms = <0>;
			awinic,fall-time-ms = <6>;
			awinic,off-time-ms = <4>;
		};

	};
};

&bengal_snd {
	qcom,model = "bengal-qrd-snd-card";
	qcom,msm-mi2s-master = <1>, <1>, <1>, <1>;
	qcom,wcn-btfm = <1>;
	qcom,ext-disp-audio-rx = <0>;
	qcom,audio-routing =
		"AMIC1", "MIC BIAS1",
		"MIC BIAS1", "Analog Mic1",
		"AMIC2", "MIC BIAS2",
		"MIC BIAS2", "Analog Mic2",
		"AMIC3", "MIC BIAS3",
		"MIC BIAS3", "Analog Mic3",
		"AMIC4", "MIC BIAS3",
		"MIC BIAS3", "Analog Mic4",
		"IN1_HPHL", "HPHL_OUT",
		"IN2_HPHR", "HPHR_OUT",
		"IN3_AUX", "AUX_OUT",
		"SpkrMono WSA_IN", "AUX",
		"TX SWR_MIC0", "ADC1_OUTPUT",
		"TX SWR_MIC4", "ADC2_OUTPUT",
		"TX SWR_MIC5", "ADC3_OUTPUT",
		"TX SWR_MIC0", "VA_TX_SWR_CLK",
		"TX SWR_MIC1", "VA_TX_SWR_CLK",
		"TX SWR_MIC2", "VA_TX_SWR_CLK",
		"TX SWR_MIC3", "VA_TX_SWR_CLK",
		"TX SWR_MIC4", "VA_TX_SWR_CLK",
		"TX SWR_MIC5", "VA_TX_SWR_CLK",
		"TX SWR_MIC6", "VA_TX_SWR_CLK",
		"TX SWR_MIC7", "VA_TX_SWR_CLK",
		"TX SWR_MIC8", "VA_TX_SWR_CLK",
		"TX SWR_MIC9", "VA_TX_SWR_CLK",
		"TX SWR_MIC10", "VA_TX_SWR_CLK",
		"TX SWR_MIC11", "VA_TX_SWR_CLK",
		"RX_TX DEC0_INP", "TX DEC0 MUX",
		"RX_TX DEC1_INP", "TX DEC1 MUX",
		"RX_TX DEC2_INP", "TX DEC2 MUX",
		"RX_TX DEC3_INP", "TX DEC3 MUX",
		"TX_AIF1 CAP", "VA_TX_SWR_CLK",
		"TX_AIF2 CAP", "VA_TX_SWR_CLK",
		"TX_AIF3 CAP", "VA_TX_SWR_CLK",
		"VA SWR_MIC0", "ADC1_OUTPUT",
		"VA SWR_MIC4", "ADC2_OUTPUT",
		"VA SWR_MIC5", "ADC3_OUTPUT";
	qcom,msm-mbhc-hphl-swh = <1>;
	qcom,msm-mbhc-gnd-swh = <1>;
	asoc-codec  = <&stub_codec>, <&bolero>;
	asoc-codec-names = "msm-stub-codec.1", "bolero_codec";
	qcom,wsa-max-devs = <1>;
	qcom,wsa-devs = <&wsa881x_i2c_e>;
	qcom,wsa-aux-dev-prefix = "SpkrMono";
	qcom,codec-max-aux-devs = <1>;
	qcom,codec-aux-devs = <&wcd937x_codec>;
	qcom,msm_audio_ssr_devs = <&audio_apr>, <&q6core>, <&bolero>,
				<&lpi_tlmm>;
};

&qupv3_se1_i2c {
	status = "ok";
	#address-cells = <1>;
	#size-cells = <0>;
	nq@28 {
		compatible = "qcom,nq-nci";
		reg = <0x28>;
		qcom,nq-irq = <&tlmm 70 0x00>;
		qcom,nq-ven = <&tlmm 69 0x00>;
		qcom,nq-firm = <&tlmm 31 0x00>;
		qcom,nq-clkreq = <&tlmm 71 0x00>;
		interrupt-parent = <&tlmm>;
		interrupts = <70 0>;
		interrupt-names = "nfc_irq";
		pinctrl-names = "nfc_active", "nfc_suspend";
		pinctrl-0 = <&nfc_int_active &nfc_enable_active
				&nfc_clk_req_active>;
		pinctrl-1 = <&nfc_int_suspend &nfc_enable_suspend
				&nfc_clk_req_suspend>;
	};
};

&sdhc_1 {
	vdd-supply = <&L24A>;
	qcom,vdd-voltage-level = <2960000 2960000>;
	qcom,vdd-current-level = <0 570000>;

	vdd-io-supply = <&L11A>;
	qcom,vdd-io-always-on;
	qcom,vdd-io-lpm-sup;
	qcom,vdd-io-voltage-level = <1800000 1800000>;
	qcom,vdd-io-current-level = <0 325000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on
					&sdc1_rclk_on>;
	pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off
					&sdc1_rclk_off>;

	status = "ok";
};

&sdhc_2 {
	vdd-supply = <&L22A>;
	qcom,vdd-voltage-level = <2960000 2960000>;
	qcom,vdd-current-level = <0 800000>;

	vdd-io-supply = <&L5A>;
	qcom,vdd-io-voltage-level = <1800000 2960000>;
	qcom,vdd-io-current-level = <0 22000>;

	vdd-io-bias-supply = <&L7A>;
	qcom,vdd-io-bias-voltage-level = <1256000 1256000>;
	qcom,vdd-io-bias-current-level = <0 6000>;

	pinctrl-names = "active", "sleep";
	pinctrl-0 = <&sdc2_clk_on  &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
	pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;

	cd-gpios = <&tlmm 88 GPIO_ACTIVE_LOW>;

	status = "ok";
};

&ufsphy_mem {
	compatible = "qcom,ufs-phy-qmp-v4";

	vdda-phy-supply = <&L4A>; /* 0.9v */
	vdda-pll-supply = <&L18A>; /* 1.8v */
	vdda-phy-max-microamp = <85700>;
	vdda-pll-max-microamp = <18300>;

	status = "ok";
};

&ufshc_mem {
	vdd-hba-supply = <&gcc_ufs_phy_gdsc>;
	vdd-hba-fixed-regulator;
	vcc-supply = <&L24A>;
	vcc-voltage-level = <2950000 2960000>;
	vccq2-supply = <&L11A>;
	vccq2-voltage-level = <1800000 1800000>;
	vcc-max-microamp = <800000>;
	vccq2-max-microamp = <800000>;
	vccq2-pwr-collapse-sup;

	qcom,vddp-ref-clk-supply = <&L18A>;
	qcom,vddp-ref-clk-max-microamp = <100>;
	qcom,vddp-ref-clk-min-uV = <1232000>;
	qcom,vddp-ref-clk-max-uV = <1232000>;

	status = "ok";
};

&pm6125_pwm {
	status = "ok";
};

&dsi_td4330_truly_v2_video {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply_no_labibb>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
	pwms = <&pm6125_pwm 0 0>;
	qcom,bl-pmic-pwm-period-usecs = <100>;
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-reset-gpio = <&tlmm 82 0>;
};

&dsi_td4330_truly_v2_cmd {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply_no_labibb>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_pwm";
	pwms = <&pm6125_pwm 0 0>;
	qcom,bl-pmic-pwm-period-usecs = <100>;
	qcom,mdss-dsi-bl-min-level = <1>;
	qcom,mdss-dsi-bl-max-level = <4095>;
	qcom,platform-te-gpio = <&tlmm 81 0>;
	qcom,platform-reset-gpio = <&tlmm 82 0>;
};

&dsi_sim_vid {
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply_no_labibb>;
	qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_dcs";
	qcom,platform-reset-gpio = <&tlmm 82 0>;
};

&sde_dsi {
	qcom,dsi-default-panel = <&dsi_td4330_truly_v2_video>;
};

&qupv3_se2_i2c {
	status = "okay";
	qcom,i2c-touch-active="synaptics,tcm-i2c";

	synaptics_tcm@20 {
		compatible = "synaptics,tcm-i2c";
		reg = <0x20>;
		interrupt-parent = <&tlmm>;
		interrupts = <80 0x2008>;
		pinctrl-names = "pmx_ts_active","pmx_ts_suspend",
			"pmx_ts_release";
		pinctrl-0 = <&ts_int_active &ts_reset_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&ts_release>;
		synaptics,irq-gpio = <&tlmm 80 0x2008>;
		synaptics,irq-on-state = <0>;
		synaptics,reset-gpio = <&tlmm 86 0x00>;
		synaptics,reset-on-state = <0>;
		synaptics,reset-active-ms = <20>;
		synaptics,reset-delay-ms = <200>;
		synaptics,power-delay-ms = <200>;
		synaptics,ubl-i2c-addr = <0x20>;
		synaptics,extend_report;
		synaptics,firmware-name = "synaptics_firmware_k.img";

		panel = <&dsi_td4330_truly_v2_video &dsi_td4330_truly_v2_cmd>;
	};
};

&thermal_zones {
	quiet-thermal-step {
		polling-delay-passive = <2000>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm6125_adc_tm ADC_AMUX_THM2_PU2>;
		wake-capable-sensor;

		trips {
			quiet_batt_trip0: batt-trip0 {
				temperature = <41000>;
				hysteresis = <2000>;
				type = "passive";
			};

			quiet_modem_trip0: modem-trip0 {
				temperature = <42000>;
				hysteresis = <2000>;
				type = "passive";
			};

			quiet_batt_trip1: batt-trip1 {
				temperature = <43000>;
				hysteresis = <2000>;
				type = "passive";
			};

			quiet_batt_trip2: batt-trip2 {
				temperature = <45000>;
				hysteresis = <2000>;
				type = "passive";
			};

			quiet_gold_trip: gold-trip {
				temperature = <47000>;
				hysteresis = <0>;
				type = "passive";
			};

			quiet_batt_trip3: batt-trip3 {
				temperature = <47000>;
				hysteresis = <2000>;
				type = "passive";
			};

			quiet_batt_trip4: batt-trip4 {
				temperature = <48000>;
				hysteresis = <1000>;
				type = "passive";
			};

			quiet_gpu_trip: gpu-trip {
				temperature = <48000>;
				hysteresis = <4000>;
				type = "passive";
			};

			quiet_silver_trip: silver-trip {
				temperature = <50000>;
				hysteresis = <0>;
				type = "passive";
			};

			quiet_hvx_trip: hvx-trip {
				temperature = <52000>;
				hysteresis = <4000>;
				type = "passive";
			};

			quiet_modem_trip1: modem-trip1 {
				temperature = <60000>;
				hysteresis = <4000>;
				type = "passive";
			};
		};

		cooling-maps {
			gold_cdev {
				trip = <&quiet_gold_trip>;
				/* limit to 1766400khz */
				cooling-device = <&CPU4 THERMAL_NO_LIMIT
							(THERMAL_MAX_LIMIT-4)>;
			};

			silver_cdev {
				trip = <&quiet_silver_trip>;
				/* limit to 1516800khz */
				cooling-device = <&CPU0 THERMAL_NO_LIMIT
							(THERMAL_MAX_LIMIT-4)>;
			};

			gpu_cdev {
				trip = <&quiet_gpu_trip>;
				/* limit 785000000hz */
				cooling-device = <&msm_gpu THERMAL_NO_LIMIT
							(THERMAL_MAX_LIMIT-3)>;
			};

			hvx_cdev {
				trip = <&quiet_hvx_trip>;
				cooling-device = <&cdsp_sw 4 4>;
			};

			mdm_cdev0 {
				trip = <&quiet_modem_trip0>;
				cooling-device = <&modem_proc 1 1>;
			};

			mdm_cdev1 {
				trip = <&quiet_modem_trip1>;
				cooling-device = <&modem_proc 3 3>;
			};
		};
	};

	pa-therm0-step {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm6125_adc_tm ADC_AMUX_THM1_PU2>;
		wake-capable-sensor;

		trips {
			pa_therm0_trip0: pa-therm0-trip0 {
				temperature = <52000>;
				hysteresis = <2000>;
				type = "passive";
			};

			pa_therm0_trip1: pa-therm0-trip1 {
				temperature = <54000>;
				hysteresis = <2000>;
				type = "passive";
			};

			pa_therm0_trip2: pa-therm0-trip2 {
				temperature = <60000>;
				hysteresis = <4000>;
				type = "passive";
			};
		};

		cooling-maps {
			modem_cdev0 {
				trip = <&pa_therm0_trip0>;
				cooling-device = <&modem_pa 1 1>;
			};

			modem_cdev1 {
				trip = <&pa_therm0_trip1>;
				cooling-device = <&modem_pa 2 2>;
			};

			modem_cdev2 {
				trip = <&pa_therm0_trip2>;
				cooling-device = <&modem_pa 3 3>;
			};
		};
	};
};

&tlmm {
	fpc_reset_int: fpc_reset_int {
		fpc_reset_low: reset_low {
			mux {
				pins = "gpio104";
				function = "gpio";
			};

			config {
				pins = "gpio104";
				drive-strength = <2>;
				bias-disable;
				output-low;
			};
		};

		fpc_reset_high: reset_high {
			mux {
				pins = "gpio104";
				function = "gpio";
			};

			config {
				pins = "gpio104";
				drive-strength = <2>;
				bias-disable;
				output-high;
			};
		};

		fpc_int_low: int_low {
			mux {
				pins = "gpio97";
				function = "gpio";
			};

			config {
				pins = "gpio97";
				drive-strength = <2>;
				bias-pull-down;
				input-enable;
			};
		};
	};
};

&soc {
	fingerprint: fpc1020 {
		compatible = "fpc,fpc1020";
		interrupt-parent = <&tlmm>;
		interrupts = <97 0>;
		fpc,gpio_rst = <&tlmm 104 0>;
		fpc,gpio_irq = <&tlmm 97 0>;
		fpc,enable-on-boot;
		pinctrl-names = "fpc1020_reset_reset",
				"fpc1020_reset_active",
				"fpc1020_irq_active";
		pinctrl-0 = <&fpc_reset_low>;
		pinctrl-1 = <&fpc_reset_high>;
		pinctrl-2 = <&fpc_int_low>;
	};
};
