diff options
author | Andrew McRae <amcrae@google.com> | 2022-04-19 11:50:13 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-20 01:35:43 +0000 |
commit | 7dc9537d7a56dab267e4facb3c1398e1d0e44175 (patch) | |
tree | 4160f88f567d00f733b947af04725e3afa9d8c63 | |
parent | 9ce84b03e16fc4f4f00170644901988d7f897f16 (diff) | |
download | chrome-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>
-rw-r--r-- | common/acpi.c | 3 | ||||
-rw-r--r-- | common/usb_port_power_dumb.c | 9 | ||||
-rw-r--r-- | common/usb_port_power_smart.c | 7 | ||||
-rw-r--r-- | util/config_allowed.txt | 1 | ||||
-rw-r--r-- | zephyr/Kconfig.usba | 10 | ||||
-rw-r--r-- | zephyr/projects/nissa/prj.conf | 1 | ||||
-rw-r--r-- | zephyr/projects/nissa/src/sub_board.c | 5 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 5 |
8 files changed, 36 insertions, 5 deletions
diff --git a/common/acpi.c b/common/acpi.c index 6717732e06..c234347019 100644 --- a/common/acpi.c +++ b/common/acpi.c @@ -284,7 +284,8 @@ int acpi_ap_to_ec(int is_cmd, uint8_t value, uint8_t *resultptr) */ result = 0; for (i = 0; i < port_count; ++i) { - if (gpio_get_level(usb_port_enable[i]) != 0) + if ((usb_port_enable[i] >= 0) && + (gpio_get_level(usb_port_enable[i]) != 0)) result |= 1 << i; } break; diff --git a/common/usb_port_power_dumb.c b/common/usb_port_power_dumb.c index d298444fb7..ea2d4eb668 100644 --- a/common/usb_port_power_dumb.c +++ b/common/usb_port_power_dumb.c @@ -22,8 +22,13 @@ static uint8_t charge_mode[USB_PORT_COUNT]; static void usb_port_set_enabled(int port_id, int en) { - gpio_or_ioex_set_level(usb_port_enable[port_id], en); - charge_mode[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); + charge_mode[port_id] = en; + } } __maybe_unused static void usb_port_all_ports_on(void) 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) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 6714872fa4..4e3e4e30ed 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -1060,7 +1060,6 @@ CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC CONFIG_USB_PD_TX_PHY_ONLY CONFIG_USB_PD_USB4_DRD CONFIG_USB_PD_VBUS_DETECT_GPIO -CONFIG_USB_PORT_ENABLE_DYNAMIC CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE CONFIG_USB_PORT_POWER_SMART_PORT_COUNT CONFIG_USB_POWER diff --git a/zephyr/Kconfig.usba b/zephyr/Kconfig.usba index c0cbdacdfe..380d277d2c 100644 --- a/zephyr/Kconfig.usba +++ b/zephyr/Kconfig.usba @@ -15,6 +15,16 @@ menuconfig PLATFORM_EC_USBA if PLATFORM_EC_USBA +config PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC + bool "USB Type-A dynamic port count" + help + Allow the USB Type-A port array to be dynamically + modified by board specific code. + + This allows boards to selectively disable any of the + USB Type-A ports by setting the enable entry to + a negative value. + choice PLATFORM_EC_USBA_PORT_POWER_TYPE prompt "Port power control mode" default PLATFORM_EC_USB_PORT_POWER_DUMB diff --git a/zephyr/projects/nissa/prj.conf b/zephyr/projects/nissa/prj.conf index 61c2252583..e507319a8a 100644 --- a/zephyr/projects/nissa/prj.conf +++ b/zephyr/projects/nissa/prj.conf @@ -130,6 +130,7 @@ CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y # USB-A host ports CONFIG_PLATFORM_EC_USBA=y +CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y # Both ports use a smart switch with CTL1..3 fixed high, for SDP2 or CDP only: # either SLGC55545 or PI5USB2546. CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART=y diff --git a/zephyr/projects/nissa/src/sub_board.c b/zephyr/projects/nissa/src/sub_board.c index 7dd5a6208d..1282ffec54 100644 --- a/zephyr/projects/nissa/src/sub_board.c +++ b/zephyr/projects/nissa/src/sub_board.c @@ -14,6 +14,7 @@ #include "driver/tcpm/tcpci.h" #include "gpio/gpio_int.h" #include "hooks.h" +#include "usb_charge.h" #include "usb_pd.h" #include "task.h" @@ -120,6 +121,10 @@ static void nereid_subboard_config(void) gpio_pin_configure_dt( GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), GPIO_DISCONNECTED); + /* Disable second USB-A port enable GPIO */ + __ASSERT(USB_PORT_ENABLE_COUNT == 2, + "USB A port count != 2 (%d)", USB_PORT_ENABLE_COUNT); + usb_port_enable[1] = -1; } /* * USB-C port: the default configuration has I2C on the I2C pins, diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index b19aa11ead..10d3c3b8e9 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1056,6 +1056,11 @@ extern struct jump_data mock_jump_data; enable_pins)), \ (0)) +#undef CONFIG_USB_PORT_ENABLE_DYNAMIC +#ifdef CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC +#define CONFIG_USB_PORT_ENABLE_DYNAMIC +#endif + #undef CONFIG_USB_PORT_POWER_DUMB #ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB #define CONFIG_USB_PORT_POWER_DUMB |