mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
usb: dwc3-msm: Revert back to power_supply_by_name() lookup
commit af34613293 ("usb: dwc3-msm: Get usb power_supply from
device tree") changed the power_supply_get_by_name() to
get_by_phandle(), however this does not work if the device
pointed to by the phandle registers multiple power_supply
objects (including battery & wireless as is the case for
QTI PMICs) as we are not guaranteed to get back the USB psy.
Hence revert back to using power_supply_get_by_name() for
the named "usb" psy. We can keep using the "qcom,usb-charger"
DT property but just treat it as boolean instead so that we
can support USB controllers that may not be tied to a charger.
Change-Id: Ic7e4c58b096b0d6210cd55f1ff6edf21ffc5b4b1
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
parent
97ed757748
commit
8f6813196f
1 changed files with 11 additions and 7 deletions
|
|
@ -4276,6 +4276,9 @@ static int dwc3_msm_remove(struct platform_device *pdev)
|
|||
mdwc->dpdm_nb.notifier_call = NULL;
|
||||
}
|
||||
|
||||
if (mdwc->usb_psy)
|
||||
power_supply_put(mdwc->usb_psy);
|
||||
|
||||
/*
|
||||
* In case of system suspend, pm_runtime_get_sync fails.
|
||||
* Hence turn ON the clocks manually.
|
||||
|
|
@ -4684,17 +4687,18 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA)
|
|||
union power_supply_propval pval = {0};
|
||||
int ret;
|
||||
|
||||
if (!mdwc->usb_psy) {
|
||||
mdwc->usb_psy = devm_power_supply_get_by_phandle(mdwc->dev,
|
||||
"qcom,usb-charger");
|
||||
if (IS_ERR_OR_NULL(mdwc->usb_psy)) {
|
||||
dev_info(mdwc->dev, "Could not get usb psy\n");
|
||||
if (!mdwc->usb_psy && of_property_read_bool(mdwc->dev->of_node,
|
||||
"qcom,usb-charger")) {
|
||||
mdwc->usb_psy = power_supply_get_by_name("usb");
|
||||
if (!mdwc->usb_psy) {
|
||||
dev_err(mdwc->dev, "Could not get usb psy\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
} else if (IS_ERR(mdwc->usb_psy)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mdwc->usb_psy)
|
||||
return 0;
|
||||
|
||||
if (mdwc->max_power == mA)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue