summaryrefslogtreecommitdiff
path: root/include/charge_ramp.h
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-02-06 11:01:18 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-18 04:53:22 +0000
commita573a6c0fd051599c711c8748c4fe92743d93b6c (patch)
treeeed6897d13ca07d56ccc17136938a0f7dda679d0 /include/charge_ramp.h
parentac5f11bf84d8186a899454e50da3fd634bc9b35e (diff)
downloadchrome-ec-a573a6c0fd051599c711c8748c4fe92743d93b6c.tar.gz
charge_ramp: initial commit of charge ramp module
Add new charge_ramp module which works with charge_manager to slowly increase input current limit in order to find the optimal charging current. To do this it looks for either VBUS drooping too low or for the charger to over-current. BUG=chrome-os-partner:34946 BRANCH=samus TEST=tested with a variety of BC1.2 chargers, type-C only chargers, and PD chargers to make sure we always stabilize charging at an appropriate current limit. Change-Id: Icc95aa2738ddb221f163f91c14a342a0674f9e0f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/247304 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'include/charge_ramp.h')
-rw-r--r--include/charge_ramp.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/include/charge_ramp.h b/include/charge_ramp.h
new file mode 100644
index 0000000000..629499e6ac
--- /dev/null
+++ b/include/charge_ramp.h
@@ -0,0 +1,82 @@
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Charge input current limit ramp header for Chrome EC */
+
+#ifndef __CROS_EC_CHG_RAMP_H
+#define __CROS_EC_CHG_RAMP_H
+
+#include "timer.h"
+
+/* Charge ramp state used for checking VBUS */
+enum chg_ramp_vbus_state {
+ CHG_RAMP_VBUS_RAMPING,
+ CHG_RAMP_VBUS_STABLE
+};
+
+/**
+ * Check if ramping is allowed for given supplier
+ *
+ * @supplier Supplier to check
+ *
+ * @return Ramping is allowed for given supplier
+ */
+int board_is_ramp_allowed(int supplier);
+
+/**
+ * Get the maximum current limit that we are allowed to ramp to
+ *
+ * @supplier Active supplier type
+ *
+ * @return Maximum current in mA
+ */
+int board_get_ramp_current_limit(int supplier);
+
+/**
+ * Check if board is consuming full input current
+ *
+ * @return Board is consuming full input current
+ */
+int board_is_consuming_full_charge(void);
+
+/**
+ * Check if VBUS is too low
+ *
+ * @param ramp_state Current ramp state
+ *
+ * @return VBUS is sagging low
+ */
+int board_is_vbus_too_low(enum chg_ramp_vbus_state ramp_state);
+
+/**
+ * Get the input current limit set by ramp module
+ *
+ * Active input current limit (mA)
+ */
+int chg_ramp_get_current_limit(void);
+
+#ifdef HAS_TASK_CHG_RAMP
+/**
+ * Notify charge ramp module of supplier type change on a port. If port
+ * is CHARGE_PORT_NONE, the call indicates the last charge supplier went
+ * away.
+ *
+ * @port Active charging port
+ * @supplier Active charging supplier
+ * @current Minimum input current limit
+ * @registration_time Timestamp of when the supplier is registered
+ */
+void chg_ramp_charge_supplier_change(int port, int supplier, int current,
+ timestamp_t registration_time);
+
+#else
+static inline void chg_ramp_charge_supplier_change(
+ int port, int supplier, timestamp_t registration_time) { }
+
+/* Point directly to board function to set charge limit */
+#define chg_ramp_set_min_current board_set_charge_limit
+#endif
+
+#endif /* __CROS_EC_CHG_RAMP_H */