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

&spmi_bus {

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

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

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


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

		pm8937_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 = "pm8937_mpp1", "pm8937_mpp2",
					  "pm8937_mpp3", "pm8937_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>;
				};
			};
		};

		pm8937_gpios: gpios {
			compatible = "qcom,spmi-gpio";
			reg = <0xc000 0x800>;
			interrupts = <0x0 0xc0 0 IRQ_TYPE_NONE>,
				     <0x0 0xc1 0 IRQ_TYPE_NONE>,
				     <0x0 0xc4 0 IRQ_TYPE_NONE>,
				     <0x0 0xc6 0 IRQ_TYPE_NONE>,
				     <0x0 0xc7 0 IRQ_TYPE_NONE>;
			interrupt-names = "pm8937_gpio1", "pm8937_gpio2",
					  "pm8937_gpio5", "pmi8937_gpio7",
					  "pm8937_gpio8";
			gpio-controller;
			#gpio-cells = <2>;
			qcom,gpios-disallowed = <3 4 6>;
		};

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

		pm8937_adc_tm_iio: adc_tm_iio {
			compatible = "qcom,adc-tm5-iio";
			reg = <0x3500 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
			#thermal-sensor-cells = <1>;
			io-channels = <&pm8937_vadc VADC_P_MUX2_1_1>,
					<&pm8937_vadc VADC_LR_MUX3_XO_THERM>,
					<&pm8937_vadc
						VADC_LR_MUX3_BUF_XO_THERM>,
					<&pm8937_vadc VADC_P_MUX4_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>;
			};
		};

		pm8937_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 = <&pm8937_vadc VADC_REF_625MV>,
					<&pm8937_vadc VADC_REF_1250MV>,
					<&pm8937_vadc VADC_VDD_VADC>,
					<&pm8937_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 = <&pm8937_vadc VADC_LR_MUX7_HW_ID>;
				io-channel-names = "pa_therm0";
				qcom,decimation = <0>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,ratiometric;
				qcom,scale-fn-type = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
				qcom,btm-channel-number = <0x48>;
				qcom,thermal-node;
			};

			vph_pwr {
				label = "vph_pwr";
				reg = <VADC_VSYS>;
				io-channels = <&pm8937_vadc VADC_VSYS>;
				io-channel-names = "vph_pwr";
				qcom,decimation = <0>;
				qcom,pre-div-channel-scaling = <1>;
				qcom,scale-fn-type = <0>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
				qcom,btm-channel-number = <0x68>;
			};
		};
	};

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

		pm8937_pwm: pwm@bc00 {
			status = "disabled";
			compatible = "qcom,qpnp-pwm";
			reg = <0xbc00 0x100>;
			reg-names = "qpnp-lpg-channel-base";
			qcom,channel-id = <0>;
			qcom,supported-sizes = <6>, <9>;
			#pwm-cells = <2>;
		};
	};
};

&thermal_zones {
	pa-therm1-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8937_adc_tm_iio VADC_P_MUX2_1_1>;
		thermal-governor = "user_space";
		wake-capable-sensor;

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

	xo-therm-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8937_adc_tm_iio 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 = <&pm8937_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";
			};
		};
	};

	case-therm-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8937_adc_tm_iio VADC_P_MUX4_1_1>;
		thermal-governor = "user_space";
		wake-capable-sensor;

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

	pa-therm0-adc {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8937_adc_tm VADC_LR_MUX7_HW_ID>;
		thermal-governor = "user_space";
		wake-capable-sensor;

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

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

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

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

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