summaryrefslogtreecommitdiff
path: root/include/usb_common.h
diff options
context:
space:
mode:
authorYilun Lin <yllin@chromium.org>2019-11-05 14:52:45 +0800
committerCommit Bot <commit-bot@chromium.org>2019-12-09 07:50:34 +0000
commit053bc5659353c4aa127430f48f55633217a96d2a (patch)
treebb1d68dcb474fd0eb7e40f8d4a91f6287f7b8bb4 /include/usb_common.h
parent8260bc9ebe7d32fe8154af0447f67d64b0499031 (diff)
downloadchrome-ec-053bc5659353c4aa127430f48f55633217a96d2a.tar.gz
usb_pd: request preferred voltage PDO
Add CONFIG_USB_PD_PREFER_MV to support PD will request preferred voltage. One should define pd_pref_config, including preferd voltage, e.g. 5000, and PD_PREFER_BOOST or PD_PREFER_BUCK based on the board charging efficiency. Also, system PLT power is needed for evaluating board's desired power. The option will try to find a most fit PDO: 1. Pick the PDO which fulfills the system desired power. If a preferred voltage PDO doesn't provide enough power, it will be skipped. 2. If none of the PDO meets the preferred voltage, it will pick the closest voltage PDO based on prefer boost or prefer bulk. 3. The system desired power will be constantly updated when system in constant voltage stage (battery percent > 70%). This is done by monitoring the battery charging current. 4. If the system desired power changes, it will re-evaluate the PDO and send request if has a better fit. TEST=Set prefer_mv to 5000 and ensure PD voltage could pick 9V/12V when desired voltage > 15W (5V/3A) and pick 5V when desired voltage <= 15W BUG=b:141170279 b:141903096 b:144073892 BRANCH=kukui Change-Id: I94646cb1c74c10cf8db889f19c3df6339844042c Signed-off-by: Yilun Lin <yllin@chromium.org> Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1871499
Diffstat (limited to 'include/usb_common.h')
-rw-r--r--include/usb_common.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/usb_common.h b/include/usb_common.h
index b35e5f27f9..13bebc7915 100644
--- a/include/usb_common.h
+++ b/include/usb_common.h
@@ -32,6 +32,24 @@ enum pd_drp_next_states drp_auto_toggle_next_state(uint64_t *drp_sink_time,
enum pd_power_role power_role, enum pd_dual_role_states drp_state,
enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2);
+enum pd_pref_type {
+ /* prefer voltage larger than or equal to pd_pref_config.mv */
+ PD_PREFER_BUCK,
+ /* prefer voltage less than or equal to pd_pref_config.mv */
+ PD_PREFER_BOOST,
+};
+
+struct pd_pref_config_t {
+ /* Preferred PD voltage in mV */
+ int mv;
+ /* above which percent the battery is in constant voltage stage */
+ int cv;
+ /* System PLT (minimum consuming) power in mW. */
+ int plt_mw;
+ /* Preferred PD voltage pick strategy */
+ enum pd_pref_type type;
+};
+
/* Returns the battery percentage [0-100] of the system. */
int usb_get_battery_soc(void);