From: Ray Chi <raychi@google.com>
To: balbi@kernel.org, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
kyletso@google.com, badhri@google.com,
Ray Chi <raychi@google.com>
Subject: [PATCH 2/2] usb: dwc3: add an alternate path in vbus_draw callback
Date: Mon, 22 Feb 2021 19:51:49 +0800 [thread overview]
Message-ID: <20210222115149.3606776-3-raychi@google.com> (raw)
In-Reply-To: <20210222115149.3606776-1-raychi@google.com>
This patch adds an alternate path in vbus_draw callback through
power supply property POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT.
Signed-off-by: Ray Chi <raychi@google.com>
---
drivers/usb/dwc3/gadget.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index aebcf8ec0716..47809835e163 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2530,11 +2530,19 @@ static void dwc3_gadget_set_ssp_rate(struct usb_gadget *g,
static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
{
struct dwc3 *dwc = gadget_to_dwc(g);
+ union power_supply_propval val = {0};
+ int ret;
if (dwc->usb2_phy)
return usb_phy_set_power(dwc->usb2_phy, mA);
- return 0;
+ if (!dwc->usb_psy)
+ return -EOPNOTSUPP;
+
+ val.intval = mA;
+ ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val);
+
+ return ret;
}
static const struct usb_gadget_ops dwc3_gadget_ops = {
--
2.30.0.617.g56c4b15f3c-goog
next prev parent reply other threads:[~2021-02-22 11:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 11:51 [PATCH 0/2] an additional path to control charging current Ray Chi
2021-02-22 11:51 ` [PATCH 1/2] usb: dwc3: add a power supply for current control Ray Chi
2021-03-04 17:24 ` Naresh Kamboju
2021-02-22 11:51 ` Ray Chi [this message]
2021-03-03 15:01 ` [PATCH 0/2] an additional path to control charging current Heiko Thiery
2021-03-03 15:26 ` Heiko Thiery
2021-03-04 8:21 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210222115149.3606776-3-raychi@google.com \
--to=raychi@google.com \
--cc=badhri@google.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kyletso@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).