From patchwork Tue Feb 24 04:33:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 5875441 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F41BC9F37F for ; Tue, 24 Feb 2015 20:59:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D3D620260 for ; Tue, 24 Feb 2015 20:59:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A991320263 for ; Tue, 24 Feb 2015 20:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752868AbbBXU5G (ORCPT ); Tue, 24 Feb 2015 15:57:06 -0500 Received: from cantor2.suse.de ([195.135.220.15]:36321 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752401AbbBXU5D (ORCPT ); Tue, 24 Feb 2015 15:57:03 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 66975AB0C; Tue, 24 Feb 2015 20:57:01 +0000 (UTC) From: NeilBrown To: Samuel Ortiz , Tony Lindgren , Lee Jones , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse Date: Tue, 24 Feb 2015 15:33:52 +1100 Subject: [PATCH 10/15] twl4030_charger: only draw USB current as negotiated with host. Cc: GTA04 owners , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Message-ID: <20150224043352.4243.84042.stgit@notabene.brown> In-Reply-To: <20150224043341.4243.23291.stgit@notabene.brown> References: <20150224043341.4243.23291.stgit@notabene.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_12_24, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: NeilBrown Acked-by: Pavel Machek --- drivers/power/twl4030_charger.c | 5 +++++ 1 file changed, 5 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index b0242786d047..01090a440583 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -597,6 +597,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: @@ -609,6 +610,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 *vbus_draw = priv; dev_dbg(bci->dev, "OTG notify %lu\n", val); @@ -619,6 +621,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;