diff mbox

[57/57] power: ab8500_charger: Limit USB charger current

Message ID 1348776554-10019-58-git-send-email-mathieu.poirier@linaro.org
State New
Headers show

Commit Message

Mathieu Poirier Sept. 27, 2012, 8:09 p.m. UTC
From: Martin Bergstrom <martin.bergstrom@stericsson.com>

The USB charger current is limited according to information comming
from the USB driver

Signed-off-by: Martin Bergstrom <martin.bergstrom@stericsson.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
---
 drivers/power/ab8500_charger.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index afb4fda..3c6f11c 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -1248,6 +1248,9 @@  static int ab8500_charger_set_vbus_in_curr(struct ab8500_charger *di,
 	if (di->max_usb_in_curr.set_max > 0)
 		min_value = min(di->max_usb_in_curr.set_max, min_value);
 
+	if (di->usb_state.usb_current >= 0)
+		min_value = min(di->usb_state.usb_current, min_value);
+
 	switch (min_value) {
 	case 100:
 		if (di->vbat < VBAT_TRESH_IP_CUR_RED)
@@ -3413,6 +3416,7 @@  static int __devinit ab8500_charger_probe(struct platform_device *pdev)
 	di->usb_chg.wdt_refresh = CHG_WD_INTERVAL;
 	di->usb_chg.enabled = di->pdata->usb_enabled;
 	di->usb_chg.external = false;
+	di->usb_state.usb_current = -1;
 
 	/* Create a work queue for the charger */
 	di->charger_wq =