spring: Handle dead battery and booting with low power charger

This tweaks initial PWM configuration so that:
  - When battery is dead, more current is allowed to sustain the system.
  - When EC boots with a low power charger, input current is throttled
    so as not to kill the charger.

BUG=chrome-os-partner:14319
TEST=Manual
BRANCH=none

Change-Id: Ib52894b07fecdd533aecab312f40afa0b6df5676
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43600
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2013-02-20 21:27:37 +08:00
committed by ChromeBot
parent 95253a68dd
commit 070943e9bf
3 changed files with 26 additions and 1 deletions

View File

@@ -174,6 +174,9 @@ int board_get_usb_dev_type(void);
/* Get USB port current limit */
int board_get_usb_current_limit(void);
/* Properly limit input power on EC boot */
void board_pwm_init_limit(void);
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */

View File

@@ -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;
}

View File

@@ -390,6 +390,8 @@ void pmu_charger_task(void)
disable_sleep(SLEEP_MASK_CHARGING);
#ifdef CONFIG_TSU6721
board_pwm_init_limit();
/*
* Somehow TSU6721 comes up slowly. Let's wait for a moment before
* accessing it.
@@ -399,6 +401,7 @@ void pmu_charger_task(void)
tsu6721_init(); /* Init here until we can do with HOOK_INIT */
gpio_enable_interrupt(GPIO_USB_CHG_INT);
msleep(100); /* TSU6721 doesn't work properly right away. */
board_usb_charge_update(1);
#endif