summaryrefslogtreecommitdiff
path: root/include/charger.h
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-03-27 13:37:21 -0700
committerBill Richardson <wfrichar@chromium.org>2014-03-28 15:23:04 +0000
commit915137770896e9ded6068c5969479849f02ca95c (patch)
treef94a1452aa24435d8496aa8e12b01098c752fbbb /include/charger.h
parent91a5fa01940764832c1b974d2022bee4e744f09c (diff)
downloadchrome-ec-915137770896e9ded6068c5969479849f02ca95c.tar.gz
Add charger_get_params() function to query charger state.
This returns all the parameters of the charger that must be monitored frequently. While some of the fields are charger-specific, all of the parameters are present in all supported chargers. Nothing uses this yet. BUG=chrome-os-partner:20881 BRANCH=ToT TEST=make buildall -j All targets build; all tests pass. Change-Id: Id3e00532469b193aeab3acf93e94afe3ffb8c6b6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191985 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/charger.h')
-rw-r--r--include/charger.h34
1 files changed, 27 insertions, 7 deletions
diff --git a/include/charger.h b/include/charger.h
index 23a4cebb42..bb84990856 100644
--- a/include/charger.h
+++ b/include/charger.h
@@ -27,21 +27,41 @@ struct charger_info {
uint16_t input_current_step;
};
+/*
+ * Parameters common to all chargers. Current is in mA, voltage in mV.
+ * The status and option values are charger-specific.
+ */
+struct charger_params {
+ int current;
+ int voltage;
+ int input_current;
+ int status;
+ int option;
+ int flags;
+};
+
+/* Get the current charger_params. Failures are reported in .flags */
+void charger_get_params(struct charger_params *chg);
+
+/* Bits to indicate which fields of struct charger_params could not be read */
+#define CHG_FLAG_BAD_CURRENT 0x00000001
+#define CHG_FLAG_BAD_VOLTAGE 0x00000002
+#define CHG_FLAG_BAD_INPUT_CURRENT 0x00000004
+#define CHG_FLAG_BAD_STATUS 0x00000008
+#define CHG_FLAG_BAD_OPTION 0x00000010
+/* All of the above CHG_FLAG_BAD_* bits */
+#define CHG_FLAG_BAD_ANY 0x0000001f
+
/* Power state machine post init */
int charger_post_init(void);
/* Get charger information. */
const struct charger_info *charger_get_info(void);
-/* Get smart battery charger status. Supported flags:
- * CHARGER_CHARGE_INHIBITED
- * CHARGER_LEVEL_2
- */
+/* Get smart battery charger status. Supported flags may vary. */
int charger_get_status(int *status);
-/* Set smart battery charger mode. Supported mode(s):
- * CHARGER_FLAG_INHIBIT_CHARGE
- */
+/* Set smart battery charger mode. Supported modes may vary. */
int charger_set_mode(int mode);
/**