summaryrefslogtreecommitdiff
path: root/include/peripheral_charger.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/peripheral_charger.h')
-rw-r--r--include/peripheral_charger.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/include/peripheral_charger.h b/include/peripheral_charger.h
index 0479b5e7bd..ac193ba2da 100644
--- a/include/peripheral_charger.h
+++ b/include/peripheral_charger.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -87,7 +87,7 @@
*/
/* Size of event queue. Use it to initialize struct pchg.events. */
-#define PCHG_EVENT_QUEUE_SIZE 8
+#define PCHG_EVENT_QUEUE_SIZE 8
enum pchg_event {
/* No event */
@@ -143,7 +143,7 @@ enum pchg_error {
PCHG_ERROR_OTHER,
};
-#define PCHG_ERROR_MASK(e) BIT(e)
+#define PCHG_ERROR_MASK(e) BIT(e)
enum pchg_mode {
PCHG_MODE_NORMAL = 0,
@@ -189,7 +189,7 @@ struct pchg_update {
*/
struct pchg {
/* Static configuration */
- const struct pchg_config * const cfg;
+ const struct pchg_config *const cfg;
/* Current state of the port */
enum pchg_state state;
/* Event queue */
@@ -220,12 +220,23 @@ struct pchg {
* Peripheral charger driver
*/
struct pchg_drv {
- /* Reset charger chip. */
+ /*
+ * Reset charger chip. External reset (e.g by GPIO). No
+ * communication or data access is expected (e.g. no I2C access).
+ */
int (*reset)(struct pchg *ctx);
- /* Initialize the charger. */
+ /*
+ * Initialize the charger. Run setup needed only once per reset
+ * (e.g. enable I2C, unlock I2C).
+ */
int (*init)(struct pchg *ctx);
/* Enable/disable the charger. */
int (*enable)(struct pchg *ctx, bool enable);
+ /*
+ * Get chip info, identify chip and setup function pointers
+ * (e.g. I2C read function). It needs to work without IRQ.
+ */
+ int (*get_chip_info)(struct pchg *ctx);
/* Get event info. */
int (*get_event)(struct pchg *ctx);
/* Get battery level. */
@@ -246,7 +257,7 @@ extern struct pchg pchgs[];
extern const int pchg_count;
/* Utility macro converting port config to port number. */
-#define PCHG_CTX_TO_PORT(ctx) ((ctx) - &pchgs[0])
+#define PCHG_CTX_TO_PORT(ctx) ((ctx) - &pchgs[0])
/**
* Interrupt handler for a peripheral charger.