summaryrefslogtreecommitdiff
path: root/common/usb_port_power_smart.c
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-04-19 11:50:13 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-20 01:35:43 +0000
commit7dc9537d7a56dab267e4facb3c1398e1d0e44175 (patch)
tree4160f88f567d00f733b947af04725e3afa9d8c63 /common/usb_port_power_smart.c
parent9ce84b03e16fc4f4f00170644901988d7f897f16 (diff)
downloadchrome-ec-7dc9537d7a56dab267e4facb3c1398e1d0e44175.tar.gz
usba: Allow modification of USB port enable
Allow dynamic modification of the USB port enable GPIO list so that sub-boards without USB-A ports can disable the port enable setting. BUG=b:214858346 TEST=zmake build nivviks BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I12b93a3c20852f68303b158aa20bc9a1c63f6ae5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3592312 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'common/usb_port_power_smart.c')
-rw-r--r--common/usb_port_power_smart.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c
index 170180cbab..3143bdf400 100644
--- a/common/usb_port_power_smart.c
+++ b/common/usb_port_power_smart.c
@@ -62,7 +62,12 @@ static void usb_charge_set_control_mode(int port_id, int mode)
static void usb_charge_set_enabled(int port_id, int en)
{
ASSERT(port_id < CONFIG_USB_PORT_POWER_SMART_PORT_COUNT);
- gpio_or_ioex_set_level(usb_port_enable[port_id], en);
+ /*
+ * Only enable valid ports.
+ */
+ if (usb_port_enable[port_id] >= 0) {
+ gpio_or_ioex_set_level(usb_port_enable[port_id], en);
+ }
}
static void usb_charge_set_ilim(int port_id, int sel)