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>
This commit is contained in:
Prashant Malani 2022-01-19 18:58:44 +00:00 committed by Felix Held
parent a27d1fa175
commit 20f836bfdf
1 changed files with 9 additions and 2 deletions

View File

@ -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));