Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3353147rwa; Tue, 23 Aug 2022 03:25:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RqKkwKMP8e6JD/fh9zB6WyXtXmtE/p0EBxmQbpakTTlGsYUWlxbPMqz0C2//DyebDcb6B X-Received: by 2002:a17:906:98d6:b0:73d:8873:8414 with SMTP id zd22-20020a17090698d600b0073d88738414mr4755061ejb.618.1661250303326; Tue, 23 Aug 2022 03:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661250303; cv=none; d=google.com; s=arc-20160816; b=GX2cEeKMuvU88HL4D0WpIHVdKa5UzD2wglw8sSMyDx/dGOVLucqfBF1zFnZlYXhI+b xxrSaD1DfpqVUsHTI3z6k0mO1X8Wg57KrlFE4wIITbwosmW+lENPMLkwAWEFhnua5Al8 VwvLWQlEnIa+3NRN4L7gHGU9nLNRtGLOyXEj38FBQs+rsnvg6dlkarDyLaypeqPat/Z2 QKdCnGFUq1j6Rmys3YuNpd/8Wzn/SwoLk9ByNEMQVTsE74WxWPJvPpZs/F6jGXDirW6Y zViLlcujfh4/0eeZvCkXPSXYlXmmitpwPevtAkcnlm9BmA5U71FXClSXEQJQQHYaBf4a VhvA== 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=UkRz2LhcCBiEjPdUcMr2tHjLICDymgYUCZiuNaLOAmM=; b=xufOgvNR593N+j+B6UioNutxAy9CJAee1FtgI5GNcXwnrE1sP50qI7qRikl2/O1/5P JCFTLn805DoGRdItPd7GbX7A1SkjEmsK4sKJ5V5DQ8D1yaX2d71bMLIobP9FEUoJcPj1 NyS9P3XSJ5kxirqEx430kLQ/7Yx1TH30lSyB6mTjh1aBJR/zG6lRcJYeaOR30bsoaQLV 1jaaly9u3a3uvNk74T0E3SrzI3d0DRHNqiG3UuJ0yroN6DIDoVQuxnmYgaghn7Ppe1sC KgNmqALoKl/Imh+Pfe1MGoQjwRssH/MOVP1O3WlFMmyzGKQR1D+N8P8ZJ4ba2fLEqAzI Dv1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VvLWGc12; 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 m20-20020a056402511400b0043d1c347df3si2017918edd.152.2022.08.23.03.24.37; Tue, 23 Aug 2022 03:25:03 -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=VvLWGc12; 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 S1354650AbiHWKVz (ORCPT + 99 others); Tue, 23 Aug 2022 06:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352929AbiHWKJe (ORCPT ); Tue, 23 Aug 2022 06:09:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD84C7DF69; Tue, 23 Aug 2022 01:55:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6D6ABB81C3B; Tue, 23 Aug 2022 08:55:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C02C5C433D7; Tue, 23 Aug 2022 08:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244945; bh=FieQMfNxzXPSEp5kaQfeG0576MsAbAodd6WqEw1eqxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VvLWGc129qyQDlCgbrMVufxbAfpNjBdOCqbVwvwvtaDk5QOWW11b9+z0/MOa+t0U+ CvP+Du8UnPpIxVZX/rmXa4TUgdU3cLvm/SAt2aQUt4wVEqfPm8jkb89XPTt5IldQb5 12xRJyxjAMhhPMjwm2p7n9Zy3jIBb1hlkQP4gQJA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minas Harutyunyan , Amelie Delaunay , Fabrice Gasnier , Sasha Levin Subject: [PATCH 5.15 176/244] usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch Date: Tue, 23 Aug 2022 10:25:35 +0200 Message-Id: <20220823080105.159639234@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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.1 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,T_SCC_BODY_TEXT_LINE 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: Amelie Delaunay [ Upstream commit db638c6500abaffb8f7770b2a69c40d003d54ae1 ] When using usb-role-switch, D+ pull-up is set as soon as DTCL_SFTDISCON is cleared, whatever the vbus valid signal state is. The pull-up should not be set when vbus isn't present (this is determined by the drd controller). This patch ensures that B-Session (so Peripheral role + vbus valid signal) is valid before clearing the DCTL_SFTDISCON bit when role switch is used. Keep original behavior when usb-role-switch isn't used. Acked-by: Minas Harutyunyan Signed-off-by: Amelie Delaunay Signed-off-by: Fabrice Gasnier Link: https://lore.kernel.org/r/20220622160717.314580-1-fabrice.gasnier@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index e1cebf581a4a..519bb82b00e8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3594,7 +3594,8 @@ void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) { /* remove the soft-disconnect and let's go */ - dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); + if (!hsotg->role_sw || (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_BSESVLD)) + dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); } /** -- 2.35.1