Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3930425pxj; Mon, 21 Jun 2021 09:36:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+g6fBy5ZDI6Ydvc0LSriTh/J5Z9n6CX4kBDNDGo2cPcu30ISHzkjiE41EQMDGWXhVb8Uf X-Received: by 2002:a50:fe8d:: with SMTP id d13mr22624618edt.14.1624293385702; Mon, 21 Jun 2021 09:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293385; cv=none; d=google.com; s=arc-20160816; b=YSDEeZpyX82gUuggD+1XQNS52cd/HV7/a9LWUTGxn7jA+gCbIeEgBRdoOTfH7jRZki AJgGylXJZm143A2CtbmxSvSUpHygpiHS++ZUab8VIMPyMniap4YW5IkDWvkrkgjLwny3 clABSLgSh7fMSRV9Bh3Zj/IUKPx3Rke3Q7nKsw7PQm78rMNrt5pl0CEYcja2ERJQ9XdW 0ihXZHq8KPSxQP21KKxZgZpJPHQUmrk2eGd1oOVH92j0UHeR98Nmlkii661hsNnyeC2z 4nEVQY3fCvrxW+ViNgoT5XISG+15Pqwp5WFWRjxsJfdu835Jv+M7l90hNDa/Tc8hxK6M 37hg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ndk8wQrRXvZqhV10rnPbLydf5Ur/aidK6Ki42MUgbpE=; b=fSCJDDGms/uKzVOBcWpKWd5E3invBfynyZBR9w6li89AUrkfHlnJO4mhsrosZ5TRO/ 2Bbhe18su3Jj8BVH2Zf8Pzr4s2YMtcDpUYcUhrRkT9DOv2XM+/2v5QheziHCj+1TGun1 pa/iS5RQZQ1s9jhIhqtHe5gxnR5OUZtagWQwq/kmk1YHJ+JuzF8BGN70vhUAmeONWq24 ggriUF7QorE1hPj1pBKc/Apy+3pVW1GcfUY3dXAveVCGtNyIINfqTSExsWabemjFScZp u8IjF6df4KbbO3PE6PBGhd5RyO07p2gqXIP2liJ/fhiLhzHivN3/ULvJ9jS9XMDIYWVa 9fyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lgm4c3Gg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si17038771edw.44.2021.06.21.09.36.03; Mon, 21 Jun 2021 09:36:25 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lgm4c3Gg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbhFUQeE (ORCPT + 99 others); Mon, 21 Jun 2021 12:34:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:49174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbhFUQbG (ORCPT ); Mon, 21 Jun 2021 12:31:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1B9861352; Mon, 21 Jun 2021 16:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292717; bh=7D5+Z7yqnTuz20Rw2xK/398Z00a3m+DNXkDvvgn3+nQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lgm4c3GgHNIji1LnnBIgYqKF6ODHLYW1075kOl4KTZR2s9u1MBhb3O3VpbNtVFdk6 6Rk6dWOVdday2FNEm8PAxOcHy4rWTBrLXgcI0ael8KFsoT41O7JVsBT90C0s+Rpbvm J1ZGCn2TvOwrJtZWRVNdsxw7OWEhHySoxqWOYe7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Breno Lima , Jun Li , Peter Chen Subject: [PATCH 5.10 103/146] usb: chipidea: imx: Fix Battery Charger 1.2 CDP detection Date: Mon, 21 Jun 2021 18:15:33 +0200 Message-Id: <20210621154917.797476453@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Breno Lima commit c6d580d96f140596d69220f60ce0cfbea4ee5c0f upstream. 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 i.MX 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 i.MX is required to disable VDP_SRC and 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. Cc: Fixes: 746f316b753a ("usb: chipidea: introduce imx7d USB charger detection") Signed-off-by: Breno Lima Signed-off-by: Jun Li Link: https://lore.kernel.org/r/20210614175013.495808-1-breno.lima@nxp.com Signed-off-by: Peter Chen Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/usbmisc_imx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detec 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_detec 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_detecti 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);