summaryrefslogtreecommitdiff
path: root/include/charge_state.h
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-03-19 11:15:57 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-03-20 23:51:03 +0000
commitdefaf5cdb5a44067ea0f2d7f18fd57e240d992a6 (patch)
tree26abaf6936bd5bb998c0ab4d9d909261d3cee769 /include/charge_state.h
parenta025f18673583e1c030aa006e0f0cebeea18c062 (diff)
downloadchrome-ec-defaf5cdb5a44067ea0f2d7f18fd57e240d992a6.tar.gz
Create stub files for charge_state_v2.c
Remove copied code from V1 implementation, reduce to bare minimum needed to satisfy external dependencies. Don't actually enable it for any platforms, though. BRANCH=ToT BUG=chrome-os-partner:23776 TEST=make buildall -j It's used by anything and doesn't do anything if it was, but test compilation of the changed sources by defining CONFIG_CHARGER_V2. Change-Id: Iea37d0b4fc48c8ebf7f7088cd1674d6e275d03d4 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190853 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/charge_state.h')
-rw-r--r--include/charge_state.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/include/charge_state.h b/include/charge_state.h
index 8c0f73952c..581acfd285 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -8,6 +8,85 @@
#include "common.h"
/* Stuff that's common to all charger implementations can go here. */
+/* Power states */
+enum charge_state {
+ /* Meta-state; unchanged from previous time through task loop */
+ PWR_STATE_UNCHANGE = 0,
+ /* Initializing charge state machine at boot */
+ PWR_STATE_INIT,
+ /* Re-initializing charge state machine */
+ PWR_STATE_REINIT,
+ /* Just transitioned from init to idle */
+ PWR_STATE_IDLE0,
+ /* Idle; AC present */
+ PWR_STATE_IDLE,
+ /* Discharging */
+ PWR_STATE_DISCHARGE,
+ /* Charging */
+ PWR_STATE_CHARGE,
+ /* Charging, almost fully charged */
+ PWR_STATE_CHARGE_NEAR_FULL,
+ /* Charging state machine error */
+ PWR_STATE_ERROR
+};
+
+/* Charge state flags */
+/* Forcing idle state */
+#define CHARGE_FLAG_FORCE_IDLE (1 << 0)
+/* External (AC) power is present */
+#define CHARGE_FLAG_EXTERNAL_POWER (1 << 1)
+
+/* Debugging constants, in the same order as enum charge_state. This string
+ * table was moved here to sync with enum above.
+ */
+#define CHARGE_STATE_NAME_TABLE { \
+ "unchange", \
+ "init", \
+ "reinit", \
+ "idle0", \
+ "idle", \
+ "discharge", \
+ "charge", \
+ "charge_near_full", \
+ "error" \
+ }
+ /* End of CHARGE_STATE_NAME_TABLE macro */
+
+
+/**
+ * Return current charge state.
+ */
+enum charge_state charge_get_state(void);
+
+/**
+ * Return non-zero if battery is so low we want to keep AP off.
+ */
+int charge_keep_power_off(void);
+
+/**
+ * Return current charge state flags (CHARGE_FLAG_*)
+ */
+uint32_t charge_get_flags(void);
+
+/**
+ * Return current battery charge percentage.
+ */
+int charge_get_percent(void);
+
+/**
+ * Return non-zero if discharging and battery so low we should shut down.
+ */
+int charge_want_shutdown(void);
+
+/**
+ * Get the last polled battery/charger temperature.
+ *
+ * @param idx Sensor index to read.
+ * @param temp_ptr Destination for temperature in K.
+ *
+ * @return EC_SUCCESS if successful, non-zero if error.
+ */
+int charge_temp_sensor_get_val(int idx, int *temp_ptr);
/* Pick the right implementation */