[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150322232029.23789.13713.stgit@notabene.brown>
Date: Mon, 23 Mar 2015 10:20:29 +1100
From: NeilBrown <neil@...wn.name>
To: Sebastian Reichel <sre@...nel.org>
Cc: NeilBrown <neilb@...e.de>, linux-api@...r.kernel.org,
linux-kernel@...r.kernel.org,
GTA04 owners <gta04-owner@...delico.com>,
inux-pm@...r.kernel.org, Pavel Machek <pavel@....cz>,
linux-omap@...r.kernel.org, Lee Jones <lee.jones@...aro.org>
Subject: [PATCH 09/14] twl4030_charger: only draw USB current as negotiated
with host.
From: NeilBrown <neilb@...e.de>
If the phy has been told what current it can draw, it tells us
and now we use that number.
Note that 'vbus_draw' is in mA, while usb_cur is in uA.
Acked-by: Pavel Machek <pavel@....cz>
Signed-off-by: NeilBrown <neilb@...e.de>
---
drivers/power/twl4030_charger.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index df031b0123d0..2042e7619954 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -602,6 +602,7 @@ static void twl4030_bci_usb_work(struct work_struct *data)
switch (bci->event) {
case USB_EVENT_VBUS:
case USB_EVENT_CHARGER:
+ case USB_EVENT_ENUMERATED:
twl4030_charger_enable_usb(bci, true);
break;
case USB_EVENT_NONE:
@@ -614,6 +615,7 @@ static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val,
void *priv)
{
struct twl4030_bci *bci = container_of(nb, struct twl4030_bci, usb_nb);
+ unsigned int *vbus_draw = priv;
dev_dbg(bci->dev, "OTG notify %lu\n", val);
@@ -624,6 +626,9 @@ static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val,
bci->usb_cur = 100000;
bci->event = val;
+ if (val == USB_EVENT_ENUMERATED && vbus_draw &&
+ *vbus_draw * 1000 > bci->usb_cur)
+ bci->usb_cur = *vbus_draw * 1000;
schedule_work(&bci->work);
return NOTIFY_OK;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists