Skip to content

Commit 5741022

Browse files
jwrdegoedeFelipe Balbi
authored andcommitted
usb: dwc3: pci: Add GPIO lookup table on platforms without ACPI GPIO resources
Bay Trail / BYT SoCs do not have a builtin device-mode phy, instead they require an external ULPI phy for device-mode. Only some BYT devices have an external phy, but even on those devices device-mode is not working because the dwc3 does not see the phy. The problem is that the ACPI fwnode for the dwc3 does not contain the expected GPIO resources for the GPIOs connected to the chip-select and reset pins of the phy. I've found the workaround which some Android x86 kernels use for this: https://github.com/BORETS24/Kernel-for-Asus-Zenfone-2/blob/master/arch/x86/platform/intel-mid/device_libs/pci/platform_usb_otg.c Which boils down to hardcoding the GPIOs for these devices. The good news it that all boards (*) use the same GPIOs. This commit fixes the ULPI phy not woring by adding a gpiod_lookup_table call which adds a hardcoded mapping for BYT devices. Note that the mapping added by gpiod_add_lookup_table is a fallback mapping, so boards which properly provide GPIO resources in the ACPI firmware-node resources will not use this. *) Except for the first revision of the evalulation-kit, which normal users don't have Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent ee9a4ae commit 5741022

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/pm_runtime.h>
1717
#include <linux/platform_device.h>
1818
#include <linux/gpio/consumer.h>
19+
#include <linux/gpio/machine.h>
1920
#include <linux/acpi.h>
2021
#include <linux/delay.h>
2122

@@ -64,6 +65,15 @@ static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
6465
{ },
6566
};
6667

68+
static struct gpiod_lookup_table platform_bytcr_gpios = {
69+
.dev_id = "0000:00:16.0",
70+
.table = {
71+
GPIO_LOOKUP("INT33FC:00", 54, "reset", GPIO_ACTIVE_HIGH),
72+
GPIO_LOOKUP("INT33FC:02", 14, "cs", GPIO_ACTIVE_HIGH),
73+
{}
74+
},
75+
};
76+
6777
static int dwc3_pci_quirks(struct dwc3_pci *dwc)
6878
{
6979
struct platform_device *dwc3 = dwc->dwc3;
@@ -124,6 +134,13 @@ static int dwc3_pci_quirks(struct dwc3_pci *dwc)
124134
if (ret)
125135
dev_dbg(&pdev->dev, "failed to add mapping table\n");
126136

137+
/*
138+
* A lot of BYT devices lack ACPI resource entries for
139+
* the GPIOs, add a fallback mapping to the reference
140+
* design GPIOs which all boards seem to use.
141+
*/
142+
gpiod_add_lookup_table(&platform_bytcr_gpios);
143+
127144
/*
128145
* These GPIOs will turn on the USB2 PHY. Note that we have to
129146
* put the gpio descriptors again here because the phy driver
@@ -239,6 +256,7 @@ static void dwc3_pci_remove(struct pci_dev *pci)
239256
{
240257
struct dwc3_pci *dwc = pci_get_drvdata(pci);
241258

259+
gpiod_remove_lookup_table(&platform_bytcr_gpios);
242260
#ifdef CONFIG_PM
243261
cancel_work_sync(&dwc->wakeup_work);
244262
#endif

0 commit comments

Comments
 (0)