Skip to content

Commit a89d977

Browse files
Heikki KrogerusFelipe Balbi
authored andcommitted
usb: dwc3: pci: add quirk for Baytrails
On some BYT platforms the USB2 PHY needs to be put into operational mode by the controller driver with GPIOs controlling the PHYs reset and cs signals. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent 3e10a2c commit a89d977

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <linux/slab.h>
2222
#include <linux/pci.h>
2323
#include <linux/platform_device.h>
24+
#include <linux/gpio/consumer.h>
25+
#include <linux/acpi.h>
2426

2527
#include "platform_data.h"
2628

@@ -31,6 +33,15 @@
3133
#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30
3234
#define PCI_DEVICE_ID_INTEL_SPTH 0xa130
3335

36+
static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
37+
static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
38+
39+
static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
40+
{ "reset-gpios", &reset_gpios, 1 },
41+
{ "cs-gpios", &cs_gpios, 1 },
42+
{ },
43+
};
44+
3445
static int dwc3_pci_quirks(struct pci_dev *pdev)
3546
{
3647
if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -65,6 +76,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
6576
sizeof(pdata));
6677
}
6778

79+
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
80+
pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
81+
struct gpio_desc *gpio;
82+
83+
acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
84+
acpi_dwc3_byt_gpios);
85+
86+
/* These GPIOs will turn on the USB2 PHY */
87+
gpio = gpiod_get(&pdev->dev, "cs");
88+
if (!IS_ERR(gpio)) {
89+
gpiod_direction_output(gpio, 0);
90+
gpiod_set_value_cansleep(gpio, 1);
91+
gpiod_put(gpio);
92+
}
93+
94+
gpio = gpiod_get(&pdev->dev, "reset");
95+
if (!IS_ERR(gpio)) {
96+
gpiod_direction_output(gpio, 0);
97+
gpiod_set_value_cansleep(gpio, 1);
98+
gpiod_put(gpio);
99+
usleep_range(10000, 11000);
100+
}
101+
}
102+
68103
return 0;
69104
}
70105

@@ -128,6 +163,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
128163

129164
static void dwc3_pci_remove(struct pci_dev *pci)
130165
{
166+
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
131167
platform_device_unregister(pci_get_drvdata(pci));
132168
}
133169

0 commit comments

Comments
 (0)