From 6249a400696f270e7c9216db8e2998d7331f4613 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Mon, 4 Mar 2013 10:42:01 +0800 Subject: [PATCH] spring: set maximum allowed duty cycle We should allow a minimum amount of current input in case the battery is dead. BUG=chrome-os-partner:14319 TEST=Boot with a dead battery BRANCH=none Change-Id: I3c172d43c8190ed2dc5d421dcf2b5aaf0e88ecd9 Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/44510 Reviewed-by: Vincent Palatin --- board/spring/usb_charging.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index ce864e1d9f..cf17170129 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -39,6 +39,7 @@ #define I_LIMIT_3000MA 0 /* PWM control loop parameters */ +#define PWM_CTRL_MAX_DUTY 96 /* Minimum current for dead battery */ #define PWM_CTRL_BEGIN_OFFSET 30 #define PWM_CTRL_OC_MARGIN 15 #define PWM_CTRL_OC_DETECT_TIME (800 * MSEC) @@ -249,6 +250,8 @@ void board_pwm_nominal_duty_cycle(int percent) if (battery_current(&dummy)) board_pwm_duty_cycle(percent); + else if (percent + PWM_CTRL_BEGIN_OFFSET > PWM_CTRL_MAX_DUTY) + board_pwm_duty_cycle(PWM_CTRL_MAX_DUTY); else board_pwm_duty_cycle(percent + PWM_CTRL_BEGIN_OFFSET); nominal_pwm_duty = percent;