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>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56024
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
Maulik V Vaghela 2021-07-02 12:09:42 +05:30 committed by Patrick Georgi
parent 43b2212d13
commit 8e885a57b1
2 changed files with 23 additions and 8 deletions

View File

@ -68,4 +68,7 @@ struct drivers_usb_acpi_config {
struct acpi_gpio privacy_gpio; struct acpi_gpio privacy_gpio;
}; };
/* Method to get PLD structure from USB device */
bool usb_acpi_get_pld(const struct device *usb_device, struct acpi_pld *pld);
#endif /* __USB_ACPI_CHIP_H__ */ #endif /* __USB_ACPI_CHIP_H__ */

View File

@ -37,6 +37,7 @@ static void usb_acpi_fill_ssdt_generator(const struct device *dev)
{ {
struct drivers_usb_acpi_config *config = dev->chip_info; struct drivers_usb_acpi_config *config = dev->chip_info;
const char *path = acpi_device_path(dev); const char *path = acpi_device_path(dev);
struct acpi_pld pld;
if (!path || !config) if (!path || !config)
return; return;
@ -50,15 +51,10 @@ static void usb_acpi_fill_ssdt_generator(const struct device *dev)
acpigen_write_name_string("_DDN", config->desc); acpigen_write_name_string("_DDN", config->desc);
acpigen_write_upc(config->type); acpigen_write_upc(config->type);
if (config->use_custom_pld) { if (usb_acpi_get_pld(dev, &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); acpigen_write_pld(&pld);
} else
printk(BIOS_ERR, "Error retrieving PLD for %s\n", path);
/* Resources */ /* Resources */
if (usb_acpi_add_gpios_to_crs(config) == true) { if (usb_acpi_add_gpios_to_crs(config) == true) {
@ -126,3 +122,19 @@ struct chip_operations drivers_usb_acpi_ops = {
CHIP_NAME("USB ACPI Device") CHIP_NAME("USB ACPI Device")
.enable_dev = usb_acpi_enable .enable_dev = usb_acpi_enable
}; };
bool usb_acpi_get_pld(const struct device *usb_device, struct acpi_pld *pld)
{
struct drivers_usb_acpi_config *config = usb_device->chip_info;
if (!usb_device || !usb_device->chip_info ||
usb_device->chip_ops != &drivers_usb_acpi_ops)
return false;
if (config->use_custom_pld)
memcpy(pld, &config->custom_pld, sizeof(pld));
else
acpi_pld_fill_usb(pld, config->type, &config->group);
return true;
}