summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/battery.h14
-rw-r--r--include/config.h28
-rw-r--r--include/ec_ec_comm_master.h19
-rw-r--r--include/ec_ec_comm_slave.h4
4 files changed, 48 insertions, 17 deletions
diff --git a/include/battery.h b/include/battery.h
index 43425fcd8c..b783432ded 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -9,6 +9,20 @@
#define __CROS_EC_BATTERY_H
#include "common.h"
+#include "host_command.h"
+
+/* Battery index, only used with CONFIG_BATTERY_V2. */
+enum battery_index {
+ BATT_IDX_MAIN,
+ BATT_IDX_BASE,
+};
+
+#ifdef CONFIG_BATTERY_V2
+extern struct ec_response_battery_static_info
+ battery_static[CONFIG_BATTERY_COUNT];
+extern struct ec_response_battery_dynamic_info
+ battery_dynamic[CONFIG_BATTERY_COUNT];
+#endif
/* Stop charge when charging and battery level >= this percentage */
#define BATTERY_LEVEL_FULL 100
diff --git a/include/config.h b/include/config.h
index 243b51ca33..f091694ec1 100644
--- a/include/config.h
+++ b/include/config.h
@@ -335,6 +335,23 @@
#undef CONFIG_BATTERY_LEVEL_NEAR_FULL
/*
+ * 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.
+ */
+#undef CONFIG_BATTERY_V2
+
+/*
+ * Number of batteries, only matters when CONFIG_BATTERY_V2 is used.
+ */
+#undef CONFIG_BATTERY_COUNT
+
+/*
* Expose some data when it is needed.
* For example, battery disconnect state
*/
@@ -1546,6 +1563,13 @@
*/
#undef CONFIG_HOSTCMD_ALIGNED
+/*
+ * Include host commands to fetch battery information from
+ * ec_response_battery_static/dynamic_info structures, only makes sense when
+ * CONFIG_BATTERY_V2 is enabled.
+ */
+#undef CONFIG_HOSTCMD_BATTERY_V2
+
/* Default hcdebug mode, e.g. HCDEBUG_OFF or HCDEBUG_NORMAL */
#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_NORMAL
@@ -3303,10 +3327,14 @@
#ifdef CONFIG_EC_EC_COMM_BATTERY
#ifdef CONFIG_EC_EC_COMM_MASTER
#define CONFIG_EC_EC_COMM_BATTERY_MASTER
+#define CONFIG_BATTERY_V2
+#define CONFIG_BATTERY_COUNT 2
#endif
#ifdef CONFIG_EC_EC_COMM_SLAVE
#define CONFIG_EC_EC_COMM_BATTERY_SLAVE
+#define CONFIG_BATTERY_V2
+#define CONFIG_BATTERY_COUNT 1
#endif
#endif /* CONFIG_EC_EC_COMM_BATTERY */
diff --git a/include/ec_ec_comm_master.h b/include/ec_ec_comm_master.h
index 98b8011b95..adaf564c65 100644
--- a/include/ec_ec_comm_master.h
+++ b/include/ec_ec_comm_master.h
@@ -11,19 +11,12 @@
#include <stdint.h>
#include "config.h"
-/*
- * TODO(b:65697620): Move these to some other C file, depending on a config
- * option.
- */
-extern struct ec_response_battery_static_info base_battery_static;
-extern struct ec_response_battery_dynamic_info base_battery_dynamic;
-
/**
* Sends EC_CMD_BATTERY_GET_DYNAMIC command to slave, and writes the
- * battery dynamic information into base_battery_dynamic.
+ * battery dynamic information into battery_dynamic[BATT_IDX_BASE].
*
- * Leaves base_battery_dynamic intact on error: it is the callers responsability
- * to clear the data or ignore it.
+ * Leaves battery_dynamic[BATT_IDX_BASE] intact on error: it is the callers
+ * responsibility to clear the data or ignore it.
* @return EC_RES_SUCCESS on success, EC_RES_ERROR on communication error,
* else forwards the error code from the slave.
@@ -32,10 +25,10 @@ int ec_ec_master_base_get_dynamic_info(void);
/**
* Sends EC_CMD_BATTERY_GET_STATIC command to slave, and writes the
- * battery static information into base_static_dynamic.
+ * battery static information into battery_static[BATT_IDX_BASE].
*
- * Leaves base_battery_static intact on error: it is the callers responsability
- * to clear the data or ignore it.
+ * Leaves battery_static[BATT_IDX_BASE] intact on error: it is the callers
+ * responsibility to clear the data or ignore it.
*
* @return EC_RES_SUCCESS on success, EC_RES_ERROR on communication error,
* else forwards the error code from the slave.
diff --git a/include/ec_ec_comm_slave.h b/include/ec_ec_comm_slave.h
index e3501400e2..19e1912d94 100644
--- a/include/ec_ec_comm_slave.h
+++ b/include/ec_ec_comm_slave.h
@@ -12,10 +12,6 @@
#include "consumer.h"
#include "queue.h"
-/* TODO(b:65697620): Move these to battery.h, depending on a config option. */
-extern struct ec_response_battery_static_info base_battery_static;
-extern struct ec_response_battery_dynamic_info base_battery_dynamic;
-
extern struct queue const ec_ec_comm_slave_input;
extern struct queue const ec_ec_comm_slave_output;