#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/iio/qti_power_supply_iio.h>

#include "pm6350.dtsi"
#include "pm7250b.dtsi"
#include "pm6150l.dtsi"

#define PMK8350_SID	6

#include "pmk8350.dtsi"

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

&pm7250b_vadc {
	charger_skin_therm {
		reg = <ADC5_AMUX_THM1_100K_PU>;
		label = "charger_skin_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	conn_therm {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		label = "conn_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};
};

&pm7250b_adc_tm {
	io-channels = <&pm7250b_vadc ADC5_AMUX_THM1_100K_PU>,
			<&pm7250b_vadc ADC5_AMUX_THM3_100K_PU>;

	/* Channel nodes */
	charger_skin_therm {
		reg = <ADC5_AMUX_THM1_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	conn_therm {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&pm6150l_vadc {
	pinctrl-names = "default";
	pinctrl-0 = <
			&rfc_cam_therm_default
			&rear_cam_flash_therm_default
			&quiet_therm_default>;

	pa_therm2 {
		reg = <ADC5_AMUX_THM1_100K_PU>;
		label = "pa_therm2";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	msm_therm {
		reg = <ADC5_AMUX_THM2_100K_PU>;
		label = "msm_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	pa_therm1 {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		label = "pa_therm1";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	rfc_cam_therm {
		reg = <ADC5_GPIO2_100K_PU>;
		label = "rfc_cam_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	rear_cam_flash_therm {
		reg = <ADC5_GPIO3_100K_PU>;
		label = "rear_cam_flash_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	quiet_therm {
		reg = <ADC5_GPIO4_100K_PU>;
		label = "quiet_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};
};

&pm6150l_gpios {
	rfc_cam_therm {
		rfc_cam_therm_default: rfc_cam_therm_default {
			pins = "gpio6";
			bias-high-impedance;
		};
	};

	rear_cam_flash_therm {
		rear_cam_flash_therm_default: rear_cam_flash_therm_default {
			pins = "gpio7";
			bias-high-impedance;
		};
	};

	quiet_therm {
		quiet_therm_default: quiet_therm_default {
			pins = "gpio10";
			bias-high-impedance;
		};
	};
};

&pm6150l_adc_tm {
	io-channels = <&pm6150l_vadc ADC5_AMUX_THM1_100K_PU>,
			<&pm6150l_vadc ADC5_AMUX_THM3_100K_PU>,
			<&pm6150l_vadc ADC5_GPIO3_100K_PU>,
			<&pm6150l_vadc ADC5_GPIO4_100K_PU>;

	/* Channel nodes */
	pa_therm1 {
		reg = <ADC5_AMUX_THM1_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	pa_therm0 {
		reg = <ADC5_AMUX_THM3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	rear_cam_flash_therm {
		reg = <ADC5_GPIO3_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	quiet_therm {
		reg = <ADC5_GPIO4_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&spmi_bus {
	qcom,pm6150l@4 {
		pm6150l_adc_tm_iio: adc_tm@3400 {
			compatible = "qcom,adc-tm5-iio";
			reg = <0x3400>;
			#thermal-sensor-cells = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			io-channels = <&pm6150l_vadc ADC5_AMUX_THM2_100K_PU>,
					<&pm6150l_vadc ADC5_GPIO2_100K_PU>;

			msm_therm {
				reg = <ADC5_AMUX_THM2_100K_PU>;
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
			};

			rfc_cam_therm {
				reg = <ADC5_GPIO2_100K_PU>;
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
			};
		};
	};
};

&pmk8350 {
	reg = <6 SPMI_USID>;

	pon_pbs@800 {
		status = "disabled";
	};

	pon_hlos@1300 {
		status = "disabled";
	};
};

&pmk8350_rtc {
	interrupts = <0x6 0x62 0x1 IRQ_TYPE_EDGE_RISING>;
};

&pmk8350_vadc {
	interrupts = <0x6 0x31 0x0 IRQ_TYPE_EDGE_RISING>;

	/delete-node/ pm8350_ref_gnd;
	/delete-node/ pm8350_vref_1p25;
	/delete-node/ pm8350_die_temp;
	/delete-node/ pm8350_vph_pwr;

	/delete-node/ pm8350b_ref_gnd;
	/delete-node/ pm8350b_vref_1p25;
	/delete-node/ pm8350b_die_temp;
	/delete-node/ pm8350b_vph_pwr;
	/delete-node/ pm8350b_vbat_sns;

	/delete-node/ pmr735a_ref_gnd;
	/delete-node/ pmr735a_vref_1p25;
	/delete-node/ pmr735a_die_temp;

	/delete-node/ pmr735b_ref_gnd;
	/delete-node/ pmr735b_vref_1p25;
	/delete-node/ pmr735b_die_temp;
};

&pmk8350_adc_tm {
	interrupts = <0x6 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
	io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;

	xo_therm {
		reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&flash_led {
	status = "ok";
	io-channels = <&pm7250b_qg PSY_IIO_RESISTANCE>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_OCV>,
		      <&pm7250b_qg PSY_IIO_CURRENT_NOW>,
		      <&pm7250b_charger PSY_IIO_FLASH_TRIGGER>,
		      <&pm7250b_charger PSY_IIO_FLASH_ACTIVE>;
	io-channel-names = "rbatt",
			   "voltage_ocv",
			   "current_now",
			   "flash_trigger",
			   "flash_active";
};

&pm6150l_wled {
	io-channels = <&pm7250b_qg PSY_IIO_RESISTANCE>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_OCV>,
		      <&pm7250b_qg PSY_IIO_CURRENT_NOW>;
	io-channel-names = "rbatt",
			   "voltage_ocv",
			   "current_now";
};

&thermal_zones {
	chg-skin-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm7250b_adc_tm ADC5_AMUX_THM1_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	conn-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm7250b_adc_tm ADC5_AMUX_THM3_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	sdm-skin-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm_iio ADC5_AMUX_THM2_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	rfc-cam-pa3-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm_iio ADC5_GPIO2_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	camera-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm ADC5_GPIO3_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	quiet-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm ADC5_GPIO4_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pa-therm0-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm ADC5_AMUX_THM3_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pa-therm1-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm6150l_adc_tm ADC5_AMUX_THM1_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	xo-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pmk8350_adc_tm PMK8350_ADC7_AMUX_THM1_100K_PU>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};
};

&qupv3_se10_i2c {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "ok";

	pm8008_8: qcom,pm8008@8 {
		compatible = "qcom,i2c-pmic";
		reg = <0x8>;
		#address-cells = <1>;
		#size-cells = <0>;
		pinctrl-names = "default";
		pinctrl-0 = <&pm8008_active>;

		pm8008_chip: qcom,pm8008-chip@900 {
			compatible = "qcom,pm8008-chip";
			reg = <0x900>;

			PM8008_EN: qcom,pm8008-chip-en {
				regulator-name = "pm8008-chip-en";
			};
		};

		qcom,revid@100 {
			compatible = "qcom,qpnp-revid";
			reg = <0x100>;
		};
	};

	pm8008_9: qcom,pm8008@9 {
		compatible = "qcom,i2c-pmic";
		reg = <0x9>;
		#address-cells = <1>;
		#size-cells = <0>;

		pm8008_regulators: qcom,pm8008-regulator {
			compatible = "qcom,pm8008-regulator";
			#address-cells = <1>;
			#size-cells = <0>;
			pm8008_en-supply = <&PM8008_EN>;

			vdd_l1_l2-supply = <&S8E>;
			vdd_l3_l4-supply = <&BOB>;
			vdd_l5-supply = <&BOB>;
			vdd_l6-supply = <&S2A>;
			vdd_l7-supply = <&BOB>;

			L1P: qcom,pm8008-l1@4000 {
				reg = <0x4000>;
				regulator-name = "pm8008_l1";
				regulator-min-microvolt = <528000>;
				regulator-max-microvolt = <1200000>;
				qcom,min-dropout-voltage = <120000>;
				qcom,hpm-min-load = <10000>;
			};

			L2P: qcom,pm8008-l2@4100 {
				reg = <0x4100>;
				regulator-name = "pm8008_l2";
				regulator-min-microvolt = <528000>;
				regulator-max-microvolt = <1056000>;
				qcom,min-dropout-voltage = <200000>;
				qcom,hpm-min-load = <10000>;
			};

			L3P: qcom,pm8008-l3@4200 {
				reg = <0x4200>;
				regulator-name = "pm8008_l3";
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <192000>;
				qcom,hpm-min-load = <10000>;
			};

			L4P: qcom,pm8008-l4@4300 {
				reg = <0x4300>;
				regulator-name = "pm8008_l4";
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <160000>;
				qcom,hpm-min-load = <10000>;
			};

			L5P: qcom,pm8008-l5@4400 {
				reg = <0x4400>;
				regulator-name = "pm8008_l5";
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <296000>;
				qcom,hpm-min-load = <10000>;
			};

			L6P: qcom,pm8008-l6@4400 {
				reg = <0x4500>;
				regulator-name = "pm8008_l6";
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <1800000>;
				qcom,min-dropout-voltage = <72000>;
				qcom,hpm-min-load = <10000>;
			};

			L7P: qcom,pm8008-l7@4400 {
				reg = <0x4600>;
				regulator-name = "pm8008_l7";
				regulator-min-microvolt = <1500000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <112000>;
				qcom,hpm-min-load = <10000>;
			};
		};
	};
};
