summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-11-24 16:01:54 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-29 00:44:04 +0000
commit1fc2ef1334bb550a558fedf6d9ed824be3272c41 (patch)
tree26a9fbc334aff4b8e9a6ae389f3186c6a41cbee1
parent5fa09f3889b8476e5c34df1d363b514dec0738fe (diff)
downloadchrome-ec-1fc2ef1334bb550a558fedf6d9ed824be3272c41.tar.gz
nissa/sm5803: avoid charging from 12V with 3S battery
The combination of 12V VBUS and 3S battery is extremely inefficient with the SM5803, so completely reject 12V PD contracts when the battery design voltage is consistent with a 3S battery and the board uses SM5803. BUG=b:260271871, b:258754576 TEST=With PD max voltage limited to 12V and a charger with 12V source caps, nereid negotiates a 9V PD contract instead. BRANCH=nissa LOW_COVERAGE_REASON=no emulator for SM5803 yet Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ieb93d5ca410e8b942686c23cb4b761416f8981d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054762 Reviewed-by: Andrew McRae <amcrae@google.com> Commit-Queue: Andrew McRae <amcrae@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/Kconfig.charger6
-rw-r--r--zephyr/program/nissa/src/common.c39
2 files changed, 45 insertions, 0 deletions
diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger
index 35bd8590ab..c2c6eeb3f4 100644
--- a/zephyr/Kconfig.charger
+++ b/zephyr/Kconfig.charger
@@ -204,6 +204,12 @@ config PLATFORM_EC_CHARGER_SM5803
Enables the driver for the SM5803.
The SM5803 is the Silicon Mitus SM5803 Buck-Boost Charger.
+ This charger is known to be very inefficient when operating in buck-boost
+ mode (when input voltage is close to output voltage), such that permanent
+ damage may be done to the charger. Users should exercise caution around
+ choice of supported configurations: see b:260271871, b:258754576, and
+ b:230712704 for more information.
+
if PLATFORM_EC_OCPC
diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c
index 119a999736..155dc541d4 100644
--- a/zephyr/program/nissa/src/common.c
+++ b/zephyr/program/nissa/src/common.c
@@ -148,3 +148,42 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
*kd = 0;
*kd_div = 1;
}
+
+#ifdef CONFIG_PLATFORM_EC_CHARGER_SM5803
+/*
+ * 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
+ * inductor have been observed when sinking normal charge current in
+ * buck-boost mode (but not in buck or boost mode) so we choose to
+ * completely exclude some voltages that are likely to be problematic.
+ *
+ * Nissa devices use either 2S or 3S batteries, for which VBUS will
+ * usually only be near VSYS with a 3S battery and 12V input (picked
+ * from among common supported PD voltages)- 2S can get close to
+ * 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
+ * that other problematic PD voltages (near to, but not exactly 12V)
+ * will rarely occur.
+ */
+ if (battery_voltage > 9000 && mv == 12000) {
+ return false;
+ }
+ return true;
+}
+#endif