summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-03-03 09:34:44 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-03-04 05:08:32 +0000
commit040bd9b3590d8012a9adf7eb9c8ea7e6bb56167c (patch)
tree0754a35dfe9a42ab448969b91b92ec975c31527f
parent3827e7bdc32950ce637d5f9c8cfb1817f7f2b830 (diff)
downloadchrome-ec-040bd9b3590d8012a9adf7eb9c8ea7e6bb56167c.tar.gz
charger: Add state for discharge + full
When battery is fully charged, Reef starts discharging to protect battery and starts charging again when charge level goes down around 95%. To prevent the battery LED from showing blue with the charger plugged in, this patch adds a new state for discharge + nearly full. Reef shows a color indicating battery is full if an external charger is present. BUG=b:35775017 BRANCH=none TEST=Fully charge Electro. Plug in OEM charger. LED lights blue. Change-Id: I4c7c62f2c51c1d39188d1b271331984e89d5d7a3 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/448961 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 7757a8e872588fda9643f31399c5641982e07439) Reviewed-on: https://chromium-review.googlesource.com/449477 Commit-Queue: Keith Tzeng <keith.tzeng@quantatw.com> Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
-rw-r--r--board/reef/board.h1
-rw-r--r--board/reef/led.c8
-rw-r--r--common/charge_state_v2.c7
-rw-r--r--include/charge_state.h3
-rw-r--r--include/config.h6
5 files changed, 23 insertions, 2 deletions
diff --git a/board/reef/board.h b/board/reef/board.h
index 52a893a9fe..30f08a109c 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -151,6 +151,7 @@
#define CONFIG_WIRELESS_SUSPEND EC_WIRELESS_SWITCH_WLAN_POWER
#define CONFIG_WLAN_POWER_ACTIVE_LOW
#define WIRELESS_GPIO_WLAN_POWER GPIO_WIRELESS_GPIO_WLAN_POWER
+#define CONFIG_PWR_STATE_DISCHARGE_FULL
/*
* During shutdown sequence TPS65094x PMIC turns off the sensor rails
diff --git a/board/reef/led.c b/board/reef/led.c
index ee06d31995..b559a00da8 100644
--- a/board/reef/led.c
+++ b/board/reef/led.c
@@ -100,7 +100,13 @@ static void led_set_battery(void)
case PWR_STATE_CHARGE:
led_set_color_battery(LED_AMBER);
break;
- case PWR_STATE_DISCHARGE:
+ case PWR_STATE_DISCHARGE_FULL:
+ if (extpower_is_present()) {
+ led_set_color_battery(LED_BLUE);
+ break;
+ }
+ /* Intentional fall-through */
+ case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */:
if (chipset_in_state(CHIPSET_STATE_ON)) {
led_set_color_battery(LED_BLUE);
} else if (chipset_in_state(CHIPSET_STATE_SUSPEND |
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 94dd210972..2df555f54a 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1012,7 +1012,12 @@ enum charge_state charge_get_state(void)
return PWR_STATE_ERROR;
return PWR_STATE_IDLE;
case ST_DISCHARGE:
- return PWR_STATE_DISCHARGE;
+#ifdef CONFIG_PWR_STATE_DISCHARGE_FULL
+ if (curr.batt.state_of_charge >= BATTERY_LEVEL_NEAR_FULL)
+ return PWR_STATE_DISCHARGE_FULL;
+ else
+#endif
+ return PWR_STATE_DISCHARGE;
case ST_CHARGE:
/* The only difference here is what the LEDs display. */
if (curr.batt.state_of_charge >= BATTERY_LEVEL_NEAR_FULL)
diff --git a/include/charge_state.h b/include/charge_state.h
index a1e476209d..d0c7eb91db 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -35,6 +35,8 @@ enum charge_state {
PWR_STATE_IDLE,
/* Discharging */
PWR_STATE_DISCHARGE,
+ /* Discharging and fully charged */
+ PWR_STATE_DISCHARGE_FULL,
/* Charging */
PWR_STATE_CHARGE,
/* Charging, almost fully charged */
@@ -61,6 +63,7 @@ enum charge_state {
"idle0", \
"idle", \
"discharge", \
+ "discharge_full", \
"charge", \
"charge_near_full", \
"error" \
diff --git a/include/config.h b/include/config.h
index c431a34ce0..ed971ddc27 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2484,6 +2484,12 @@
/* A different config for the same update. TODO(vbendeb): dedup these */
#undef CONFIG_USB_UPDATE
+/*
+ * If defined, charge_get_state returns a special status if battery is
+ * discharging and battery is nearly full.
+ */
+#undef CONFIG_PWR_STATE_DISCHARGE_FULL
+
/*****************************************************************************/
/*
* Include board and core configs, since those hold the CONFIG_ constants for a