Skip to content

Commit 1a91faf

Browse files
brenolimanxpgregkh
authored andcommitted
usb: chipidea: imx: Fix Battery Charger 1.2 CDP detection
commit c6d580d 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: <stable@vger.kernel.org> Fixes: 746f316 ("usb: chipidea: introduce imx7d USB charger detection") Signed-off-by: Breno Lima <breno.lima@nxp.com> Signed-off-by: Jun Li <jun.li@nxp.com> Link: https://lore.kernel.org/r/20210614175013.495808-1-breno.lima@nxp.com Signed-off-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 576996b commit 1a91faf

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎drivers/usb/chipidea/usbmisc_imx.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data)
686686
int val;
687687
unsigned long flags;
688688

689+
/* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */
690+
spin_lock_irqsave(&usbmisc->lock, flags);
691+
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
692+
val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0;
693+
writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
694+
spin_unlock_irqrestore(&usbmisc->lock, flags);
695+
696+
/* TVDMSRC_DIS */
697+
msleep(20);
698+
689699
/* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */
690700
spin_lock_irqsave(&usbmisc->lock, flags);
691701
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
@@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data)
695705
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
696706
spin_unlock_irqrestore(&usbmisc->lock, flags);
697707

698-
usleep_range(1000, 2000);
708+
/* TVDMSRC_ON */
709+
msleep(40);
699710

700711
/*
701712
* Per BC 1.2, check voltage of D+:
@@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data)
798809
usbmisc->base + MX7D_USB_OTG_PHY_CFG2);
799810
spin_unlock_irqrestore(&usbmisc->lock, flags);
800811

801-
usleep_range(1000, 2000);
812+
/* TVDPSRC_ON */
813+
msleep(40);
802814

803815
/* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */
804816
val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);

0 commit comments

Comments
 (0)