From patchwork Tue Nov 28 17:11:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Wallis X-Patchwork-Id: 10080791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B938B6056A for ; Tue, 28 Nov 2017 17:12:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A62C3294F9 for ; Tue, 28 Nov 2017 17:12:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AC51294F7; Tue, 28 Nov 2017 17:12:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 02FC7294F0 for ; Tue, 28 Nov 2017 17:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=pBGL7GmaGwkQxtjbT8/qDkskW996PZnE9EfRa05Ia0k=; b=rQc K0nc+1dlzXnLJxPTDzRBUt6J13NmRNZifRsk2TN1sUFXF+2eM1VTPDlOz4RdWEx1SVOeNQo78w+Mr CLicW1AWsZ4YBuM4v/mLNQ6My1V9ukm/jmrMD09/jUsO8Sunzyx4MX4JKq1JsdZ5kdxePL8GxuTi8 N81hTNnUeyKv82gX/nBhNvXKWVaVbciwFZ2WVAlYI9u4QpgW9U7O5b7cfG8zaNrFY5BvuIUvHNu0e UEwDt5rsIqK6U14M9/VpdCnu5B0jepZ1mksvXa9bV/D/IaHnzl90ofoHneHJicjjXNZ34AhgfxffR wIQxI5h30QJ3ccdKsDh6K9ZQ2uDHg2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJjQn-0001cL-Tf; Tue, 28 Nov 2017 17:12:25 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJjQh-0001Qk-Gd; Tue, 28 Nov 2017 17:12:23 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 95B026A1F2; Tue, 28 Nov 2017 17:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511889118; bh=eD0I7xW0uqCBFzLsf4jag1JtJMLEPHiCqL27UfgKkC8=; h=From:To:Cc:Subject:Date:From; b=YemQgtZCYAV/WpmAoIFYllG2pQNYAX51XEnNh0nssygTvCO7nBnwg6fQHEkothPc+ azMIKgCOAU+ls+jracWgqJbp6HRuXoL9ognYZW5ZNy5dxYn8jKXgCcsDWuq2T6dfcf ctGXMaymBg9O1Ae5z0DQYF1l1FN0sLEsZXbc842w= Received: from chromaggus.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: awallis@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8E2C66A077; Tue, 28 Nov 2017 17:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511889117; bh=eD0I7xW0uqCBFzLsf4jag1JtJMLEPHiCqL27UfgKkC8=; h=From:To:Cc:Subject:Date:From; b=ZS4ak78K5cAMR0Csitjq+aiDyNp9FIbB+yZH8AT9HcbMRG99abfvXUCSaMNfHgnyt PSnUrj4wscDqiRneT2DxL9OqUQsw1+2JFjmp9keWEg/PYBQ1c+iwcoRzWms9fvxfRM GqHRiXpAvi5NAnVxmlfHpNQn/ywQpRbiLlCLIGXI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8E2C66A077 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=awallis@codeaurora.org From: Adam Wallis To: linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Rob Herring , Mathias Nyman , linux-usb@vger.kernel.org, Mark Rutland , Matthias Brugger , devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, chunfeng.yun@mediatek.com Subject: [PATCH v1] usb: xhci: allow imod-interval to be configurable Date: Tue, 28 Nov 2017 12:11:46 -0500 Message-Id: <1511889106-9239-1-git-send-email-awallis@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171128_091220_157098_89ED45BD X-CRM114-Status: GOOD ( 18.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timur@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The xHCI driver currently has the IMOD set to 160, which translates to an IMOD interval of 40,000ns (160 * 250)ns Commit 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller") introduced a QUIRK for the MTK platform to adjust this interval to 20, which translates to an IMOD interval of 5,000ns (20 * 250)ns. This is due to the fact that the MTK controller IMOD interval is 8 times as much as defined in xHCI spec. Instead of adding more quirk bits for additional platforms, this patch introduces the ability for vendors to set the IMOD_INTERVAL as is optimal for their platform. By using device_property_read_u32() on "imod-interval", the IMOD INTERVAL can be specified in nano seconds. If no interval is specified, the default of 40,000ns (IMOD=160) will be used. No bounds checking has been implemented due to the fact that a vendor may have violated the spec and would need to specify a value outside of the max 8,000 IRQs/second limit specified in the xHCI spec. Backwards compatibility is maintained for MTK_HOSTS through the quirk bit, however, imod_interval should be pushed into device tree at a future point and this quirk should be removed from xhci_plat_probe Signed-off-by: Adam Wallis --- Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 + drivers/usb/host/xhci-plat.c | 15 +++++++++++++++ drivers/usb/host/xhci.c | 7 ++----- drivers/usb/host/xhci.h | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index ae6e484..3998459 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -29,6 +29,7 @@ Optional properties: - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM - usb3-lpm-capable: determines if platform is USB3 LPM capable - quirk-broken-port-ped: set if the controller has broken port disable mechanism + - imod-interval: IMOD_INTERVAL in nano-seconds. Default is 40000 Example: usb@f0931000 { diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 09f164f..f7730c8 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -23,6 +23,7 @@ #include "xhci-plat.h" #include "xhci-mvebu.h" #include "xhci-rcar.h" +#include "xhci-mtk.h" static struct hc_driver __read_mostly xhci_plat_hc_driver; @@ -269,6 +270,20 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; + /* imod interval in nanoseconds */ + if (device_property_read_u32(sysdev, + "imod-interval", &xhci->imod_interval)) + xhci->imod_interval = 40000; + else if (xhci->quirks & XHCI_MTK_HOST) + /* + * The increment interval is 8 times as much as that defined in + * the xHCI spec on MTK's controller. This is added to provide + * backwards compatibility, however, this should be pushed into + * the device tree files at some point in the future and + * removed from xhci_plat_probe + */ + xhci->imod_interval = 5000; + hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); if (IS_ERR(hcd->usb_phy)) { ret = PTR_ERR(hcd->usb_phy); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 2424d30..6a09311 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -586,11 +586,8 @@ int xhci_run(struct usb_hcd *hcd) "// Set the interrupt modulation register"); temp = readl(&xhci->ir_set->irq_control); temp &= ~ER_IRQ_INTERVAL_MASK; - /* - * the increment interval is 8 times as much as that defined - * in xHCI spec on MTK's controller - */ - temp |= (u32) ((xhci->quirks & XHCI_MTK_HOST) ? 20 : 160); + temp |= (u16) (xhci->imod_interval / 250); + writel(temp, &xhci->ir_set->irq_control); /* Set the HCD state before we enable the irqs */ diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 99a014a..2a4177b 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1717,6 +1717,8 @@ struct xhci_hcd { u8 max_interrupters; u8 max_ports; u8 isoc_threshold; + /* imod_interval in ns (I * 250ns) */ + u32 imod_interval; int event_ring_max; /* 4KB min, 128MB max */ int page_size;