diff options
author | Cloud <cloud_lin@compal.com> | 2017-04-14 15:29:11 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-06 13:59:24 -0700 |
commit | de7e54c302a570e6bb99881836fc3bafe80acdbe (patch) | |
tree | eca54b50e2580236555648e05280d27e33b7e697 | |
parent | a58f5545c62283adbc7926635acbb6357f0d89b0 (diff) | |
download | chrome-ec-de7e54c302a570e6bb99881836fc3bafe80acdbe.tar.gz |
kahlee: check if battery is present by HW pin
Battery present should be correctly detected even the battery is
in ship mode and waked by AC.
BRANCH=None
BUG=None
TEST=Use "ectool batterycutoff" to enter battery ship mode and plug
in type-c adapter to wake battery
Change-Id: Ic10844562def23a9633dd8333ffbd9a75340bf03
Reviewed-on: https://chromium-review.googlesource.com/477813
Commit-Ready: Martin Roth <martinroth@chromium.org>
Tested-by: Lin Cloud <cloud_lin@compal.com>
Tested-by: Martin Roth <martinroth@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: YH Lin <yueherngl@chromium.org>
Reviewed-by: Martin Roth <martinroth@chromium.org>
-rw-r--r-- | board/kahlee/battery.c | 50 | ||||
-rw-r--r-- | board/kahlee/board.h | 2 |
2 files changed, 1 insertions, 51 deletions
diff --git a/board/kahlee/battery.c b/board/kahlee/battery.c index 1d6d30e890..f1dc9f9432 100644 --- a/board/kahlee/battery.c +++ b/board/kahlee/battery.c @@ -12,8 +12,6 @@ /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 -static enum battery_present batt_pres_prev = BP_NOT_SURE; - static const struct battery_info info = { .voltage_max = 13200,/* mV */ .voltage_normal = 11400, @@ -39,51 +37,3 @@ int board_cut_off_battery(void) return rv; return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); } - -static inline enum battery_present battery_hw_present(void) -{ - /* The GPIO is low when the battery is physically present */ - return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; -} - -static int battery_init(void) -{ - int batt_status; - - return battery_status(&batt_status) ? 0 : - !!(batt_status & STATUS_INITIALIZED); -} - -/* - * Physical detection of battery. - */ -enum battery_present battery_is_present(void) -{ - enum battery_present batt_pres; - - /* Get the physical hardware status */ - batt_pres = battery_hw_present(); - - /* - * Make sure battery status is implemented, I2C transactions are - * success & the battery status is Initialized to find out if it - * is a working battery and it is not in the cut-off mode. - * - * If battery I2C fails but VBATT is high, battery is booting from - * cut-off mode. - * - * FETs are turned off after Power Shutdown time. - * The device will wake up when a voltage is applied to PACK. - * Battery status will be inactive until it is initialized. - */ - if (batt_pres == BP_YES && batt_pres_prev != batt_pres && - !battery_is_cut_off() && !battery_init()) { - batt_pres = BP_NO; - } - - batt_pres_prev = batt_pres; - - return batt_pres; -} - - diff --git a/board/kahlee/board.h b/board/kahlee/board.h index a81e4fb2ee..67355ed04f 100644 --- a/board/kahlee/board.h +++ b/board/kahlee/board.h @@ -27,7 +27,7 @@ /* Battery */ #define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION" #define CONFIG_BATTERY_CUT_OFF -#define CONFIG_BATTERY_PRESENT_CUSTOM +#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_L #define CONFIG_BATTERY_SMART /* Charger */ |