power: pm8921-charger: support dc charging while in usb host mode
The current code disables charging when the usb is operating in host
mode. This unnecessarily stops charging from the DC path. The board
layout (the ovp fet and otg path) is assumed to support host mode and
charging from dc path.
Also make the usb driver change the power supply framework's scope
property instead of calling 8921 charger apis directly.
CRs-Fixed: 373365
Change-Id: I2a9fb32de22cbe68e26078b97a7d83c40272a370
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 1d9c84f..5b85d98 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -972,6 +972,21 @@
}
#endif
+static int msm_otg_notify_host_mode(struct msm_otg *motg, bool host_mode)
+{
+ if (!psy)
+ goto psy_not_supported;
+
+ if (host_mode)
+ power_supply_set_scope(psy, POWER_SUPPLY_SCOPE_SYSTEM);
+ else
+ power_supply_set_scope(psy, POWER_SUPPLY_SCOPE_DEVICE);
+
+psy_not_supported:
+ dev_dbg(motg->phy.dev, "Power Supply doesn't support USB charger\n");
+ return -ENXIO;
+}
+
static int msm_otg_notify_chg_type(struct msm_otg *motg)
{
static int charger_type;
@@ -1220,7 +1235,7 @@
* current from the source.
*/
if (on) {
- pm8921_disable_source_current(on);
+ msm_otg_notify_host_mode(motg, on);
ret = regulator_enable(vbus_otg);
if (ret) {
pr_err("unable to enable vbus_otg\n");
@@ -1233,7 +1248,7 @@
pr_err("unable to disable vbus_otg\n");
return;
}
- pm8921_disable_source_current(on);
+ msm_otg_notify_host_mode(motg, on);
vbus_is_on = false;
}
}