diff options
author | Vic Yang <victoryang@chromium.org> | 2013-07-18 23:13:30 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-18 12:42:23 -0700 |
commit | 795f82ca36060268aa520867bd935ee88a0e1f44 (patch) | |
tree | 2dc44186749b8b396d2e80d5f0b0d827d1980a30 | |
parent | 42a3daf8fb55fb3a35b6e064aa678708a25366a4 (diff) | |
download | chrome-ec-795f82ca36060268aa520867bd935ee88a0e1f44.tar.gz |
spring: Tweak S5 boost on/off bounds
Instead of reading charge percentage from the battery, let's read
battery capacity. This avoids the rounding done by the battery and gives
us more precise percentage value.
BUG=chrome-os-partner:20768
TEST=Build success. Check boost is turned off when battery is at 98%.
BRANCH=Spring
Change-Id: Ieb56e8fced5261f7964287932718b239833dd7b4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62478
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
-rw-r--r-- | board/spring/usb_charging.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index 4094a19faa..eb47f92eba 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -535,7 +535,7 @@ static int usb_need_boost(int dev_type) static void usb_s5_manage_boost(void) { - int charge; + int chg, cap; int boost = gpio_get_level(GPIO_BOOST_EN); if (!usb_maybe_power_input(current_dev_type)) { @@ -544,13 +544,14 @@ static void usb_s5_manage_boost(void) return; } - if (battery_state_of_charge(&charge)) + if (battery_remaining_capacity(&chg) || + battery_full_charge_capacity(&cap)) return; - if (boost == 0 && charge <= S5_BOOST_CTRL_LOWER_BOUND) { + if (boost == 0 && chg * 100 <= S5_BOOST_CTRL_LOWER_BOUND * cap) { gpio_set_level(GPIO_BOOST_EN, 1); gpio_set_level(GPIO_CHARGER_EN, 1); - } else if (boost == 1 && charge >= S5_BOOST_CTRL_UPPER_BOUND) { + } else if (boost == 1 && chg * 100 >= S5_BOOST_CTRL_UPPER_BOUND * cap) { gpio_set_level(GPIO_CHARGER_EN, 0); gpio_set_level(GPIO_BOOST_EN, 0); } |