All of lore.kernel.org
 help / color / mirror / Atom feed
* [4/8] usb: xhci: pci: Only create Intel mux device when it's needed
@ 2018-08-31 14:20 Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2018-08-31 14:20 UTC (permalink / raw)
  To: Hans de Goede, Greg Kroah-Hartman
  Cc: Andy Shevchenko, Darren Hart, platform-driver-x86, linux-usb,
	Mathias Nyman

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.krogerus@linux.intel.com>
Cc: Mathias Nyman <mathias.nyman@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) {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [4/8] usb: xhci: pci: Only create Intel mux device when it's needed
@ 2018-09-03 11:01 Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2018-09-03 11:01 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Greg Kroah-Hartman, Andy Shevchenko, Darren Hart,
	platform-driver-x86, linux-usb, Mathias Nyman

On Mon, Sep 03, 2018 at 10:01:01AM +0200, Hans de Goede wrote:
> 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.

OK, fair enough. I'll drop those.

Thanks,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [4/8] usb: xhci: pci: Only create Intel mux device when it's needed
@ 2018-09-03  8:01 Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2018-09-03  8:01 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Andy Shevchenko, Darren Hart, platform-driver-x86, linux-usb,
	Mathias Nyman

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.krogerus@linux.intel.com>
> Cc: Mathias Nyman <mathias.nyman@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [4/8] usb: xhci: pci: Only create Intel mux device when it's needed
@ 2018-09-03  7:15 Heikki Krogerus
  0 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2018-09-03  7:15 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Greg Kroah-Hartman, Andy Shevchenko, Darren Hart,
	Platform Driver, USB, Mathias Nyman

On Mon, Sep 03, 2018 at 09:01:47AM +0300, Andy Shevchenko wrote:
> On Fri, Aug 31, 2018 at 5:21 PM Heikki Krogerus
> <heikki.krogerus@linux.intel.com> 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.
> 
> > +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;
> > +}
> 
> Looks like a code duplication with patch 3. Does it make sense to have
> this in some header (usb.h?)?

I don't know. The check is very PCI specific. I'm not sure ush.h
would be appropriate place for it. I don't know where should it go?

Right now the check is only needed on Intel CHT (in both patches), so
I figured that it's better wait for an other user before introducing
a helper for it. Would that make sense?


Thanks,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [4/8] usb: xhci: pci: Only create Intel mux device when it's needed
@ 2018-09-03  6:01 Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-09-03  6:01 UTC (permalink / raw)
  To: Krogerus, Heikki
  Cc: Hans de Goede, Greg Kroah-Hartman, Andy Shevchenko, Darren Hart,
	Platform Driver, USB, Mathias Nyman

On Fri, Aug 31, 2018 at 5:21 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> 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.

> +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;
> +}

Looks like a code duplication with patch 3. Does it make sense to have
this in some header (usb.h?)?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-03 11:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 14:20 [4/8] usb: xhci: pci: Only create Intel mux device when it's needed Heikki Krogerus
2018-09-03  6:01 Andy Shevchenko
2018-09-03  7:15 Heikki Krogerus
2018-09-03  8:01 Hans de Goede
2018-09-03 11:01 Heikki Krogerus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.