Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1138779rwi; Wed, 19 Oct 2022 07:10:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73AAVnnof1MG6wB19IV+VMh9RHaEOf6/ROA4p50CsgkIsj+c4iunceLanhz/8VPinz7Q9G X-Received: by 2002:a63:fa17:0:b0:43c:3f26:48e3 with SMTP id y23-20020a63fa17000000b0043c3f2648e3mr7394028pgh.66.1666188638603; Wed, 19 Oct 2022 07:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666188638; cv=none; d=google.com; s=arc-20160816; b=Jefwi7/pvDUwbdVyo/c4aN+TJDd5gzs4reXwH3RQG1e+NUrkTIzEw0Nh5+G3U79Gb+ gD8fMk+GoqqBPSdeQHRk/gviT8/+YPrs97mS9gwYkIfYrGDF879CHGY/D5UprvFGY2TM cWR0yeHH6+93P4LSQ6AorvQ0FTSGCR8ogd+2BOmxWLaM6Hf04KMEu4+tCCaiFGDAqzUo bCdD1MqA3c1oXYiN1Jl5WayLnawGiY+OJaCyotCCTPsDeu8kAvjfg33FcSZ1J4Pev5cX M2NiibybjJJuIjwPnpj4u9PlzF5E30oIRmbQmqwsINGqTR3nz7IbeNwuGmxalyLQIpgv rJjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZxsFFKr7JQuZ4NTCoPv36zAIT5+3z5sCqxV6YeB4iKI=; b=UJoioVV8L33NESK8tZgfP4EjiulWKnJoauM5bOdWWOAJPeEIdekiAXrcpCAKaHs9YQ CAFwSC4sC3aLAI+whzQv2gA7M40i/sit4rw85J7qghW544HSTgriU7t6bvW9H1O5GdTp WaeSstXU6Eb1y4w/WUOV4Fi2XB55LTG37D6MQA7PElFVCvoV2MQ63ccquqizH8yKVzba mgex2uPGxt7hJseLA/yDdCD3ranhV/XKcgkIc6ghFBEDaSyB01p39XkM3d+hLdX42dXo BTChvX8sXEFCErZGjlRn8/ae1DzKCVTCghzqt8012Hw+xbn/uHTVrLJKckQL9P9h5Giq GOXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ubxDk+eB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a170902ed8300b00183e5698836si16369513plj.189.2022.10.19.07.10.24; Wed, 19 Oct 2022 07:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ubxDk+eB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbiJSNwn (ORCPT + 99 others); Wed, 19 Oct 2022 09:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233729AbiJSNwG (ORCPT ); Wed, 19 Oct 2022 09:52:06 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F147C106E00; Wed, 19 Oct 2022 06:35:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id DB2C0CE2179; Wed, 19 Oct 2022 09:16:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC9B4C4314D; Wed, 19 Oct 2022 09:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170962; bh=1IB80J7gN/8BTd5cQPn7K1RP9SCIs8k6JUiLfMEL1mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ubxDk+eBo/DlwGCslvszr9BRIX3QJye3+NRKSkbDsgU/4w4rl/2FH/JwDdYjleDAY JYFi+TcU5ia+WmhE4Cl/tsbpyjUjvmBAXsUAmjFlvDTqYBrdkMkvwO8lyUXk49jhgy JljiVRyixac+N8RpPIkVRcLpvReteqAlLzn4FW9s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Piyush Mehta , Sasha Levin Subject: [PATCH 6.0 821/862] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing termination error after resume bug Date: Wed, 19 Oct 2022 10:35:08 +0200 Message-Id: <20221019083326.186968148@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Piyush Mehta [ Upstream commit 63d7f9810a38102cdb8cad214fac98682081e1a7 ] When configured in HOST mode, after issuing U3/L2 exit controller fails to send proper CRC checksum in CRC5 field. Because of this behavior Transaction Error is generated, resulting in reset and re-enumeration of usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this problem. When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations, term, and xcvr signals after EOR. This option is to support certain legacy UTMI/ULPI PHYs. Added "snps,resume-hs-terminations" quirk to resolved the above issue. Signed-off-by: Piyush Mehta Link: https://lore.kernel.org/r/20220920052235.194272-3-piyush.mehta@amd.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 17 +++++++++++++++++ drivers/usb/dwc3/core.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index f7f1952b2901..68d986361c49 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1183,6 +1183,21 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_GUCTL2, reg); } + /* + * When configured in HOST mode, after issuing U3/L2 exit controller + * fails to send proper CRC checksum in CRC5 feild. Because of this + * behaviour Transaction Error is generated, resulting in reset and + * re-enumeration of usb device attached. All the termsel, xcvrsel, + * opmode becomes 0 during end of resume. Enabling bit 10 of GUCTL1 + * will correct this problem. This option is to support certain + * legacy ULPI PHYs. + */ + if (dwc->resume_hs_terminations) { + reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); + reg |= DWC3_GUCTL1_RESUME_OPMODE_HS_HOST; + dwc3_writel(dwc->regs, DWC3_GUCTL1, reg); + } + if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) { reg = dwc3_readl(dwc->regs, DWC3_GUCTL1); @@ -1526,6 +1541,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,dis-del-phy-power-chg-quirk"); dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev, "snps,dis-tx-ipgap-linecheck-quirk"); + dwc->resume_hs_terminations = device_property_read_bool(dev, + "snps,resume-hs-terminations"); dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev, "snps,parkmode-disable-ss-quirk"); dwc->gfladj_refclk_lpm_sel = device_property_read_bool(dev, diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 11975a03316f..3ac9313e66f9 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -263,6 +263,7 @@ #define DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK BIT(26) #define DWC3_GUCTL1_DEV_L1_EXIT_BY_HW BIT(24) #define DWC3_GUCTL1_PARKMODE_DISABLE_SS BIT(17) +#define DWC3_GUCTL1_RESUME_OPMODE_HS_HOST BIT(10) /* Global Status Register */ #define DWC3_GSTS_OTG_IP BIT(10) @@ -1097,6 +1098,8 @@ struct dwc3_scratchpad_array { * change quirk. * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate * check during HS transmit. + * @resume-hs-terminations: Set if we enable quirk for fixing improper crc + * generation after resume from suspend. * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed * instances in park mode. * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk @@ -1312,6 +1315,7 @@ struct dwc3 { unsigned dis_u2_freeclk_exists_quirk:1; unsigned dis_del_phy_power_chg_quirk:1; unsigned dis_tx_ipgap_linecheck_quirk:1; + unsigned resume_hs_terminations:1; unsigned parkmode_disable_ss_quirk:1; unsigned gfladj_refclk_lpm_sel:1; -- 2.35.1