summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2019-01-15 14:05:14 +0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-16 05:26:13 -0800
commitc5d961bd3d17cfe6d6764533d532661dc617967c (patch)
tree63762cc4c85fbda724cad513f2ad3eeaa2eb062d
parente3b446951d6001b5c6cb0e3019e908205d75f31a (diff)
downloadchrome-ec-c5d961bd3d17cfe6d6764533d532661dc617967c.tar.gz
kukui: Take scarlet charger workaround CLs.
This CL squashed several scarlet charger fixes. https://crrev.com/c/1055194 scarlet: Clamp reported battery SOC when charge terminates https://crrev.com/c/1200416 scarlet: Limit PD max voltage in a special case https://crrev.com/c/1311753 scarlet: Throttle PD voltage based on battery level https://crrev.com/c/1338601 scarlet: Consider power state transition when throttling PD https://crrev.com/c/1344799 scarlet: Limit PD voltage when battery SOC > 85% https://crrev.com/c/1378765 scarlet: Throttle PD voltage regardless of power state In general, it reduces the PD charging voltage to 5.5V when the battery percent is over 85 percent. TEST=Charge kukui with PD charger <= 85%, and see it switches to 5V when battery > 85%. BUG=b:78792296 BRANCH=None Change-Id: Ibdd496085f25b715ab2efb1b284f1aa5e3246653 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1411436 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org>
-rw-r--r--board/kukui/battery.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/board/kukui/battery.c b/board/kukui/battery.c
index ff5764ff97..5a3e27b844 100644
--- a/board/kukui/battery.c
+++ b/board/kukui/battery.c
@@ -16,6 +16,7 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "usb_pd.h"
#include "util.h"
#define TEMP_OUT_OF_RANGE TEMP_ZONE_COUNT
@@ -23,6 +24,8 @@
/* We have only one battery now. */
#define BATT_ID 0
+#define BAT_LEVEL_PD_LIMIT 85
+
#define BATTERY_SIMPLO_CHARGE_MIN_TEMP 0
#define BATTERY_SIMPLO_CHARGE_MAX_TEMP 60
@@ -166,6 +169,17 @@ int charger_profile_override(struct charge_state_data *curr)
break;
}
+ /*
+ * When the charger says it's done charging, even if fuel gauge says
+ * SOC < BATTERY_LEVEL_NEAR_FULL, we'll overwrite SOC with
+ * BATTERY_LEVEL_NEAR_FULL. So we can ensure both Chrome OS UI
+ * and battery LED indicate full charge.
+ */
+ if (rt946x_is_charge_done()) {
+ curr->batt.state_of_charge = MAX(BATTERY_LEVEL_NEAR_FULL,
+ curr->batt.state_of_charge);
+ }
+
return 0;
}
@@ -182,6 +196,23 @@ DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
board_charge_termination,
HOOK_PRIO_DEFAULT);
+static void pd_limit_5v(uint8_t en)
+{
+ int wanted_pd_voltage;
+
+ wanted_pd_voltage = en ? 5500 : PD_MAX_VOLTAGE_MV;
+
+ if (pd_get_max_voltage() != wanted_pd_voltage)
+ pd_set_external_voltage_limit(0, wanted_pd_voltage);
+}
+
+/* When battery level > BAT_LEVEL_PD_LIMIT, we limit PD voltage to 5V. */
+static void board_pd_voltage(void)
+{
+ pd_limit_5v(charge_get_percent() > BAT_LEVEL_PD_LIMIT);
+}
+DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, board_pd_voltage, HOOK_PRIO_DEFAULT);
+
/* Customs options controllable by host command. */
#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)