From: Heikki Krogerus <heikki.kroge...@linux.intel.com>

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.kroge...@linux.intel.com>
Signed-off-by: Felipe Balbi <ba...@ti.com>
(cherry picked from commit a89d977cc04c77d9aa45d426dbf8de9dd1326c77)
Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.moha...@intel.com>

Conflicts:
        drivers/usb/dwc3/dwc3-pci.c
Resolved. Conflicted due to commit
usb: dwc3: pci: Add platform data for Synopsys HAPS
---
 drivers/usb/dwc3/dwc3-pci.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 830f020..fcdbd13 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -21,6 +21,8 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/gpio/consumer.h>
+#include <linux/acpi.h>
 
 #include "platform_data.h"
 
@@ -33,6 +35,15 @@
 #define PCI_DEVICE_ID_INTEL_SPTLP      0x9d30
 #define PCI_DEVICE_ID_INTEL_SPTH       0xa130
 
+static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
+static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
+       { "reset-gpios", &reset_gpios, 1 },
+       { "cs-gpios", &cs_gpios, 1 },
+       { },
+};
+
 static int dwc3_pci_quirks(struct pci_dev *pdev)
 {
        if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -82,6 +93,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
                                                sizeof(pdata));
        }
 
+       if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+           pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
+               struct gpio_desc *gpio;
+
+               acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
+                                         acpi_dwc3_byt_gpios);
+
+               /* These GPIOs will turn on the USB2 PHY */
+               gpio = gpiod_get(&pdev->dev, "cs");
+               if (!IS_ERR(gpio)) {
+                       gpiod_direction_output(gpio, 0);
+                       gpiod_set_value_cansleep(gpio, 1);
+                       gpiod_put(gpio);
+               }
+
+               gpio = gpiod_get(&pdev->dev, "reset");
+               if (!IS_ERR(gpio)) {
+                       gpiod_direction_output(gpio, 0);
+                       gpiod_set_value_cansleep(gpio, 1);
+                       gpiod_put(gpio);
+                       usleep_range(10000, 11000);
+               }
+       }
+
        return 0;
 }
 
@@ -145,6 +180,7 @@ err:
 
 static void dwc3_pci_remove(struct pci_dev *pci)
 {
+       acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
        platform_device_unregister(pci_get_drvdata(pci));
 }
 
-- 
1.9.1

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to