summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2015-10-21 10:51:21 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-27 11:52:34 -0700
commitcb4a76e8022c73fb0a0b50700912d86f41ea3dbb (patch)
tree0cfcc8ead036350e3ad994ee8229dac69a7f5b28 /include
parent95e8bc2e0bed68b040d2b19d1dd62a4debcc1852 (diff)
downloadchrome-ec-cb4a76e8022c73fb0a0b50700912d86f41ea3dbb.tar.gz
i2c: get battery information from charge state
ARM systems currently use SBS kernel driver which talks to the battery through I2C passthu in the EC. Instead when asking for battery information try getting it from the charge state machine first, and then try the battery if charge state does not have the information. This reduces latency by cutting out the battery response time. BUG=chromium:484841 BRANCH=none TEST=check that power_supply_info works properly on Jerry Change-Id: If4da15ccabe412adc31fc94b189089ebb3e9265c Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/307905 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/battery.h4
-rw-r--r--include/charge_state_v2.h15
-rw-r--r--include/config.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/include/battery.h b/include/battery.h
index 18c84a37d3..e79ddd3adf 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -65,6 +65,7 @@ struct batt_params {
int desired_current; /* Charging current desired by battery (mA) */
int remaining_capacity; /* Remaining capacity in mAh */
int full_capacity; /* Capacity in mAh (might change occasionally) */
+ int status; /* Battery status */
enum battery_present is_present; /* Is the battery physically present */
int flags; /* Flags */
};
@@ -86,8 +87,9 @@ struct batt_params {
#define BATT_FLAG_BAD_DESIRED_CURRENT 0x00000080
#define BATT_FLAG_BAD_REMAINING_CAPACITY 0x00000100
#define BATT_FLAG_BAD_FULL_CAPACITY 0x00000200
+#define BATT_FLAG_BAD_STATUS 0x00000400
/* All of the above BATT_FLAG_BAD_* bits */
-#define BATT_FLAG_BAD_ANY 0x000003fc
+#define BATT_FLAG_BAD_ANY 0x000007fc
/* Battery constants */
struct battery_info {
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index 37b88326c9..c5aedb7a94 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -4,12 +4,16 @@
*/
#include "battery.h"
+#include "battery_smart.h"
#include "charger.h"
#include "timer.h"
#ifndef __CROS_EC_CHARGE_STATE_V2_H
#define __CROS_EC_CHARGE_STATE_V2_H
+#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART)
+#define VIRTUAL_BATTERY_ADDR BATTERY_ADDR
+#endif
/*
* The values exported by charge_get_state() and charge_get_flags() are used
* only to control the LEDs (with one not-quite-correct exception). For V2
@@ -68,5 +72,16 @@ enum ec_status charger_profile_override_set_param(uint32_t param,
*/
int charge_set_input_current_limit(int ma);
+
+/**
+ * Get value of battery parameter from charge state.
+ *
+ * @param batt_param battery parameter
+ * @param dest Destination buffer for data
+ * @param read_len Number of bytes to write to buffer
+ * @return EC_SUCCESS if successful, non-zero if error.
+ *
+ */
+int virtual_battery_read(uint8_t batt_param, uint8_t *dest, int read_len);
#endif /* __CROS_EC_CHARGE_STATE_V2_H */
diff --git a/include/config.h b/include/config.h
index 9bd278359c..26fced9a46 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1048,6 +1048,7 @@
#undef CONFIG_I2C_DEBUG_PASSTHRU
#undef CONFIG_I2C_PASSTHROUGH
#undef CONFIG_I2C_PASSTHRU_RESTRICTED
+#undef CONFIG_I2C_VIRTUAL_BATTERY
/* For EC that is only an I2C slave */
#undef CONFIG_I2C_SLAVE_ONLY