/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

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

&spmi_bus {
	qcom,pm660@0 {
		spmi-slave-container;
		reg = <0x0>;
		#address-cells = <1>;
		#size-cells = <1>;

		pm660_revid: qcom,revid@100 {
			compatible = "qcom,qpnp-revid";
			reg = <0x100 0x100>;
			qcom,fab-id-valid;
		};

		pm660_misc: qcom,misc@900 {
			compatible = "qcom,qpnp-misc";
			reg = <0x900 0x100>;
		};

		pm660_pon: qcom,power-on@800 {
			compatible = "qcom,qpnp-power-on";
			reg = <0x800 0x100>;
			interrupts = <0x0 0x8 0x0>,
				     <0x0 0x8 0x1>,
				     <0x0 0x8 0x4>,
				     <0x0 0x8 0x5>;
			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>;
			};
		};

		qcom,temp-alarm@2400 {
			compatible = "qcom,qpnp-temp-alarm";
			reg = <0x2400 0x100>;
			interrupts = <0x0 0x24 0x0 IRQ_TYPE_EDGE_RISING>;
			label = "pm660_tz";
			qcom,channel-num = <6>;
			qcom,temp_alarm-vadc = <&pm660_vadc>;
		};

		pm660_gpios: gpios {
			spmi-dev-container;
			compatible = "qcom,qpnp-pin";
			gpio-controller;
			#gpio-cells = <2>;
			#address-cells = <1>;
			#size-cells = <1>;
			label = "pm660-gpio";

			gpio@c000 {
				reg = <0xc000 0x100>;
				qcom,pin-num = <1>;
				status = "disabled";
			};

			gpio@c100 {
				reg = <0xc100 0x100>;
				qcom,pin-num = <2>;
				status = "disabled";
			};

			gpio@c200 {
				reg = <0xc200 0x100>;
				qcom,pin-num = <3>;
				status = "disabled";
			};

			gpio@c300 {
				reg = <0xc300 0x100>;
				qcom,pin-num = <4>;
				status = "disabled";
			};

			gpio@c400 {
				reg = <0xc400 0x100>;
				qcom,pin-num = <5>;
				status = "disabled";
			};

			gpio@c500 {
				reg = <0xc500 0x100>;
				qcom,pin-num = <6>;
				status = "disabled";
			};

			gpio@c600 {
				reg = <0xc600 0x100>;
				qcom,pin-num = <7>;
				status = "disabled";
			};

			gpio@c700 {
				reg = <0xc700 0x100>;
				qcom,pin-num = <8>;
				status = "disabled";
			};

			gpio@c800 {
				reg = <0xc800 0x100>;
				qcom,pin-num = <9>;
				status = "disabled";
			};

			gpio@c900 {
				reg = <0xc900 0x100>;
				qcom,pin-num = <10>;
				status = "disabled";
			};

			gpio@ca00 {
				reg = <0xca00 0x100>;
				qcom,pin-num = <11>;
				status = "disabled";
			};

			gpio@cb00 {
				reg = <0xcb00 0x100>;
				qcom,pin-num = <12>;
				status = "disabled";
			};

			gpio@cc00 {
				reg = <0xcc00 0x100>;
				qcom,pin-num = <13>;
				status = "disabled";
			};
		};

		pm660_coincell: qcom,coincell@2800 {
			compatible = "qcom,qpnp-coincell";
			reg = <0x2800 0x100>;
		};

		pm660_rtc: qcom,pm660_rtc {
			spmi-dev-container;
			compatible = "qcom,qpnp-rtc";
			#address-cells = <1>;
			#size-cells = <1>;
			qcom,qpnp-rtc-write = <0>;
			qcom,qpnp-rtc-alarm-pwrup = <0>;

			qcom,pm660_rtc_rw@6000 {
				reg = <0x6000 0x100>;
			};
			qcom,pm660_rtc_alarm@6100 {
				reg = <0x6100 0x100>;
				interrupts = <0x0 0x61 0x1 IRQ_TYPE_NONE>;
			};
		};

		pm660_vadc: vadc@3100 {
			compatible = "qcom,qpnp-vadc-hc";
			reg = <0x3100 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
			interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "eoc-int-en-set";
			qcom,adc-bit-resolution = <15>;
			qcom,adc-vdd-reference = <1875>;

			chan@6 {
				label = "die_temp";
				reg = <6>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <3>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
				qcom,cal-val = <0>;
			};

			chan@0 {
				label = "ref_gnd";
				reg = <0>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <0>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
				qcom,cal-val = <0>;
			};

			chan@1 {
				label = "ref_1250v";
				reg = <1>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <0>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
				qcom,cal-val = <0>;
			};

			chan@83 {
				label = "vph_pwr";
				reg = <0x83>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <1>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <0>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
			};

			chan@85 {
				label = "vcoin";
				reg = <0x85>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <1>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <0>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
			};

			chan@4c {
				label = "xo_therm";
				reg = <0x4c>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <4>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
			};

			chan@4d {
				label = "msm_therm";
				reg = <0x4d>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
			};

			chan@51 {
				label = "quiet_therm";
				reg = <0x51>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
			};

			chan@4e {
				label = "emmc_therm";
				reg = <0x4e>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
				qcom,vadc-thermal-node;
			};

			chan@4f {
				label = "pa_therm0";
				reg = <0x4f>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,fast-avg-setup = <0>;
				qcom,vadc-thermal-node;
			};

			chan@1d {
				label = "drax_temp";
				reg = <0x1d>;
				qcom,decimation = <2>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <3>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
				qcom,cal-val = <0>;
			};
		};

		pm660_charger: qcom,qpnp-smb2 {
			spmi-dev-container;
			compatible = "qcom,qpnp-smb2";
			#address-cells = <1>;
			#size-cells = <1>;

			qcom,pmic-revid = <&pm660_revid>;
			qcom,wipower-max-uw = <5000000>;

			qcom,thermal-mitigation
					= <3000000 2500000 2000000 1500000
						1000000 500000>;
			qcom,chgr@1000 {
				reg = <0x1000 0x100>;
				interrupts =
					<0x0 0x10 0x0>,
					<0x0 0x10 0x1>,
					<0x0 0x10 0x2>,
					<0x0 0x10 0x3>,
					<0x0 0x10 0x4>;

				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>,
					     <0x0 0x11 0x1>,
					     <0x0 0x11 0x2>,
					     <0x0 0x11 0x3>;

				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>,
					<0x0 0x12 0x1>,
					<0x0 0x12 0x2>,
					<0x0 0x12 0x3>,
					<0x0 0x12 0x4>,
					<0x0 0x12 0x5>;

				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>,
					<0x0 0x13 0x1>,
					<0x0 0x13 0x2>,
					<0x0 0x13 0x3>,
					<0x0 0x13 0x4>,
					<0x0 0x13 0x5>,
					<0x0 0x13 0x6>,
					<0x0 0x13 0x7>;

				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>,
					<0x0 0x14 0x1>,
					<0x0 0x14 0x2>,
					<0x0 0x14 0x3>,
					<0x0 0x14 0x4>,
					<0x0 0x14 0x5>,
					<0x0 0x14 0x6>;

				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>,
					<0x0 0x16 0x1>,
					<0x0 0x16 0x2>,
					<0x0 0x16 0x3>,
					<0x0 0x16 0x4>,
					<0x0 0x16 0x5>,
					<0x0 0x16 0x6>,
					<0x0 0x16 0x7>;

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

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

		pm660_fg: qpnp,fg {
			spmi-dev-container;
			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 = <96 96>;
			qcom,fg-esr-timer-asleep = <256 256>;
			qcom,fg-esr-timer-charging = <0 96>;
			qcom,cycle-counter-en;
			status = "okay";

			qcom,fg-batt-soc@4000 {
				status = "okay";
				reg = <0x4000 0x100>;
				interrupts = <0x0 0x40 0x0>,
					     <0x0 0x40 0x1>,
					     <0x0 0x40 0x2>,
					     <0x0 0x40 0x3>,
					     <0x0 0x40 0x4>,
					     <0x0 0x40 0x5>,
					     <0x0 0x40 0x6>,
					     <0x0 0x40 0x7>;
				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>,
					     <0x0 0x41 0x1>,
					     <0x0 0x41 0x2>,
					     <0x0 0x41 0x3>,
					     <0x0 0x41 0x6>;
				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>,
					     <0x0 0x44 0x1>,
					     <0x0 0x44 0x2>;
				interrupt-names = "ima-rdy",
						  "mem-xcp",
						  "dma-grant";
			};
		};

		pm660_adc_tm: vadc@3400 {
			compatible = "qcom,qpnp-adc-tm-hc";
			reg = <0x3400 0x100>;
			#address-cells = <1>;
			#size-cells = <0>;
			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "eoc-int-en-set";
			qcom,adc-bit-resolution = <15>;
			qcom,adc-vdd-reference = <1875>;
			qcom,adc_tm-vadc = <&pm660_vadc>;
			qcom,decimation = <0>;
			qcom,fast-avg-setup = <0>;

			chan@83 {
				label = "vph_pwr";
				reg = <0x83>;
				qcom,pre-div-channel-scaling = <1>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <0>;
				qcom,hw-settle-time = <0>;
				qcom,btm-channel-number = <0x60>;
			};

			chan@4d {
				label = "msm_therm";
				reg = <0x4d>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,btm-channel-number = <0x68>;
				qcom,thermal-node;
			};

			chan@51 {
				label = "quiet_therm";
				reg = <0x51>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <2>;
				qcom,hw-settle-time = <2>;
				qcom,btm-channel-number = <0x70>;
				qcom,thermal-node;
			};

			chan@4c {
				label = "xo_therm";
				reg = <0x4c>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "ratiometric";
				qcom,scale-function = <4>;
				qcom,hw-settle-time = <2>;
				qcom,btm-channel-number = <0x78>;
				qcom,thermal-node;
			};
		};

		pm660_pbs: qcom,pbs@7400 {
			compatible = "qcom,qpnp-pbs";
			reg = <0x7400 0x100>;
			status = "disabled";
		};

		bcl@4200 {
			compatible = "qcom,msm-bcl-lmh";
			reg = <0x4200 0xff>;
			reg-names = "fg_user_adc";
			interrupts = <0x0 0x42 0x0>,
					<0x0 0x42 0x2>;
			interrupt-names = "bcl-high-ibat-int",
					"bcl-low-vbat-int";
			qcom,vbat-polling-delay-ms = <100>;
			qcom,ibat-polling-delay-ms = <100>;
		};
	};

	qcom,pm660@1 {
		spmi-slave-container;
		reg = <0x1>;
		#address-cells = <1>;
		#size-cells = <1>;

		pm660_haptics: qcom,haptic@c000 {
			compatible = "qcom,qpnp-haptic";
			reg = <0xc000 0x100>;
			interrupts = <0x1 0xc0 0x0 IRQ_TYPE_EDGE_BOTH>,
				     <0x1 0xc0 0x1 IRQ_TYPE_EDGE_BOTH>;
			interrupt-names = "sc-irq", "play-irq";
			qcom,pmic-revid = <&pm660_revid>;
			qcom,pmic-misc = <&pm660_misc>;
			qcom,misc-clk-trim-error-reg = <0xf3>;
			qcom,actuator-type = "lra";
			qcom,play-mode = "direct";
			qcom,vmax-mv = <3200>;
			qcom,ilim-ma = <800>;
			qcom,wave-shape = "square";
			qcom,wave-play-rate-us = <6667>;
			qcom,int-pwm-freq-khz = <505>;
			qcom,sc-deb-cycles = <8>;
			qcom,en-brake;
			qcom,brake-pattern = [03 03 00 00];
			qcom,lra-high-z = "opt0";
			qcom,lra-auto-res-mode = "qwd";
			qcom,lra-calibrate-at-eop = <0>;
			qcom,correct-lra-drive-freq;
		};
	};
};
