From 70ea3b9141ee92177c1a1185a7e6a468fd59bc85 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Wed, 18 Mar 2020 23:45:32 -0500 Subject: [PATCH] ec/google/chromeec: don't put empty block in SSDT Check that there are actually USB-PD ports for which to add data to SSDT, before actually generating SSDT data. This prevents an empty scope from being generated on devices without any USB-PD ports, which was breaking parsing/decompilation on some older platforms (eg, Braswell). Test: build/boot google/edgar, verify SSDT table able to be parsed via iasl after dumping. Change-Id: Ia213e5815e9160e9b36b2501eeccb6385abef47e Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/39665 Reviewed-by: Tim Wawrzynczak Reviewed-by: Furquan Shaikh Reviewed-by: Angel Pons Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/ec/google/chromeec/ec_acpi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ec/google/chromeec/ec_acpi.c b/src/ec/google/chromeec/ec_acpi.c index 4dfd44bf4e..47d60d5b75 100644 --- a/src/ec/google/chromeec/ec_acpi.c +++ b/src/ec/google/chromeec/ec_acpi.c @@ -177,19 +177,14 @@ static void add_usb_port_references(struct acpi_dp *dsd, int port_number) } } -static void fill_ssdt_typec_device(struct device *dev) +static void fill_ssdt_typec_device(int num_ports) { struct usb_pd_port_caps port_caps; char con_name[] = "CONx"; struct acpi_dp *dsd; - int num_ports; int rv; int i; - rv = google_chromeec_get_num_pd_ports(&num_ports); - if (rv) - return; - acpigen_write_device(GOOGLE_CHROMEEC_USBC_DEVICE_NAME); acpigen_write_name_string("_HID", GOOGLE_CHROMEEC_USBC_DEVICE_HID); acpigen_write_name_string("_DDN", "ChromeOS EC Embedded Controller " @@ -220,8 +215,12 @@ static void fill_ssdt_typec_device(struct device *dev) void google_chromeec_fill_ssdt_generator(struct device *dev) { + int num_ports; + if (google_chromeec_get_num_pd_ports(&num_ports)) + return; + /* Reference the existing device's scope */ acpigen_write_scope(acpi_device_path(dev)); - fill_ssdt_typec_device(dev); + fill_ssdt_typec_device(num_ports); acpigen_pop_len(); /* Scope */ }