From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756310AbdJPQki (ORCPT ); Mon, 16 Oct 2017 12:40:38 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:47813 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbdJPQkf (ORCPT ); Mon, 16 Oct 2017 12:40:35 -0400 X-Auth-Info: IprJBJis+Ezz8XQF6W3i/2GZGW824VOkiafBEbV0SCg= Subject: Re: [PATCH] usb: dwc2: disable erroneous overcurrent condition To: Dinh Nguyen , johnyoun@synopsys.com Cc: balbi@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <1508162238-12206-1-git-send-email-dinguyen@kernel.org> From: Marek Vasut Message-ID: <90d8caae-baaa-244f-a6f3-1ce6fd4e8143@denx.de> Date: Mon, 16 Oct 2017 18:37:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1508162238-12206-1-git-send-email-dinguyen@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/16/2017 03:57 PM, Dinh Nguyen wrote: > For the case where an external VBUS is used, we should enable the external > VBUS comparator in the driver. This would prevent an unnecessary > overcurrent error which would then disable the host port. > > This patch uses the standard 'disable-over-current' binding to allow of the > option of disabling the over-current condition. > > Signed-off-by: Dinh Nguyen Reviewed-by: Marek Vasut Similar patch was in U-Boot for two years now and it does the trick indeed. > --- > drivers/usb/dwc2/core.h | 4 ++++ > drivers/usb/dwc2/hcd.c | 5 +++++ > drivers/usb/dwc2/params.c | 3 +++ > 3 files changed, 12 insertions(+) > > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h > index 8367d4f9..730d7eb 100644 > --- a/drivers/usb/dwc2/core.h > +++ b/drivers/usb/dwc2/core.h > @@ -395,6 +395,9 @@ enum dwc2_ep0_state { > * (default when phy_type is UTMI+ or ULPI) > * 1 - 6 MHz > * (default when phy_type is Full Speed) > + * @oc_disable: Flag to disable overcurrent condition. > + * 0 - Allow overcurrent condition to get detected > + * 1 - Disable overcurrent condtion to get detected > * @ts_dline: Enable Term Select Dline pulsing > * 0 - No (default) > * 1 - Yes > @@ -492,6 +495,7 @@ struct dwc2_core_params { > bool dma_desc_fs_enable; > bool host_support_fs_ls_low_power; > bool host_ls_low_power_phy_clk; > + bool oc_disable; > > u8 host_channels; > u16 host_rx_fifo_size; > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > index c263114..5e20336 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -213,6 +213,11 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) > usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL); > if (hsotg->params.phy_ulpi_ddr) > usbcfg |= GUSBCFG_DDRSEL; > + > + /* Set external VBUS indicator as needed. */ > + if (hsotg->params.oc_disable) > + usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND | > + GUSBCFG_INDICATORPASSTHROUGH); > break; > case DWC2_PHY_TYPE_PARAM_UTMI: > /* UTMI+ interface */ > diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c > index a3ffe97..39e02cd 100644 > --- a/drivers/usb/dwc2/params.c > +++ b/drivers/usb/dwc2/params.c > @@ -335,6 +335,9 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) > num); > } > } > + > + if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL)) > + p->oc_disable = true; > } > > static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg) > -- Best regards, Marek Vasut