diff options
author | Patryk Duda <pdk@semihalf.com> | 2020-06-18 09:14:08 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-23 01:02:54 +0000 |
commit | 42df9ca1bc055f27d8a0b19348023a5e224f556a (patch) | |
tree | fc4d135b108fa0dd2fd28968a5cea7cbf37f39bd | |
parent | d6ef825953626dbbf9fbf50d43ff165429889dd5 (diff) | |
download | chrome-ec-42df9ca1bc055f27d8a0b19348023a5e224f556a.tar.gz |
baseboard/octopus: Use PD port count obtained dynamically
Some boards from octopus family have only one USB-C port.
Performing any operation on inexistent ports will always result in
failure.
BUG=b:154602760
BRANCH=none
TEST=Flash casta board.
Make sure that EC RW doesn't report:
"Disabling C1 as sink failed" or
"C1: sink path disable failed."
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: Ifc1da701bd862a74d1d434c3839511d5340c2fce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2250684
Commit-Queue: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | baseboard/octopus/baseboard.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c index 2577dbaf1a..e2c4eb30f4 100644 --- a/baseboard/octopus/baseboard.c +++ b/baseboard/octopus/baseboard.c @@ -238,7 +238,7 @@ void baseboard_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) + for (int port = 0; port < board_get_usb_pd_port_count(); ++port) usb_mux_hpd_update(port, 0, 0); } /* Called after the cbi_init (via +2) */ @@ -247,7 +247,7 @@ DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 2); int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_MAX_COUNT); + port < board_get_usb_pd_port_count()); int i; if (!is_valid_port && port != CHARGE_PORT_NONE) @@ -258,7 +258,8 @@ int board_set_active_charge_port(int port) CPRINTSUSB("Disabling all charger ports"); /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { + for (i = 0; (i < ppc_cnt) && + (i < board_get_usb_pd_port_count()); i++) { /* * Do not return early if one fails otherwise we can * get into a boot loop assertion failure. @@ -282,7 +283,8 @@ int board_set_active_charge_port(int port) * Turn off the other ports' sink path FETs, before enabling the * requested charge port. */ - for (i = 0; i < ppc_cnt; i++) { + for (i = 0; (i < ppc_cnt) && + (i < board_get_usb_pd_port_count()); i++) { if (i == port) continue; @@ -353,7 +355,7 @@ void board_hibernate(void) * low power mode or open the SNK FET based on which signals wake up * the EC from hibernate. */ - for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { + for (port = 0; port < board_get_usb_pd_port_count(); port++) { if (!pd_is_vbus_present(port)) { #ifdef VARIANT_OCTOPUS_EC_ITE8320 /* |