linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: felipe.balbi@linux.intel.com,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Lee Jones <lee.jones@linaro.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lu Baolu <baolu.lu@linux.intel.com>
Subject: [PATCH v10 6/7] usb: pci-quirks: add Intel USB drcfg mux device
Date: Thu,  2 Jun 2016 09:37:28 +0800	[thread overview]
Message-ID: <1464831449-8973-7-git-send-email-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <1464831449-8973-1-git-send-email-baolu.lu@linux.intel.com>

In some Intel platforms, a single usb port is shared between USB host
and device controllers. The shared port is under control of a switch
which is defined in the Intel vendor defined extended capability for
xHCI.

This patch adds the support to detect and create the platform device
for the port mux switch.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@kernel.org>
---
 drivers/usb/host/pci-quirks.c    | 42 +++++++++++++++++++++++++++++++++++++++-
 drivers/usb/host/xhci-ext-caps.h |  2 ++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 35af362..7e3194f 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -16,6 +16,8 @@
 #include <linux/export.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/platform_device.h>
+
 #include "pci-quirks.h"
 #include "xhci-ext-caps.h"
 
@@ -78,6 +80,9 @@
 #define USB_INTEL_USB3_PSSEN   0xD8
 #define USB_INTEL_USB3PRM      0xDC
 
+#define DEVICE_ID_INTEL_BROXTON_P_XHCI		0x5aa8
+#define DEVICE_ID_INTEL_CHERRYVIEW_XHCI		0x22b5
+
 /*
  * amd_chipset_gen values represent AMD different chipset generations
  */
@@ -956,6 +961,36 @@ void usb_disable_xhci_ports(struct pci_dev *xhci_pdev)
 }
 EXPORT_SYMBOL_GPL(usb_disable_xhci_ports);
 
+static void create_intel_usb_mux_device(struct pci_dev *xhci_pdev,
+					void __iomem *base)
+{
+	int ret;
+	struct platform_device *plat_dev;
+	struct property_entry pentry[] = {
+		PROPERTY_ENTRY_U64("reg-start",
+				   pci_resource_start(xhci_pdev, 0) + 0x80d8),
+		PROPERTY_ENTRY_U64("reg-size", 8),
+		{ },
+	};
+
+	if (!xhci_find_next_ext_cap(base, 0, XHCI_EXT_CAPS_INTEL_USB_MUX))
+		return;
+
+	plat_dev = platform_device_alloc("intel-mux-drcfg",
+					 PLATFORM_DEVID_NONE);
+	if (!plat_dev)
+		return;
+
+	plat_dev->dev.parent = &xhci_pdev->dev;
+	platform_device_add_properties(plat_dev, pentry);
+	ret = platform_device_add(plat_dev);
+	if (ret) {
+		dev_warn(&xhci_pdev->dev,
+			 "failed to create mux device with error %d", ret);
+		platform_device_put(plat_dev);
+	}
+}
+
 /**
  * PCI Quirks for xHCI.
  *
@@ -1022,9 +1057,14 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
 	writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET);
 
 hc_init:
-	if (pdev->vendor == PCI_VENDOR_ID_INTEL)
+	if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
 		usb_enable_intel_xhci_ports(pdev);
 
+		if (pdev->device == DEVICE_ID_INTEL_BROXTON_P_XHCI ||
+		    pdev->device == DEVICE_ID_INTEL_CHERRYVIEW_XHCI)
+			create_intel_usb_mux_device(pdev, base);
+	}
+
 	op_reg_base = base + XHCI_HC_LENGTH(readl(base));
 
 	/* Wait for the host controller to be ready before writing any
diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
index e0244fb..e368ccb 100644
--- a/drivers/usb/host/xhci-ext-caps.h
+++ b/drivers/usb/host/xhci-ext-caps.h
@@ -51,6 +51,8 @@
 #define XHCI_EXT_CAPS_ROUTE	5
 /* IDs 6-9 reserved */
 #define XHCI_EXT_CAPS_DEBUG	10
+/* Vendor defined 192-255 */
+#define XHCI_EXT_CAPS_INTEL_USB_MUX	192
 /* USB Legacy Support Capability - section 7.1.1 */
 #define XHCI_HC_BIOS_OWNED	(1 << 16)
 #define XHCI_HC_OS_OWNED	(1 << 24)
-- 
2.1.4

  parent reply	other threads:[~2016-06-02  1:38 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02  1:37 [PATCH v10 0/7] usb: add support for Intel dual role port mux Lu Baolu
2016-06-02  1:37 ` [PATCH v10 1/7] regulator: fixed: add support for ACPI interface Lu Baolu
2016-06-08  4:42   ` Greg Kroah-Hartman
2016-06-08 13:43     ` Mark Brown
2016-06-08 15:46       ` Greg Kroah-Hartman
2016-06-09  2:43     ` Lu Baolu
2016-06-02  1:37 ` [PATCH v10 2/7] usb: mux: add generic code for dual role port mux Lu Baolu
2016-06-03  7:41   ` Peter Chen
2016-06-03  8:16     ` Heikki Krogerus
2016-06-03  9:20       ` Peter Chen
2016-06-03 16:06     ` Lu Baolu
2016-06-04  2:28       ` Peter Chen
2016-06-05  6:55         ` Lu Baolu
2016-06-05  8:33           ` Jun Li
2016-06-05  8:46             ` Lu Baolu
2016-06-06  1:08               ` Jun Li
2016-06-06  2:30                 ` Lu Baolu
2016-06-06  2:05               ` Peter Chen
2016-06-06  2:45                 ` Lu Baolu
2016-06-06  6:48                   ` Peter Chen
2016-06-06  1:25           ` Peter Chen
2016-06-06  3:04             ` Lu Baolu
2016-06-06  7:02               ` Roger Quadros
2016-06-07  3:03                 ` Jun Li
2016-06-07  6:27                   ` Lu Baolu
2016-06-07  6:34                     ` Jun Li
2016-06-07  9:27                       ` Lu Baolu
2016-06-07 12:49                         ` Roger Quadros
2016-06-07  9:53                   ` Lu Baolu
2016-06-07 12:58                     ` Roger Quadros
2016-06-07 13:04                       ` Felipe Balbi
2016-06-07 14:02                         ` Roger Quadros
2016-06-07 15:05                           ` Felipe Balbi
2016-06-08  3:04                             ` Jun Li
     [not found]                               ` <5757A8CB.90402@linux.intel.com>
2016-06-08  6:20                                 ` Jun Li
2016-06-08  6:25                             ` Peter Chen
2016-06-08  7:58                             ` Roger Quadros
2016-06-06  7:02               ` Peter Chen
2016-06-06  7:35                 ` Lu Baolu
2016-06-02  1:37 ` [PATCH v10 3/7] usb: mux: add driver for Intel gpio controlled " Lu Baolu
2016-06-02  1:37 ` [PATCH v10 4/7] usb: mux: add driver for Intel drcfg " Lu Baolu
2016-06-02  1:37 ` [PATCH v10 5/7] mfd: intel_vuport: Add Intel virtual USB port MFD Driver Lu Baolu
2016-06-02  1:37 ` Lu Baolu [this message]
2016-06-08  4:45   ` [PATCH v10 6/7] usb: pci-quirks: add Intel USB drcfg mux device Greg Kroah-Hartman
2016-06-08  7:56     ` Lu Baolu
2016-06-08 15:45       ` Greg Kroah-Hartman
2016-06-09  2:39         ` Lu Baolu
2016-06-16  0:27           ` Lu Baolu
2016-06-18  0:58             ` Greg Kroah-Hartman
2016-06-19  9:52               ` Lu Baolu
2016-06-02  1:37 ` [PATCH v10 7/7] MAINTAINERS: add maintainer entry for Intel USB dual role mux drivers Lu Baolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464831449-8973-7-git-send-email-baolu.lu@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).