#include "khaje-pm7250b.dtsi"
#include "khaje-thermal-pm7250b-overlay.dtsi"
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/iio/qti_power_supply_iio.h>

&soc {
	mtp_batterydata: qcom,battery-data {
		qcom,batt-id-range-pct = <15>;
		#include "qg-batterydata-alium-3600mah.dtsi"
	};
};

&pm7250b_gpios {
	pm7250b_smb_int_default: pm7250b_smb_int_default {
		pins = "gpio6";
		function = "gpio";
		input-enable;
		bias-pull-up;
		qcom,pull-up-strength = <PMIC_GPIO_PULL_UP_30>;
		power-source = <0>;
	 };
};

&qupv3_se1_i2c {
	status = "ok";
	#include "smb1355.dtsi"
};

&smb1355 {
	pinctrl-names = "default";
	pinctrl-0 = <&pm7250b_smb_int_default>;
	status = "ok";
};

&smb1355_charger {
	qcom,parallel-mode = <1>;
	qcom,hw-die-temp-mitigation;
	status = "ok";
};

&pm7250b_charger {
	status = "ok";
	#io-channel-cells = <1>;
	io-channels = <&pm7250b_vadc ADC5_USB_IN_V_16>,
		      <&pm7250b_vadc ADC5_USB_IN_I>,
		      <&pm7250b_vadc ADC5_CHG_TEMP>,
		      <&pm7250b_vadc ADC5_DIE_TEMP>,
		      <&pm7250b_vadc ADC5_AMUX_THM3_100K_PU>,
		      <&pm7250b_vadc ADC5_SBUx>,
		      <&pm7250b_vadc ADC5_VPH_PWR>,
		      <&pm7250b_vadc ADC5_AMUX_THM1_100K_PU>,
		      <&pm7250b_qg PSY_IIO_RESISTANCE_ID>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_NOW>,
		      <&pm7250b_qg PSY_IIO_TEMP>,
		      <&pm7250b_qg PSY_IIO_CAPACITY>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_OCV>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_AVG>,
		      <&pm7250b_qg PSY_IIO_DEBUG_BATTERY>,
		      <&pm7250b_qg PSY_IIO_REAL_CAPACITY>,
		      <&pm7250b_qg PSY_IIO_CC_SOC>,
		      <&pm7250b_qg PSY_IIO_CURRENT_NOW>,
		      <&pm7250b_qg PSY_IIO_VOLTAGE_MAX>,
		      <&pm7250b_qg PSY_IIO_CHARGE_FULL>,
		      <&pm7250b_qg PSY_IIO_CHARGE_COUNTER>,
		      <&pm7250b_qg PSY_IIO_CYCLE_COUNT>,
		      <&pm7250b_qg PSY_IIO_CHARGE_FULL_DESIGN>,
		      <&pm7250b_qg PSY_IIO_TIME_TO_FULL_NOW>;
	io-channel-names = "usb_in_voltage",
			   "usb_in_current",
			   "chg_temp",
			   "die_temp",
			   "conn_temp",
			   "sbux_res",
			   "vph_voltage",
			   "skin_temp",
			   "resistance_id",
			   "voltage_now",
			   "temp",
			   "capacity",
			   "voltage_ocv",
			   "voltage_avg",
			   "debug_battery",
			   "real_capacity",
			   "cc_soc",
			   "current_now",
			   "voltage_max",
			   "charge_full",
			   "charge_counter",
			   "cycle_count",
			   "charge_full_design",
			   "time_to_full_now";
	qcom,battery-data = <&mtp_batterydata>;
	qcom,sec-charger-config = <2>;
	qcom,auto-recharge-soc = <98>;
	qcom,step-charging-enable;
	qcom,sw-jeita-enable;
	qcom,charger-temp-max = <800>;
	qcom,smb-temp-max = <800>;
	qcom,suspend-input-on-debug-batt;
	qcom,fcc-stepping-enable;
	qcom,fcc-step-delay-ms = <100>;
	qcom,fcc-step-size-ua = <100000>;
	qcom,smb-internal-pull-kohm = <0>;
	qcom,en-skin-therm-mitigation;
	qcom,hvdcp3-standalone-config;
};

&pm7250b_qg {
	status = "ok";
	#io-channel-cells = <1>;
	io-channels = <&pm7250b_vadc ADC5_BAT_THERM_100K_PU>,
		      <&pm7250b_vadc ADC5_BAT_ID_100K_PU>,
		      <&pm7250b_charger PSY_IIO_INPUT_CURRENT_LIMITED>,
		      <&pm7250b_charger PSY_IIO_RECHARGE_SOC>,
		      <&pm7250b_charger PSY_IIO_FORCE_RECHARGE>,
		      <&pm7250b_charger PSY_IIO_CHARGE_DONE>;
	io-channel-names = "batt-therm",
			   "batt-id",
			   "input_current_limited",
			   "recharge_soc",
			   "force_recharge",
			   "charge_done";
	qcom,battery-data = <&mtp_batterydata>;
	qcom,qg-iterm-ma = <100>;
	qcom,hold-soc-while-full;
	qcom,linearize-soc;
	qcom,cl-feedback-on;
	qcom,tcss-enable;
	qcom,fvss-enable;
	qcom,fvss-vbatt-mv = <3500>;
	qcom,bass-enable;
	qcom,vbatt-cutoff-mv = <3400>;
	qcom,vbatt-low-mv = <3500>;
	qcom,vbatt-low-cold-mv = <3800>;
	qcom,vbatt-empty-mv = <3200>;
	qcom,vbatt-empty-cold-mv = <3100>;
};

&pm7250b_charger {
	dpdm-supply = <&usb2_phy0>;

	smb5_vbus: qcom,smb5-vbus {
		regulator-name = "smb5-vbus";
	};

	smb5_vconn: qcom,smb5-vconn {
		regulator-name = "smb5-vconn";
	};
};

&pm7250b_pdphy {
	vdd-pdphy-supply = <&L15A>;
	vbus-supply = <&smb5_vbus>;
	vconn-supply = <&smb5_vconn>;

	#io-channel-cells = <1>;
	io-channels = <&pm7250b_charger PSY_IIO_PD_ACTIVE>,
		      <&pm7250b_charger PSY_IIO_TYPEC_CC_ORIENTATION>,
		      <&pm7250b_charger PSY_IIO_CONNECTOR_TYPE>,
		      <&pm7250b_charger PSY_IIO_TYPEC_POWER_ROLE>,
		      <&pm7250b_charger PSY_IIO_PD_USB_SUSPEND_SUPPORTED>,
		      <&pm7250b_charger PSY_IIO_TYPEC_SRC_RP>,
		      <&pm7250b_charger PSY_IIO_PD_IN_HARD_RESET>,
		      <&pm7250b_charger PSY_IIO_PD_CURRENT_MAX>,
		      <&pm7250b_charger PSY_IIO_PR_SWAP>,
		      <&pm7250b_charger PSY_IIO_PD_VOLTAGE_MIN>,
		      <&pm7250b_charger PSY_IIO_PD_VOLTAGE_MAX>,
		      <&pm7250b_charger PSY_IIO_USB_REAL_TYPE>,
		      <&pm7250b_charger PSY_IIO_TYPEC_MODE>,
		      <&pm7250b_charger PSY_IIO_PE_START>;
	io-channel-names = "pd_active",
		      "typec_cc_orientation",
		      "connector_type",
		      "typec_power_role",
		      "pd_usb_suspend_supported",
		      "typec_src_rp",
		      "pd_in_hard_reset",
		      "pr_current_max",
		      "pr_swap",
		      "pd_voltage_min",
		      "pd_voltage_max",
		      "real_type",
		      "typec_mode",
		      "pe_start";
};

&usb0 {
	extcon = <&pm7250b_pdphy>, <&pm7250b_charger>, <&eud>;
};
