|
21 | 21 | #include <linux/slab.h>
|
22 | 22 | #include <linux/pci.h>
|
23 | 23 | #include <linux/platform_device.h>
|
| 24 | +#include <linux/gpio/consumer.h> |
| 25 | +#include <linux/acpi.h> |
24 | 26 |
|
25 | 27 | #include "platform_data.h"
|
26 | 28 |
|
|
31 | 33 | #define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30
|
32 | 34 | #define PCI_DEVICE_ID_INTEL_SPTH 0xa130
|
33 | 35 |
|
| 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 | + |
34 | 45 | static int dwc3_pci_quirks(struct pci_dev *pdev)
|
35 | 46 | {
|
36 | 47 | if (pdev->vendor == PCI_VENDOR_ID_AMD &&
|
@@ -65,6 +76,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
|
65 | 76 | sizeof(pdata));
|
66 | 77 | }
|
67 | 78 |
|
| 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 | + |
68 | 103 | return 0;
|
69 | 104 | }
|
70 | 105 |
|
@@ -128,6 +163,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
|
128 | 163 |
|
129 | 164 | static void dwc3_pci_remove(struct pci_dev *pci)
|
130 | 165 | {
|
| 166 | + acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev)); |
131 | 167 | platform_device_unregister(pci_get_drvdata(pci));
|
132 | 168 | }
|
133 | 169 |
|
|
0 commit comments