#include <dt-bindings/clock/qcom,rpmh.h>
#include <dt-bindings/thermal/thermal_qti.h>
#include "pmi632.dtsi"

&soc {
	qcom,pmic_glink {
		status = "okay";
	};

	qcom,pmic_glink_log {
		compatible = "qcom,pmic-glink";
		qcom,pmic-glink-channel = "PMIC_LOGS_ADSP_APPS";

		qcom,battery_debug {
			compatible = "qcom,battery-debug";
		};

		qcom,charger_ulog_glink {
			compatible = "qcom,charger-ulog-glink";
		};

		spmi_glink_debug: qcom,spmi_glink_debug {
			compatible = "qcom,spmi-glink-debug";
			#address-cells = <1>;
			#size-cells = <0>;
			depends-on-supply = <&spmi0_bus>;

			/* Primary SPMI bus */
			spmi@0 {
				reg = <0>;
				#address-cells = <2>;
				#size-cells = <0>;

				qcom,pmi632-debug@2 {
					compatible = "qcom,spmi-pmic";
					reg = <2 SPMI_USID>;
					qcom,can-sleep;
				};
			};
		};
	};
};

&glink_edge {
	qcom,pmic_glink_rpmsg {
		qcom,glink-channels = "PMIC_RTR_ADSP_APPS";
	};

	qcom,pmic_glink_log_rpmsg {
		qcom,glink-channels = "PMIC_LOGS_ADSP_APPS";
		qcom,intents = <0x800  5
			0xc00 3
			0x2000 1>;
	};
};

&battery_charger {
	status = "okay";
};

&ucsi {
	status = "okay";
};

&altmode {
	status = "disabled";
};

&spmi0_debug_bus {
	qcom,pmi632-debug@2 {
		compatible = "qcom,spmi-pmic";
		reg = <2 SPMI_USID>;
		#address-cells = <2>;
		#size-cells = <0>;
		qcom,can-sleep;
	};

	qcom,pmi632-debug@3 {
		compatible = "qcom,spmi-pmic";
		reg = <3 SPMI_USID>;
		#address-cells = <2>;
		#size-cells = <0>;
		qcom,can-sleep;
	};
};

&pmi632_gpios {
	usb_conn_therm {
		usb_conn_therm_default: usb_conn_therm_default {
			pins = "gpio1";
			bias-high-impedance;
		};
	};

	charger_skin_temp {
		charger_skin_temp_default: charger_skin_temp_default {
			pins = "gpio3";
			bias-high-impedance;
		};
	};

	smb_skin_therm {
		smb_skin_therm_default: smb_skin_therm_default {
			pins = "gpio4";
			bias-high-impedance;
		};
	};
};

&pmi632_vadc {
	pinctrl-names = "default";
	pinctrl-0 = <&usb_conn_therm_default &charger_skin_temp_default
			&smb_skin_therm_default>;

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

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

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

&pmi632_adc_tm {
	io-channels = <&pmi632_vadc ADC5_GPIO1_100K_PU>,
			<&pmi632_vadc  ADC5_GPIO2_100K_PU>,
			<&pmi632_vadc  ADC5_GPIO3_100K_PU>;

	pmi632_usb_conn_therm {
		reg = <ADC5_GPIO1_100K_PU>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

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

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

};

&thermal_zones {
	socd {
		cooling-maps {
			socd_cpu_6_7 {
				trip = <&socd_trip>;
				cooling-device = <&cpu_6_7_pause 1 1>;
			};

			socd_gpu0 {
				trip = <&socd_trip>;
				cooling-device = <&msm_gpu 2 2>;
			};
		};
	};

	pmi632-bcl-lvl0 {
		cooling-maps {
			vbat_lte0 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&modem_lte_dsc 8 8>;
			};

			vbat_nr0_scg {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&modem_nr_scg_dsc 3 3>;
			};

			vbat_nr0 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&modem_nr_dsc 6 6>;
			};

			vbat_cpu_4 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&cpu4_pause 1 1>;
			};

			vbat_cpu_5 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&cpu5_pause 1 1>;
			};

			vbat_cpu_6 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&cpu6_pause 1 1>;
			};

			vbat_gpu0 {
				trip = <&b_bcl_lvl0>;
				cooling-device = <&msm_gpu 2 2>;
			};
		};
	};

	pmi632-bcl-lvl1 {
		cooling-maps {
			vbat_lte1 {
				trip = <&b_bcl_lvl1>;
				cooling-device = <&modem_lte_dsc 255 255>;
			};

			vbat_nr1_scg {
				trip = <&b_bcl_lvl1>;
				cooling-device = <&modem_nr_scg_dsc 255 255>;
			};

			vbat_nr1 {
				trip = <&b_bcl_lvl1>;
				cooling-device = <&modem_nr_dsc 255 255>;
			};

			vbat_cpu_7 {
				trip = <&b_bcl_lvl1>;
				cooling-device = <&cpu7_pause 1 1>;
			};

			vbat_gpu1 {
				trip = <&b_bcl_lvl1>;
				cooling-device = <&msm_gpu 4 4>;
			};
		};
	};

	pmi632-bcl-lvl2 {
		cooling-maps {
			vbat_gpu2 {
				trip = <&b_bcl_lvl2>;
				cooling-device = <&msm_gpu 3 THERMAL_NO_LIMIT>;
			};
		};
	};

	sys-therm-9 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors =  <&pmi632_adc_tm ADC5_GPIO1_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

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

	sys-therm-7 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors =  <&pmi632_adc_tm ADC5_GPIO2_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

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

	sys-therm-8 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors =  <&pmi632_adc_tm ADC5_GPIO3_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

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

&flash_led {
	qcom,use-qti-battery-interface;
};

&pmi632_lcdb {
	status = "ok";
};
