From patchwork Tue May 26 03:33:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 1235 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 75D463F08B for ; Tue, 26 May 2020 05:34:37 +0200 (CEST) Received: by mail-oi1-f197.google.com with SMTP id j19sf10468937oie.18 for ; Mon, 25 May 2020 20:34:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1590464076; cv=pass; d=google.com; s=arc-20160816; b=BCbaCYY0D+Kv7ZvcD+xFYkljDTH0IlFOVsWsUp/k4k5zjV/Ucbiz1AbLMbW5jK6iKA DNWfGUDY1nCL45+yJXfc/iBpky/jXdePr9yylPUV35GAfmSl61d1x8njKfIn73IEiuLK u5+lqxHyzS39rf9eJJbxpENVzxU2nAsGi2Nv1qtAUkGmxM4vDTu0VkUdhLX/VFYVfiHp NldbWkp2yOX5RGqL8za96bb36Xec3rstD5jIYQnaOgs/qulc5r9c7bwAeFDvFE9BqjVC 5Y7ap9fhnHFQjSBx1/rc3TyV7yxzgIL1ODUDHZZcg05y9HZ8+ZlZfmuEg6EWoWrBc6fd 8Y6w== 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=kClJgjr8bjDp5sHMvaITzAHaOpC+ipkC4vPrvkEm6Tk=; b=fosg5Kfe23PGCfTut6FRl7T3PBXRT1o+9hZSCZimeORs1gfynlfbWRMsMY004PbvSJ 0ZxcZBUt+ew2xggMtu2Gk/hYidW1D5bTEhkDk7CO/EuOVRnL6/2WgjbFjNrVHMia8x2V TzWwvN65UvLb6Cn6gIIk3KWWjlJqC/HxGbzsnE1onIFOrpz1rPW/+ZRQgTOrOOkpHIhA CyVqhfgG6Jcq6d7WUraplqXr1hiG3YLyOSz1zcmdVQizkmv/ehVgpZI6dvf22P/AfWu6 vZ2GKDD+Uo/7UbYYqzyIJdj3YCPfabmvPhnoLeMcdCo1Z4fd/3LTN2AoNfP3UMS4U+OG tnlg== ARC-Authentication-Results: i=2; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.133 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=kClJgjr8bjDp5sHMvaITzAHaOpC+ipkC4vPrvkEm6Tk=; b=bHZmf12pR487m7R64iYXMMperN2qAQj7Ura/sKZDne+6dRulTdpM7cQmFy9Ipn8wpn lbVjF70IFyDZVMp+kiWlvLDdbBWARgyJ6bzEe98DY5C6+5sxg4Vy4tORSIX0dQZ0uwMV 41UZyw0hpx5EXO6ncY/Wq62/jL8/Pv95lRe04= 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=kClJgjr8bjDp5sHMvaITzAHaOpC+ipkC4vPrvkEm6Tk=; b=dqMp731IbJZL0KndEsc1H8ESTnoOl1GFplPPTRuU77DtPzAuJUAzc7M6RmZ2aSbqwR /iNwzuFY2c6KMHOwxOJUtRiYaPbknAycSlMWLZj7LkXo/3d39Wdif1OyAT/64MQzcNwU t1312H7o2hv2DPF6Dmp9Vy7B4RWNJmPg0KxUnQPWC4HIvzMUTeiUV4gVHJMY4LZyqXAP uqdMaKRPN6JJ0QRyvySZgjB0DY63wyAFfaS9uvy+u8aWSCnMG4UXf0nBO+QXw7fY7qCQ ew7RV5eppeX8msGIJwudIu6zn9LK7bbduZqmXMftCnNquipNY1PCndhY7mqDJpEAEjsF zUQA== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AOAM533DoGfjk1nHToMTDwVLP50Q/O6n0WcgoJtxiyD9z8MvUsGORLrH FsQaIq4E6o2ZbwHFv5b4jz9kymh2 X-Google-Smtp-Source: ABdhPJx/3vuHYngmcMehhntqIjOBvgXBwe9l2NkEbrJ/V/xyiiNBjr+ubj3oHj/DhebafsVYdTO1qQ== X-Received: by 2002:a4a:3556:: with SMTP id w22mr15228246oog.20.1590464075806; Mon, 25 May 2020 20:34:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aca:c7d2:: with SMTP id x201ls1812462oif.8.gmail; Mon, 25 May 2020 20:34:35 -0700 (PDT) X-Received: by 2002:aca:914:: with SMTP id 20mr12418645oij.50.1590464075423; Mon, 25 May 2020 20:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590464075; cv=none; d=google.com; s=arc-20160816; b=PVTTtRYy1zmvfvU9bvc/XFjSoPA0HaPKKN6OiUccXQRtDtfNGVSTg2jGqKA6v7esgt bSOIVKx3eLpmOAzCCA/ReF7J9O+VhL3DV2G3PNQudBVzTbErHXHKR9JABnhQ9FgI8D0L SST3f9GhFbktRNwAIHwEEMwoWH6ECkleR2lK4YOMndujzH960BFqlJZ/kQz4Jezi70QB U+PQbCxQQ12gxnp3dXWjwEQ0qd2c1vKX/wbZ8w6eENtwRqmqE4Dyn13txlIAm7zo72IT JH8c1I/xv/gl7VEX9aZ5Xh74sjztdDVcEYLy3fGoFzSEckqohnig29yaflbSlCl0Ma4V I6DQ== 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=snZMI4/K4p7HjIIwqrL2hzmEz4B1zzx2T00UTmMIKRs=; b=YhdadIad6GMy5E+MCmM28LnZvp+SxK5d2ZVKaO8Oo+rTwhR9yFtvjf2nrB+DObbSrt B8Mo+MKDT4bRq/qEnkWVYByv8s3trBZp8UlmmdXUV5nO95L9dOdJas04YhL2zdgUR4cJ 4lBF5qeDfTuS0UQoLux2mPxox9tIxInkHVHtrI2WE6ippoKGm5PDUWv9EWVgh3T4BMzS n1LZUe26ZKG1OV+EiD5Id4in7nDXJCl5OasPB75SAcGgxXw2GrgYsvUHKRc/ouXFxyA4 dvTLFpPy2+3j5NMoTFkUuVefYbNF1xMJsITjzCQWV3+VQUmCuAi/ppZ7sL+/9dIA60Na XLkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.133 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Received: from lucky1.263xmail.com (lucky1.263xmail.com. [211.157.147.133]) by mx.google.com with ESMTPS id c16si4091280oib.73.2020.05.25.20.34.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 May 2020 20:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.133 as permitted sender) client-ip=211.157.147.133; Received: from localhost (unknown [192.168.167.8]) by lucky1.263xmail.com (Postfix) with ESMTP id 102BEB71C1; Tue, 26 May 2020 11:34:03 +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 P21206T140696195421952S1590464037437993_; Tue, 26 May 2020 11:34:02 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <3dd4d80d440b51edeb3d49142fbb629b> 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 v6 09/16] usb: dwc3: Add disable u2mac linestate check quirk Date: Tue, 26 May 2020 11:33:48 +0800 Message-Id: <20200526033355.20147-5-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526033355.20147-1-frank.wang@rock-chips.com> References: <20200526033220.20047-1-frank.wang@rock-chips.com> <20200526033355.20147-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.133 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 Reviewed-by: Kever Yang --- 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;