summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZick Wei <zick.wei@quanta.corp-partner.google.com>2022-12-01 15:13:54 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-02 05:00:23 +0000
commit4e61180495797e59edca0374d62c7c0539cf0099 (patch)
treedf41c38339b522746a168966f8f4e98475ff1b43
parent25b49cfcb6368a9ee1811f73d1be0c5f63dbd208 (diff)
downloadchrome-ec-4e61180495797e59edca0374d62c7c0539cf0099.tar.gz
nissa/sm5803: fix USBC1 malfunction with adapter
CL:4054762 will cause USBC1 port malfunction when plug in adapter, this CL read charger pmode during init and use in pd_is_valid_input_voltage(). BUG=none BRANCH=none TEST=On yaviks, USBC1 charge normal with adapter. LOW_COVERAGE_REASON=no emulator for SM5803 yet Signed-off-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Change-Id: I15308bc1101d4c0cff2558729e56324ec6108522 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4066726 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Devin Lu <devin.lu@quantatw.com>
-rw-r--r--zephyr/program/nissa/src/common.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c
index d437bfca47..9ca754de21 100644
--- a/zephyr/program/nissa/src/common.c
+++ b/zephyr/program/nissa/src/common.c
@@ -150,20 +150,26 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
}
#ifdef CONFIG_PLATFORM_EC_CHARGER_SM5803
+
+static int battery_cells;
+
+void board_get_battery_cells(void)
+{
+ if (charger_get_battery_cells(CHARGER_PRIMARY, &battery_cells) ==
+ EC_SUCCESS) {
+ LOG_INF("battery_cells:%d", battery_cells);
+ } else {
+ LOG_ERR("Failed to get default battery type");
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_get_battery_cells, HOOK_PRIO_DEFAULT);
+
/*
* Called by USB-PD code to determine whether a given input voltage is
* acceptable.
*/
__override int pd_is_valid_input_voltage(int mv)
{
- int battery_voltage, rv;
-
- rv = battery_design_voltage(&battery_voltage);
- if (rv) {
- LOG_ERR("Unable to get battery design voltage: %d", rv);
- return true;
- }
-
/*
* SM5803 is extremely inefficient in buck-boost mode, when
* VBUS ~= VSYS: very high temperatures on the chip and associated
@@ -177,11 +183,11 @@ __override int pd_is_valid_input_voltage(int mv)
* 9V, but we expect charge current to be low when a 2S battery is
* charged to that voltage (because it will be nearly full).
*
- * We assume that any battery with a design voltage above 9V is 3S, and
+ * We assume that any battery with a design 3S, and
* that other problematic PD voltages (near to, but not exactly 12V)
* will rarely occur.
*/
- if (battery_voltage > 9000 && mv == 12000) {
+ if (battery_cells == 3 && mv == 12000) {
return false;
}
return true;