• Gratian Crisan's avatar
    usb: dwc3: pci: skip BYT GPIO lookup table for hardwired phy · b32b8f2b
    Gratian Crisan authored
    Hardware based on the Bay Trail / BYT SoCs require an external ULPI phy for
    USB device-mode. The phy chip usually has its 'reset' and 'chip select'
    lines connected to GPIOs described by ACPI fwnodes in the DSDT table.
    
    Because of hardware with missing ACPI resources for the 'reset' and 'chip
    select' GPIOs commit 5741022c ("usb: dwc3: pci: Add GPIO lookup table
    on platforms without ACPI GPIO resources") introduced a fallback
    gpiod_lookup_table with hard-coded mappings for Bay Trail devices.
    
    However there are existing Bay Trail based devices, like the National
    Instruments cRIO-903x series, where the phy chip has its 'reset' and
    'chip-select' lines always asserted in hardware via resistor pull-ups. On
    this hardware the phy chip is always enabled and the ACPI dsdt table is
    missing information not only for the 'chip-select' and 'reset' lines but
    also for the BYT GPIO controller itself "INT33FC".
    
    With the introduction of the gpiod_lookup_table initializing the USB
    device-mode on these hardware now errors out. The error comes from the
    gpiod_get_optional() calls in dwc3_pci_quirks() which will now return an
    -ENOENT error due to the missing ACPI entry for the INT33FC gpio controller
    used in the aforementioned table.
    
    This hardware used to work before because gpiod_get_optional() will return
    NULL instead of -ENOENT if no GPIO has been assigned to the requested
    function. The dwc3_pci_quirks() code for setting the 'cs' and 'reset' GPIOs
    was then skipped (due to the NULL return). This is the correct behavior in
    cases where the phy chip is hardwired and there are no GPIOs to control.
    
    Since the gpiod_lookup_table relies on the presence of INT33FC fwnode
    in ACPI tables only add the table if we know the entry for the INT33FC
    gpio controller is present. This allows Bay Trail based devices with
    hardwired dwc3 ULPI phys to continue working.
    
    Fixes: 5741022c ("usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resources")
    Cc: stable <stable@kernel.org>
    Signed-off-by: default avatarGratian Crisan <gratian.crisan@ni.com>
    Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230726184555.218091-2-gratian.crisan@ni.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    b32b8f2b
dwc3-pci.c 15.2 KB