From 20f836bfdf2611c7aced8ad4b3452fc4db519727 Mon Sep 17 00:00:00 2001 From: Prashant Malani Date: Wed, 19 Jan 2022 18:58:44 +0000 Subject: [PATCH] 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 Tested-by: Alyssa Ross Change-Id: I5e1598bd637ec9f50e7bf8dab9e3c757a30b9848 Reviewed-on: https://review.coreboot.org/c/coreboot/+/61262 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Nick Vaccaro Reviewed-by: Matt DeVillier --- src/ec/google/chromeec/ec_acpi.c | 11 +++++++++-- 1 file 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));