#include <dt-bindings/interrupt-controller/arm-gic.h>

&pm660_0 {
	pm660_charger: qcom,qpnp-smb2 {
		compatible = "qcom,qpnp-smb2";
		#address-cells = <1>;
		#size-cells = <1>;
		#cooling-cells = <2>;

		qcom,pmic-revid = <&pm660_revid>;

		io-channels = <&pm660_rradc 8>,
			      <&pm660_rradc 10>,
			      <&pm660_rradc 3>,
			      <&pm660_rradc 4>;
		io-channel-names = "charger_temp",
				   "charger_temp_max",
				   "usbin_i",
				   "usbin_v";

		qcom,wipower-max-uw = <5000000>;

		dpdm-supply = <&qusb_phy0>;

		qcom,thermal-mitigation
				= <3000000 2500000 2000000 1500000
					1000000 500000>;
		qcom,auto-recharge-soc;

		qcom,chgr@1000 {
			reg = <0x1000 0x100>;
			interrupts =
				<0x0 0x10 0x0 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x10 0x1 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x10 0x2 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x10 0x3 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x10 0x4 IRQ_TYPE_EDGE_RISING>;

			interrupt-names = "chg-error",
					  "chg-state-change",
					  "step-chg-state-change",
					  "step-chg-soc-update-fail",
					  "step-chg-soc-update-request";
		};

		qcom,otg@1100 {
			reg = <0x1100 0x100>;
			interrupts = <0x0 0x11 0x0 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x11 0x1 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x11 0x2 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x11 0x3 IRQ_TYPE_EDGE_BOTH>;

			interrupt-names = "otg-fail",
					  "otg-overcurrent",
					  "otg-oc-dis-sw-sts",
					  "testmode-change-detect";
		};

		qcom,bat-if@1200 {
			reg = <0x1200 0x100>;
			interrupts =
				<0x0 0x12 0x0 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x12 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x12 0x5 IRQ_TYPE_EDGE_BOTH>;

			interrupt-names = "bat-temp",
					  "bat-ocp",
					  "bat-ov",
					  "bat-low",
					  "bat-therm-or-id-missing",
					  "bat-terminal-missing";
		};

		qcom,usb-chgpth@1300 {
			reg = <0x1300 0x100>;
			interrupts =
				<0x0 0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x13 0x5 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x13 0x6 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x13 0x7 IRQ_TYPE_EDGE_RISING>;

			interrupt-names = "usbin-collapse",
					  "usbin-lt-3p6v",
					  "usbin-uv",
					  "usbin-ov",
					  "usbin-plugin",
					  "usbin-src-change",
					  "usbin-icl-change",
					  "type-c-change";
		};

		qcom,dc-chgpth@1400 {
			reg = <0x1400 0x100>;
			interrupts =
				<0x0 0x14 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x14 0x6 IRQ_TYPE_EDGE_RISING>;

			interrupt-names = "dcin-collapse",
					  "dcin-lt-3p6v",
					  "dcin-uv",
					  "dcin-ov",
					  "dcin-plugin",
					  "div2-en-dg",
					  "dcin-icl-change";
		};

		qcom,chgr-misc@1600 {
			reg = <0x1600 0x100>;
			interrupts =
				<0x0 0x16 0x0 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x16 0x1 IRQ_TYPE_EDGE_RISING>,
				<0x0 0x16 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x16 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x16 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x16 0x5 IRQ_TYPE_EDGE_BOTH>,
				<0x0 0x16 0x6 IRQ_TYPE_EDGE_FALLING>,
				<0x0 0x16 0x7 IRQ_TYPE_EDGE_BOTH>;

			interrupt-names = "wdog-snarl",
					  "wdog-bark",
					  "aicl-fail",
					  "aicl-done",
					  "high-duty-cycle",
					  "input-current-limiting",
					  "temperature-change",
					  "switcher-power-ok";
		};

		smb2_vbus: qcom,smb2-vbus {
			regulator-name = "smb2-vbus";
		};

		smb2_vconn: qcom,smb2-vconn {
			regulator-name = "smb2-vconn";
		};
	};

	pm660_rradc: rradc@4500 {
		reg = <0x4500 0x100>;
		#address-cells = <1>;
		#size-cells = <0>;
		#io-channel-cells = <1>;
		qcom,pmic-revid = <&pm660_revid>;
	};

	pm660_fg: qpnp,fg {
		compatible = "qcom,fg-gen3";
		#address-cells = <1>;
		#size-cells = <1>;
		qcom,pmic-revid = <&pm660_revid>;
		io-channels = <&pm660_rradc 0>,
			      <&pm660_rradc 7>;
		io-channel-names = "rradc_batt_id",
				   "rradc_die_temp";
		qcom,rradc-base = <0x4500>;
		qcom,fg-esr-timer-awake = <64 96>;
		qcom,fg-esr-timer-asleep = <224 256>;
		qcom,fg-esr-timer-charging = <0 96>;
		qcom,cycle-counter-en;
		qcom,hold-soc-while-full;
		qcom,fg-auto-recharge-soc;
		qcom,fg-recharge-soc-thr = <98>;
		status = "okay";

		qcom,fg-batt-soc@4000 {
			status = "okay";
			reg = <0x4000 0x100>;
			interrupts = <0x0 0x40 0x0 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x40 0x1 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x40 0x2
						IRQ_TYPE_EDGE_RISING>,
				     <0x0 0x40 0x3
						IRQ_TYPE_EDGE_RISING>,
				     <0x0 0x40 0x4 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x40 0x5
						IRQ_TYPE_EDGE_RISING>,
				     <0x0 0x40 0x6 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x40 0x7 IRQ_TYPE_EDGE_BOTH>;
			interrupt-names = "soc-update",
					  "soc-ready",
					  "bsoc-delta",
					  "msoc-delta",
					  "msoc-low",
					  "msoc-empty",
					  "msoc-high",
					  "msoc-full";
		};

		qcom,fg-batt-info@4100 {
			status = "okay";
			reg = <0x4100 0x100>;
			interrupts = <0x0 0x41 0x0 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x41 0x1 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x41 0x2 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x41 0x3 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x41 0x6 IRQ_TYPE_EDGE_BOTH>;
			interrupt-names = "vbatt-pred-delta",
					  "vbatt-low",
					  "esr-delta",
					  "batt-missing",
					  "batt-temp-delta";
		};

		qcom,fg-memif@4400 {
			status = "okay";
			reg = <0x4400 0x100>;
			interrupts = <0x0 0x44 0x0 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x44 0x1 IRQ_TYPE_EDGE_BOTH>,
				     <0x0 0x44 0x2 IRQ_TYPE_EDGE_BOTH>;
			interrupt-names = "ima-rdy",
					  "mem-xcp",
					  "dma-grant";
		};
	};
};

&pm660_1 {
	pm660_haptics: qcom,haptics@c000 {
		reg = <0xc000 0x100>;
		interrupts = <0x1 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
			     <0x1 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
		interrupt-names = "hap-sc-irq", "hap-play-irq";
		qcom,pmic-revid = <&pm660_revid>;
		qcom,pmic-misc = <&pm660_misc>;
		qcom,misc-clk-trim-error-reg = <0xf3>;
		qcom,actuator-type = <0>;
		qcom,play-mode = "direct";
		qcom,vmax-mv = <3200>;
		qcom,ilim-ma = <800>;
		qcom,sc-dbc-cycles = <8>;
		qcom,wave-play-rate-us = <6667>;
		qcom,en-brake;
		qcom,lra-high-z = "opt0";
		qcom,lra-auto-res-mode = "qwd";
		qcom,lra-res-cal-period = <4>;
	};
};

&pm660l_3 {
	pm660l_wled: qcom,leds@d800 {
		reg = <0xd800 0x100>,
			<0xd900 0x100>;
		reg-names = "qpnp-wled-ctrl-base",
				"qpnp-wled-sink-base";
		interrupts = <0x3 0xd8 0x1 IRQ_TYPE_EDGE_RISING>;
		interrupt-names = "ovp-irq";
		linux,name = "wled";
		linux,default-trigger = "bkl-trigger";
		qcom,fdbk-output = "auto";
		qcom,vref-uv = <127500>;
		qcom,switch-freq-khz = <800>;
		qcom,ovp-mv = <29600>;
		qcom,ilim-ma = <970>;
		qcom,boost-duty-ns = <26>;
		qcom,mod-freq-khz = <9600>;
		qcom,dim-mode = "hybrid";
		qcom,hyb-thres = <625>;
		qcom,sync-dly-us = <800>;
		qcom,fs-curr-ua = <25000>;
		qcom,cons-sync-write-delay-us = <1000>;
		qcom,led-strings-list = [00 01 02];
		qcom,loop-auto-gm-en;
		qcom,pmic-revid = <&pm660l_revid>;
		qcom,auto-calibration-enable;
		status = "ok";
	};

	pm660l_lcdb: qpnp-lcdb@ec00 {
		compatible = "qcom,qpnp-lcdb-regulator";
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0xec00 0x100>;
		interrupts = <0x3 0xec 0x1 IRQ_TYPE_EDGE_RISING>;
		interrupt-names = "sc-irq";

		qcom,pmic-revid = <&pm660l_revid>;

		lcdb_ldo_vreg: ldo {
			label = "ldo";
			regulator-name = "lcdb_ldo";
			regulator-min-microvolt = <4000000>;
			regulator-max-microvolt = <6000000>;
		};

		lcdb_ncp_vreg: ncp {
			label = "ncp";
			regulator-name = "lcdb_ncp";
			regulator-min-microvolt = <4000000>;
			regulator-max-microvolt = <6000000>;
		};
	};

	pm660a_oledb: qpnp-oledb@e000 {
	       compatible = "qcom,qpnp-oledb-regulator";
	       #address-cells = <1>;
	       #size-cells = <1>;
	       qcom,pmic-revid = <&pm660l_revid>;
	       reg = <0xe000 0x100>;
	       qcom,pbs-client = <&pm660l_pbs>;

	       label = "oledb";
	       regulator-name = "regulator-oledb";
	       regulator-min-microvolt = <5000000>;
	       regulator-max-microvolt = <8100000>;

	       qcom,swire-control;
	       qcom,ext-pin-control;
	       status = "disabled";
	};

	pm660a_labibb: qpnp-labibb-regulator {
		compatible = "qcom,qpnp-labibb-regulator";
		#address-cells = <1>;
		#size-cells = <1>;
		qcom,pmic-revid = <&pm660l_revid>;
		qcom,swire-control;
		status = "disabled";

		ibb_regulator: qcom,ibb@dc00 {
			reg = <0xdc00 0x100>;
			reg-names = "ibb_reg";
			regulator-name = "ibb_reg";

			regulator-min-microvolt = <4000000>;
			regulator-max-microvolt = <6300000>;

			qcom,qpnp-ibb-min-voltage = <1400000>;
			qcom,qpnp-ibb-step-size = <100000>;
			qcom,qpnp-ibb-slew-rate = <2000000>;
			qcom,qpnp-ibb-init-voltage = <4000000>;
			qcom,qpnp-ibb-init-amoled-voltage = <4000000>;
		};

		lab_regulator: qcom,lab@de00 {
			reg = <0xde00 0x100>;
			reg-names = "lab";
			regulator-name = "lab_reg";

			regulator-min-microvolt = <4600000>;
			regulator-max-microvolt = <6100000>;

			qcom,qpnp-lab-min-voltage = <4600000>;
			qcom,qpnp-lab-step-size = <100000>;
			qcom,qpnp-lab-slew-rate = <5000>;
			qcom,qpnp-lab-init-voltage = <4600000>;
			qcom,qpnp-lab-init-amoled-voltage = <4600000>;

			qcom,notify-lab-vreg-ok-sts;
		};
	};
};

&usb0 {
	qcom,no-vbus-vote-with-type-C;
};

&thermal_zones {
	xo-therm-step {
		trips {
			batt_trip1: batt-trip1 {
				temperature = <50000>;
				hysteresis = <4000>;
				type = "passive";
			};

			batt_trip2: batt-trip2 {
				temperature = <52000>;
				hysteresis = <2000>;
				type = "passive";
			};

			batt_trip3: batt-trip3 {
				temperature = <54000>;
				hysteresis = <2000>;
				type = "passive";
			};

			batt_trip4: batt-trip4 {
				temperature = <56000>;
				hysteresis = <2000>;
				type = "passive";
			};
		};

		cooling-maps {
			battery_lvl1 {
				trip = <&batt_trip1>;
				cooling-device = <&pm660_charger 1 1>;
			};

			battery_lvl2 {
				trip = <&batt_trip2>;
				cooling-device = <&pm660_charger 2 2>;
			};

			battery_lvl3 {
				trip = <&batt_trip3>;
				cooling-device = <&pm660_charger 4 4>;
			};

			battery_lvl4 {
				trip = <&batt_trip4>;
				cooling-device = <&pm660_charger 5 5>;
			};
		};
	};

	xo-therm-605-step {
		trips {
			qcs605_batt_trip1: qcs605-batt-trip1 {
				temperature = <42000>;
				hysteresis = <4000>;
				type = "passive";
			};

			qcs605_batt_trip2: qcs605-batt-trip2 {
				temperature = <44000>;
				hysteresis = <2000>;
				type = "passive";
			};

			qcs605_batt_trip3: qcs605-batt-trip3 {
				temperature = <46000>;
				hysteresis = <2000>;
				type = "passive";
			};

			qcs605_batt_trip4: qcs605-batt-trip4 {
				temperature = <48000>;
				hysteresis = <2000>;
				type = "passive";
			};
		};

		cooling-maps {
			battery_lvl1 {
				trip = <&qcs605_batt_trip1>;
				cooling-device = <&pm660_charger 1 1>;
			};

			battery_lvl2 {
				trip = <&qcs605_batt_trip2>;
				cooling-device = <&pm660_charger 2 2>;
			};

			battery_lvl3 {
				trip = <&qcs605_batt_trip3>;
				cooling-device = <&pm660_charger 3 3>;
			};

			battery_lvl4 {
				trip = <&qcs605_batt_trip4>;
				cooling-device = <&pm660_charger 4 4>;
			};
		};
	};
};
