summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-02-20 21:27:37 +0800
committerChromeBot <chrome-bot@google.com>2013-02-20 09:22:43 -0800
commit070943e9bfa2530603bb84ddaecd209aa53208da (patch)
tree8bec0cf81b64f2e50a6df5dd63802c1b4643f795
parent95253a68dd9ec77388d6556f384299ecb80cfb7e (diff)
downloadchrome-ec-070943e9bfa2530603bb84ddaecd209aa53208da.tar.gz
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>
-rw-r--r--board/spring/board.h3
-rw-r--r--board/spring/usb_charging.c21
-rw-r--r--common/pmu_tps65090_charger.c3
3 files changed, 26 insertions, 1 deletions
diff --git a/board/spring/board.h b/board/spring/board.h
index 5a026d9051..dd1b755da0 100644
--- a/board/spring/board.h
+++ b/board/spring/board.h
@@ -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 */
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;
}
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index 3df1ef3350..4881de5aa7 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -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