Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756124AbbLANcz (ORCPT ); Tue, 1 Dec 2015 08:32:55 -0500 Received: from mga14.intel.com ([192.55.52.115]:50284 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755351AbbLANcv (ORCPT ); Tue, 1 Dec 2015 08:32:51 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,369,1444719600"; d="scan'208";a="851409497" From: Heikki Krogerus To: Chanwoo Choi , Greg Kroah-Hartman Cc: MyungJoo Ham , David Cohen , Lu Baolu , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] usb: pci-quirks: register USB mux found on Cherrytrail SOC Date: Tue, 1 Dec 2015 15:32:38 +0200 Message-Id: <1448976758-35807-3-git-send-email-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1448976758-35807-1-git-send-email-heikki.krogerus@linux.intel.com> References: <1448976758-35807-1-git-send-email-heikki.krogerus@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2503 Lines: 73 Intel Braswell/Cherrytrail has an internal mux that shares one USB port between USB Device Controller and xHCI. The same mux is found on several SOCs from Intel, but only on a few Cherrytrail based platforms the OS is expected to configure it. Normally BIOS takes care of it. The driver for the mux is an "extcon" driver. With this we only register the mux if it's detected. Suggested-by: Lu Baolu Signed-off-by: Heikki Krogerus --- drivers/usb/host/pci-quirks.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index f940056..4e3016a 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "pci-quirks.h" #include "xhci-ext-caps.h" @@ -1029,9 +1030,36 @@ 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); + /* + * Initialize the internal mux that shares a port between USB + * Device Controller and xHCI on platforms that have it. + */ +#define XHCI_INTEL_VENDOR_CAPS 192 +#define XHCI_INTEL_USB_MUX_OFFSET 0x80d8 + ext_cap_offset = xhci_find_next_cap_offset(base, + XHCI_HCC_PARAMS_OFFSET); + ext_cap_offset = xhci_find_ext_cap_by_id(base, ext_cap_offset, + XHCI_INTEL_VENDOR_CAPS); + if (ext_cap_offset) { + struct intel_usb_mux *mux; + struct resource r; + + r.start = pci_resource_start(pdev, 0) + + XHCI_INTEL_USB_MUX_OFFSET; + r.end = r.start + 8; + r.flags = IORESOURCE_MEM; + + mux = intel_usb_mux_register(&pdev->dev, &r); + if (IS_ERR(mux) && PTR_ERR(mux) == -ENOTSUPP) + dev_dbg(&pdev->dev, "USB mux not supported\n"); + else if (IS_ERR(mux)) + dev_err(&pdev->dev, "failed to register mux\n"); + } + } + op_reg_base = base + XHCI_HC_LENGTH(readl(base)); /* Wait for the host controller to be ready before writing any -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/