diff options
author | Prashant Malani <pmalani@chromium.org> | 2022-01-19 18:58:44 +0000 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-01-25 03:52:00 +0000 |
commit | 20f836bfdf2611c7aced8ad4b3452fc4db519727 (patch) | |
tree | b479eecda2310f6c4d727fcca8d3c0e4d59d639f | |
parent | a27d1fa175a814f32ada7b82144ff54ffdf7e654 (diff) |
ec/google/chromeec: Add checks before creating Type C device
Check for situations where a Type C device isn't useful and avoid
creating one for those scenarios.
BUG=b:215199976
TEST=Tested on brya; verified that USBC device is created.
Signed-off-by: Prashant Malani <pmalani@chromium.org>
Tested-by: Alyssa Ross <hi@alyssa.is>
Change-Id: I5e1598bd637ec9f50e7bf8dab9e3c757a30b9848
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61262
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
-rw-r--r-- | src/ec/google/chromeec/ec_acpi.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ec/google/chromeec/ec_acpi.c b/src/ec/google/chromeec/ec_acpi.c index 4fcc679d70..9343d6d4f4 100644 --- a/src/ec/google/chromeec/ec_acpi.c +++ b/src/ec/google/chromeec/ec_acpi.c @@ -144,13 +144,20 @@ static void fill_ssdt_typec_device(const struct device *dev) struct ec_google_chromeec_config *config = dev->chip_info; int rv; int i; - unsigned int num_ports; + unsigned int num_ports = 0; struct device *usb2_port; struct device *usb3_port; struct device *usb4_port; struct acpi_pld pld = {0}; + uint32_t pcap_mask = 0; - if (google_chromeec_get_num_pd_ports(&num_ports)) + rv = google_chromeec_get_num_pd_ports(&num_ports); + if (rv || num_ports == 0) + return; + + /* If we can't get port caps, we shouldn't bother creating a device. */ + rv = google_chromeec_get_cmd_versions(EC_CMD_GET_PD_PORT_CAPS, &pcap_mask); + if (rv || pcap_mask == 0) return; acpigen_write_scope(acpi_device_path(dev)); |