Skip to content

Commit 11992b4

Browse files
Xu Yanggregkh
authored andcommitted
usb: chipidea: imx: implement workaround for ERR051725
ERR051725: USB: With the USB controller configured as device mode, Clearing the RS bit of USBCMD register fails to cause USB device to be detached Description 1. USB controller working as high speed device mode with USB gadget function enabled 2. Cable plugged into USB host 3. Use case is software-controlled detach from USB device side The expected result is device side terminations removed, increase in USB signal amplitude, USB host detect device is detached. But the issue is that the clear RS bit of USBCMD register cannot cause device detach event. Workaround - Use the below steps to detach from the host: write USBCMD.RS = 0b write CTRL2[7:6] = 01b write CTRL2[8] = 1b - As CTRL2[8] is set at detach case, so attach the steps should add clear CTRL2[8]: write USBCMD.RS = 1b write CTRL2[8] = 0b Signed-off-by: Xu Yang <[email protected]> Acked-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1a76b63 commit 11992b4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
331331
if (ci->usb_phy)
332332
schedule_work(&ci->usb_phy->chg_work);
333333
break;
334+
case CI_HDRC_CONTROLLER_PULLUP_EVENT:
335+
if (ci->role == CI_ROLE_GADGET)
336+
imx_usbmisc_pullup(data->usbmisc_data,
337+
ci->gadget.connected);
338+
break;
334339
default:
335340
break;
336341
}

drivers/usb/chipidea/usbmisc_imx.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,25 @@ static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data)
998998
return 0;
999999
}
10001000

1001+
static void usbmisc_imx7d_pullup(struct imx_usbmisc_data *data, bool on)
1002+
{
1003+
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
1004+
unsigned long flags;
1005+
u32 val;
1006+
1007+
spin_lock_irqsave(&usbmisc->lock, flags);
1008+
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
1009+
if (!on) {
1010+
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
1011+
val |= MX7D_USBNC_USB_CTRL2_OPMODE(1);
1012+
val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
1013+
} else {
1014+
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
1015+
}
1016+
writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
1017+
spin_unlock_irqrestore(&usbmisc->lock, flags);
1018+
}
1019+
10011020
static int usbmisc_imx7d_power_lost_check(struct imx_usbmisc_data *data)
10021021
{
10031022
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
@@ -1115,6 +1134,7 @@ static const struct usbmisc_ops imx7d_usbmisc_ops = {
11151134
.set_wakeup = usbmisc_imx7d_set_wakeup,
11161135
.charger_detection = imx7d_charger_detection,
11171136
.power_lost_check = usbmisc_imx7d_power_lost_check,
1137+
.pullup = usbmisc_imx7d_pullup,
11181138
.vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
11191139
};
11201140

@@ -1131,6 +1151,7 @@ static const struct usbmisc_ops imx95_usbmisc_ops = {
11311151
.set_wakeup = usbmisc_imx95_set_wakeup,
11321152
.charger_detection = imx7d_charger_detection,
11331153
.power_lost_check = usbmisc_imx7d_power_lost_check,
1154+
.pullup = usbmisc_imx7d_pullup,
11341155
.vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
11351156
};
11361157

0 commit comments

Comments
 (0)