Hi,

On 31-08-18 16:20, Heikki Krogerus wrote:
Only create thre Intel role mux device if the platform has
USB peripheral controller PCI device.

While here, enable the role mux on Apollo Lake platforms.

Signed-off-by: Heikki Krogerus <heikki.kroge...@linux.intel.com>
Cc: Mathias Nyman <mathias.ny...@linux.intel.com>
---
  drivers/usb/host/xhci-pci.c | 20 +++++++++++++++++---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 6372edf339d9..ea651c2adcfd 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -75,6 +75,17 @@ static int xhci_pci_reinit(struct xhci_hcd *xhci, struct 
pci_dev *pdev)
        return 0;
  }
+static int xhci_pci_board_has_udc(void)
+{
+       struct pci_dev *udc = pci_get_class(PCI_CLASS_SERIAL_USB_DEVICE, NULL);
+
+       if (udc) {
+               pci_dev_put(udc);
+               return true;
+       }
+       return false;
+}
+
  static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  {
        struct pci_dev          *pdev = to_pci_dev(dev);
@@ -179,15 +190,18 @@ static void xhci_pci_quirks(struct device *dev, struct 
xhci_hcd *xhci)
                xhci->quirks |= XHCI_PME_STUCK_QUIRK;
        }
        if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
-                pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
+           pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI)
                xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
-               xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
-       }
        if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
            (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
             pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
             pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI))
                xhci->quirks |= XHCI_MISSING_CAS;
+       if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+           (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
+            pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI) &&
+           xhci_pci_board_has_udc())
+               xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
                        pdev->device == PCI_DEVICE_ID_EJ168) {


This patch and "[PATCH 3/8] plarform: x86: intel_cht_int33fe: Use the USB role 
switch conditionally"
both assume that the mux will be in host mode when Linux boots, so we do not 
need to
touch it. I'm not sure that is a valid assumption.

More over the USB DP- / DP+ lines should be floated when in device
mode, otherwise USB BC1.2 charger detection will not work, some
PMIC-s have their mux for the data lines and will decouple them
from the SoCs usb data lines when doing charger detection, but
others simply piggy-back on the datalines and are hardwired to
the DP- / DP+ lines of the SoC, if we then do not float the datalines
the PMICs BC detection logic sees a USB host and assumes its a SDP
(standard downstream port) and will limit the charging to 500mA.

This is at least true for all devices with an AXP288 PMIC, of which
there are a lot (all recent cheap CHT designs use this PMIC).

So I believe it is best to drop patches 3 and 4 from this patch-set.

Regards,

Hans

Reply via email to