power: pm8921-charger: add enable/disable api

Add api to enable/disable battery charging. This api will help
start/stop current flowing in the battery for charging purposes, but
it does not affect the current the device draws from a charger source.

CRs-Fixed: 300786
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c
index e250d54..dbd8ba6 100644
--- a/drivers/power/pm8921-charger.c
+++ b/drivers/power/pm8921-charger.c
@@ -766,6 +766,22 @@
 }
 EXPORT_SYMBOL_GPL(pm8921_charger_vbus_draw);
 
+int pm8921_charger_enable(bool enable)
+{
+	int rc;
+
+	if (!the_chip) {
+		pr_err("called before init\n");
+		return -EINVAL;
+	}
+	enable = !!enable;
+	rc = pm_chg_auto_enable(the_chip, enable);
+	if (rc)
+		pr_err("Failed rc=%d\n", rc);
+	return rc;
+}
+EXPORT_SYMBOL(pm8921_charger_enable);
+
 static void handle_usb_insertion_removal(struct pm8921_chg_chip *chip)
 {
 	int usb_present;
@@ -1040,6 +1056,13 @@
 	return IRQ_HANDLED;
 }
 
+/**
+ * set_disable_status_param -
+ *
+ * Internal function to disable battery charging and also disable drawing
+ * any current from the source. The device is forced to run on a battery
+ * after this.
+ */
 static int set_disable_status_param(const char *val, struct kernel_param *kp)
 {
 	int ret;
diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h
index a79d753..8c908e4b 100644
--- a/include/linux/mfd/pm8xxx/pm8921-charger.h
+++ b/include/linux/mfd/pm8xxx/pm8921-charger.h
@@ -52,6 +52,15 @@
 void pm8921_charger_vbus_draw(unsigned int mA);
 int pm8921_charger_register_vbus_sn(void (*callback)(int));
 void pm8921_charger_unregister_vbus_sn(void (*callback)(int));
+/**
+ * pm8921_charger_enable -
+ *
+ * @enable: 1 means enable charging, 0 means disable
+ *
+ * Enable/Disable battery charging current, the device will still draw current
+ * from the charging source
+ */
+int pm8921_charger_enable(bool enable);
 #else
 static inline void pm8921_charger_vbus_draw(unsigned int mA)
 {
@@ -63,6 +72,10 @@
 static inline void pm8921_charger_unregister_vbus_sn(void (*callback)(int))
 {
 }
+static inline int pm8921_charger_enable(bool enable)
+{
+	return -ENXIO;
+}
 #endif
 
 #endif