summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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