From patchwork Thu Jan 19 19:58:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 717302 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3v4Dxs4lD4z9tT8 for ; Fri, 20 Jan 2017 06:52:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nexus-software-ie.20150623.gappssmtp.com header.i=@nexus-software-ie.20150623.gappssmtp.com header.b="YIW0fWIA"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751757AbdASTvz (ORCPT ); Thu, 19 Jan 2017 14:51:55 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:37343 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbdASTvv (ORCPT ); Thu, 19 Jan 2017 14:51:51 -0500 Received: by mail-wm0-f44.google.com with SMTP id c206so10169782wme.0 for ; Thu, 19 Jan 2017 11:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=pFtL/95NTvhwo4N3fsj41JM26xRJnaSmmErsOyA+/cQ=; b=YIW0fWIAs+BlkIkE/icxYs/+HDjLL3nBkO9mutCCM30S9g5b0sBVrAvW+1uqkHcL2R Svxuh9TGX6VRxWPVzqlusyiTZGSHnBv5vK/y2wV1vnnGt6eLybEf2xz+QG0HNLFXF+on aCiEisaNuEuWCD9VApd3Enmgrfm+ydUr1OVuCUEeW6pwvifJKEBuVIZgLX/4ls0+MtEJ 4jhp+bMVoEcsOqBdxP4hlStiLfYt/tFZZdq3GE5Dl37LLVWPKFCiUGbR7oB0OFp+1t8V JvCF5kXF9PP8QBsMmyAlLa/o7TLo3INXCEd2m6pkMVpVtR2J18OUBcosSX7PFYZ7sizm 3gQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pFtL/95NTvhwo4N3fsj41JM26xRJnaSmmErsOyA+/cQ=; b=DLTA4QOcKAaD7GnsD7BN7zVfwl96aCPfFWYueD0pXgDVNagebhnL5NdUzs8M4b8OrY IRkywDECd4oNAXTzY6hzjv+H5FjIzhoArGiRiGAklvsls45kX7T9lIahNWDbD0MRdw0d B9gy5sciSDrxjsBNIol4OSzeT4ev+hAhHwtQ4FNAShOhKy65mhevDpOaWAVgVGiHHPR7 Ojzfx6XE+aFSzq00iMruPW621RGe0NdRFd45xkm5Kk1R64chUmJNrF0Gv12JtQbiLxaW LBp2sEvq+DUZuXwmO/Po3BeeIy3METrD54fny+0OaKZdi8Ct1DtRQM1roSPQxrPMPvMy iscg== X-Gm-Message-State: AIkVDXK51r45u3aPN/sv26k0A1HezbHXsHFrWsoDghMK6Kxcmd/VSmVhyFiPNxS1T4gxKQ== X-Received: by 10.28.222.11 with SMTP id v11mr195763wmg.1.1484855042038; Thu, 19 Jan 2017 11:44:02 -0800 (PST) Received: from localhost.localdomain (188-39-186-226.static.enta.net. [188.39.186.226]) by smtp.gmail.com with ESMTPSA id r6sm448973wmd.4.2017.01.19.11.44.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 11:44:01 -0800 (PST) From: Bryan O'Donoghue To: gregkh@linuxfoundation.org, robh+dt@kernel.org, mark.rutland@arm.com, balbi@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org Cc: Bryan O'Donoghue Subject: [PATCH] usb: dwc3: add quirk to handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS Date: Thu, 19 Jan 2017 19:58:02 +0000 Message-Id: <1484855882-4936-1-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org - DWC_USB3_NUM indicates the number of Device mode single directional endpoints, including OUT and IN endpoint 0. - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN endpoints active at any time, including control endpoint 0. It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to DWC_USB3_NUM_IN_EPS. dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT endpoints as zero. For example a from dwc3_core_num_eps() shows: [ 1.565000] /usb0@f01d0000: found 8 IN and 0 OUT endpoints This patch fixes this case by adding a snps,num_in_eps quirk and an over-ride value for DWC_USB3_NUM_IN_EPS snps,num_in_eps_override. When the quirk is declared then snps,num_in_eps_override will be used instead of DWC_USB3_NUM_IN_EPS as the value of the number active IN endpoints. The minimum value specified for DWC_USB3_NUM_IN_EPS in the Designware data-book is two, if snps,num_in_eps_quirk is declared but snps,num_in_eps_override is omitted, then the minimum value will be used as the default. Signed-off-by: Bryan O'Donoghue --- Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ drivers/usb/dwc3/core.c | 11 +++++++++++ drivers/usb/dwc3/core.h | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index e3e6983..bb383bf 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -55,6 +55,9 @@ Optional properties: fladj_30mhz_sdbnd signal is invalid or incorrect. - tx-fifo-resize: determines if the FIFO *has* to be reallocated. + - snps,num_in_eps_quirk: when set core will over-ride the num_in_eps value. + - snps,num_in_eps_override: the value that will be used for num_in_eps when + num_in_eps_quirk is true This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 369bab1..d5e472a 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -398,6 +398,8 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) struct dwc3_hwparams *parms = &dwc->hwparams; dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); + if (dwc->num_in_eps_quirk) + dwc->num_in_eps = dwc->num_in_eps_override; dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; } @@ -908,6 +910,7 @@ static void dwc3_get_properties(struct dwc3 *dwc) struct device *dev = dwc->dev; u8 lpm_nyet_threshold; u8 tx_de_emphasis; + u8 num_in_eps_override; u8 hird_threshold; /* default to highest possible threshold */ @@ -922,6 +925,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) */ hird_threshold = 12; + /* default value of 2 is the minimum RTL parameter value */ + num_in_eps_override = 2; + dwc->maximum_speed = usb_get_maximum_speed(dev); dwc->dr_mode = usb_get_dr_mode(dev); dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node); @@ -981,9 +987,14 @@ static void dwc3_get_properties(struct dwc3 *dwc) &dwc->hsphy_interface); device_property_read_u32(dev, "snps,quirk-frame-length-adjustment", &dwc->fladj); + dwc->num_in_eps_quirk = device_property_read_bool(dev, + "snps,num_in_eps_quirk"); + device_property_read_u8(dev, "snps,num_in_eps_override", + &num_in_eps_override); dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; + dwc->num_in_eps_override = num_in_eps_override; dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend << 4); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 14b7602..3fe6dfc 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -853,6 +853,9 @@ struct dwc3_scratchpad_array { * 3 - Reserved * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. + * @num_in_eps_quirk: set if silicon reports number of device-mode IN endpoints + * as equal to equal to the total number of endpoints. + * @num_in_eps_override: The value to set the number of IN endpoints to. */ struct dwc3 { struct usb_ctrlrequest *ctrl_req; @@ -1003,6 +1006,9 @@ struct dwc3 { unsigned tx_de_emphasis:2; u16 imod_interval; + + unsigned num_in_eps_quirk:1; + unsigned num_in_eps_override:6; }; /* -------------------------------------------------------------------------- */