power: smb5: Configure termination current thresholds

Add support to configure charge termination upper and lower thresholds
for ADC comparator. Since the charge termination can be based off analog
comparator in the charger peripheral, add support to configure the type
of source for termination.

Also expose the configured charge termination threshold (upper
in case of ADC comparator) through CHARGE_TERM_CURRENT property.

CRs-Fixed: 2255712
Change-Id: I5596877a9954b5a5e3c36e3f0b2c5159e03f6e61
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
diff --git a/drivers/power/supply/qcom/smb5-lib.h b/drivers/power/supply/qcom/smb5-lib.h
index e59b11b..5477477 100644
--- a/drivers/power/supply/qcom/smb5-lib.h
+++ b/drivers/power/supply/qcom/smb5-lib.h
@@ -82,6 +82,7 @@
 #define TYPEC_DEFAULT_CURRENT_UA	900000
 #define TYPEC_MEDIUM_CURRENT_UA		1500000
 #define TYPEC_HIGH_CURRENT_UA		3000000
+#define ADC_CHG_TERM_MASK	32767
 
 enum smb_mode {
 	PARALLEL_MASTER = 0,
@@ -188,6 +189,12 @@
 	SUSPEND_INPUT		= 4,
 };
 
+enum chg_term_config_src {
+	ITERM_SRC_UNSPECIFIED,
+	ITERM_SRC_ADC,
+	ITERM_SRC_ANALOG
+};
+
 struct smb_irq_info {
 	const char			*name;
 	const irq_handler_t		handler;
@@ -487,6 +494,8 @@
 				union power_supply_propval *val);
 int smblib_get_prop_batt_current_now(struct smb_charger *chg,
 				union power_supply_propval *val);
+int smblib_get_prop_batt_iterm(struct smb_charger *chg,
+				union power_supply_propval *val);
 int smblib_get_prop_batt_temp(struct smb_charger *chg,
 				union power_supply_propval *val);
 int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,