summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2018-08-31 18:42:52 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-09-19 23:58:54 +0000
commit417695542129ade7e452c1297d8957fc0da071f4 (patch)
tree27e0b1af37f38674ce6d35736055a8ce6ed4459f
parentf97f4ab348fca723281b852af4d7264a54e075f7 (diff)
downloadchrome-ec-417695542129ade7e452c1297d8957fc0da071f4.tar.gz
scarlet: Limit PD max voltage in a special case
BUG=b:78792296 BRANCH=scarlet TEST=See PD voltage locked to 5V and back to normal (9V in my case) when rt946x enters/exits charge termination. Change-Id: I0889badcaf4a8d435dc53f6fa986b3d6e06c285b Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/1200416 Reviewed-by: David Schneider <dnschneid@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org>
-rw-r--r--board/scarlet/battery.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c
index 7c407fe6d1..76184d7485 100644
--- a/board/scarlet/battery.c
+++ b/board/scarlet/battery.c
@@ -17,6 +17,7 @@
#include "gpio.h"
#include "hooks.h"
#include "system.h"
+#include "usb_pd.h"
#include "util.h"
/*
@@ -98,6 +99,16 @@ static const struct max17055_batt_profile batt_profile[] = {
},
};
+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);
+}
+
const struct battery_info *battery_get_info(void)
{
if (batt_id >= BATTERY_COUNT)
@@ -255,22 +266,27 @@ int charger_profile_override(struct charge_state_data *curr)
curr->batt.state_of_charge);
/*
* This is a workaround for b:78792296. When AP is off and
- * charge termination is detected, we disable idle mode.
+ * charge termination is detected, we disable idle mode and
+ * lower the max PD voltage.
*/
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
disable_idle();
- else
+ pd_limit_5v(1);
+ } else {
enable_idle();
+ pd_limit_5v(0);
+ }
}
return 0;
}
-static void board_enable_idle(void)
+static void board_protection_reset(void)
{
enable_idle();
+ pd_limit_5v(0);
}
-DECLARE_HOOK(HOOK_AC_CHANGE, board_enable_idle, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_AC_CHANGE, board_protection_reset, HOOK_PRIO_DEFAULT);
static void board_charge_termination(void)
{