From patchwork Tue Oct 22 19:09:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11205205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B930313B1 for ; Tue, 22 Oct 2019 19:09:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9771421872 for ; Tue, 22 Oct 2019 19:09:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="PRX30vfB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732251AbfJVTJu (ORCPT ); Tue, 22 Oct 2019 15:09:50 -0400 Received: from us03-smtprelay2.synopsys.com ([149.117.87.133]:36058 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730186AbfJVTJt (ORCPT ); Tue, 22 Oct 2019 15:09:49 -0400 Received: from mailhost.synopsys.com (sv1-mailhost1.synopsys.com [10.205.2.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 082F1C08CA; Tue, 22 Oct 2019 19:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1571771389; bh=Z4Fe0WCvdYyiIcY4n0xzak9n0o7a3HJDpHUNzdNQJRY=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=PRX30vfBjzuF/jmImBWew5yMcwFifCPJDkH2V1GUcEHL7B+zab+RtDUyazr/TZ+pj GjYeYAHhPnHnL8uQtVeaM16QE/ylLTxLSGv3XGyLzh735ftMHpardPzz+7Xw2KWgJL sQfxziJnP5G83DDf9y8PoKdwxzybw+9ATyo8XRTq24GCLK6pjKzDJ/zv0dQJ7shRHi osgLUt4udlTWJIJA+J2myI8Dpb54QloASU3OwGjUdo+PkvQvJZXcxLH5j7T6ubMNNE gVwevZ+S6V+g/9l9wl6v10qRc6sZYn89bdlaWJQN415HTMOGjo43+9y8QSwwu6hmIB BxRky8wsQhX/w== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id C77BCA005C; Tue, 22 Oct 2019 19:09:47 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Tue, 22 Oct 2019 12:09:47 -0700 Date: Tue, 22 Oct 2019 12:09:47 -0700 Message-Id: In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 1/4] usb: dwc3: gadget: Don't send unintended link state change To: Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org DCTL.ULSTCHNGREQ is a write-only field. When doing a read-modify-write to DCTL, the driver must make sure that there's no unintended link state change request from whatever is read from DCTL.ULSTCHNGREQ. Set link state change to no-action when the driver writes to DCTL. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 86dc1db788a9..24178b4b9d46 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -57,6 +57,8 @@ int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode) return -EINVAL; } + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; dwc3_writel(dwc->regs, DWC3_DCTL, reg); return 0; @@ -1822,6 +1824,9 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) dwc->pullups_connected = false; } + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); do { @@ -2744,6 +2749,10 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) int reg; reg = dwc3_readl(dwc->regs, DWC3_DCTL); + + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + reg &= ~DWC3_DCTL_INITU1ENA; dwc3_writel(dwc->regs, DWC3_DCTL, reg); @@ -2799,6 +2808,10 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) dwc3_reset_gadget(dwc); reg = dwc3_readl(dwc->regs, DWC3_DCTL); + + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + reg &= ~DWC3_DCTL_TSTCTRL_MASK; dwc3_writel(dwc->regs, DWC3_DCTL, reg); dwc->test_mode = false; @@ -2904,10 +2917,15 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) if (dwc->has_lpm_erratum && dwc->revision >= DWC3_REVISION_240A) reg |= DWC3_DCTL_NYET_THRES(dwc->lpm_nyet_threshold); + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; dwc3_writel(dwc->regs, DWC3_DCTL, reg); } else { reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~DWC3_DCTL_HIRD_THRES_MASK; + + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; dwc3_writel(dwc->regs, DWC3_DCTL, reg); } @@ -3017,6 +3035,9 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, reg &= ~u1u2; + /* Don't send link state change request */ + reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + dwc3_writel(dwc->regs, DWC3_DCTL, reg); break; default: From patchwork Tue Oct 22 19:09:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11205207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15B8B139A for ; Tue, 22 Oct 2019 19:10:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAEAE21920 for ; Tue, 22 Oct 2019 19:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="ENJy0waT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732436AbfJVTKF (ORCPT ); Tue, 22 Oct 2019 15:10:05 -0400 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:51042 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729696AbfJVTKF (ORCPT ); Tue, 22 Oct 2019 15:10:05 -0400 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 19F3AC0D22; Tue, 22 Oct 2019 19:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1571771405; bh=uLOYdKOEXB4a8pu4zgFHYTlYQmavBw2OJ3qMWN7cles=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=ENJy0waT3djI0xqR3+I9b2uy6LX1kEXfvesBC26Gdpu9kcqhfTrotjIjqC/h27SI9 Cw6KlEfsrgLVOAuQrb4zWGRK+sB8hTwePtHkdSJjraj+GDy53mxDZpaFhpJcFiJcoc um2yGrKGLPNH7pCD2QUTh/5lrHwT23b4oq2LH1QlaRlNDlfJljQGk+AG4d/eCxxawC XX8McNZgZLnNQfFGDwQpXnyh99HGZ6eA7dN29QFG/Ag5srnpLuitMY1NhrvgIXVZgK pRSoBT5QAza7XmJD58/fbkkb2YSNg4lOtDeXs7Gj4ojf0oqP89DmGOAUB+I+D6WQXC r2Hty9ZQfVFow== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id E8328A005A; Tue, 22 Oct 2019 19:09:53 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Tue, 22 Oct 2019 12:09:53 -0700 Date: Tue, 22 Oct 2019 12:09:53 -0700 Message-Id: In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 2/4] usb: dwc3: gadget: Set link state to RX_Detect on disconnect To: Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When DWC3 receives disconnect event, it needs to set the link state to RX_Detect. DWC_usb3 3.30a programming guide 4.1.7 Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 24178b4b9d46..37631d2e2a2e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2748,6 +2748,8 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) { int reg; + dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RX_DET); + reg = dwc3_readl(dwc->regs, DWC3_DCTL); /* Don't send link state change request */ From patchwork Tue Oct 22 19:10:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11205209 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF52B139A for ; Tue, 22 Oct 2019 19:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E58C21872 for ; Tue, 22 Oct 2019 19:10:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="I9Uwh3Ka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732542AbfJVTKM (ORCPT ); Tue, 22 Oct 2019 15:10:12 -0400 Received: from us03-smtprelay2.synopsys.com ([149.117.87.133]:36114 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729696AbfJVTKL (ORCPT ); Tue, 22 Oct 2019 15:10:11 -0400 Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3AD10C08B9; Tue, 22 Oct 2019 19:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1571771411; bh=xeePJAmW2kK1b5Lzcx3jp9qVTEeHFNdz5IIjFlm/wzE=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=I9Uwh3KaM1RCw557mJk8jdlIVOSPJ3t8uReC3ZqIZlWMlr9fHpvFlh9exAINmOfAC W5H8/PXcCT9e7tQF4DIsCpZ6cyZoGYFbXdt8QRuFQ+/Vnoc4vWGCdzyEBgTm4fF3b1 rYpl90CTg8XfTz+zRAaXFjeNpoJs3tiJgQJAOEYfPW/Nl0vEB6YcSOzrxy2244dV4z ennlv7eJv0VeRUI/LIx5U4ml2mQ7cB0ZDdTkBVIyNIiXTEZb7ISLnIl5mp04emFmC+ xI7zLxh5fRWWcHMdk5C1UZa9V6o4HWZ3TZ2Fx4oyKaZyp3pOUPeTgIU5vTM09f/cmr TWTVxYrSvldaA== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 0C548A005A; Tue, 22 Oct 2019 19:10:10 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Tue, 22 Oct 2019 12:10:10 -0700 Date: Tue, 22 Oct 2019 12:10:10 -0700 Message-Id: <90732ce7d362021ba0e8709c8b9c9e2eb02b83c2.1571770732.git.thinhn@synopsys.com> In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 3/4] usb: dwc3: gadget: Clear DCTL.ULSTCHNGREQ before set To: Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Send a no-action link state change request before the actual request so DWC3 can send the same request whenever we call dwc3_gadget_set_link_state(). Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 37631d2e2a2e..03d58254d1e6 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -113,6 +113,9 @@ int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state) reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; + /* set no action before sending new link state change */ + dwc3_writel(dwc->regs, DWC3_DCTL, reg); + /* set requested state */ reg |= DWC3_DCTL_ULSTCHNGREQ(state); dwc3_writel(dwc->regs, DWC3_DCTL, reg); From patchwork Tue Oct 22 19:10:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11205211 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40BB113B1 for ; Tue, 22 Oct 2019 19:10:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 149CB218AE for ; Tue, 22 Oct 2019 19:10:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="kQ7zwpXW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732623AbfJVTKR (ORCPT ); Tue, 22 Oct 2019 15:10:17 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.47.102]:51074 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729696AbfJVTKR (ORCPT ); Tue, 22 Oct 2019 15:10:17 -0400 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3331BC0DAA; Tue, 22 Oct 2019 19:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1571771417; bh=Ot6jUybTLjzITL1McgAzEtE8wQEtYOI7xyxGMxD6Oug=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=kQ7zwpXWEOQL6seNzmoQZx58+Dk9uo7cK3bXBWA0YjHyd913TIa4p4aJHygm+5MTl Ut4QMYFRVUkQczQ4ZCo37tz65e35NJrVZJqT3atfE4Pk5R5wWjH+8xU4hv5lDhcx8+ NpgoSV3g/iTc6k8M+OIyQ6+hdcdYpabVGd0+2MMVWluUGeIbuKFltuyliiosIkcmdK da/78jrap8bhzzU9ic4BEx5PLTrbLjrkx0cQgkXH2CXEsb/YqAtV3J22qb/tsDgVpv c/DyTKwehktzwHgZ8UU7rkv9eTtU1OCwaGh4X/fckdOghQJS8q5rYzR18aIrT9sVyY VfZ8bHEel6nAA== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 1CAABA005A; Tue, 22 Oct 2019 19:10:16 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Tue, 22 Oct 2019 12:10:16 -0700 Date: Tue, 22 Oct 2019 12:10:16 -0700 Message-Id: <28742e00bedd92bb7052d573eef5f74b66a7970e.1571770732.git.thinhn@synopsys.com> In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 4/4] usb: dwc3: debug: Remove newline printout To: Felipe Balbi , Thinh Nguyen , linux-usb@vger.kernel.org Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newline from the unknown link state tracepoint doesn't follow the other tracepoints, and it looks unsightly. Let's remove it. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 9baabed87d61..e56beb9d1e36 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -112,7 +112,7 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state) case DWC3_LINK_STATE_RESUME: return "Resume"; default: - return "UNKNOWN link state\n"; + return "UNKNOWN link state"; } } @@ -141,7 +141,7 @@ dwc3_gadget_hs_link_string(enum dwc3_link_state link_state) case DWC3_LINK_STATE_RESUME: return "Resume"; default: - return "UNKNOWN link state\n"; + return "UNKNOWN link state"; } }