summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-20 17:31:17 +0800
committerChromeBot <chrome-bot@google.com>2013-05-20 10:11:04 -0700
commit2d1268d891b525e71e3b268d0f90aa89137c008d (patch)
tree5d6292ce072e368cacbe5c419ba14143928e627e
parent70ada0603c88d0fc2e074768f99abc6e3fcf0fe1 (diff)
downloadchrome-ec-2d1268d891b525e71e3b268d0f90aa89137c008d.tar.gz
Draw more current when lower than 500mA
If the current value is lower than 500mA and voltage is higher than 4.55V, draw more current. Also to make PWM duty cycle more stable, disable fast mode once we hit low voltage condition. BUG=chrome-os-partner:19486 TEST=Plug in a low voltage USB host. Check we draw more current. BRANCH=spring Change-Id: I91ee97ca15247d49427d4db34d17a0d0c55b2684 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/55722 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/extpower_usb.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/common/extpower_usb.c b/common/extpower_usb.c
index 3628c9541c..719527f4a3 100644
--- a/common/extpower_usb.c
+++ b/common/extpower_usb.c
@@ -69,6 +69,7 @@ enum ilim_config {
#define PWM_CTRL_VBUS_HARD_LOW 4400
#define PWM_CTRL_VBUS_LOW 4500
#define PWM_CTRL_VBUS_HIGH 4700 /* Must be higher than 4.5V */
+#define PWM_CTRL_VBUS_HIGH_500MA 4550
/* Delay for signals to settle */
#define DELAY_POWER_MS 20
@@ -90,6 +91,7 @@ static int current_dev_type = TSU6721_TYPE_NONE;
static int nominal_pwm_duty;
static int current_pwm_duty;
static int user_pwm_duty = -1;
+static int pwm_fast_mode;
static int pending_tsu6721_reset;
@@ -315,7 +317,8 @@ static int pwm_get_next_lower(void)
int fast_next = current_pwm_duty - PWM_CTRL_STEP_FAST_DOWN;
if (current_limit_mode == LIMIT_AGGRESSIVE) {
- if (fast_next >= nominal_pwm_duty - PWM_CTRL_OC_MARGIN &&
+ if (pwm_fast_mode &&
+ fast_next >= nominal_pwm_duty - PWM_CTRL_OC_MARGIN &&
fast_next >= over_current_pwm_duty)
return MAX(fast_next, 0);
if (current_pwm_duty > nominal_pwm_duty -
@@ -340,6 +343,15 @@ static int pwm_check_vbus_low(int vbus, int battery_current)
return vbus < PWM_CTRL_VBUS_HARD_LOW && current_pwm_duty < 100;
}
+static int pwm_check_vbus_high(int vbus)
+{
+ if (vbus > PWM_CTRL_VBUS_HIGH)
+ return 1;
+ if (vbus > PWM_CTRL_VBUS_HIGH_500MA && current_pwm_duty > I_LIMIT_500MA)
+ return 1;
+ return 0;
+}
+
static void pwm_nominal_duty_cycle(int percent)
{
int dummy;
@@ -351,6 +363,7 @@ static void pwm_nominal_duty_cycle(int percent)
else
set_pwm_duty_cycle(percent + PWM_CTRL_BEGIN_OFFSET);
nominal_pwm_duty = percent;
+ pwm_fast_mode = 1;
}
static void adc_watch_toad(void)
@@ -667,8 +680,9 @@ static void pwm_tweak(void)
*/
if (pwm_check_vbus_low(vbus, current)) {
set_pwm_duty_cycle(current_pwm_duty + PWM_CTRL_STEP_UP);
+ pwm_fast_mode = 0;
CPRINTF("[%T PWM duty up %d%%]\n", current_pwm_duty);
- } else if (vbus > PWM_CTRL_VBUS_HIGH) {
+ } else if (pwm_check_vbus_high(vbus)) {
next = pwm_get_next_lower();
if (next >= 0) {
set_pwm_duty_cycle(next);