#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>

#include "pmk8350.dtsi"
#include "pm8350c.dtsi"
#include "pm7325.dtsi"
#include "pmr735a.dtsi"

&pm8350c_gpios {
	pm8008i_reset {
		pm8008i_active: pm8008i_active {
			pins = "gpio3";
			function = "normal";
			bias-disable;
			output-high;
			power-source = <0>;
		};
	};

	pm8010j_reset {
		pm8010j_active: pm8010j_active {
			pins = "gpio4";
			function = "normal";
			bias-disable;
			output-high;
			power-source = <0>;
		};
	};
};

&pmk8350 {
	/delete-node/ pon_pbs@800;
	/delete-node/ pon_hlos@1300;

	pon_hlos@1300 {
		compatible = "qcom,pm8998-pon";
		reg = <0x1300>, <0x800>;
		reg-names = "pon_hlos", "pon_pbs";
		qcom,log-kpd-event;

		pwrkey {
			compatible = "qcom,pmk8350-pwrkey";
			interrupts = <0x0 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
			linux,code = <KEY_POWER>;
		};

		resin {
			compatible = "qcom,pmk8350-resin";
			interrupts = <0x0 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
			linux,code = <KEY_VOLUMEDOWN>;
		};

		pwrkey-bark {
			compatible = "qcom,pmk8350-pwrkey-bark";
			interrupts = <0x0 0x13 0x0 IRQ_TYPE_EDGE_BOTH>;
			linux,code = <KEY_POWER>;
		};

		pwrkey-resin-bark {
			compatible = "qcom,pmk8350-pwrkey-resin-bark";
			interrupts = <0x0 0x13 0x2 IRQ_TYPE_EDGE_BOTH>;
			linux,code = <KEY_POWER>;
		};
	};
};

&pmk8350_sdam_1 {
	ufs_dev: ufs_dev@94 {
		reg = <0x94 0x1>;
		bits = <0 0>;
	};
};

&pmk8350_sdam_23 {
	adc_scaling: scaling@bf {
		reg = <0xbf 0x1>;
		bits = <0 2>;
	};
};

&pm7325_gpios {
	key_vol_up {
		key_vol_up_default: key_vol_up_default {
			pins = "gpio6";
			function = "normal";
			input-enable;
			bias-pull-up;
			power-source = <1>;
		};
	};
};

&pm8350c_gpios {
	lcd_backlight_ctrl {
		lcd_backlight_ctrl_default: lcd_backlight_ctrl_default {
			pins = "gpio8";
			function = "func1";
			input-disable;
			output-enable;
			bias-disable;
			power-source = <1>;       /* 1.8V */
			qcom,drive-strength = <2>;
		};
	};
};

&soc {
	reboot_reason {
		compatible = "qcom,reboot-reason";
		nvmem-cells = <&restart_reason>;
		nvmem-cell-names = "restart_reason";
	};

	pmic-pon-log {
		compatible = "qcom,pmic-pon-log";
		nvmem = <&pmk8350_sdam_5>;
		nvmem-names = "pon_log";
	};
};

&pmk8350_vadc {
	/delete-node/ pm8350_ref_gnd;
	/delete-node/ pm8350_vref_1p25;
	/delete-node/ pm8350_die_temp;
	/delete-node/ pm8350_vph_pwr;

	/delete-node/ pm8350b_ref_gnd;
	/delete-node/ pm8350b_vref_1p25;
	/delete-node/ pm8350b_die_temp;
	/delete-node/ pm8350b_vph_pwr;
	/delete-node/ pm8350b_vbat_sns;

	/delete-node/ pmr735b_ref_gnd;
	/delete-node/ pmr735b_vref_1p25;
	/delete-node/ pmr735b_die_temp;

	/* PM7325 Channel nodes */
	pm7325_ref_gnd {
		reg = <PM7325_ADC7_REF_GND>;
		label = "pm7325_ref_gnd";
		qcom,pre-scaling = <1 1>;
	};

	pm7325_vref_1p25 {
		reg = <PM7325_ADC7_1P25VREF>;
		label = "pm7325_vref_1p25";
		qcom,pre-scaling = <1 1>;
	};

	pm7325_die_temp {
		reg = <PM7325_ADC7_DIE_TEMP>;
		label = "pm7325_die_temp";
		qcom,pre-scaling = <1 1>;
	};

	pm7325_vph_pwr {
		reg = <PM7325_ADC7_VPH_PWR>;
		label = "pm7325_vph_pwr";
		qcom,pre-scaling = <1 3>;
	};
};

&pm7325_tz {
	io-channels = <&pmk8350_vadc PM7325_ADC7_DIE_TEMP>;
	io-channel-names = "thermal";
};

&pmr735a_tz {
	io-channels = <&pmk8350_vadc PMR735A_ADC7_DIE_TEMP>;
	io-channel-names = "thermal";
};

/*
 * Each QUP device that's a parent to PMIC must be listed as a critical device
 * to GCC
 */
&gcc {
	qcom,critical-devices = <&qupv3_se2_i2c>;
};

&qupv3_se2_i2c {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "ok";

	pm8008i@8 {
		compatible = "qcom,i2c-pmic";
		reg = <0x8>;
		#address-cells = <1>;
		#size-cells = <0>;

		pinctrl-names = "default";
		pinctrl-0 = <&pm8008i_active>;

		pm8008-chip@900 {
			compatible = "qcom,pm8008-chip";
			reg = <0x900>;

			PM8008I_EN: qcom,pm8008-chip-en {
				regulator-name = "pm8008i-chip-en";
			};
		};

		qcom,revid@100 {
			compatible = "qcom,qpnp-revid";
			reg = <0x100>;
		};
	};

	pm8008i@9 {
		compatible = "qcom,i2c-pmic";
		reg = <0x9>;
		#address-cells = <1>;
		#size-cells = <0>;

		qcom,pm8008i-regulator {
			compatible = "qcom,pm8008-regulator";
			#address-cells = <1>;
			#size-cells = <0>;

			pm8008_en-supply = <&PM8008I_EN>;
			vdd_l1_l2-supply = <&S8B>;
			vdd_l3_l4-supply = <&BOB>;
			vdd_l5-supply = <&S1B>;
			vdd_l6-supply = <&S1B>;
			vdd_l7-supply = <&BOB>;

			L1I: pm8008i_l1: regulator@4000 {
				reg = <0x4000>;
				regulator-name = "pm8008i_l1";
				regulator-min-microvolt = <1000000>;
				regulator-max-microvolt = <1000000>;
				qcom,min-dropout-voltage = <128000>;
				qcom,hpm-min-load = <30000>;
			};

			L2I: pm8008i_l2: regulator@4100 {
				reg = <0x4100>;
				regulator-name = "pm8008i_l2";
				regulator-min-microvolt = <1000000>;
				regulator-max-microvolt = <1200000>;
				qcom,min-dropout-voltage = <104000>;
				qcom,hpm-min-load = <30000>;
			};

			L3I: pm8008i_l3: regulator@4200 {
				reg = <0x4200>;
				regulator-name = "pm8008i_l3";
				regulator-min-microvolt = <2800000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <192000>;
				qcom,hpm-min-load = <0>;
			};

			L4I: pm8008i_l4: regulator@4300 {
				reg = <0x4300>;
				regulator-name = "pm8008i_l4";
				regulator-min-microvolt = <2800000>;
				regulator-max-microvolt = <2800000>;
				qcom,min-dropout-voltage = <128000>;
				qcom,hpm-min-load = <0>;
			};

			L5I: pm8008i_l5: regulator@4400 {
				reg = <0x4400>;
				regulator-name = "pm8008i_l5";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				qcom,min-dropout-voltage = <0>;
				qcom,hpm-min-load = <0>;
			};

			L6I: pm8008i_l6: regulator@4500 {
				reg = <0x4500>;
				regulator-name = "pm8008i_l6";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				qcom,min-dropout-voltage = <128000>;
				qcom,hpm-min-load = <0>;
			};

			L7I: pm8008i_l7: regulator@4600 {
				reg = <0x4600>;
				regulator-name = "pm8008i_l7";
				regulator-min-microvolt = <2700000>;
				regulator-max-microvolt = <3000000>;
				qcom,min-dropout-voltage = <256000>;
				qcom,hpm-min-load = <0>;
			};
		};
	};

	pm8010j@c {
		compatible = "qcom,i2c-pmic";
		reg = <0xc>;
		#address-cells = <1>;
		#size-cells = <0>;

		pinctrl-names = "default";
		pinctrl-0 = <&pm8010j_active>;

		pm8010-chip@900 {
			compatible = "qcom,pm8008-chip";
			reg = <0x900>;

			PM8010J_EN: qcom,pm8008-chip-en {
				regulator-name = "pm8010j-chip-en";
			};
		};

		qcom,revid@100 {
			compatible = "qcom,qpnp-revid";
			reg = <0x100>;
		};
	};

	pm8010j@d {
		compatible = "qcom,i2c-pmic";
		reg = <0xd>;
		#address-cells = <1>;
		#size-cells = <0>;

		qcom,pm8010j-regulator {
			compatible = "qcom,pm8010-regulator";
			#address-cells = <1>;
			#size-cells = <0>;

			pm8008_en-supply = <&PM8010J_EN>;
			vdd_l1_l2-supply = <&S8B>;
			vdd_l3_l4-supply = <&S1B>;
			vdd_l5-supply = <&BOB>;
			vdd_l6-supply = <&BOB>;
			vdd_l7-supply = <&BOB>;

			L1J: pm8010j_l1: regulator@4000 {
				reg = <0x4000>;
				regulator-name = "pm8010j_l1";
				regulator-min-microvolt = <310000>;
				regulator-max-microvolt = <1150000>;
				qcom,min-dropout-voltage = <72000>;
				qcom,hpm-min-load = <30000>;
			};

			L2J: pm8010j_l2: regulator@4100 {
				reg = <0x4100>;
				regulator-name = "pm8010j_l2";
				regulator-min-microvolt = <358000>;
				regulator-max-microvolt = <1486000>;
				qcom,min-dropout-voltage = <24000>;
				qcom,hpm-min-load = <30000>;
			};

			L3J: pm8010j_l3: regulator@4200 {
				reg = <0x4200>;
				regulator-name = "pm8010j_l3";
				regulator-min-microvolt = <1628000>;
				regulator-max-microvolt = <1950000>;
				qcom,min-dropout-voltage = <72000>;
				qcom,hpm-min-load = <0>;
			};

			L4J: pm8010j_l4: regulator@4300 {
				reg = <0x4300>;
				regulator-name = "pm8010j_l4";
				regulator-min-microvolt = <1548000>;
				regulator-max-microvolt = <1888000>;
				qcom,min-dropout-voltage = <152000>;
				qcom,hpm-min-load = <0>;
			};

			L5J: pm8010j_l5: regulator@4400 {
				reg = <0x4400>;
				regulator-name = "pm8010j_l5";
				regulator-min-microvolt = <1504000>;
				regulator-max-microvolt = <3544000>;
				qcom,min-dropout-voltage = <0>;
				qcom,hpm-min-load = <0>;
			};

			L6J: pm8010j_l6: regulator@4500 {
				reg = <0x4500>;
				regulator-name = "pm8010j_l6";
				regulator-min-microvolt = <2700000>;
				regulator-max-microvolt = <2900000>;
				qcom,min-dropout-voltage = <128000>;
				qcom,hpm-min-load = <0>;
			};

			L7J: pm8010j_l7: regulator@4600 {
				reg = <0x4600>;
				regulator-name = "pm8010j_l7";
				regulator-min-microvolt = <1504000>;
				regulator-max-microvolt = <3544000>;
				qcom,min-dropout-voltage = <0>;
				qcom,hpm-min-load = <0>;
			};
		};
	};
};

&pm8350c_switch0 {
	qcom,led-mask = <9>; /* Channels 1 & 4 */
	qcom,symmetry-en;
};

&pm8350c_switch1 {
	qcom,led-mask = <6>; /* Channels 2 & 3 */
	qcom,symmetry-en;
};

&pm8350c_switch2 {
	qcom,led-mask = <15>; /* All Channels */
	qcom,symmetry-en;
};

&pm8350c_flash {
	status = "ok";
};
