summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-06-19 10:46:43 +0800
committerChromeBot <chrome-bot@google.com>2013-06-19 17:12:35 -0700
commitc5d978baacc44220445ad7b5641bbdb7b634cbfa (patch)
treeb4560349f0f2940d99305e0cf9ae5f347c586cd8
parent89ee180156889ce0fab13fb1a2905bd2270ab8a9 (diff)
downloadchrome-ec-c5d978baacc44220445ad7b5641bbdb7b634cbfa.tar.gz
spring: Hard-limit current draw from Toad
The Toad cable is browning out from time to time. Let's limit its current in aggressive mode. Also fix a bug in hard current limit calculation. BUG=None TEST=Plug-in Toad cable and see PWM duty cycle starts higher. BRANCH=Spring Change-Id: I06d64418989aa32a99545986fe841914f054acde Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/59161 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/extpower_usb.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/extpower_usb.c b/common/extpower_usb.c
index 97034b1eec..5be7d2efc9 100644
--- a/common/extpower_usb.c
+++ b/common/extpower_usb.c
@@ -278,8 +278,14 @@ static int apple_charger_current(void)
static int hard_current_limit(int limit)
{
+ /*
+ * In aggressive mode, the PWM duty cycle goes lower than the nominal
+ * cycle for PWM_CTRL_OC_MARGIN. Therefore, increase duty cycle by
+ * PWM_CTRL_OC_MARGIN avoids going over the hard limit.
+ * (Note that lower PWM cycle translates to higher current)
+ */
if (current_limit_mode == LIMIT_AGGRESSIVE)
- return limit - PWM_CTRL_OC_MARGIN;
+ return MIN(limit + PWM_CTRL_OC_MARGIN, 100);
else
return limit;
}
@@ -524,6 +530,8 @@ static void usb_update_ilim(int dev_type)
current_limit = hard_current_limit(I_LIMIT_1500MA);
else if (dev_type & TSU6721_TYPE_JIG_UART_ON)
current_limit = hard_current_limit(I_LIMIT_2000MA);
+ else if (dev_type & TOAD_DEVICE_TYPE)
+ current_limit = hard_current_limit(I_LIMIT_500MA);
pwm_nominal_duty_cycle(current_limit);
} else {