summaryrefslogtreecommitdiff
path: root/board/ampton
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2021-03-05 09:55:02 +0000
committerCommit Bot <commit-bot@chromium.org>2021-03-09 21:22:56 +0000
commit4d5b07d43ba15f5f704722649def0c18ea967871 (patch)
treea5f8847f4c849812264c0feacfa16c492f998a70 /board/ampton
parent76fcd2f08711cd6603c9a2643d88e42a45edbfff (diff)
downloadchrome-ec-4d5b07d43ba15f5f704722649def0c18ea967871.tar.gz
ampton: Change input voltage only when conditions changed
Ampton reduces input voltage to 5 volts when battery is full and chipset is in one of suspend states. When this condition is not true, calling 'reduce_input_voltage_when_full()' always removes the limit by setting maximum voltage to PD_MAX_VOLTAGE_MV. When battery is charging, this function is called every SOC change. As a result any voltage limit is removed on SOC change which effectively breaks firmware_PDVbusRequest test. This patch changes behaviour of this function to restore previous voltage limit when 5 volts limit is no longer needed (chipset is running or battery is charging) BUG=b:161775827 BRANCH=none TEST=Run firmware_PDVbusRequest test on Ampton when battery is not full, test should pass. TEST=Charge battery to 100%. Set 9 volts limit using 'pd 0 dev 9' when chipset is running. Shutdown AP and check if VBUS drops to 5 volts. Wake up board, check if 9 volts limit is restored. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I4a7b1db53b89845e63cbb6a1a4927a2d8e4f0a26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2739680 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/ampton')
-rw-r--r--board/ampton/battery.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/board/ampton/battery.c b/board/ampton/battery.c
index 481216cf61..dab93a4869 100644
--- a/board/ampton/battery.c
+++ b/board/ampton/battery.c
@@ -120,18 +120,29 @@ const struct board_batt_params board_battery_info[] = {
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C214;
+static int saved_input_voltage = -1;
/* Lower our input voltage to 5V in S5/G3 when battery is full. */
static void reduce_input_voltage_when_full(void)
{
- int max_pd_voltage_mv;
+ int max_pd_voltage_mv = pd_get_max_voltage();
int port;
if (charge_get_percent() == 100 &&
- chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF))
+ chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF) &&
+ max_pd_voltage_mv != 5000) {
+ saved_input_voltage = max_pd_voltage_mv;
max_pd_voltage_mv = 5000;
- else
- max_pd_voltage_mv = PD_MAX_VOLTAGE_MV;
+ }
+ else if (saved_input_voltage != -1) {
+ /*
+ * Chipset is not in S5/G3 or battery is not full and input
+ * voltage is reduced
+ */
+ max_pd_voltage_mv = saved_input_voltage;
+ saved_input_voltage = -1;
+ }
+
if (pd_get_max_voltage() != max_pd_voltage_mv) {
for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
pd_set_external_voltage_limit(port, max_pd_voltage_mv);