From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3151C48BE5 for ; Sat, 12 Jun 2021 07:24:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6D8761001 for ; Sat, 12 Jun 2021 07:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbhFLH0q (ORCPT ); Sat, 12 Jun 2021 03:26:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:51308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbhFLH0o (ORCPT ); Sat, 12 Jun 2021 03:26:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BC5861001; Sat, 12 Jun 2021 07:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623482685; bh=t/XgaghKUAW5fxfIyI1pGDsxc8Nx4j/oqsUFlYCf95A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F93w5krVy5rN/nUpUkyS3OZy1OARVmNHDpaf0oWXXjel4wxg1enDo26a4XVxfUpkf 0gHrvfv8CGndUS5EYRTMDSw2b9KffdXfne8T5c7X9iM+/NxeKXbICNxcaER2paOKEo CYaulMrzN6yvV06erad0M3OGVTzh2d8eSbMco0zaq/uXFj7PUN3kU3OnUAh589h7Z7 E8sasOynewQB0QjlkV+6tThNb/IbtF4bhFgxdGoxSD4yl2Q5xMCrNuYY8q22nTGRLV csA+pc9E12A+fYMQKiGt8OqhGe3n6jvvPey9wak3hvrpRWlpr6aTjCOwhwUxR3ihou /ppjuY3QEM3sw== Date: Sat, 12 Jun 2021 15:24:38 +0800 From: Peter Chen To: Breno Lima Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, brenomatheus@gmail.com, jun.li@nxp.com Subject: Re: [PATCH v2] mx8mm: usb: chipidea: Fix Battery Charger 1.2 CDP detection Message-ID: <20210612072438.GA4580@Peter> References: <20210611145607.147207-1-breno.lima@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210611145607.147207-1-breno.lima@nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-06-11 10:56:07, Breno Lima wrote: > i.MX8MM cannot detect certain CDP USB HUBs. usbmisc_imx.c driver is not > following CDP timing requirements defined by USB BC 1.2 specification > and section 3.2.4 Detection Timing CDP. > > During Primary Detection the i.MX device should turn on VDP_SRC and > IDM_SINK for a minimum of 40ms (TVDPSRC_ON). After a time of TVDPSRC_ON, > the PD is allowed to check the status of the D- line. Current > implementation is waiting between 1ms and 2ms, and certain BC 1.2 > complaint USB HUBs cannot be detected. Increase delay to 40ms allowing > enough time for primary detection. > > During secondary detection the PD is required to disable VDP_SRC and What does the "PD" mean here? > IDM_SNK, and enable VDM_SRC and IDP_SINK for at least 40ms (TVDMSRC_ON). > > Current implementation is not disabling VDP_SRC and IDM_SNK, introduce > disable sequence in imx7d_charger_secondary_detection() function. > > VDM_SRC and IDP_SINK should be enabled for at least 40ms (TVDMSRC_ON). > Increase delay allowing enough time for detection. > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection") I assume this one needs to go stable tree? Peter > > Signed-off-by: Breno Lima > Signed-off-by: Jun Li > --- > Changes since V1: > - Updated commit log to include commit ID fix > drivers/usb/chipidea/usbmisc_imx.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c > index 4545b23bda3f..bac0f5458cab 100644 > --- a/drivers/usb/chipidea/usbmisc_imx.c > +++ b/drivers/usb/chipidea/usbmisc_imx.c > @@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) > int val; > unsigned long flags; > > + /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */ > + spin_lock_irqsave(&usbmisc->lock, flags); > + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > + val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0; > + writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > + spin_unlock_irqrestore(&usbmisc->lock, flags); > + > + /* TVDMSRC_DIS */ > + msleep(20); > + > /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ > spin_lock_irqsave(&usbmisc->lock, flags); > val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > @@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) > usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > spin_unlock_irqrestore(&usbmisc->lock, flags); > > - usleep_range(1000, 2000); > + /* TVDMSRC_ON */ > + msleep(40); > > /* > * Per BC 1.2, check voltage of D+: > @@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) > usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > spin_unlock_irqrestore(&usbmisc->lock, flags); > > - usleep_range(1000, 2000); > + /* TVDPSRC_ON */ > + msleep(40); > > /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ > val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); > -- > 2.25.1 > -- Thanks, Peter Chen From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FFDDC48BE5 for ; Sat, 12 Jun 2021 07:26:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3965061076 for ; Sat, 12 Jun 2021 07:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3965061076 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5JLsIkQkdOjVy++rOQlUbSTkKcyuZE1jVhVyTXrY2Dw=; b=xwS3OPx+Dintap zlmHCABPyILfUMHuAz09iRAHZvHWde6juz/aM0PK2kEvHxx67NRZhiBRrxUqCEGIWeDw5eSQ6iM2t 4r5bux2e+Y/CKduri30ekpUacauqf/wMU2/5RLNwEvJRjg4SVHCOy/80DOxdhjChFK4I6Q9i2TuNZ ySmrOn+DZ9a882iagw1jASlrfnli/0tvq9GrLM0F1qSv/oFF3GfCw5TnisJdnuoWr3rLB53mZv2z5 9pMcY115hVSYhij1ZHWu7xLAhMJg4jNxh52ANL9QcSDNOTLHelqNKw/5Rp4lFwawYABXslgZYAZlJ AARmG+pVhuH8JoJQk2Fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lry0g-00818t-1d; Sat, 12 Jun 2021 07:24:50 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lry0c-00817n-D2 for linux-arm-kernel@lists.infradead.org; Sat, 12 Jun 2021 07:24:47 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BC5861001; Sat, 12 Jun 2021 07:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623482685; bh=t/XgaghKUAW5fxfIyI1pGDsxc8Nx4j/oqsUFlYCf95A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F93w5krVy5rN/nUpUkyS3OZy1OARVmNHDpaf0oWXXjel4wxg1enDo26a4XVxfUpkf 0gHrvfv8CGndUS5EYRTMDSw2b9KffdXfne8T5c7X9iM+/NxeKXbICNxcaER2paOKEo CYaulMrzN6yvV06erad0M3OGVTzh2d8eSbMco0zaq/uXFj7PUN3kU3OnUAh589h7Z7 E8sasOynewQB0QjlkV+6tThNb/IbtF4bhFgxdGoxSD4yl2Q5xMCrNuYY8q22nTGRLV csA+pc9E12A+fYMQKiGt8OqhGe3n6jvvPey9wak3hvrpRWlpr6aTjCOwhwUxR3ihou /ppjuY3QEM3sw== Date: Sat, 12 Jun 2021 15:24:38 +0800 From: Peter Chen To: Breno Lima Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, brenomatheus@gmail.com, jun.li@nxp.com Subject: Re: [PATCH v2] mx8mm: usb: chipidea: Fix Battery Charger 1.2 CDP detection Message-ID: <20210612072438.GA4580@Peter> References: <20210611145607.147207-1-breno.lima@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210611145607.147207-1-breno.lima@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210612_002446_501312_8F3D1854 X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 21-06-11 10:56:07, Breno Lima wrote: > i.MX8MM cannot detect certain CDP USB HUBs. usbmisc_imx.c driver is not > following CDP timing requirements defined by USB BC 1.2 specification > and section 3.2.4 Detection Timing CDP. > > During Primary Detection the i.MX device should turn on VDP_SRC and > IDM_SINK for a minimum of 40ms (TVDPSRC_ON). After a time of TVDPSRC_ON, > the PD is allowed to check the status of the D- line. Current > implementation is waiting between 1ms and 2ms, and certain BC 1.2 > complaint USB HUBs cannot be detected. Increase delay to 40ms allowing > enough time for primary detection. > > During secondary detection the PD is required to disable VDP_SRC and What does the "PD" mean here? > IDM_SNK, and enable VDM_SRC and IDP_SINK for at least 40ms (TVDMSRC_ON). > > Current implementation is not disabling VDP_SRC and IDM_SNK, introduce > disable sequence in imx7d_charger_secondary_detection() function. > > VDM_SRC and IDP_SINK should be enabled for at least 40ms (TVDMSRC_ON). > Increase delay allowing enough time for detection. > > Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection") I assume this one needs to go stable tree? Peter > > Signed-off-by: Breno Lima > Signed-off-by: Jun Li > --- > Changes since V1: > - Updated commit log to include commit ID fix > drivers/usb/chipidea/usbmisc_imx.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c > index 4545b23bda3f..bac0f5458cab 100644 > --- a/drivers/usb/chipidea/usbmisc_imx.c > +++ b/drivers/usb/chipidea/usbmisc_imx.c > @@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) > int val; > unsigned long flags; > > + /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */ > + spin_lock_irqsave(&usbmisc->lock, flags); > + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > + val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0; > + writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > + spin_unlock_irqrestore(&usbmisc->lock, flags); > + > + /* TVDMSRC_DIS */ > + msleep(20); > + > /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ > spin_lock_irqsave(&usbmisc->lock, flags); > val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > @@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) > usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > spin_unlock_irqrestore(&usbmisc->lock, flags); > > - usleep_range(1000, 2000); > + /* TVDMSRC_ON */ > + msleep(40); > > /* > * Per BC 1.2, check voltage of D+: > @@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) > usbmisc->base + MX7D_USB_OTG_PHY_CFG2); > spin_unlock_irqrestore(&usbmisc->lock, flags); > > - usleep_range(1000, 2000); > + /* TVDPSRC_ON */ > + msleep(40); > > /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ > val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); > -- > 2.25.1 > -- Thanks, Peter Chen _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel