From patchwork Wed May 13 07:15:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 1190 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 49EEF3F066 for ; Wed, 13 May 2020 09:15:58 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id v6sf12989927pgh.16 for ; Wed, 13 May 2020 00:15:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589354157; cv=pass; d=google.com; s=arc-20160816; b=CLG+Q+cDpNN+Uu92DL7o/pcQCTeSktLG2DQSBLjm8udF0D12I57oF5hPUsaMkjzgcl Zlu2ws0x4BRSanU9CnUbF5+s3lmjxNtduc4o4IkTu9e9OJpUhlzZOQEcHhm+synGk13v MV6Ql7ySgT4C2GraXb5zDxL1Bw3W9ieiomnpkf/RKgvTjLMRCzJ7pbFAk/DJHf/bMeaP s++5F5UrNC/qj1doPhpTAo1iIgbfD2yhWON8MMjDf4Nov0ZFvTB1Es/y8EzmG8r1D+ng aIo5GxtW26vhvNHfxuphndubi7cfs6pc43WO/CU3XqzzdQgUbdttfT4VAXeL8v6eYCfd NW+A== 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=ppsGOzyGrhBqLRqYau21zGzmI0o/FLmzJ0Ib9Iip/VQcYsX2CZG0V5tnC4o2FvA1l1 NQ4QpBbQfV0COquKkVmzuDMcVt5RCFLRWqqZL7CB4ULRm9pxuBFn94IJYNAHml9diD0N ame2bDkak3ImvQBHjX8jdR/mVFnDfjrUqohmTR1i4gO57IzAV0VfjV9bMg/nin2NOymx LWJaJWxBO2NNzOwDOf0ajYqo2JveiAvuETwLU3YGR/TUEnxh+uqCNR+KaGU1cLmAhfJg DbjP3Vay0W7gjYkEj9bccOiclG/LmUo13nvFXyb9gLVW7ug72WgNT6WzjJZaFW9e1Cea jnzg== ARC-Authentication-Results: i=2; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.135 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=U2EFEr7HKlqgGuCTOuNdNliO7XUcEhVORBNrdcK/eCkN98RQejNiknkLYyiORrgHbr jfbP2iCamYQTzCR1NqYS3tqDtv0kdauZUKCiCnEKiNqsV1xu2fNzQ2pFMJHqSpVyd+H4 wrWQIPX05FudPQmFkOtfCkg/yQw8X+UqBDC4s= 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=hjNI6yzC6quUg68SFGLtjuz3b9LPXKVaFm9aLU8p3m8oFHPpoRNoahLyCg+4/9w/NN DSlJcjz3PccPJAyJ9ezwCRdqJamd8SPlgobPF/7+vyUy+pvg3/Sbkf5AaJdHI5OttdpQ V9D1OYx9PmUirinc5TvLnMl7B5I40O6uuKU6xvux5vsdN5uwCV1G76oBjwKXMWUmun5g 243hxlGjWXdlqrDS/HCrOcvtecpXwWDTb1leyojInA0tkK+c0nUDyNYgU1SCfZR0JTL6 sWk/RDbdXIn6YlpUJ7LMXY8A9/27gIw2aCd+FIfpEpj1B4fxYWE/NeL6LPd9G8Wurbe/ tYmA== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AGi0PuZxBcarRm5AwcEghL4VLNaBYHn4P/thtUBHvY1Pclm6NF0VOnk6 mldwTf+C/7CeVuf6pSTbPh+z26JV X-Google-Smtp-Source: APiQypJqhGL/4TxwY1ZLmKFFDMbGgriSbONNvLd7YzYttVAns6GNXfh7YvdiUHR+EpbswDjSBQyaAw== X-Received: by 2002:a17:90a:558a:: with SMTP id c10mr32384459pji.53.1589354157106; Wed, 13 May 2020 00:15:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:a717:: with SMTP id w23ls499082plq.7.gmail; Wed, 13 May 2020 00:15:56 -0700 (PDT) X-Received: by 2002:a17:90a:8d02:: with SMTP id c2mr30343970pjo.113.1589354156406; Wed, 13 May 2020 00:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589354156; cv=none; d=google.com; s=arc-20160816; b=Kdd+CcXhE2Fh/QyfunwEubiZeYMk9PKxNguq/9Mkj6OgYRtKGS9STd3Hmb5dcsq83s MPpk6Uiw0AUYIuOC9wDPxeFEUjXLMh3NlmgVhMfFL5PG0+qrrZKYwH10QbG8k7VW2Gcy +07PlaU9WQSSVepHUs+5dctdEc0c8ONhQS9Se5ylhoqbQ1/vaFZPztmoSXz7/eWCwJoO vuP1e7YBZXt+f5Bossmatx2HywPtyDtcHzTr/lafLNWsbKs7pXRb2CRQ0Wx2R5JpibV4 erFyCceyh3RGGHCKip/ByqzYfEOzPN4GbB4dnw1g+3vFyK0at96YM4B2UwjD8q2KYqMN f2bg== 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=qNPySMyyrzbohDX9MNBhZjvfPsuQ95+Udp27H75UPC3kzVuX6r4aedfHwIk/J/h1gP 1uoap5P0PAKF01g/aDl/cqcT+jDaPiVzz8jRC5m/SokZx7yxgXgGi1xpjQ95RP3l64mz 2cO0DlKm5jsQDyJCR2oivpOShAw32Jt0WTRr8XO8Iir8Xv0kB0zWDfyPycocfYojXjbs gm8cCYxSb71BdnK9lVc66T7wyyfsU96z+9/YmP5jOylb+P/JzROL0bN9eyBalFfddYM3 +p4lC7H8ZctECHwlgsMLZ6ujDptPcNErMU1Y1oguAb8aNIKGtUFUd7wbj7O4fY4kAe5f mtWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.135 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Received: from lucky1.263xmail.com (lucky1.263xmail.com. [211.157.147.135]) by mx.google.com with ESMTPS id n6si12319151pgn.270.2020.05.13.00.15.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 May 2020 00:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.135 as permitted sender) client-ip=211.157.147.135; Received: from localhost (unknown [192.168.167.16]) by lucky1.263xmail.com (Postfix) with ESMTP id 6FFD982AC8; Wed, 13 May 2020 15:15:54 +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 P15407T140446440306432S1589354149129638_; Wed, 13 May 2020 15:15:55 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <3ddc54ec96f37bbc93d37ee0e17b2699> 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 v5 09/16] usb: dwc3: Add disable u2mac linestate check quirk Date: Wed, 13 May 2020 15:15:39 +0800 Message-Id: <20200513071546.5560-5-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200513071546.5560-1-frank.wang@rock-chips.com> References: <20200513071344.5430-1-frank.wang@rock-chips.com> <20200513071546.5560-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.135 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;