#include <dt-bindings/clock/qcom,rpmh.h>
#include <dt-bindings/thermal/thermal_qti.h>
#include "pm7250b.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,pm7250b-debug@8 {
					compatible = "qcom,spmi-pmic";
					reg = <8 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 = "okay";
};

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

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

&pm7250b_2 {
	/* Slave ID - 8 */
	reg = <8 SPMI_USID>;
};

&pm7250b_3 {
	/* Slave ID - 9 */
	reg = <9 SPMI_USID>;
};

&pm7250b_clkdiv {
	clocks = <&rpmhcc RPMH_CXO_CLK>;
};

&pm7250b_vadc {
	interrupts = <0x8 0x31 0x0 IRQ_TYPE_EDGE_RISING>;

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

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

&pm7250b_adc_tm {
	interrupts = <0x8 0x35 0x0 IRQ_TYPE_EDGE_RISING>;
	io-channels = <&pm7250b_vadc ADC5_AMUX_THM3_100K_PU>,
			<&pm7250b_vadc ADC5_AMUX_THM1_100K_PU>;

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

	pm7250b_charger_skin_therm {
		reg = <ADC5_AMUX_THM1_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>;
			};
		};
	};

	pm7250b-ibat-lvl0 {
		trips {
			ibat-lvl0 {
				temperature = <4000>;
			};
		};
	};

	pm7250b-ibat-lvl1 {
		trips {
			ibat-lvl1 {
				temperature = <5000>;
			};
		};
	};

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

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

	pm7250b-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 =  <&pm7250b_adc_tm ADC5_AMUX_THM3_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 =  <&pm7250b_adc_tm ADC5_AMUX_THM1_100K_PU>;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};

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

&pm7250b_tz {
	interrupts = <0x8 0x24 0x0 IRQ_TYPE_EDGE_BOTH>;
};

&pm7250b_bcl {
	interrupts = <0x8 0x1d 0x0 IRQ_TYPE_EDGE_RISING>,
		   <0x8 0x1d 0x1 IRQ_TYPE_EDGE_RISING>,
		   <0x8 0x1d 0x2 IRQ_TYPE_EDGE_RISING>;
};

/* Below peripherals are supported over ADSP Glink */
&pm7250b_charger {
	status = "disabled";
};

&pm7250b_qg {
	status = "disabled";
};

&pm7250b_pdphy {
	status = "disabled";
};

&pm7250b_gpios {
	display_panel_supply_ctrl {
		display_panel_vddio_default: display_panel_vddio_default {
			pins = "gpio11";
			function = "normal";
			input-disable;
			output-enable;
			bias-disable;
			power-source = <0>;
			qcom,drive-strength = <2>;
		};

		display_panel_extvdd_default: display_panel_extvdd_default {
			pins = "gpio12";
			function = "normal";
			input-disable;
			output-enable;
			bias-disable;
			power-source = <0>;
			qcom,drive-strength = <2>;
		};
	};
};

&soc {
	display_panel_vddio: display_gpio_regulator@1 {
		compatible = "qti-regulator-fixed";
		regulator-name = "display_panel_vddio";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-enable-ramp-delay = <233>;
		gpio = <&pm7250b_gpios 11 0>;
		enable-active-high;
		regulator-boot-on;
		proxy-supply = <&display_panel_vddio>;
		qcom,proxy-consumer-enable;
		pinctrl-names = "default";
		pinctrl-0 = <&display_panel_vddio_default>;
	};

	display_panel_extvdd: display_gpio_regulator@2 {
		compatible = "qti-regulator-fixed";
		regulator-name = "display_panel_extvdd";
		regulator-min-microvolt = <1200000>;
		regulator-max-microvolt = <1200000>;
		regulator-enable-ramp-delay = <233>;
		gpio = <&pm7250b_gpios 12 0>;
		enable-active-high;
		regulator-boot-on;
		proxy-supply = <&display_panel_extvdd>;
		qcom,proxy-consumer-enable;
		pinctrl-names = "default";
		pinctrl-0 = <&display_panel_extvdd_default>;
	};
};
