summaryrefslogtreecommitdiff
path: root/include/charge_state_v2.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/charge_state_v2.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/charge_state_v2.h')
-rw-r--r--include/charge_state_v2.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index c958c0ed7c..ab9f54b46d 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -131,4 +131,40 @@ enum critical_shutdown board_critical_shutdown_check(
*/
uint8_t board_set_battery_level_shutdown(void);
+/**
+ * Return system PLT power and battery's desired power.
+ *
+ * @return desired power in mW
+ */
+int charge_get_plt_plus_bat_desired_mw(void);
+
+/**
+ * Get the stable battery charging current. The current will be
+ * CHARGE_CURRENT_UNINITIALIZED if not yet stable.
+ *
+ * @return stable battery charging current in mA
+ */
+int charge_get_stable_current(void);
+
+/**
+ * Set the stable current.
+ *
+ * @param ma: battery charging current in mA
+ */
+void charge_set_stable_current(int ma);
+
+/**
+ * Reset stable current counter stable_ts. Calling this function would set
+ * stable_current to CHARGE_CURRENT_UNINITIALIZED.
+ */
+void charge_reset_stable_current(void);
+
+/**
+ * Reset stable current counter stable_ts. Calling this function would set
+ * stable_current to CHARGE_CURRENT_UNINITIALIZED.
+ *
+ * @param us: sample stable current until us later.
+ */
+void charge_reset_stable_current_us(uint64_t us);
+
#endif /* __CROS_EC_CHARGE_STATE_V2_H */