From patchwork Fri May 8 18:39:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1156 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 951E63F22D for ; Fri, 8 May 2020 20:39:35 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id 85sf1963159pgh.13 for ; Fri, 08 May 2020 11:39:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588963173; cv=pass; d=google.com; s=arc-20160816; b=yVBh/y+GZ9LpT23nYgJEjHFlzfkC4oEcuwEOOJlLeOKoubCBIumhsvynOToQtV8Imw sxV2l5rR7GfrOEaY3qZpfYpbqdKyNBUzkHCPXoYDtrk0RyiZm8zRUAwLztYy1rJIEVQK 4q4OJBlWaM49ReD0MthxeSWeA/8KZ+ufnsBjwqKsIoCslyvg5pRNMQBefq0Q/NV00FL5 to70o9yVTGKlw63d9jwX+ZDxibef8yZ0RilzoFzr0uizf9lLIO96nCtvEq+XyLV247l0 qWGvGxjY3gDi/Dg2RgHuzuv4kZk2P2dFqI0eCciyKWwdgoKV11FldVw/DTd6+Mp6qUSP 5XJg== 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:message-id:date:subject:cc:to:from :mime-version:dkim-signature; bh=ac35qldoCXvjJAaVjliidNjPK9AjyHRbjpX26EUmzk8=; b=xwLblpdJ0Nbd0id4431R9TezHP9DwdllrSErs0VaT0rWAT31izG19+tFsfYeN6LWkY DUvNaDhVqBG4k1UeUGBgIqyW/iFmBKD6upqZfNh6i9o6Qw7eGNoFi5GGxmCYgAKpsIRq GuLpOE0WHVccKDO9sXkBDP9YI2SxPqd6yDKpSDzIKPmTq2vcipptFlmlSrtP5pbsElAJ Q2eDusu6OpoME9LXK0f/LaKieop18vNMAvLOkj7ayDV9lU9jehe/KflxUM9rNr56BXpu YL2+bhqtyCM2ikFXtbE22uNib6J05XyqsdrCezFDDZOBQu5lmlFctH1eoxKjbLW7aZgP oFkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mKG2h2LT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ac35qldoCXvjJAaVjliidNjPK9AjyHRbjpX26EUmzk8=; b=SpidIxdgXQ3w9+DuweAguj22I7ywfFsKCDI2sbIIXwlyNk3aGZYHMrH0Ry3+W+2/1M QJ8JXzY8M+gw3ON/zpRJHK7yuAv4/XbV3zL20RwkTndysEEV+0183Hj+aOYZJXvqD9yC QTqsAhoalSN2Sf3PcIxLi86BRdKPDm6nI9Wdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :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=ac35qldoCXvjJAaVjliidNjPK9AjyHRbjpX26EUmzk8=; b=f5jDXRP9Bc+62VESIehBrb2n+vAkrlbbuuaa5LHIJPkRzqHFSnapaczzLLGGQUYRNu B7BvjSUDBioEnf8vmfeGYa/CNW1kyhyLUos+jKPq5p9et137zZuzY90K/3GLaOiOTbsT pbyyhPf1VYmug/DO3CyiX6y+5EEpfodInueHtwFsDFqnWzefDFpII3sisGEIjY7pRBmN Bhjy2OqignOh1H72qOzPBpWsLSDKWt1v6EW/7z5gu66/YDkd6mCoLk7wL9K0VS37oqHQ VloZofm5Du88HtMQwbDaf2s3u4Gw5Gkj+kiCJHXMChw+nogwQiU5N3ftRPTOXnQePFTv brdA== X-Gm-Message-State: AGi0PuYwEVKRCr+gnSQKxgcenve7XdpT01ZfQqa+4MkPabQ/KQHwGv4R I0u5MJtKsPlRqL9hv5hMrtPhZcRe X-Google-Smtp-Source: APiQypK0wFbdPfMHS2ppRPvE+RWlTZ0K9mK3CdKFQhB06REily2HTq7lBAXcRM0BXf9fCZOkXfx2aA== X-Received: by 2002:a17:90b:4c88:: with SMTP id my8mr7767803pjb.199.1588963173297; Fri, 08 May 2020 11:39:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:4001:: with SMTP id f1ls1476354pgp.3.gmail; Fri, 08 May 2020 11:39:33 -0700 (PDT) X-Received: by 2002:aa7:8084:: with SMTP id v4mr2187526pff.39.1588963172770; Fri, 08 May 2020 11:39:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588963172; cv=none; d=google.com; s=arc-20160816; b=XXc1zNFidmGUejvyWWo8g0k8PSKpHOk8Y1MPRmwZhc+ADMfrCP3VZk8Dxq8ebufuEf 5+2HwnUFdJtixYtEDw3AUi2PHk49aRQB5FsSo6WsKqvbTRStGO37OCgG4L+1wN614G7j ydp/6F1MK4qc5uvnOYmBxPTJ2TW0g75rDBnNCiiTBS4IKMRekqncFh6s/bZNd/lIdQfQ +GZBHOAqde/Sk9EzWGaHFGsWU9MRSy4GiNyHYMkO9XAQBw0qLDluk2jsW0YNWysGUdru LPWhTGIwL/em7//CkI70+TU/xxHSof4UYfqtz15iMKcgE0dUYiMjZxrtSnS0bfj/xBSQ xYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=BA+Lj0pAy8m8uHkBEEFt4lhW0undAg74kRq+M3wwCFM=; b=a+sUqXsVlKRE84Hz4OTSZv2IBFoinRd/2C1DPsm1KZmlX1nt0MAvHI5MxhlwxsxyqL IMIDGFn/h4pWChqn0RjIfp1/XwxrOyokFE96GEsKk6sfSc6ULW6/lnID1wz8aTcCnhbs SyhzqBqVNNZN1HKW8NI2R7ePBfY7IFFwEkEU40CoGGDANNxoUN7beJS0Sjw56eFgnNlW eoOOo4QeV4Sy0NsdMWSzjRjYEAfxcmAW5trsF3T4F1K08maWGAPYxvrM7sUf4fRf7EYU 7Dtx2c5hjJSHSGF1ZWPq65UsJs64Vuurp4MJPjurxbE1hz8vuBVBznsqM+OAMtx7Y2sQ 6T6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mKG2h2LT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i3sor3098552pli.24.2020.05.08.11.39.32 for (Google Transport Security); Fri, 08 May 2020 11:39:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:b48f:: with SMTP id y15mr3568786plr.114.1588963172022; Fri, 08 May 2020 11:39:32 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:d9bf:2f67:3bc1:eec1]) by smtp.gmail.com with ESMTPSA id a23sm2372951pfo.145.2020.05.08.11.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 11:39:30 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Jagan Teki , Marek Vasut , Kever Yang , Frank Wang , William Wu Subject: [PATCH] usb: dwc3: Add disable u2mac linestate check quirk Date: Sat, 9 May 2020 00:09:21 +0530 Message-Id: <20200508183921.7169-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mKG2h2LT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.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: , 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 Cc: Kever Yang Cc: Frank Wang Cc: William Wu Signed-off-by: Jagan Teki --- Note: This patch is on top of below quirk patches, https://patchwork.ozlabs.org/project/uboot/patch/20200507081213.16107-2-frank.wang@rock-chips.com/ https://patchwork.ozlabs.org/project/uboot/patch/20200507081213.16107-3-frank.wang@rock-chips.com/ drivers/usb/dwc3/core.c | 19 +++++++++++++++++++ drivers/usb/dwc3/core.h | 7 +++++++ include/dwc3-uboot.h | 1 + 3 files changed, 27 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3cb66515a2..20f5c3de01 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, @@ -975,6 +978,22 @@ int dwc3_init(struct dwc3 *dwc) goto event_fail; } + if (dwc->revision >= DWC3_REVISION_250A) { + u32 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;