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

&spmi_bus {

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

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

		qcom,power-on@800 {
			compatible = "qcom,qpnp-power-on";
			reg = <0x800 0x100>;
			interrupts = <0x0 0x8 0x0 IRQ_TYPE_NONE>,
				<0x0 0x8 0x1 IRQ_TYPE_NONE>,
				<0x0 0x8 0x4 IRQ_TYPE_NONE>,
				<0x0 0x8 0x5 IRQ_TYPE_NONE>;
			interrupt-names = "kpdpwr", "resin",
				"resin-bark", "kpdpwr-resin-bark";
			qcom,pon-dbc-delay = <15625>;
			qcom,system-reset;
			qcom,store-hard-reset-reason;

			qcom,pon_1 {
				qcom,pon-type = <0>;
				qcom,pull-up = <1>;
				linux,code = <116>;
			};

			qcom,pon_2 {
				qcom,pon-type = <1>;
				qcom,pull-up = <1>;
				linux,code = <114>;
			};
		};

		pm8953_tz: qcom,temp-alarm@2400 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0x2400 0x100>;
			interrupts = <0x0 0x24 0x0 IRQ_TYPE_EDGE_RISING>;
			io-channels = <&pm8953_vadc VADC_DIE_TEMP>;
			io-channel-names = "thermal";
			#thermal-sensor-cells = <0>;
		};

		pm8953_mpps: mpps {
			compatible = "qcom,spmi-mpp";
			reg = <0xa000 0x400>;

			interrupts = <0x0 0xa0 0 IRQ_TYPE_NONE>,
				<0x0 0xa1 0 IRQ_TYPE_NONE>,
				<0x0 0xa2 0 IRQ_TYPE_NONE>,
				<0x0 0xa3 0 IRQ_TYPE_NONE>;
			interrupt-names = "pm8953_mpp1", "pm8953_mpp2",
					"pm8953_mpp3", "pm8953_mpp4";

			gpio-controller;
			#gpio-cells = <2>;

			case_therm {
				cas_therm_default: cas_therm_default {
					pins = "mpp4";
					function = "analog";
					input-enable;
					qcom,amux-route = <3>;
				};
			};

			pa_therm1 {
				pa_therm1_default: pa_therm1_default {
					pins = "mpp2";
					function = "analog";
					input-enable;
					qcom,amux-route = <1>;
				};
			};
		};

		pm8953_gpios: gpios {
			compatible = "qcom,spmi-gpio";
			reg = <0xc000 0x800>;

			interrupts = <0x0 0xc0 0 IRQ_TYPE_NONE>,
				<0x0 0xc1 0 IRQ_TYPE_NONE>,
				<0x0 0xc3 0 IRQ_TYPE_NONE>,
				<0x0 0xc4 0 IRQ_TYPE_NONE>,
				<0x0 0xc6 0 IRQ_TYPE_NONE>,
				<0x0 0xc7 0 IRQ_TYPE_NONE>;
			interrupt-names = "pm8953_gpio1", "pm8953_gpio2",
					"pm8953_gpio4", "pm8953_gpio5",
					"pm8953_gpio7", "pm8953_gpio8";

			gpio-controller;
			#gpio-cells = <2>;
			qcom,gpios-disallowed = <3 6>;
		};

		pm8953_vadc: vadc@3100 {
			compatible = "qcom,spmi-vadc";
			reg = <0x3100 0x100>;
			interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
			#address-cells = <1>;
			#size-cells = <0>;
			#io-channel-cells = <1>;
			io-channel-ranges;
			pinctrl-names = "default";
			pinctrl-0 = <&pa_therm1_default &cas_therm_default>;

			/* Channel nodes */
			vcoin {
				reg = <VADC_VCOIN>;
				label = "vcoin";
				qcom,pre-scaling = <1 3>;
			};

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

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

			ref_625mv {
				reg = <VADC_REF_625MV>;
				label = "ref_625mv";
				qcom,pre-scaling = <1 1>;
			};

			ref_1250v {
				reg = <VADC_REF_1250MV>;
				label = "ref_1250v";
				qcom,pre-scaling = <1 1>;
			};

			ref_buf_625mv {
				reg = <VADC_SPARE1>;
				label = "ref_buf_625mv";
				qcom,pre-scaling = <1 1>;
			};

			ref_vdd {
				reg = <VADC_VDD_VADC>;
				label = "ref_vdd";
				qcom,pre-scaling = <1 1>;
			};

			ref_gnd {
				reg = <VADC_GND_REF>;
				label = "ref_gnd";
				qcom,pre-scaling = <1 1>;
			};

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

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

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

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

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

		pm8953_adc_tm_iio: adc_tm_iio {
			compatible = "qcom,adc-tm5-iio";
			reg = <0x3500 0x100>;
			#thermal-sensor-cells = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			io-channels = <&pm8953_vadc VADC_LR_MUX3_BUF_XO_THERM>;

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

		pm8953_adc_tm: vadc@3400 {
			compatible = "qcom,qpnp-adc-tm";
			reg = <0x3400 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
			interrupts =    <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x0 0x34 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x0 0x34 0x4 IRQ_TYPE_EDGE_RISING>;
			interrupt-names =       "eoc-int-en-set",
						"high-thr-en-set",
						"low-thr-en-set";
			#thermal-sensor-cells = <1>;
			qcom,adc-vdd-reference = <1800>;
			io-channels = <&pm8953_vadc VADC_REF_625MV>,
					<&pm8953_vadc VADC_REF_1250MV>,
					<&pm8953_vadc VADC_VDD_VADC>,
					<&pm8953_vadc VADC_GND_REF>;
			io-channel-names = "ref_625mv", "ref_1250v", "ref_vdd",
						"ref_gnd";

			pa_therm0 {
				label = "pa_therm0";
				reg = <VADC_LR_MUX7_HW_ID>;
				io-channels = <&pm8953_vadc VADC_LR_MUX7_HW_ID>;
				io-channel-names = "pa_therm0";
				qcom,pre-div-channel-scaling = <0>;
				qcom,decimation = <0>;
				qcom,ratiometric;
				qcom,scale-fn-type = <2>;
				qcom,hw-settle-time = <2>;
				qcom,btm-channel-number = <0x48>;
				qcom,fast-avg-setup = <0>;
				qcom,thermal-node;
			};

			xo_therm {
				label = "xo_therm";
				reg = <VADC_LR_MUX3_XO_THERM>;
				io-channels = <&pm8953_vadc
							VADC_LR_MUX3_XO_THERM>;
				io-channel-names = "xo_therm";
				qcom,pre-div-channel-scaling = <0>;
				qcom,decimation = <0>;
				qcom,ratiometric;
				qcom,scale-fn-type = <4>;
				qcom,hw-settle-time = <2>;
				qcom,btm-channel-number = <0x68>;
				qcom,fast-avg-setup = <0>;
				qcom,thermal-node;
			};
		};

		pm8953_rtc: qcom,pm8953_rtc {
			compatible = "qcom,pm8916-rtc";
			interrupts = <0x0 0x61 0x1 IRQ_TYPE_NONE>;
		};

		pm8953_typec: qcom,pm8953_typec@bf00 {
			compatible = "qcom,qpnp-typec";
			reg = <0xbf00 0x100>;
			interrupts =    <0x0 0xbf 0x0 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x1 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x2 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x3 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x4 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x6 IRQ_TYPE_EDGE_RISING>,
					<0x0 0xbf 0x7 IRQ_TYPE_EDGE_RISING>;

			interrupt-names =       "vrd-change",
						"ufp-detect",
						"ufp-detach",
						"dfp-detect",
						"dfp-detach",
						"vbus-err",
						"vconn-oc";
		};
	};

	pm8953_1: qcom,pm8953@1 {
		compatible = "qcom,spmi-pmic";
		reg = <1 SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <1>;

		pm8953_pwm: qcom,pwms@bc00 {
			status = "disabled";
			compatible = "qcom,pwm-lpg";
			reg = <0xbc00 0x100>;
			reg-names = "lpg-base";
			#pwm-cells = <2>;
			qcom,num-lpg-channels = <1>;
		};
	};
};

&thermal_zones {
	xo-therm-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8953_adc_tm VADC_LR_MUX3_XO_THERM>;
		thermal-governor = "user_space";
		wake-capable-sensor;

		trips {
			active-config0 {
				temperature = <65000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	xo-therm-buf-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8953_adc_tm_iio
					VADC_LR_MUX3_BUF_XO_THERM>;
		thermal-governor = "user_space";
		wake-capable-sensor;

		trips {
			active-config0 {
				temperature = <65000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pm8953_temp_alarm: pm8953_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm8953_tz>;
		wake-capable-sensor;

		trips {
			pm8953_trip0: pm8953-trip0 {
				temperature = <105000>;
				hysteresis = <0>;
				type = "passive";
			};

			pm8953_trip1: pm8953-trip1 {
				temperature = <125000>;
				hysteresis = <0>;
				type = "passive";
			};

			pm8953_trip2: pm8953-trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "passive";
			};
		};
	};
};
