From patchwork Mon May 11 07:55:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 1173 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 66E423F08B for ; Mon, 11 May 2020 09:55:31 +0200 (CEST) Received: by mail-pf1-f200.google.com with SMTP id q142sf8137424pfc.21 for ; Mon, 11 May 2020 00:55:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589183730; cv=pass; d=google.com; s=arc-20160816; b=GmgjMf9DUjeY4fD5tHR7H5k5l19rntDq+dhxLd1hfnGvSK3t2F8SCnEAB05C5Lf27p lNj0A8skFa5RP8ebaHSWqpN65uMzxGHDo4Mz60UwWua8gcVh9wzDq7O5qZU/mN6Li4kc HLEG4Ap64aImTwKZYqw6iV94nPl4zoRZLyuZKlumC2KfWBZYpmARe6iKN68k4N9/5Gkj Lv7OBcBocismyoYEUdUsoghwnx52NR/GqBj6Zofg3ZIzrnzUVUgAuoRSmQrw5iBWfps3 Qx9UITrDHDKKJQqenI9Z5OXnO7Jf8aRlChcXW6JGPVHaaZkltYpZPX8Kt5crrQUCaQ7o PPcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:sender:dkim-signature; bh=e/1LCDRj8p/rOW7qojIR/KOanDuW6UsfVfzxS/X11/8=; b=wqB5qnp6Qf/pi71/ggJstNn0F8fiqMgbyjCu6nB6B96Qfso85W7hQRJyG3T+WnPe7I LgWQWf9EH3SXDEK7mcVrcN5aRjw+EjWWc+RHDi6EUXZI37WPjTQag7RB8mPHnJW2q2uj 6ZZkBEkSj84OVKpprJeUe85diLWzhSU84VQAoNvffEBAZnC1jD2rdrncrNAGS/WOSq7c dhgw4ayP9Xsr+TXX+ySTfOqKrHDj5NlaePVwnZjYZcKxztdlfhCeU0B9k70XW2rOuphY qG6BoDM4YKVVQ9d1cq1RBoxd0VT1JmyK8UVuylAS6flfTlk1D4kGIvUhPUAFMt/eXmYU QxIg== ARC-Authentication-Results: i=2; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.130 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=e/1LCDRj8p/rOW7qojIR/KOanDuW6UsfVfzxS/X11/8=; b=FHYbI5JUzuYwJAxyu29f4KcZQ5rDMKJcTKoFzftfmMGSvGgoVio0JTCBFReoN+7Hzh vm1tUUyAisF0AxKFv5XfX+dlB+2ehgMuHUCWfuAfYRTeUaOoIrO956LmZ8h0v7mWxvAH QqLfcGm1EPvYf3Vz3whVCGqxjquBaqAXm4zN4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=e/1LCDRj8p/rOW7qojIR/KOanDuW6UsfVfzxS/X11/8=; b=Xhvielk3FBZB0cOJVhMBYE2B1m5oRnghCYbp/lA4a0lY2nagp2D0a2bIY2M/Qg7KTx 2fILFfb4zSt38HdRon8Ebm7PbYqdpqdYJK/r+6f9NrWcuc8dU9wLpP3wN6sgY3NgdgLV b7R7qF1yg0qC3breLwNJ8t0AgyEm2HfZYPEWo4e07V5PTh6diaNnDqB/G6LyyLtdQ8mO WPmWWjHLBFHRUeuSutD+viqVCAIG+wOjtjqlP+ZNJmz+Y9veFNKcUbGIw+TXwo85OaE0 TJmKRJcPyibybc9XD4WSkD09yx0gUkSZmNM+0RURTq2jhusSsQ9ao49GuY5/LAnjSBki ebtw== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AGi0PubJa/+V8hViAx0y/wKLqFw0NrbSMBAwtOD95es24Zib8zzSwKqH woAfioVg4Nh9qXk+Bl7TeRhvriPd X-Google-Smtp-Source: APiQypImFpjAPrYRRnzUgC/id2NCCu5RTtdDlaTBniQ+UlFfHJm5sKzEMFMNLAhbo/g5kZt8ivk4WQ== X-Received: by 2002:a17:90a:db83:: with SMTP id h3mr21647446pjv.87.1589183730215; Mon, 11 May 2020 00:55:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:ca12:: with SMTP id x18ls16168383pjt.2.canary-gmail; Mon, 11 May 2020 00:55:29 -0700 (PDT) X-Received: by 2002:a17:90a:3b0c:: with SMTP id d12mr19981404pjc.78.1589183729596; Mon, 11 May 2020 00:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589183729; cv=none; d=google.com; s=arc-20160816; b=Hl1vugrsE4Wq4Oxv3K8YCKXz9IijW32eAQUh9xbcoOH68mUZaLUPYPjjnPgVOnbeQv GfCnxrBRhuJGHGfUXsLFeG9y8nqNm1J/JspBvUsQ6lFcvsSeEHpUe8dcLpLAcetNPPjP avtBNdpDCUlfshK8O1IrEgA45kSKS/RQS0WUcTYf4VTp/KUS+KG8pGaDodMkS98d9pDo bSZBHSReaHiytPHiLceKUpoYxkSFoHogAj0CmlnkZ53WeetdZAHtkVhNfm3SlfBBb4rT ewrR5xP7OYgWzY6pnUUI7RHluW5jj+XMt9vseMERLkJn9zXBlIpVluR2ItX/77HXD3AN xifA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=UBuGY4J2YSmoEWCwFCKAx6HD7Tfx9/3EKMY0sXZuxBI=; b=BmZU4oGfOcxAbC7KHbhZYIgCnOvPl6slOnkEyIw7BU2yEqmquQkrgl5V4bTwMoGmey JMc0uLtxBKTwPas4gR1pLsuWIvb2EKX7PPHKhrUS/mc0R/KvlIu8wYIT97b2aN7wGDIL Wx5C2ihxbzfkoM0FSdkqTeIFB4eKvB2ulCOdBBA9GGGrlut4dfTwlLdmSEk5BQhW2J5o J2sCEipLqnHRAdFvchuwGoHRmqOyKpPuP6Ws/BwTYM+VcmNrWocyUqwd/GVw9dJ0jGhp 46exfmOTsu48QwcnPuM3U16ATQaG+m8mr6q5mZHeDDMaXimZRveioLvy2e33p/xMqNcI LkIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.130 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Received: from lucky1.263xmail.com (lucky1.263xmail.com. [211.157.147.130]) by mx.google.com with ESMTPS id c9si6935605pgk.423.2020.05.11.00.55.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2020 00:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.130 as permitted sender) client-ip=211.157.147.130; Received: from localhost (unknown [192.168.167.8]) by lucky1.263xmail.com (Postfix) with ESMTP id 22FC4B4E8D; Mon, 11 May 2020 15:55:28 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P2949T140479804974848S1589183722650576_; Mon, 11 May 2020 15:55:28 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: frank.wang@rock-chips.com X-SENDER: wmc@rock-chips.com X-LOGIN-NAME: frank.wang@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Frank Wang To: heiko@sntech.de, marex@denx.de, bmeng.cn@gmail.com, philipp.tomsich@theobroma-systems.com, klaus.goger@theobroma-systems.com, jagan@amarulasolutions.com, sjg@chromium.org, kever.yang@rock-chips.com Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, marek.belisko@gmail.com, william.wu@rock-chips.com, jianing.ren@rock-chips.com, chenjh@rock-chips.com, wmc@rock-chips.com Subject: [PATCH v4 09/16] usb: dwc3: Add disable u2mac linestate check quirk Date: Mon, 11 May 2020 15:55:13 +0800 Message-Id: <20200511075520.26557-5-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511075520.26557-1-frank.wang@rock-chips.com> References: <20200511075330.26462-1-frank.wang@rock-chips.com> <20200511075520.26557-1-frank.wang@rock-chips.com> X-Original-Sender: frank.wang@rock-chips.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.130 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Jagan Teki This patch adds a quirk to disable USB 2.0 MAC linestate check during HS transmit. Refer the dwc3 databook, we can use it for some special platforms if the linestate not reflect the expected line state(J) during transmission. When use this quirk, the controller implements a fixed 40-bit TxEndDelay after the packet is given on UTMI and ignores the linestate during the transmit of a token (during token-to-token and token-to-data IPGAP). On some rockchip platforms (e.g. rk3399), it requires to disable the u2mac linestate check to decrease the SSPLIT token to SETUP token inter-packet delay from 566ns to 466ns, and fix the issue that FS/LS devices not recognized if inserted through USB 3.0 HUB. Reference from below Linux commit, commit <65db7a0c9816> ("usb: dwc3: add disable u2mac linestate check quirk") Cc: Marek Vasut Signed-off-by: Jagan Teki --- drivers/usb/dwc3/core.c | 20 ++++++++++++++++++++ drivers/usb/dwc3/core.h | 7 +++++++ include/dwc3-uboot.h | 1 + 3 files changed, 28 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3cb66515a2..dc92f471c1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -725,6 +725,7 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk; dwc->dis_del_phy_power_chg_quirk = dwc3_dev->dis_del_phy_power_chg_quirk; + dwc->dis_tx_ipgap_linecheck_quirk = dwc3_dev->dis_tx_ipgap_linecheck_quirk; dwc->dis_enblslpm_quirk = dwc3_dev->dis_enblslpm_quirk; dwc->dis_u2_freeclk_exists_quirk = dwc3_dev->dis_u2_freeclk_exists_quirk; @@ -934,6 +935,8 @@ void dwc3_of_parse(struct dwc3 *dwc) "snps,dis_u2_susphy_quirk"); dwc->dis_del_phy_power_chg_quirk = dev_read_bool(dev, "snps,dis-del-phy-power-chg-quirk"); + dwc->dis_tx_ipgap_linecheck_quirk = dev_read_bool(dev, + "snps,dis-tx-ipgap-linecheck-quirk"); dwc->dis_enblslpm_quirk = dev_read_bool(dev, "snps,dis_enblslpm_quirk"); dwc->dis_u2_freeclk_exists_quirk = dev_read_bool(dev, @@ -954,6 +957,7 @@ void dwc3_of_parse(struct dwc3 *dwc) int dwc3_init(struct dwc3 *dwc) { int ret; + u32 reg; dwc3_cache_hwparams(dwc); @@ -975,6 +979,22 @@ int dwc3_init(struct dwc3 *dwc) goto event_fail; } + if (dwc->revision >= DWC3_REVISION_250A) { + reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); + + /* + * Enable hardware control of sending remote wakeup + * in HS when the device is in the L1 state. + */ + if (dwc->revision >= DWC3_REVISION_290A) + reg |= DWC3_GUCTL1_DEV_L1_EXIT_BY_HW; + + if (dwc->dis_tx_ipgap_linecheck_quirk) + reg |= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS; + + dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); + } + ret = dwc3_core_init_mode(dwc); if (ret) goto mode_fail; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index c5e656885a..b510d8a983 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -73,6 +73,7 @@ #define DWC3_GCTL 0xc110 #define DWC3_GEVTEN 0xc114 #define DWC3_GSTS 0xc118 +#define DWC3_GUCTL1 0xc11c #define DWC3_GSNPSID 0xc120 #define DWC3_GGPIO 0xc124 #define DWC3_GUID 0xc128 @@ -159,6 +160,10 @@ #define DWC3_GCTL_GBLHIBERNATIONEN (1 << 1) #define DWC3_GCTL_DSBLCLKGTNG (1 << 0) +/* Global User Control 1 Register */ +#define DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS BIT(28) +#define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24) + /* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31) #define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS (1 << 30) @@ -771,6 +776,7 @@ struct dwc3 { #define DWC3_REVISION_260A 0x5533260a #define DWC3_REVISION_270A 0x5533270a #define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_290A 0x5533290a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; @@ -824,6 +830,7 @@ struct dwc3 { unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; unsigned dis_del_phy_power_chg_quirk:1; + unsigned dis_tx_ipgap_linecheck_quirk:1; unsigned dis_enblslpm_quirk:1; unsigned dis_u2_freeclk_exists_quirk:1; diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h index 193d225d31..e08530ec4e 100644 --- a/include/dwc3-uboot.h +++ b/include/dwc3-uboot.h @@ -34,6 +34,7 @@ struct dwc3_device { unsigned dis_u3_susphy_quirk; unsigned dis_u2_susphy_quirk; unsigned dis_del_phy_power_chg_quirk; + unsigned dis_tx_ipgap_linecheck_quirk; unsigned dis_enblslpm_quirk; unsigned dis_u2_freeclk_exists_quirk; unsigned tx_de_emphasis_quirk;