#include <dt-bindings/input/qcom,hv-haptics.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/spmi/spmi.h>

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

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

		pm8550b_tz: pm8550b-temp-alarm@a00 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0xa00>;
			interrupts = <0x7 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
			#thermal-sensor-cells = <0>;
		};

		pm8550b_lite_tz: pm8550b-temp-alarm-lite@c00 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0xc00>;
			interrupts = <0x7 0xc 0x0 IRQ_TYPE_EDGE_BOTH>;
			#thermal-sensor-cells = <0>;
		};

		pm8550b_gpios: pinctrl@8800 {
			compatible = "qcom,pm8550b-gpio";
			reg = <0x8800>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;
		};

		pm8550b_haptics: qcom,hv-haptics@f000 {
			compatible = "qcom,hv-haptics";
			reg = <0xf000>, <0xf100>, <0xf200>;
			interrupts = <0x7 0xf0 0x1 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "fifo-empty";
			qcom,vmax-mv = <3600>;
			qcom,brake-mode = <BRAKE_CLOSE_LOOP>;
			qcom,brake-pattern = /bits/ 8 <0xff 0x3f 0x1f>;
			qcom,lra-period-us = <6667>;
			qcom,drv-sig-shape = <WF_SINE>;
			qcom,brake-sig-shape = <WF_SINE>;
			status = "disabled";

			hap_swr_slave_reg: qcom,hap-swr-slave-reg {
				regulator-name = "hap-swr-slave-reg";
			};

			effect_0 {
				/* CLICK */
				qcom,effect-id = <0>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-pattern-preload;
				qcom,wf-auto-res-disable;
			};

			effect_1 {
				/* DOUBLE_CLICK */
				qcom,effect-id = <1>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			effect_2 {
				/* TICK */
				qcom,effect-id = <2>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			effect_3 {
				/* THUD */
				qcom,effect-id = <3>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			effect_4 {
				/* POP */
				qcom,effect-id = <4>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			effect_5 {
				/* HEAVY CLICK */
				qcom,effect-id = <5>;
				qcom,wf-vmax-mv = <3600>;
				qcom,wf-pattern-data =  <0x01f  S_PERIOD_T_LRA  0>,
							<0x03f  S_PERIOD_T_LRA  0>,
							<0x05f  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>,
							<0x17f  S_PERIOD_T_LRA  0>,
							<0x15f  S_PERIOD_T_LRA  0>,
							<0x13f  S_PERIOD_T_LRA  0>,
							<0x11f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <6667>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_0 {
				/* NOOP */
				qcom,primitive-id = <0>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0  S_PERIOD_T_LRA  0>,
							<0  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_1 {
				/* CLICK */
				qcom,primitive-id = <1>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_2 {
				/* THUD */
				qcom,primitive-id = <2>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_3 {
				/* SPIN */
				qcom,primitive-id = <3>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_4 {
				/* QUICK_RISE */
				qcom,primitive-id = <4>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_5 {
				/* SLOW_RISE */
				qcom,primitive-id = <5>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_6 {
				/* QUICK_FALL */
				qcom,primitive-id = <6>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_7 {
				/* LIGHT_TICK */
				qcom,primitive-id = <7>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};

			primitive_8 {
				/* LOW_TICK */
				qcom,primitive-id = <8>;
				qcom,wf-vmax-mv = <4800>;
				qcom,wf-pattern-data =  <0x0ff  S_PERIOD_T_LRA  0>,
							<0x07f  S_PERIOD_T_LRA  0>;
				qcom,wf-pattern-period-us = <4167>;
				qcom,wf-brake-pattern = /bits/ 8 <0x0 0x0 0x0>;
				qcom,wf-auto-res-disable;
			};
		};

		pm8550b_bcl: bcl@4700 {
			compatible = "qcom,bcl-v5";
			reg = <0x4700 0x100>;
			interrupts = <0x7 0x47 0x0 IRQ_TYPE_NONE>,
					<0x7 0x47 0x1 IRQ_TYPE_NONE>,
					<0x7 0x47 0x2 IRQ_TYPE_NONE>;
			interrupt-names = "bcl-lvl0",
						"bcl-lvl1",
						"bcl-lvl2";
			qcom,pmic7-threshold;
			#thermal-sensor-cells = <1>;
		};

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

		pm8550b_eusb2_repeater: eusb2-repeater@fd00 {
			compatible = "qcom,pmic-eusb2-repeater";
			reg = <0xfd00>;
		};
	};
};

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

		trips {
			pm8550b_trip0: trip0 {
				temperature = <95000>;
				hysteresis = <0>;
				type = "passive";
			};

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

			pm8550b_trip2: trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "critical";
			};
		};
	};

	pm8550b_lite_temp_alarm: pm8550b_lite_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pm8550b_lite_tz>;

		trips {
			trip0 {
				temperature = <125000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip1 {
				temperature = <135000>;
				hysteresis = <0>;
				type = "passive";
			};

			trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "critical";
			};
		};
	};

	pm8550b-ibat-lvl0 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8550b_bcl 0>;

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

	pm8550b-ibat-lvl1 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8550b_bcl 1>;

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

	pm8550b-bcl-lvl0 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-sensors = <&pm8550b_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";
			};
		};
	};

	pm8550b-bcl-lvl1 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-sensors = <&pm8550b_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";
			};
		};
	};

	pm8550b-bcl-lvl2 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-sensors = <&pm8550b_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-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 = <0>;
				type = "passive";
			};
		};
	};
};
