summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael5 Chen <michael5_chen@pegatroncorp.com>2019-08-27 10:27:58 +0800
committerCommit Bot <commit-bot@chromium.org>2019-09-20 04:55:19 +0000
commit6e0dd622e2f4d83432f0b518b58cf99645097ab4 (patch)
tree6fcd055d5a229fc505ea763d81ff92594e2c0929
parentb40d293f3767f196c3fc926125c467033981a02a (diff)
downloadchrome-ec-6e0dd622e2f4d83432f0b518b58cf99645097ab4.tar.gz
rammus: Set input voltage to 9V when batt full
To reduce our power consumption in our lowest power state, we should reduce the charger's input voltage down to 9V when the battery is full and we are no longer charging it. This commit will trigger a PD negotiation to select a 9V source cap. BUG=b:139429471 BRANCH=firmware-rammus-11275.B TEST=Manual Power team check power consumption under S5. Change-Id: I88517255b196ca56660441270fe01143f97f4f4d Signed-off-by: Michael5 Chen <michael5_chen@pegatroncorp.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1772576 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org> Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r--board/rammus/battery.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/board/rammus/battery.c b/board/rammus/battery.c
index 916aac5fd3..d0cc2f13d2 100644
--- a/board/rammus/battery.c
+++ b/board/rammus/battery.c
@@ -7,11 +7,15 @@
#include "battery.h"
#include "battery_smart.h"
+#include "charge_manager.h"
#include "charge_state.h"
+#include "chipset.h"
#include "console.h"
#include "ec_commands.h"
#include "extpower.h"
+#include "hooks.h"
#include "gpio.h"
+#include "usb_pd.h"
#include "util.h"
static enum battery_present batt_pres_prev = BP_NOT_SURE;
@@ -128,3 +132,28 @@ enum battery_present battery_is_present(void)
return batt_pres;
}
+static void reduce_input_voltage_when_full(void)
+{
+ struct batt_params batt;
+ int max_pd_voltage_mv;
+ int active_chg_port;
+
+ active_chg_port = charge_manager_get_active_charge_port();
+ if (active_chg_port == CHARGE_PORT_NONE)
+ return;
+
+ battery_get_params(&batt);
+ if (!(batt.flags & BATT_FLAG_BAD_STATUS)) {
+ /* Lower our input voltage to 9V when battery is full. */
+ if ((batt.status & STATUS_FULLY_CHARGED) &&
+ chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ max_pd_voltage_mv = 9000;
+ else
+ max_pd_voltage_mv = PD_MAX_VOLTAGE_MV;
+
+ if (pd_get_max_voltage() != max_pd_voltage_mv)
+ pd_set_external_voltage_limit(active_chg_port,
+ max_pd_voltage_mv);
+ }
+}
+DECLARE_HOOK(HOOK_SECOND, reduce_input_voltage_when_full, HOOK_PRIO_DEFAULT);