#include <dt-bindings/clock/qcom,rpmcc.h>
#include <dt-bindings/spmi/spmi.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/iio/qcom,spmi-vadc.h>

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

	pm7250b_2: qcom,pm7250b@2 {
		compatible = "qcom,spmi-pmic";
		reg = <2 SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		qcom,power-on@800 {
			compatible = "qcom,qpnp-power-on";
			reg = <0x800>;
		};

		pm7250b_charger: qcom,qpnp-smb5 {
			compatible = "qcom,pm7250b-smb5";
			depends-on-supply = <&pm7250b_vadc>;
			#address-cells = <1>;
			#size-cells = <0>;
			#cooling-cells = <2>;

			qcom,thermal-mitigation = <5400000 4500000 4000000
				3500000 3000000 2500000 2000000 1500000
				1000000 500000>;

			qcom,chgr@1000 {
				reg = <0x1000>;
				interrupts =
					<0x2 0x10 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x1 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x4 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x5 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x10 0x7 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "chgr-error",
						  "chg-state-change",
						  "step-chg-state-change",
						  "step-chg-soc-update-fail",
						  "step-chg-soc-update-req",
						  "fg-fvcal-qualified",
						  "vph-alarm",
						  "vph-drop-prechg";
			};

			qcom,dcdc@1100 {
				reg = <0x1100>;
				interrupts =
					<0x2 0x11 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x11 0x1 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x11 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x11 0x3 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x11 0x4 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x11 0x5 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x11 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x11 0x7 IRQ_TYPE_EDGE_BOTH>;
				interrupt-names = "otg-fail",
						  "otg-oc-disable-sw",
						  "otg-oc-hiccup",
						  "bsm-active",
						  "high-duty-cycle",
						  "input-current-limiting",
						  "concurrent-mode-disable",
						  "switcher-power-ok";
			};

			qcom,batif@1200 {
				reg = <0x1200>;
				interrupts =
					<0x2 0x12 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x12 0x5 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x12 0x6 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x12 0x7 IRQ_TYPE_EDGE_BOTH>;
				interrupt-names = "bat-temp",
						  "bat-ov",
						  "bat-low",
						  "bat-therm-or-id-missing",
						  "bat-terminal-missing",
						  "buck-oc",
						  "vph-ov";
			};

			qcom,usb@1300 {
				reg = <0x1300>;
				interrupts =
					<0x2 0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x5 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x13 0x7 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "usbin-collapse",
						  "usbin-vashdn",
						  "usbin-uv",
						  "usbin-ov",
						  "usbin-plugin",
						  "usbin-revi-change",
						  "usbin-src-change",
						  "usbin-icl-change";
			};

			qcom,dc@1400 {
				reg = <0x1400>;
				interrupts =
					<0x2 0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x14 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x14 0x7 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "dcin-vashdn",
						  "dcin-uv",
						  "dcin-ov",
						  "dcin-plugin",
						  "dcin-revi",
						  "dcin-pon",
						  "dcin-en";
			};

			qcom,typec@1500 {
				reg = <0x1500>;
				interrupts =
					<0x2 0x15 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x1 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x4 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x5 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x15 0x7 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "typec-or-rid-detect-change",
						  "typec-vpd-detect",
						  "typec-cc-state-change",
						  "typec-vconn-oc",
						  "typec-vbus-change",
						  "typec-attach-detach",
						  "typec-legacy-cable-detect",
						  "typec-try-snk-src-detect";
			};

			qcom,misc@1600 {
				reg = <0x1600>;
				interrupts =
					<0x2 0x16 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x4 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x16 0x5 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x16 0x7 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "wdog-snarl",
						  "wdog-bark",
						  "aicl-fail",
						  "aicl-done",
						  "smb-en",
						  "imp-trigger",
						  "temp-change",
						  "temp-change-smb";
			};

			qcom,chg-sdam@b000 {
				reg = <0xb000>;
			};
		};

		pm7250b_qg: qpnp,qg {
			compatible = "qcom,pm7250b-qg";
			#address-cells = <1>;
			#size-cells = <0>;

			qcom,vbatt-cutoff-mv = <3200>;
			qcom,vbatt-low-mv = <3300>;
			qcom,vbatt-low-cold-mv = <3700>;
			qcom,vbatt-empty-mv = <3000>;
			qcom,vbatt-empty-cold-mv = <3000>;
			qcom,s3-entry-fifo-length = <2>;

			qcom,qgauge@4800 {
				status = "okay";
				reg = <0x4800>;
				interrupts =
					<0x2 0x48 0x0 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x48 0x1 IRQ_TYPE_EDGE_BOTH>,
					<0x2 0x48 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x48 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x2 0x48 0x4 IRQ_TYPE_EDGE_RISING>;
				interrupt-names = "qg-batt-missing",
						  "qg-vbat-low",
						  "qg-vbat-empty",
						  "qg-fifo-done",
						  "qg-good-ocv";
			};

			qcom,qg-sdam@b100 {
				status = "okay";
				reg = <0xb100>;
			};
		};

		pm7250b_tz: qcom,temp-alarm@2400 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0x2400>;
			interrupts = <0x2 0x24 0x0 IRQ_TYPE_EDGE_BOTH>;
			io-channels = <&pm7250b_vadc ADC5_DIE_TEMP>;
			io-channel-names = "thermal";
			#thermal-sensor-cells = <0>;
			qcom,temperature-threshold-set = <1>;
		};

		pm7250b_clkdiv: clock-controller@5b00 {
			compatible = "qcom,spmi-clkdiv";
			reg = <0x5b00>;
			#clock-cells = <1>;
			qcom,num-clkdivs = <1>;
			clock-output-names = "pm7250b_div_clk1";
			clocks = <&rpmcc RPM_SMD_XO_CLK_SRC>;
			clock-names = "xo";
			status = "disabled";
		};

		pm7250b_vadc: vadc@3100 {
			compatible = "qcom,spmi-adc5";
			reg = <0x3100>;
			#address-cells = <1>;
			#size-cells = <0>;
			interrupts = <0x2 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "eoc-int-en-set";
			#io-channel-cells = <1>;
			io-channel-ranges;

			/* Channel node */
			ref_gnd@0 {
				reg = <ADC5_REF_GND>;
				label = "ref_gnd";
				qcom,pre-scaling = <1 1>;
			};

			vref_1p25@1 {
				reg = <ADC5_1P25VREF>;
				label = "vref_1p25";
				qcom,pre-scaling = <1 1>;
			};

			die_temp@2 {
				reg = <ADC5_DIE_TEMP>;
				label = "die_temp";
				qcom,pre-scaling = <1 1>;
			};

			vph_pwr@83 {
				reg = <ADC5_VPH_PWR>;
				label = "vph_pwr";
				qcom,pre-scaling = <1 3>;
			};

			vbat_sns@84 {
				reg = <ADC5_VBAT_SNS>;
				label = "vbat_sns";
				qcom,pre-scaling = <1 3>;
			};

			usb_in_i_uv@7 {
				reg = <ADC5_USB_IN_I>;
				label = "usb_in_i_uv";
				qcom,pre-scaling = <1 1>;
			};

			usb_in_v_div_16@8 {
				reg = <ADC5_USB_IN_V_16>;
				label = "usb_in_v_div_16";
				qcom,pre-scaling = <1 16>;
			};

			chg_temp@9 {
				reg = <ADC5_CHG_TEMP>;
				label = "chg_temp";
				qcom,pre-scaling = <1 1>;
			};

			bat_therm@4a {
				reg = <ADC5_BAT_THERM_100K_PU>;
				label = "bat_therm";
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
				qcom,pre-scaling = <1 1>;
			};

			bat_therm_30k@2a {
				reg = <ADC5_BAT_THERM_30K_PU>;
				label = "bat_therm_30k";
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
				qcom,pre-scaling = <1 1>;
			};

			bat_therm_400k@6a {
				reg = <ADC5_BAT_THERM_400K_PU>;
				label = "bat_therm_400k";
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
				qcom,pre-scaling = <1 1>;
			};

			bat_id@4b {
				reg = <ADC5_BAT_ID_100K_PU>;
				label = "bat_id";
				qcom,ratiometric;
				qcom,hw-settle-time = <200>;
				qcom,pre-scaling = <1 1>;
			};

			smb1390_therm@e {
				reg = <ADC5_AMUX_THM2>;
				label = "smb1390_therm";
				qcom,hw-settle-time = <200>;
				qcom,pre-scaling = <1 1>;
			};

			chg_sbux@99 {
				reg = <ADC5_SBUx>;
				label = "chg_sbux";
				qcom,pre-scaling = <1 3>;
			};

			mid_chg_div6@1e {
				reg = <ADC5_MID_CHG_DIV6>;
				label = "chg_mid";
				qcom,pre-scaling = <1 6>;
			};
		};

		pm7250b_adc_tm: adc_tm@3500 {
			compatible = "qcom,adc-tm5";
			reg = <0x3500>;
			interrupts = <0x2 0x35 0x0 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "threshold";
			#address-cells = <1>;
			#size-cells = <0>;
			#thermal-sensor-cells = <1>;
		};

		pm7250b_bcl: bcl@1d00 {
			compatible = "qcom,bcl-v5";
			reg = <0x1d00>;
			interrupts = <0x2 0x1d 0x0 IRQ_TYPE_NONE>,
					<0x2 0x1d 0x1 IRQ_TYPE_NONE>,
					<0x2 0x1d 0x2 IRQ_TYPE_NONE>;
			interrupt-names = "bcl-lvl0",
						"bcl-lvl1",
						"bcl-lvl2";
			#thermal-sensor-cells = <1>;
		};

		bcl_soc:bcl-soc {
			compatible = "qcom,msm-bcl-soc";
			#thermal-sensor-cells = <0>;
		};

		pm7250b_gpios: pinctrl@c000 {
			compatible = "qcom,pm7250b-gpio";
			reg = <0xc000>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;
		};

		pm7250b_pdphy: qcom,usb-pdphy@1700 {
			compatible = "qcom,qpnp-pdphy";
			reg = <0x1700 0x100>;
			interrupts = <0x2 0x17 0x0 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x1 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x2 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x3 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x4 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x5 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x6 IRQ_TYPE_EDGE_RISING>,
				     <0x2 0x17 0x7 IRQ_TYPE_EDGE_RISING>;

			interrupt-names = "sig-tx",
					  "sig-rx",
					  "msg-tx",
					  "msg-rx",
					  "msg-tx-failed",
					  "msg-tx-discarded",
					  "msg-rx-discarded",
					  "fr-swap";

			qcom,default-sink-caps = <5000 3000>, /* 5V @ 3A */
						 <9000 3000>, /* 9V @ 3A */
						 <12000 2250>; /* 12V @ 2.25A */
		};
	};

	pm7250b_3: qcom,pm7250b@3 {
		compatible = "qcom,spmi-pmic";
		reg = <3 SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		pm7250b_vib: qcom,vibrator@5300 {
			compatible = "qcom,qpnp-vibrator-ldo";
			reg = <0x5300>;
			qcom,vib-ldo-volt-uv = <3000000>;
			qcom,disable-overdrive;
		};
	};
};

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

		trips {
			pm7250b_trip0: trip0 {
				temperature = <90000>;
				hysteresis = <0>;
				type = "passive";
			};

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

			pm7250b_trip2: trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "passive";
			};
		};
	};

	pm7250b-ibat-lvl0 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm7250b_bcl 0>;

		trips {
			ibat_lvl0:ibat-lvl0 {
				temperature = <5500>;
				hysteresis = <200>;
				type = "passive";
			};
		};
	};

	pm7250b-ibat-lvl1 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm7250b_bcl 1>;

		trips {
			ibat_lvl1:ibat-lvl1 {
				temperature = <6000>;
				hysteresis = <200>;
				type = "passive";
			};
		};
	};

	pm7250b-bcl-lvl0 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm7250b_bcl 5>;

		trips {
			thermal-engine-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			thermal-hal-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			b_bcl_lvl0: b-bcl-lvl0 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};

	pm7250b-bcl-lvl1 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm7250b_bcl 6>;

		trips {
			thermal-engine-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			thermal-hal-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			b_bcl_lvl1: b-bcl-lvl1 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};

	pm7250b-bcl-lvl2 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm7250b_bcl 7>;

		trips {
			thermal-engine-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			thermal-hal-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			b_bcl_lvl2: b-bcl-lvl2 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};

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

		trips {
			thermal-engine-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			thermal-hal-trip {
				temperature = <100>;
				hysteresis = <0>;
				type = "passive";
			};

			socd_trip:socd-trip {
				temperature = <90>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};
};
