summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-10-15 14:18:28 -0700
committerCommit Bot <commit-bot@chromium.org>2021-10-26 22:16:37 +0000
commit8106efd33a7897e071410201ba85804bfba9dfcd (patch)
tree0a706751becdccdf06fb38211730da1c21bd8efc /include
parent1f1103b4b875a4ce12fb666fa69572747e02996c (diff)
downloadchrome-ec-8106efd33a7897e071410201ba85804bfba9dfcd.tar.gz
Battery: Move battery code to battery_v1.c and v2.c
BUG=b:198722643, b:203031618 BRANCH=None TEST=buildall Change-Id: I595da56412f4d30684b00d1138f7e2339c7f5204 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3227372 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/battery.h15
-rw-r--r--include/charge_state_v2.h20
-rw-r--r--include/config.h15
3 files changed, 48 insertions, 2 deletions
diff --git a/include/battery.h b/include/battery.h
index 2de5835807..be23863c23 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -54,6 +54,9 @@ extern struct ec_response_battery_dynamic_info
*/
#define BATTERY_LEVEL_SHUTDOWN 3
+/* Full-capacity change reqd for host event */
+#define LFCC_EVENT_THRESH 5
+
/*
* Sometimes we have hardware to detect battery present, sometimes we have to
* wait until we've been able to talk to the battery.
@@ -476,4 +479,16 @@ __override_proto void board_battery_compensate_params(struct batt_params *batt);
void battery_validate_params(struct batt_params *batt);
+/**
+ * Read static battery info from a main battery and store it in a cache.
+ *
+ * @return EC_SUCCESS or EC_ERROR_*.
+ */
+int update_static_battery_info(void);
+
+/**
+ * Read dynamic battery info from a main battery and store it in a cache.
+ */
+void update_dynamic_battery_info(void);
+
#endif /* __CROS_EC_BATTERY_H */
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index 9325bcfdca..dc54ac5a89 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -191,4 +191,24 @@ bool charge_is_current_stable(void);
*/
void trigger_ocpc_reset(void);
+/* Track problems in communicating with the battery or charger */
+enum problem_type {
+ PR_STATIC_UPDATE,
+ PR_SET_VOLTAGE,
+ PR_SET_CURRENT,
+ PR_SET_MODE,
+ PR_SET_INPUT_CURR,
+ PR_POST_INIT,
+ PR_CHG_FLAGS,
+ PR_BATT_FLAGS,
+ PR_CUSTOM,
+ PR_CFG_SEC_CHG,
+
+ NUM_PROBLEM_TYPES
+};
+
+void charge_problem(enum problem_type p, int v);
+
+struct charge_state_data *charge_get_status(void);
+
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
diff --git a/include/config.h b/include/config.h
index ff6822ae51..ae78505c4f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -631,14 +631,19 @@
#undef CONFIG_BATTERY_LEVEL_NEAR_FULL
/*
+ * Use memory mapped region to store battery information. It supports only
+ * single battery systems. V2 should be used unless there is a reason not to.
+ */
+#undef CONFIG_BATTERY_V1
+
+/*
* Use an alternative method to store battery information: Instead of writing
* directly to host memory mapped region, this keeps the battery information in
* ec_response_battery_static/dynamic_info structures, that can then be fetched
* using host commands, or via EC_ACPI_MEM_BATTERY_INDEX command, which tells
* the EC to update the shared memory.
*
- * This is required on dual-battery systems, and on on hostless bases with a
- * battery.
+ * This is required on dual-battery systems and hostless bases with a battery.
*/
#undef CONFIG_BATTERY_V2
@@ -5843,6 +5848,12 @@
#endif /* CONFIG_EC_EC_COMM_BATTERY */
/*****************************************************************************/
+/* If battery_v2 isn't used, it's v1. */
+#if defined(CONFIG_BATTERY) && !defined(CONFIG_BATTERY_V2)
+#define CONFIG_BATTERY_V1
+#endif
+
+/*****************************************************************************/
/* Define derived USB PD Discharge common path */
#if defined(CONFIG_USB_PD_DISCHARGE_GPIO) || \
defined(CONFIG_USB_PD_DISCHARGE_TCPC) || \