From patchwork Wed Oct 16 03:33:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 176404 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6783598ill; Tue, 15 Oct 2019 20:33:46 -0700 (PDT) X-Received: by 2002:a62:5801:: with SMTP id m1mr43063368pfb.204.1571196826774; Tue, 15 Oct 2019 20:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571196826; cv=none; d=google.com; s=arc-20160816; b=zb7NwqMerFNRgdia9uwKPPwrnwdHx/OH4sByJG1qmdo+5NuApfmH72Ufe14P9cu+zP NXXnyTsmDXeXDuhnHnVyrube5b0sF1+E6XUF2Rs9sqXd2KeBmEBvb1cWWSun2J7M7IEQ m8mfSlvhjcBk18djA0TlhqWjf7Qh/QCRwEyoy444utbS+Yrk7JyIL7OrC93GzHBS0lZ5 n4dmib8k+bnnz3O4HTBwu7xgHbKb0gWhuwf/wGGfQJynbRC7TBuM3qwgzE0U93kUvxCL p3p4Hr6IU6Y2nqqqj0DfAcupy3IBssDtguM6JYNGSbcM9Gclx4cBn+TPYeYwO7L+ut8i 6AWA== 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=+L6QotxBXClg8Fe4NEIvH2M7vhWfz5AENh5gfCd6GV4=; b=OkBk5IEgIqUy9PUsnJfQBiIpMyF3gMIzPVha8ttS53a9Vfw3kZVGXI97ZVO7kEGjHw JodCxFI2ePR9Q8DX4s9bnk7DFv1kDihrkNbHQFQxqBsTap2kLlVaN+r4hU7C/gzQt189 PoeDaQ6q7jx4GGYxHZGkXRXUlYDXcVMfW86THdedyHu2CZFnKYv/epZH9PnTuY+aNbgy 0zL8pNTBD1/GfXZZjP9I80nvjdwT5N7U8M497jVEW1FmygtJviGzop08DnhIe59p8Ivo on/mSHi0vGXZYoRyi5Nk+eIPTBYCptd/sdd3Bg+Ehq3Bk4pqL1q0uaKYLJ2BGtKu60pf OwNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lGAST+mY; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q138sor26048165pfc.41.2019.10.15.20.33.46 for (Google Transport Security); Tue, 15 Oct 2019 20:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lGAST+mY; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 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=+L6QotxBXClg8Fe4NEIvH2M7vhWfz5AENh5gfCd6GV4=; b=lGAST+mYnUw2+fFUvOyyVN68vAR+ZDOyy8WoR3kjWo+W2+qfO342xlBSDzAujCE92W xE0pXYq5oYJMudqdUUTFcA4aWTLpzR+HCUmB2mLqubMM06EZSAOSYJjIUw4X7hTl3wuZ nuUIgEUQvBCjVCKdCz7w+QZpLjGw9uKQAXLeecMbO1I9Jv6BXS5VvWMhSILKzjD9zOKQ 13+n9QYnIPx0gCFbGdo1DDHBdarXxErH5EaN8Pyqbtxwar/4fbU5+fiWPJ2fPmqi1oJM +YU3v3GRs0ICUUyn1sNwz9LHFqOGijZHx5d3agCBmyOak2HuwQbcxym7UyWvVtNxdO5H 0a8Q== 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=+L6QotxBXClg8Fe4NEIvH2M7vhWfz5AENh5gfCd6GV4=; b=rKDxWZ4NYlh8HHInpinIQ+hvh1p9bezhmiyKacyTrZGYRbivUq5wi5V/AhfQZ5r4Yk ergOTzKxGtRmMz1+MIn0aMjK2EmcGer6NehEjGg25WiOYdyitSeKEyLpeNeLkDcqytZv 70MeVLb5SJOjiZCKP+HEiUHbMh5QSvOG6ksjYD7R46BAaa5H0kdv47bza0Q5Vui2fraR MsMJLJLitdKOtYLYghDJNgK1BqPSiRBr7K/HsF5JUECruP+5cBW9D7yTdafT6NQPTACY TYQSJFodmanjiSrrOSReIr0NDYNWj4ChFNdyBXqOe2elHE/zI5qzCUwQoWV+qwnVmx7g XbeQ== X-Gm-Message-State: APjAAAXwtCzYng2MuWlmuN/xyxOIh856swibDikax9aOGOdDdqHTIMkJ iiOAdHpNO71vNXdt+A4LujhGxFvc X-Google-Smtp-Source: APXvYqx4mHE3Pk26QZ2wQVQI9bb5Z31XRA2QB6VDKjNpj4Ri/jYSuBD2qTj2kfwGMLGU4KLE6yoqJA== X-Received: by 2002:a63:d457:: with SMTP id i23mr42038764pgj.276.1571196826240; Tue, 15 Oct 2019 20:33:46 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id l23sm748356pjy.12.2019.10.15.20.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 20:33:45 -0700 (PDT) From: John Stultz To: lkml Cc: Yu Chen , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, John Stultz Subject: [RFC][PATCH v3 02/11] usb: dwc3: Execute GCTL Core Soft Reset while switch modes Date: Wed, 16 Oct 2019 03:33:31 +0000 Message-Id: <20191016033340.1288-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191016033340.1288-1-john.stultz@linaro.org> References: <20191016033340.1288-1-john.stultz@linaro.org> From: Yu Chen On the HiKey960, we need to do a GCTL soft reset when switching modes. Jack Pham also noted that in the Synopsys databook it mentions performing a GCTL CoreSoftReset when changing the PrtCapDir between device & host modes. So this patch always does a GCTL Core Soft Reset when changing the mode. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Signed-off-by: Yu Chen Signed-off-by: John Stultz --- v3: Remove quirk conditional, as Jack Pham noted the Synopsis databook states this should be done generally. Also, at Jacks' suggestion, make the reset call before changing the prtcap direction. --- drivers/usb/dwc3/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 999ce5e84d3c..a039e35ec7ad 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -112,6 +112,19 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode) dwc->current_dr_role = mode; } +static void dwc3_gctl_core_soft_reset(struct dwc3 *dwc) +{ + u32 reg; + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg |= DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); + + reg = dwc3_readl(dwc->regs, DWC3_GCTL); + reg &= ~DWC3_GCTL_CORESOFTRESET; + dwc3_writel(dwc->regs, DWC3_GCTL, reg); +} + static void __dwc3_set_mode(struct work_struct *work) { struct dwc3 *dwc = work_to_dwc(work); @@ -154,6 +167,9 @@ static void __dwc3_set_mode(struct work_struct *work) spin_lock_irqsave(&dwc->lock, flags); + /* Execute a GCTL Core Soft Reset when switch mode */ + dwc3_gctl_core_soft_reset(dwc); + dwc3_set_prtcap(dwc, dwc->desired_dr_role); spin_unlock_irqrestore(&dwc->lock, flags);