Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4344303pxf; Tue, 23 Mar 2021 08:27:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHEq7rJJPk9d/v5H4hn9TmSqcom6Sc4UHhGCvuKOV+xX8cKmGlyH+rmI+VXeOVxgOonnhx X-Received: by 2002:a17:906:5295:: with SMTP id c21mr5460563ejm.67.1616513246233; Tue, 23 Mar 2021 08:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616513246; cv=none; d=google.com; s=arc-20160816; b=IgsQ5G7zpQGgZb7CX4bqCmvO6PJxoXTHbOVMXYcu3b2HqrD53TJL1kOy4QdSVmaHbn HBRJSuS/e/WSA/fzMszhrg491yJ1Nzq1gf3y1OcJMgOUmz1tejQ/SSnoNE8hFAGivv0B lwr2WyTHsmNoL9UJEuspzPnEsxO7Ks+NLz7rk99mGb3IuGGrgfjJ22vlectZIWVmH6JZ 91u/7iG4GGxp6PPK6wKiSg/Octgy/oySwVaDiB6KIS3gfL2fHfF74Buxu0KoU5cgiJsE 7PUyu1fQJpC3swUjLiY/Ukzv48f/tqKDS1mJLRMHd/VO4sUJvolAni6otAkJPl5Anx9M niAw== 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 :message-id:date:subject:cc:to:from; bh=7yjRG9foFUY8w4LL4eu6+c3QfNgNmbTQNoBxg0J/lmk=; b=cZR63NgYLthV3IWkMjwM3GjO5N/H/hZuqGo6SitFMW5RqX52d16gvN0XQM90c1v9CE vD9IWj3U3V6gZeZ4yUFmwUxCAZRrLTD9csSsXgeXPs8Rfayw2LCOAxxYe8VJR1+Tounv rGjR61EjnRE0JMUlDU6Qts3GMfYzgnHq2uUtbJH6fMapY5QyMnmWFYmVxtUr3Chbn42S 6xIBs4180JRKA3Iw53HJfS9Y6xVZwBbxsi/JmzZXvT10foQUWxytJFM7kHWubK3DU1lG 9p22IPbtzd8QcGaw/FFGlICYi44MkHdvsyItTRv0a3v5O4wEpQyu0AJpyX3+YhocohCr hPoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si13525263ejr.535.2021.03.23.08.26.39; Tue, 23 Mar 2021 08:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232492AbhCWPZM (ORCPT + 99 others); Tue, 23 Mar 2021 11:25:12 -0400 Received: from out28-148.mail.aliyun.com ([115.124.28.148]:49645 "EHLO out28-148.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbhCWPYy (ORCPT ); Tue, 23 Mar 2021 11:24:54 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.09372319|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.00677813-0.000306783-0.992915;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047208;MF=zhouyanjie@wanyeetech.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.Jp5t6E3_1616513066; Received: from zhouyanjie-virtual-machine.localdomain(mailfrom:zhouyanjie@wanyeetech.com fp:SMTPD_---.Jp5t6E3_1616513066) by smtp.aliyun-inc.com(10.147.44.129); Tue, 23 Mar 2021 23:24:45 +0800 From: =?UTF-8?q?=E5=91=A8=E7=90=B0=E6=9D=B0=20=28Zhou=20Yanjie=29?= To: hminas@synopsys.com, gregkh@linuxfoundation.org, paul@crapouillou.net Cc: linux-mips@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dongsheng.qiu@ingenic.com, aric.pzqi@ingenic.com, sernia.zhou@foxmail.com, =?UTF-8?q?Dragan=20=C4=8Ce=C4=8Davac?= Subject: [PATCH] USB: DWC2: Add VBUS overcurrent detection control. Date: Tue, 23 Mar 2021 23:24:26 +0800 Message-Id: <1616513066-62025-1-git-send-email-zhouyanjie@wanyeetech.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce configurable option for enabling GOTGCTL register bits VbvalidOvEn and VbvalidOvVal. Once selected it disables VBUS overcurrent detection. This patch is derived from Dragan Čečavac (in the kernel 3.18 tree of CI20). It is very useful for the MIPS Creator CI20(r1). Without this patch, CI20's OTG port has a great probability to face overcurrent warning, which breaks the OTG functionality. Signed-off-by: 周琰杰 (Zhou Yanjie) Signed-off-by: Dragan Čečavac --- drivers/usb/dwc2/Kconfig | 6 ++++++ drivers/usb/dwc2/core.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig index c131719..e40d187 100644 --- a/drivers/usb/dwc2/Kconfig +++ b/drivers/usb/dwc2/Kconfig @@ -94,4 +94,10 @@ config USB_DWC2_DEBUG_PERIODIC non-periodic transfers, but of course the debug logs will be incomplete. Note that this also disables some debug messages for which the transfer type cannot be deduced. + +config USB_DWC2_DISABLE_VOD + bool "Disable VBUS overcurrent detection" + help + Say Y here to switch off VBUS overcurrent detection. It enables USB + functionality blocked by overcurrent detection. endif diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index fec17a2..c629dc97 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -1200,6 +1200,7 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) { u32 usbcfg; + u32 otgctl; int retval = 0; if ((hsotg->params.speed == DWC2_SPEED_PARAM_FULL || @@ -1231,6 +1232,14 @@ int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) dwc2_writel(hsotg, usbcfg, GUSBCFG); } + if (IS_ENABLED(CONFIG_USB_DWC2_DISABLE_VOD)) { + if (dwc2_is_host_mode(hsotg)) { + otgctl = readl(hsotg->regs + GOTGCTL); + otgctl |= GOTGCTL_VBVALOEN | GOTGCTL_VBVALOVAL; + writel(otgctl, hsotg->regs + GOTGCTL); + } + } + return retval; } -- 2.7.4