From af346132938ad4e62df6f5e3a33ff96abea09221 Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Sat, 12 Oct 2019 00:09:28 -0700 Subject: [PATCH] usb: dwc3-msm: Get usb power_supply from device tree Not all instances of the controller should be tied to the USB power_supply. For example in cases of multiple instances, we do not want all instances manipulating the SDP current draw by setting the power_supply property, as there is only usually only a single charger instance. Replace power_supply lookup by "usb" name to a phandle lookup. DT must specify a "qcom,usb-charger" property pointing to the charger instance. Change-Id: Ibd90337782b23f5e1a1a1c2af5a48c49be37823d Signed-off-by: Jack Pham --- drivers/usb/dwc3/dwc3-msm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 3bc456e4f369..68372fe6fdff 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -4537,11 +4537,14 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA) int ret; if (!mdwc->usb_psy) { - mdwc->usb_psy = power_supply_get_by_name("usb"); - if (!mdwc->usb_psy) { - dev_err(mdwc->dev, "Could not get usb psy\n"); + mdwc->usb_psy = power_supply_get_by_phandle(mdwc->dev->of_node, + "qcom,usb-charger"); + if (IS_ERR_OR_NULL(mdwc->usb_psy)) { + dev_info(mdwc->dev, "Could not get usb psy\n"); return -ENODEV; } + } else if (IS_ERR(mdwc->usb_psy)) { + return 0; } if (mdwc->max_power == mA)