#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/iio/qcom,spmi-adc5-gen3-smb139x.h>

#include "pm8550.dtsi"
#include "pm8550b.dtsi"
#include "pm8550ve.dtsi"
#include "pm8550vs.dtsi"
#include "pmk8550.dtsi"
#include "pmr735d.dtsi"

&pm8550vs_d {
	status = "ok";
};

&pm8550vs_e {
	status = "ok";
};

&pm8550vs_g {
	status = "ok";
};

&pm8550vs_d_temp_alarm {
	status = "ok";
};

&pm8550vs_e_temp_alarm {
	status = "ok";
};

&pm8550vs_g_temp_alarm {
	status = "ok";
};

&spmi_bus {
	#address-cells = <2>;
	#size-cells = <0>;
	interrupt-controller;
	#interrupt-cells = <4>;

	pm8010_m: qcom,pm8010@c {
		compatible = "qcom,spmi-pmic";
		reg = <0xc SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		pm8010m_tz: pm8010-m-temp-alarm@2400 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0x2400>;
			interrupts = <0xc 0x24 0x0 IRQ_TYPE_EDGE_BOTH>;
			#thermal-sensor-cells = <0>;
		};
	};

	pm8010_n: qcom,pm8010@d {
		compatible = "qcom,spmi-pmic";
		reg = <0xd SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		pm8010n_tz: pm8010-n-temp-alarm@2400 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0x2400>;
			interrupts = <0xd 0x24 0x0 IRQ_TYPE_EDGE_BOTH>;
			#thermal-sensor-cells = <0>;
		};
	};
};

&pm8550_gpios {
	key_vol_up {
		key_vol_up_default: key_vol_up_default {
			pins = "gpio6";
			function = "normal";
			input-enable;
			bias-pull-up;
			power-source = <1>;
		};
	};

	sd_card_det {
		sd_card_det_default: sd_card_det_default {
			pins = "gpio12";
			function = "normal";
			input-enable;
			output-disable;
			bias-pull-up;
			power-source = <1>; /* 1.8 V */
		};
	};
};

&pmk8550_gpios {
	pinctrl-0 = <&alt_sleep_clk_default &explorer_sleep_clk_default>;
	pinctrl-names = "default";

	alt_sleep_clk {
		alt_sleep_clk_default: alt_sleep_clk_default {
			pins = "gpio3";
			function = "func1";
			input-disable;
			output-enable;
			bias-disable;
			power-source = <0>;
		};
	};

	explorer_sleep_clk {
		explorer_sleep_clk_default: explorer_sleep_clk_default {
			pins = "gpio5";
			function = "func1";
			input-disable;
			output-enable;
			bias-disable;
			power-source = <0>;
		};
	};
};

&pm8550vs_d_gpios {
	eusb2_repeater_reset {
		eusb2_repeater_reset_default: eusb2_repeater_reset_default {
			pins = "gpio4";
			function = "normal";
			input-enable;
			output-enable;
			bias-disable;
			power-source = <1>; /* 1.8V */
			qcom,drive-strength = <2>;
		};
	};
};

&pm8550_tz {
	io-channels = <&pmk8550_vadc PM8550_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550b_tz {
	io-channels = <&pmk8550_vadc PM8550B_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550b_lite_tz {
	io-channels = <&pmk8550_vadc PM8550B_ADC5_GEN3_TEMP_ALARM_LITE>;
	io-channel-names = "thermal";
};

&pm8550vs_c_tz {
	io-channels = <&pmk8550_vadc PM8550VS_C_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550vs_d_tz {
	io-channels = <&pmk8550_vadc PM8550VS_D_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550vs_e_tz {
	io-channels = <&pmk8550_vadc PM8550VS_E_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550vs_g_tz {
	io-channels = <&pmk8550_vadc PM8550VS_G_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pm8550ve_f_tz {
	io-channels = <&pmk8550_vadc PM8550VE_ADC5_GEN3_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pmk8550_vadc {
	pm8550_msm_therm {
		reg = <PM8550_ADC5_GEN3_AMUX_THM1_100K_PU>;
		label = "pm8550_msm_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550_cam_flash_therm {
		reg = <PM8550_ADC5_GEN3_AMUX_THM2_100K_PU>;
		label = "pm8550_cam_flash_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550_wlan_therm {
		reg = <PM8550_ADC5_GEN3_AMUX_THM3_100K_PU>;
		label = "pm8550_wlan_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550_pa_therm_1 {
		reg = <PM8550_ADC5_GEN3_AMUX_THM4_100K_PU>;
		label = "pm8550_pa_therm_1";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550_rear_tof_therm {
		reg = <PM8550_ADC5_GEN3_AMUX_THM5_100K_PU>;
		label = "pm8550_rear_tof_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550b_usb_therm {
		reg = <PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM_100K_PU>;
		label = "pm8550b_usb_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550b_wls_therm {
		reg = <PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10_100K_PU>;
		label = "pm8550b_wls_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
		qcom,adc-tm-type = <1>;
	};

	pm8550b_chg_temp {
		reg = <PM8550B_ADC5_GEN3_CHG_TEMP>;
		label = "pm8550b_chg_temp";
	};

	pm8550b_iin_fb {
		reg = <PM8550B_ADC5_GEN3_IIN_FB>;
		label = "pm8550b_iin_fb";
	};

	pm8550b_ichg_fb {
		reg = <PM8550B_ADC5_GEN3_ICHG_FB>;
		label = "pm8550b_ichg_fb";
	};

	smb139x_1_smb_temp {
		reg = <SMB1394_1_ADC5_GEN3_SMB_TEMP>;
		label = "smb139x_1_smb_temp";
	};

	smb139x_1_iin_smb {
		reg = <SMB1394_1_ADC5_GEN3_IIN_SMB>;
		label = "smb139x_1_iin_smb";
	};

	smb139x_1_ichg_smb {
		reg = <SMB1394_1_ADC5_GEN3_ICHG_SMB>;
		label = "smb139x_1_ichg_smb";
	};

	smb139x_2_smb_temp {
		reg = <SMB1394_2_ADC5_GEN3_SMB_TEMP>;
		label = "smb139x_2_smb_temp";
	};

	smb139x_2_iin_smb {
		reg = <SMB1394_2_ADC5_GEN3_IIN_SMB>;
		label = "smb139x_2_iin_smb";
	};

	smb139x_2_ichg_smb {
		reg = <SMB1394_2_ADC5_GEN3_ICHG_SMB>;
		label = "smb139x_2_ichg_smb";
	};
};

&thermal_zones {
	pm8010m_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm8010m_tz>;

		trips {
			trip0 {
				temperature = <95000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip1 {
				temperature = <115000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "critical";
			};
		};
	};

	pm8010n_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm8010n_tz>;

		trips {
			trip0 {
				temperature = <95000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip1 {
				temperature = <115000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "critical";
			};
		};
	};

	skin-msm-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550_ADC5_GEN3_AMUX_THM1_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	cam-flash-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550_ADC5_GEN3_AMUX_THM2_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	wlan-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550_ADC5_GEN3_AMUX_THM3_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pa-therm-1 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550_ADC5_GEN3_AMUX_THM4_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	rear-tof-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550_ADC5_GEN3_AMUX_THM5_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	usb-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550B_ADC5_GEN3_AMUX_THM4_USB_THERM_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	wls-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PM8550B_ADC5_GEN3_AMUX_THM6_GPIO10_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	xo-therm {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pmk8550_vadc PMK8550_ADC5_GEN3_AMUX_THM1_XO_THERM_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			active-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			xo_config0: xo-config0 {
				temperature = <78000>;
				hysteresis = <8000>;
				type = "passive";
			};

			xo_config1: xo-config1 {
				temperature = <80000>;
				hysteresis = <10000>;
				type = "passive";
			};

			display_test_config1: display-test-config1 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			display_test_config2: display-test-config2 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			display_test_config3: display-test-config3 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

			display_test_config4: display-test-config4 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};
};

&pm8550b_eusb2_repeater {
	vdd18-supply = <&pm_humu_l15>;
	vdd3-supply = <&pm_humu_l5>;
};

&pm8550b_haptics {
	nvmem-names = "hap_cfg_sdam";
	nvmem = <&pmk8550_sdam_46>;
};

&soc {
	reboot_reason {
		compatible = "qcom,reboot-reason";
		nvmem-cells = <&restart_reason>;
		nvmem-cell-names = "restart_reason";
	};

//#ifndef OPLUS_FEATURE_ESIM
//	DBO3: regulator-dbo3 {
//		compatible = "qti-regulator-fixed";
//		regulator-name = "dbo3";
//		regulator-min-microvolt = <3600000>;
//		regulator-max-microvolt = <3600000>;
//		gpio = <&pm8550_gpios 9 GPIO_ACTIVE_HIGH>;
//		regulator-enable-ramp-delay = <1500>;
//		enable-active-high;
//	};
//#endif /*OPLUS_FEATURE_ESIM*/

	pmic-pon-log {
		compatible = "qcom,pmic-pon-log";
		nvmem = <&pmk8550_sdam_5>, <&pmk8550_sdam_6>;
		nvmem-names = "pon_log0", "pon_log1";
	};

	regulator_ocp_notifier: regulator-ocp-notifier {
		compatible = "qcom,regulator-ocp-notifier";
		interrupt-parent = <&spmi_bus>;
		interrupts = <0x0 0x71 0x1 IRQ_TYPE_EDGE_RISING>;
		nvmem-cells = <&ocp_log>;
		nvmem-cell-names = "ocp_log";
	};
};
