summaryrefslogtreecommitdiff
path: root/driver/bc12/max14637.c
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2020-05-06 18:06:52 +0800
committerCommit Bot <commit-bot@chromium.org>2020-05-29 05:11:24 +0000
commit8975cbb645f1f07c3682334d02510a8a1d3f730b (patch)
tree1c65f1c460b25e785181b15c2d78b303b4cfacfc /driver/bc12/max14637.c
parentfad8f404df3e1b2278326c08247a62edce434f32 (diff)
downloadchrome-ec-8975cbb645f1f07c3682334d02510a8a1d3f730b.tar.gz
bc12: create bc12 driver structure
To support linking multiple bc12 drivers into ec binary, we have to remove the common symbols in drivers. This CL creates a bc12_drv structure to hold the original driver-specific usb_charger_* functions, and implements common usb_charger_* functions which whill dispatch the function call based on the information in bc12_drv table. Also add a CONFIG_BC12_SINGLE_DRIVER and enabled by default for backward compatibility. If CONFIG_BC12_SINGLE_DRIVER is defined, a default bc12_drv array with proper size and content will be created for the board. BUG=b:155611686 TEST=1) make buildall. 2) verify single driver mode on krane (rt946x) and juniper (pi3usb9201). 3) verify multiple driver works on asurada, see CL:2189624 for example usage. 4) verify single driver multi chip on blooglet. BRANCH=none Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I8a96eda47c94aeb6cc150b498cfa1a6eefcc4a5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2187080 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'driver/bc12/max14637.c')
-rw-r--r--driver/bc12/max14637.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c
index 2aab525f00..91b5441a68 100644
--- a/driver/bc12/max14637.c
+++ b/driver/bc12/max14637.c
@@ -151,9 +151,8 @@ static void detect_or_power_down_ic(const int port)
}
}
-void usb_charger_task(void *u)
+static void max14637_usb_charger_task(const int port)
{
- const int port = (intptr_t)u;
uint32_t evt;
const struct max14637_config_t * const cfg = &max14637_config[port];
@@ -175,15 +174,8 @@ void usb_charger_task(void *u)
}
}
-void usb_charger_set_switches(int port, enum usb_switch setting)
-{
- /*
- * The MAX14637 automatically sets up the USB 2.0 high-speed switches.
- */
-}
-
#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
-int usb_charger_ramp_allowed(int supplier)
+static int max14637_ramp_allowed(int supplier)
{
/*
* Due to the limitations in the application of the MAX14637, we
@@ -193,7 +185,7 @@ int usb_charger_ramp_allowed(int supplier)
return supplier == CHARGE_SUPPLIER_OTHER;
}
-int usb_charger_ramp_max(int supplier, int sup_curr)
+static int max14637_ramp_max(int supplier, int sup_curr)
{
/* Use the current limit that was decided by the MAX14637. */
if (supplier == CHARGE_SUPPLIER_OTHER)
@@ -220,3 +212,20 @@ static void bc12_chipset_startup(void)
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, bc12_chipset_startup, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_RESUME, bc12_chipset_startup, HOOK_PRIO_DEFAULT);
+
+const struct bc12_drv max14637_drv = {
+ .usb_charger_task = max14637_usb_charger_task,
+#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
+ .ramp_allowed = max14637_ramp_allowed,
+ .ramp_max = max14637_ramp_max,
+#endif /* CONFIG_CHARGE_RAMP_SW || CONFIG_CHARGE_RAMP_HW */
+};
+
+#ifdef CONFIG_BC12_SINGLE_DRIVER
+/* provide a default bc12_ports[] for backward compatibility */
+struct bc12_config bc12_ports[CHARGE_PORT_COUNT] = {
+ [0 ... (CHARGE_PORT_COUNT - 1)] = {
+ .drv = &max14637_drv,
+ },
+};
+#endif /* CONFIG_BC12_SINGLE_DRIVER */