From patchwork Tue Oct 31 13:11:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 117625 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3898150qgn; Tue, 31 Oct 2017 06:12:09 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RLOrPU7kh4bmu3NaNBTuTsIrdbJiaWYtbP29uFEzLCVxWURH2ns5E79CqisnKbV4y/DbRA X-Received: by 10.98.206.68 with SMTP id y65mr2033232pfg.138.1509455528877; Tue, 31 Oct 2017 06:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509455528; cv=none; d=google.com; s=arc-20160816; b=V3N5skfAHT/NDmuEaSTZTM7HSL2WfnpJTIiIwNHQkqS3z52FZMqwMzXINpObnR7Led F+ovpI2ayOFAu3g+/Ef+7y1AcIomRrH8rsC8X7XQxRcxMbUekaXUANKPldv0O+0gGaJP J43y6vVp0kyST7sL7yGp7ApP9axGR+Bq/CZA67qKzoHGEzjsHokFDwDzRhAISLfgTNTn DpjKb8255XMZeWQBt+GjAIcOBFzuwIWV9WyfLu3SuRI8VNjywrVd+F0eahXe3DSMkTH3 nhBqGNf5DtlzqeA3wVnMbnGiV3Dlvt3CZcUPJSho5DiExx33kfOQdfLp0Ji6heofLLRK RTvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=ULMFuyJjfDTj38+Hx3AfNjvAndeVesYwZgDM5i/qqD0=; b=URUh0O4B/Feghk0OSk7pVoQ+X43Mv5bSjve9usicMGYlIiDyfa5YqnTfML8fJVqN7W n3igkewKFxdgx3OayZ2eosThB372o0IsQ6RQiiCeHoa4tcqFuyc9t0aakbOfJWSfGHch YVdh7qRnMrJpr5HyWgeg7xLKNxxrc84nLTziNfi2UNu7cO2jQBVRZrxYuzopOYa0bl5z mtBshuSfDpWuAgzqjiWNnB9YlgQz0WsuK50dz3W3UXFPfHPJBaZoq3xdcMNTIwywlVyK 6GRFHWv7SWdR2ZIsP8uRQjpyiW4AoweDBAWrSkB2UhO4P0aRjeNBKvY0UVTdA46cOpr3 s7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vurZhTOh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32si1611611plf.183.2017.10.31.06.12.08; Tue, 31 Oct 2017 06:12:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vurZhTOh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753417AbdJaNMG (ORCPT + 27 others); Tue, 31 Oct 2017 09:12:06 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:47986 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbdJaNME (ORCPT ); Tue, 31 Oct 2017 09:12:04 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9VDC0FC012067; Tue, 31 Oct 2017 08:12:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1509455520; bh=xNPnOc5u3NetgzvDtDp8nIIjjmpV9HqgtgL2pZDX2bA=; h=From:To:CC:Subject:Date; b=vurZhTOhIUoobwAG0VePZ24xt5ohRkYDU5xu5LV8fIjQLO8azzDDBveflR4yCoGkj OLHe1+MmEefsmsqrJe/A59IK9gGkoJHgyYaoMw5Lu0hZMjOY0ICPTmj2cOwQS9LA3Q r/QavWFUgsehkv+oPkw450PUQgj2GB5kepgc2ekM= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VDC0F3016361; Tue, 31 Oct 2017 08:12:00 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 31 Oct 2017 08:12:00 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 31 Oct 2017 08:12:00 -0500 Received: from dlelxv97.itg.ti.com (dlelxv97.itg.ti.com [172.17.2.193]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VDC0df010175; Tue, 31 Oct 2017 08:12:00 -0500 Received: from lta0400828d.ti.com (vboxa0400828d.emea.dhcp.ti.com [172.22.234.209]) by dlelxv97.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9VDBw3N015512; Tue, 31 Oct 2017 08:11:58 -0500 From: Roger Quadros To: CC: , , , , Roger Quadros Subject: [PATCH] usb: dwc3: Allow disabling of metastability workaround Date: Tue, 31 Oct 2017 15:11:55 +0200 Message-ID: <1509455515-5992-1-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some platforms (e.g. TI's DRA7 USB2 instance) have more trouble with the metastability workaround as it supports only a High-Speed PHY and the PHY can enter into an Erratic state [1] when the controller is set in SuperSpeed mode as part of the metastability workaround. This causes upto 2 seconds delay in enumeration on DRA7's USB2 instance in gadget mode. If these platforms can be better off without the workaround, provide a device tree property to suggest that so the workaround is avoided. [1] Device mode enumeration trace showing PHY Erratic Error. irq/90-dwc3-969 [000] d... 52.323145: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.560646: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.798144: dwc3_event: event (00000901): Erratic Error [U0] Signed-off-by: Roger Quadros --- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 3 +++ drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/gadget.c | 6 ++++-- 4 files changed, 12 insertions(+), 2 deletions(-) -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index 52fb410..44e8bab 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -47,6 +47,8 @@ Optional properties: from P0 to P1/P2/P3 without delay. - snps,dis-tx-ipgap-linecheck-quirk: when set, disable u2mac linestate check during HS transmit. + - snps,dis_metastability_quirk: when set, disable metastability workaround. + CAUTION: use only if you are absolutely sure of it. - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 03474d3..18984b9c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1072,6 +1072,9 @@ static void dwc3_get_properties(struct dwc3 *dwc) device_property_read_u32(dev, "snps,quirk-frame-length-adjustment", &dwc->fladj); + dwc->dis_metastability_quirk = device_property_read_bool(dev, + "snps,dis_metastability_quirk"); + dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index ea910ac..c521a02 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -863,6 +863,7 @@ struct dwc3_scratchpad_array { * 1 - -3.5dB de-emphasis * 2 - No de-emphasis * 3 - Reserved + * @dis_metastability_quirk: set to disable metastability quirk. * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */ @@ -1016,6 +1017,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + unsigned dis_metastability_quirk:1; + u16 imod_interval; }; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 9f27ec0..472499b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2027,7 +2027,8 @@ static void dwc3_gadget_set_speed(struct usb_gadget *g, * STAR#9000525659: Clock Domain Crossing on DCTL in * USB 2.0 Mode */ - if (dwc->revision < DWC3_REVISION_220A) { + if (dwc->revision < DWC3_REVISION_220A && + !dwc->dis_metastability_quirk) { reg |= DWC3_DCFG_SUPERSPEED; } else { switch (speed) { @@ -3256,7 +3257,8 @@ int dwc3_gadget_init(struct dwc3 *dwc) * is less than super speed because we don't have means, yet, to tell * composite.c that we are USB 2.0 + LPM ECN. */ - if (dwc->revision < DWC3_REVISION_220A) + if (dwc->revision < DWC3_REVISION_220A && + !dwc->dis_metastability_quirk) dev_info(dwc->dev, "changing max_speed on rev %08x\n", dwc->revision);