Maulik V Vaghela has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56024 )
Change subject: drivers/usb/acpi: Create function to get PLD information ......................................................................
drivers/usb/acpi: Create function to get PLD information
Create a separate function to get PLD information from USB device. This is helpful in retimer driver where we can attach same USB port information to retimer instance and we can avoid duplication of information.
BUG=None BRANCH=None TEST=Check if code compiles and function returns correct value
Change-Id: Iaaf140ce1965dce3a812aa2701ce0e29b34ab3e7 Signed-off-by: Maulik V Vaghela maulik.v.vaghela@intel.com --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 27 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/56024/1
diff --git a/src/drivers/usb/acpi/chip.h b/src/drivers/usb/acpi/chip.h index 73c69cc..9e9772b 100644 --- a/src/drivers/usb/acpi/chip.h +++ b/src/drivers/usb/acpi/chip.h @@ -68,4 +68,7 @@ struct acpi_gpio privacy_gpio; };
+/* Method to get PLD structure from USB device */ +const struct acpi_pld *usb_acpi_get_pld(const struct device *usb_device); + #endif /* __USB_ACPI_CHIP_H__ */ diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c index 9d68d0a..da91328 100644 --- a/src/drivers/usb/acpi/usb_acpi.c +++ b/src/drivers/usb/acpi/usb_acpi.c @@ -37,6 +37,7 @@ { struct drivers_usb_acpi_config *config = dev->chip_info; const char *path = acpi_device_path(dev); + const struct acpi_pld *pld = usb_acpi_get_pld(dev);
if (!path || !config) return; @@ -50,15 +51,10 @@ acpigen_write_name_string("_DDN", config->desc); acpigen_write_upc(config->type);
- if (config->use_custom_pld) { - /* Use board defined PLD */ - acpigen_write_pld(&config->custom_pld); - } else { - /* Fill PLD strucutre based on port type */ - struct acpi_pld pld; - acpi_pld_fill_usb(&pld, config->type, &config->group); - acpigen_write_pld(&pld); - } + if (pld) + acpigen_write_pld(pld); + else + printk(BIOS_ERR, "Error retrieving PLD for %s \n", path);
/* Resources */ if (usb_acpi_add_gpios_to_crs(config) == true) { @@ -126,3 +122,22 @@ CHIP_NAME("USB ACPI Device") .enable_dev = usb_acpi_enable }; + +const struct acpi_pld *usb_acpi_get_pld(const struct device *usb_device) +{ + struct drivers_usb_acpi_config *config = usb_device->chip_info; + static struct acpi_pld pld; + + if (!usb_device || !usb_device->chip_info || usb_device->chip_ops != &drivers_usb_acpi_ops) + return NULL; + + if (config->use_custom_pld) { + /* Use board defined PLD */ + memcpy(&pld, &config->custom_pld, sizeof(pld)); + } else { + /* Fill PLD strucutre based on port type */ + acpi_pld_fill_usb(&pld, config->type, &config->group); + } + + return &pld; +}