summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-04-02 11:05:46 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-07 18:14:53 +0000
commit89756e255d378aaaea9eb0df19d31bd603dd827f (patch)
tree3edbae23903d737555c0e6a926465d66b84f2a5d
parentb7ab1b4d4fd3633ff47193f0ba7424da7ae4a6c7 (diff)
downloadchrome-ec-89756e255d378aaaea9eb0df19d31bd603dd827f.tar.gz
Mancomb: Add PPC enable and disable calls to active charger set
When mancomb is sinking power from a type-c port, enable the PPC on the port to sink. Also ensure that for all other active charge ports, we disable any PPCs which could have been previously enabled. BRANCH=None BUG=b:182468669 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I8174de08c6b8eb55a1227ce86cb786aee773afba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2802832 Reviewed-by: Andrew McRae <amcrae@chromium.org>
-rw-r--r--baseboard/mancomb/baseboard.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/baseboard/mancomb/baseboard.c b/baseboard/mancomb/baseboard.c
index 19172b4728..1fc11a710f 100644
--- a/baseboard/mancomb/baseboard.c
+++ b/baseboard/mancomb/baseboard.c
@@ -417,6 +417,8 @@ static int fsusb42umx_set_mux(const struct usb_mux *me, mux_state_t mux_state)
int board_set_active_charge_port(int port)
{
+ int rv, i;
+
CPRINTSUSB("Requested charge port change to %d", port);
/*
@@ -458,17 +460,43 @@ int board_set_active_charge_port(int port)
return EC_ERROR_INVAL;
}
+ /* Make sure BJ adapter is sourcing power */
+ if (port == CHARGE_PORT_BARRELJACK &&
+ gpio_get_level(GPIO_BJ_ADP_PRESENT_L)) {
+ CPRINTSUSB("BJ port selected, but not present!");
+ return EC_ERROR_INVAL;
+ }
+
CPRINTSUSB("New charger p%d", port);
+ /*
+ * Disable PPCs on all ports which aren't enabled.
+ *
+ * Note: this assumes that the CHARGE_PORT_ enum is ordered with the
+ * type-c ports first always.
+ */
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (i == port)
+ continue;
+
+ rv = ppc_vbus_sink_enable(port, 0);
+ if (rv) {
+ CPRINTSUSB("Failed to disable C%d sink path", i);
+ return rv;
+ }
+ }
+
switch (port) {
case CHARGE_PORT_TYPEC0:
case CHARGE_PORT_TYPEC1:
gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1);
+ rv = ppc_vbus_sink_enable(port, 1);
+ if (rv) {
+ CPRINTSUSB("Failed to enable sink path");
+ return rv;
+ }
break;
case CHARGE_PORT_BARRELJACK:
- /* Make sure BJ adapter is sourcing power */
- if (gpio_get_level(GPIO_BJ_ADP_PRESENT_L))
- return EC_ERROR_INVAL;
gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 0);
break;
default: