diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-11-03 13:42:45 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-05 01:22:13 +0000 |
commit | 213dd9e5a9981a825393eb9b29d69dc0afb426ac (patch) | |
tree | 1cea99817ad1ffd360c667563a3a4c96a6c14c15 | |
parent | 099d65c7f787b4d6b4914892ce59b6656dd03aa9 (diff) | |
download | chrome-ec-213dd9e5a9981a825393eb9b29d69dc0afb426ac.tar.gz |
Trogdor: Request 5V when AP is off and battery is full
The charger is not efficient on buck mode when the operating current
is low. It happens when AP is off and battery is full.
Request the external adapter to a lower voltage, 5V. The charger will
switch to boost mode that has a better efficiency.
BRANCH=None
BUG=b:170794007
TEST=Charged the battery to full. Checked it requesting 20V when AP is
ON, and requesting 5V when AP is OFF.
TEST=Discharged the battery to not full. Checked it requesting 20V no
matter AP is ON or OFF.
Change-Id: Ifa333fccb40e7ebb2461c396be392c4ccc2d4320
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518326
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
-rw-r--r-- | baseboard/trogdor/baseboard.c | 43 | ||||
-rw-r--r-- | baseboard/trogdor/baseboard.h | 1 |
2 files changed, 44 insertions, 0 deletions
diff --git a/baseboard/trogdor/baseboard.c b/baseboard/trogdor/baseboard.c index 0f104f83d2..affd121057 100644 --- a/baseboard/trogdor/baseboard.c +++ b/baseboard/trogdor/baseboard.c @@ -5,10 +5,15 @@ /* Trogdor baseboard-specific configuration */ +#include "charge_state.h" #include "charger.h" #include "driver/charger/isl923x.h" #include "i2c.h" #include "power.h" +#include "usb_pd.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) /* Wake-up pins for hibernate */ const enum gpio_signal hibernate_wake_pins[] = { @@ -66,3 +71,41 @@ int board_allow_i2c_passthru(int port) { return (port == I2C_PORT_VIRTUAL_BATTERY); } + +int charger_profile_override(struct charge_state_data *curr) +{ + int usb_mv; + int port; + + if (curr->state != ST_CHARGE) + return 0; + + /* Lower the max requested voltage to 5V when battery is full. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && + !(curr->batt.flags & BATT_FLAG_BAD_STATUS) && + !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && + (curr->batt.status & STATUS_FULLY_CHARGED)) + usb_mv = 5000; + else + usb_mv = PD_MAX_VOLTAGE_MV; + + if (pd_get_max_voltage() != usb_mv) { + CPRINTS("VBUS limited to %dmV", usb_mv); + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) + pd_set_external_voltage_limit(port, usb_mv); + } + + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h index da30b950ff..e2f7be6615 100644 --- a/baseboard/trogdor/baseboard.h +++ b/baseboard/trogdor/baseboard.h @@ -79,6 +79,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER_ISL9238 +#define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGE_RAMP_HW #define CONFIG_USB_CHARGER #define CONFIG_CMD_CHARGER_ADC_AMON_BMON |