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

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

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

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

		pm8350b_pbs2: qcom,pbs@1900 {
			compatible = "qcom,qpnp-pbs";
			reg = <0x1900>;
		};

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

		pm8350b_bcl: bcl@4700 {
			compatible = "qcom,bcl-v5";
			reg = <0x4700 0x100>;
			interrupts = <0x3 0x47 0x0 IRQ_TYPE_NONE>,
					<0x3 0x47 0x1 IRQ_TYPE_NONE>,
					<0x3 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>;
		};

		pm8350b_haptics: qcom,hv-haptics@f000 {
			compatible = "qcom,hv-haptics";
			reg = <0xf000>, <0xf100>, <0xf200>;
			interrupts = <0x3 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;
			};
		};

		pm8350b_amoled: qcom,amoled {
			compatible = "qcom,qpnp-amoled-regulator";
			#address-cells = <1>;
			#size-cells = <0>;

			oledb_vreg: oledb@fa00 {
				reg = <0xfa00>;
				reg-names = "oledb_base";
				regulator-name = "oledb";
				regulator-min-microvolt = <5000000>;
				regulator-max-microvolt = <8000000>;
				qcom,swire-control;
			};

			ab_vreg: ab@f900 {
				reg = <0xf900>;
				reg-names = "ab_base";
				regulator-name = "ab";
				regulator-min-microvolt = <4600000>;
				regulator-max-microvolt = <5200000>;
				qcom,swire-control;
			};

			ibb_vreg: ibb@f800 {
				reg = <0xf800>;
				reg-names = "ibb_base";
				regulator-name = "ibb";
				regulator-min-microvolt = <1400000>;
				regulator-max-microvolt = <6600000>;
				qcom,swire-control;
				regulator-allow-set-load;
			};
		};

		qcom,amoled-ecm@f900 {
			compatible = "qcom,amoled-ecm";
			reg = <0xf900>;
			nvmem-names = "amoled-ecm-sdam0", "amoled-ecm-sdam1",
				      "amoled-ecm-sdam2";
			nvmem = <&pmk8350_sdam_13>, <&pmk8350_sdam_14>,
				<&pmk8350_sdam_41>;
			interrupt-names = "ecm-sdam0", "ecm-sdam1",
					  "ecm-sdam2";
			interrupts = <0x0 0x7c 0x1 IRQ_TYPE_EDGE_RISING>,
				     <0x0 0x7d 0x1 IRQ_TYPE_EDGE_RISING>,
				     <0x0 0x98 0x1 IRQ_TYPE_EDGE_RISING>;
		};
	};
};

&thermal_zones {
	pm8350b_temp_alarm: pm8350b_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-sensors = <&pm8350b_tz>;

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

			pm8350b_trip1: trip1 {
				temperature = <115000>;
				hysteresis = <0>;
				type = "critical";
			};

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

	pm8350b-ibat-lvl0 {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-sensors = <&pm8350b_bcl 0>;

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

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

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

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

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

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