diff options
Diffstat (limited to 'board/spring/usb_charging.c')
-rw-r--r-- | board/spring/usb_charging.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index 61e2b96da3..135405d483 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -166,6 +166,20 @@ void board_pwm_duty_cycle(int percent) current_pwm_duty = percent; } +void board_pwm_init_limit(void) +{ + int dummy; + + /* + * Shut off power input if battery is good. Otherwise, leave + * 500mA to sustain the system. + */ + if (battery_current(&dummy)) + board_pwm_duty_cycle(I_LIMIT_500MA); + else + board_ilim_config(ILIM_CONFIG_MANUAL_ON); +} + static void board_pwm_tweak(void) { int vbus, current; @@ -199,7 +213,12 @@ DECLARE_HOOK(HOOK_SECOND, board_pwm_tweak, HOOK_PRIO_DEFAULT); void board_pwm_nominal_duty_cycle(int percent) { - board_pwm_duty_cycle(percent + PWM_CTRL_BEGIN_OFFSET); + int dummy; + + if (battery_current(&dummy)) + board_pwm_duty_cycle(percent); + else + board_pwm_duty_cycle(percent + PWM_CTRL_BEGIN_OFFSET); nominal_pwm_duty = percent; } |