diff options
author | Vic Yang <victoryang@chromium.org> | 2013-04-02 17:35:46 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-04-02 23:10:29 -0700 |
commit | 1b68fd9680816e42b52c525a5fa3ee1ca8a10228 (patch) | |
tree | cccaa32928604b46133c0b3eac1b397865f2ad2a | |
parent | d0912c8d92c529208d3f90bd79714d007577c553 (diff) | |
download | chrome-ec-1b68fd9680816e42b52c525a5fa3ee1ca8a10228.tar.gz |
spring: Retry when over current detected
When we detect over current event, it might be a genuine over current
event or the user messing with the charger. Let's add retry machinism to
reduce the probability that a user re-plugging adapter causes charging
current to be limited.
BUG=chrome-os-partner:18527
TEST=Manual
BRANCH=spring
Original-Change-Id: I2b55a9eae39c56ada929e167cf09c4e91a32a55e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47107
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 3c9827a64643008fbac1970871097512c6a24293)
Change-Id: Ie791d2fdf0f2f33f723627e49b47a28ea3414bd9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47217
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/spring/usb_charging.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index 10c834ee77..95449e796d 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -55,6 +55,7 @@ #define PWM_CTRL_OC_MARGIN 15 #define PWM_CTRL_OC_DETECT_TIME (800 * MSEC) #define PWM_CTRL_OC_BACK_OFF 3 +#define PWM_CTRL_OC_RETRY 1 #define PWM_CTRL_STEP_DOWN 2 #define PWM_CTRL_STEP_UP 5 #define PWM_CTRL_VBUS_HARD_LOW 4400 @@ -116,6 +117,7 @@ struct { static timestamp_t power_removed_time[2]; static uint32_t power_removed_type[2]; static int power_removed_pwm_duty[2]; +static int oc_detect_retry[2] = {PWM_CTRL_OC_RETRY, PWM_CTRL_OC_RETRY}; /* PWM duty cycle limit based on over current event */ static int over_current_pwm_duty; @@ -415,8 +417,15 @@ static void usb_detect_overcurrent(int dev_type) int idx = !(dev_type == TSU6721_TYPE_VBUS_DEBOUNCED); timestamp_t now = get_time(); now.val -= power_removed_time[idx].val; - if (power_removed_type[idx] == dev_type && - now.val < PWM_CTRL_OC_DETECT_TIME) { + if (now.val >= PWM_CTRL_OC_DETECT_TIME) { + oc_detect_retry[idx] = PWM_CTRL_OC_RETRY; + return; + } + if (power_removed_type[idx] == dev_type) { + if (oc_detect_retry[idx] > 0) { + oc_detect_retry[idx]--; + return; + } over_current_pwm_duty = power_removed_pwm_duty[idx] + PWM_CTRL_OC_BACK_OFF; } |