summaryrefslogtreecommitdiff
path: root/board/damu
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-01-14 14:18:08 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-28 20:22:22 +0000
commit4eb3a5fe699247a5767ae38c66c75872f4afc575 (patch)
tree81787f2f54ff3470ce326047213abfae234b50a1 /board/damu
parentd9a869beb6e1778cec38dcce64f289aba353a8d5 (diff)
downloadchrome-ec-4eb3a5fe699247a5767ae38c66c75872f4afc575.tar.gz
Charger: Create charger driver structure
With upcoming boards which use multiple charger chips, the EC codebase needs to be changed to assume chargers may have different I2C ports. This commit creates the driver structure and wrapper functions, which for now are hard-coded to chip 0 for equivalent behavior with previous code. A general charger config is created for all boards in charger.c for now, which uses the build information to fill in the structure. All boards will default to defining CONFIG_CHARGER_SINGLE_CHIP, which in turn defines a CHARGER_SOLO which can be used by drivers which have code that needs to determine charger numbers. For boards which have multiple chips, they may undefine this config and should generate build errors if their driver is still using the hardcoded charger reference of CHARGER_SOLO. Older drivers may continue using CHARGER_SOLO in non-static functions until they're needed in a multiple charger board. For boards which may be supporting different I2C configurations for the charger over board versions, they may define CONFIG_CHARGER_RUNTIME_CONFIG to fill in these fields after boot. BRANCH=none BUG=b:147672225 TEST=builds, chargers on hatch and octopus work Change-Id: I390ede494226252e512595c48099fa1288ffe93e Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2008451 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/damu')
-rw-r--r--board/damu/board.c17
-rw-r--r--board/damu/board.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/board/damu/board.c b/board/damu/board.c
index 546fbda4bf..946f925081 100644
--- a/board/damu/board.c
+++ b/board/damu/board.c
@@ -123,6 +123,23 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
+/* Charger config. Start i2c address at 1, update during runtime */
+struct charger_config_t chg_chips[] = {
+ {
+ .i2c_port = 1,
+ .i2c_addr_flags = ISL923X_ADDR_FLAGS,
+ .drv = &isl923x_drv,
+ },
+};
+const unsigned int chg_cnt = ARRAY_SIZE(chg_chips);
+
+/* Board version depends on ADCs, so init i2c port after ADC */
+static void charger_config_complete(void)
+{
+ chg_chips[0].i2c_port = board_get_charger_i2c();
+}
+DECLARE_HOOK(HOOK_INIT, charger_config_complete, HOOK_PRIO_INIT_ADC + 1);
+
uint16_t tcpc_get_alert_status(void)
{
uint16_t status = 0;
diff --git a/board/damu/board.h b/board/damu/board.h
index fed9012e43..8399a19b81 100644
--- a/board/damu/board.h
+++ b/board/damu/board.h
@@ -27,6 +27,8 @@
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_RUNTIME_CONFIG
+
#define CONFIG_BC12_DETECT_PI3USB9201
#define CONFIG_EXTPOWER_GPIO