From patchwork Fri Jan 8 01:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 358924 Delivered-To: patches@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp133779jai; Thu, 7 Jan 2021 17:51:24 -0800 (PST) X-Received: by 2002:a17:90b:ece:: with SMTP id gz14mr1345522pjb.158.1610070684057; Thu, 07 Jan 2021 17:51:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610070684; cv=none; d=google.com; s=arc-20160816; b=aBMPohH/MJD+PWIRPPokCreIavJxQc7rBoZlReVy+PNYoOysgUQrOwuDqq9CMmoEpo 9pPNDipxfu2b14E411UMFSpngKL4NN4JdvR9V1k/W6Qf0L4tFnxwC/PkwM19PP/RgPG1 I9Wdn6YVu9qA+iiOMb3e5YQ2nkG4pACes8rO6fDw5UGL9Fhn2bF9s1ZBxVVfns/rvQ7y B4ckQLK0pJNEYUY9uOWmdW33tkJxiLnm77Wt+CgoYLrNQe6Q4Rohst9mOXuA+UiDlp/6 ea9KbEx39F5ixc//6e7vx2oKgXJf1B0B7lfz0mAzDMXaQP7ec7pUX3plfov8x6Ywus2s qbrw== 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 :dkim-signature; bh=eaHrQpKpeurHZv+OYTMBBGGPpB4FZE1mWJW48Z/oiNs=; b=UQgKAZqyRX4kTc4bDhEL8/8rz7xGtkO2HWyD7sqxrRXLaWZfPh1ARdB7XawyJyN/e6 Z9Lde8Z9SFcon+X2tlP8+/PEPBLrYSuQCPgJI4C9bO5Gk/LDb2XQKi3MOrPMsDHHhoQD BFNv3mSDgfhOdpNNCqYCJL+fb+wZTzwRXY5JBDB0azSPoLX6AOMErGTL+5Xi61GDRQO9 pu5JMy+esqykBZT4vqzFiww4XnFPhB1Q+9WgcMJ9nItXo3Y4uSI9dorEj2465DQ9CyJ2 y5fmQdxayxHEX7K+ZsPTlCNmLi1r0GqBVyCNyOVYuQPNmxbgfVe5GKJC5RltXZ+uA4aC wHPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AP8eKNDX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id z11sor4043229pga.41.2021.01.07.17.51.23 for (Google Transport Security); Thu, 07 Jan 2021 17:51:24 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AP8eKNDX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eaHrQpKpeurHZv+OYTMBBGGPpB4FZE1mWJW48Z/oiNs=; b=AP8eKNDXK+f3yABttnermAH/48jx7jQD5O+GUTNSbdHW4WUqvESmttKvccFPZgp9Sz A/YcciJTOSsQ6+nNIXjhfmrvn0z5OHXeNczZZtuJ9rOh7lSh2pqKfx1H2QasQsPXu2uW b1XW6ubHyF2oGGSxPTrqhF2hOxNrVgHdoUz0tmPRsD9X+RpmSPMkEOi+kpNicXxGr+Uh dly3HIYPB8GjbhlHvWkUJleD9z8FLiohhDzF1EsJjM3RLPjrtmilqEhb2JCvPpLx5+jP zvTUmqdeh6WWeEkQNyu6ssL4OkK/K2O/JsOZIJZzTcpa872nVlRHmbZtZOl5GIBDIbrq 36WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eaHrQpKpeurHZv+OYTMBBGGPpB4FZE1mWJW48Z/oiNs=; b=LF3t3LIqvk4KjspY1xqI1ZBd7fLwZ0Xb217vHFoh6kQuaCbucOtYlLTsyl6+sKNSVp 2WshN3fDrC6dgYAHTOpUazgF0U7BmoUgufkS4YGikN6Cm93p14D9UywuABO4TLPO+fZO vB63vFLAQS/yYB4TiTVGbHgdNU2yn0w/DX14qdE42MsIjot6viL7MZ7xLhcKk9kgJ44w qvINVXwgKJvxyEpK53zwLGKIlAygjPCr9DF4xW39NJmW1xhLsZzg0b+g26LkwsJcxgMt Arvb0GYHfacTBHryF+ug6uvC4LV8M5lX4syM+R8ENSOvsK6DsbFOqzsqgLP4o+YGFdGU VQUw== X-Gm-Message-State: AOAM53168lz0NFi8HGchl8YVNE1UIriIOKSUDKGK9XCK0wvYxAlFYW2w lZlWQmsWDEy95Sh60qHe2LN+PLDpwDqV+RcF X-Google-Smtp-Source: ABdhPJxSbJhBpM2A0dR5cqQKxAWgztVnTaKnRROtWkb337/i7shPcaEJlVeBtCPmt827WMdg7g/VlA== X-Received: by 2002:a63:1261:: with SMTP id 33mr4538228pgs.213.1610070683769; Thu, 07 Jan 2021 17:51:23 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id fw12sm6142756pjb.43.2021.01.07.17.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 17:51:22 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Felipe Balbi , Tejas Joglekar , Yang Fei , YongQin Liu , Andrzej Pietrasiewicz , Thinh Nguyen , Jun Li , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH v3 2/2] usb: dwc3: Fix DRD mode change sequence following programming guide Date: Fri, 8 Jan 2021 01:51:15 +0000 Message-Id: <20210108015115.27920-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210108015115.27920-1-john.stultz@linaro.org> References: <20210108015115.27920-1-john.stultz@linaro.org> In reviewing the previous patch, Thinh Nguyen pointed out that the DRD mode change sequence should be like the following when switching from host -> device according to the programming guide (for all DRD IPs): 1. Reset controller with GCTL.CoreSoftReset 2. Set GCTL.PrtCapDir(device) 3. Soft reset with DCTL.CSftRst 4. Then follow up with the initializing registers sequence The current code does: a. Soft reset with DCTL.CSftRst on driver probe b. Reset controller with GCTL.CoreSoftReset (added in previous patch) c. Set GCTL.PrtCapDir(device) d. < missing DCTL.CSftRst > e. Then follow up with initializing registers sequence So this patch adds the DCTL.CSftRst soft reset that was currently missing from the dwc3 mode switching. Cc: Felipe Balbi Cc: Tejas Joglekar Cc: Yang Fei Cc: YongQin Liu Cc: Andrzej Pietrasiewicz Cc: Thinh Nguyen Cc: Jun Li Cc: Mauro Carvalho Chehab Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz --- Feedback would be appreciated. I'm a little worried I should be conditionalizing the DCTL.CSftRst on DRD mode controllers, but I'm really not sure what the right thing to do is for non-DRD mode controllers. --- drivers/usb/dwc3/core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index b6a6b90eb2d5..71f8b07ecb99 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -40,6 +40,8 @@ #define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms */ +static int dwc3_core_soft_reset(struct dwc3 *dwc); + /** * dwc3_get_dr_mode - Validates and sets dr_mode * @dwc: pointer to our context structure @@ -177,6 +179,7 @@ static void __dwc3_set_mode(struct work_struct *work) dwc3_set_prtcap(dwc, dwc->desired_dr_role); + dwc3_core_soft_reset(dwc); spin_unlock_irqrestore(&dwc->lock, flags); switch (dwc->desired_dr_role) {