From bcdfbee1b6b666ef758a35feaf37ee0aba3bf8cd Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Tue, 30 Jul 2013 05:06:49 +0800 Subject: [PATCH] spring: Always pull 500mA before charger type is determined To prevent the EC browning out when the battery is too low, let's always pull 500mA before we can determine the charger type. The correct current limit can then be set after we know the charger type. Also, even if the battery is not present, keep the PWM tweaking loop going. BUG=chrome-os-partner:21107 TEST=Plug in charger to a device with a dead battery and see it charge. BRANCH=Spring Change-Id: Iad5599b60d20fb405d78d30b2be74bcc98958dd5 Original-Change-Id: Iec2ec96e3c2c341f14888aa50bd84f72af75c073 Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/63626 Reviewed-by: Vincent Palatin Reviewed-on: https://gerrit.chromium.org/gerrit/64275 --- common/extpower_usb.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/common/extpower_usb.c b/common/extpower_usb.c index e7ec5e710c..89c9a3577f 100644 --- a/common/extpower_usb.c +++ b/common/extpower_usb.c @@ -671,16 +671,7 @@ static void usb_device_change(int dev_type) */ void extpower_charge_init(void) { - int dummy; - - /* - * Shut off power input if battery is good. Otherwise, leave - * 500mA to sustain the system. - */ - if (battery_current(&dummy)) - set_pwm_duty_cycle(I_LIMIT_500MA); - else - ilim_config(ILIM_CONFIG_MANUAL_ON); + set_pwm_duty_cycle(I_LIMIT_500MA); /* * Somehow TSU6721 comes up slowly. Let's wait for a moment before @@ -821,7 +812,7 @@ static void pwm_tweak(void) vbus = adc_read_channel(ADC_CH_USB_VBUS_SNS); if (battery_current(¤t)) - return; + current = 0; if (user_pwm_duty >= 0) { if (current_pwm_duty != user_pwm_duty)