Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20250614125645.207732-4-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
11992b41 1a76b634

+26
+5
drivers/usb/chipidea/ci_hdrc_imx.c
··· 331 331 if (ci->usb_phy) 332 332 schedule_work(&ci->usb_phy->chg_work); 333 333 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; 334 339 default: 335 340 break; 336 341 }
+21
drivers/usb/chipidea/usbmisc_imx.c
··· 998 998 return 0; 999 999 } 1000 1000 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 + 1001 1020 static int usbmisc_imx7d_power_lost_check(struct imx_usbmisc_data *data) 1002 1021 { 1003 1022 struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev); ··· 1134 1115 .set_wakeup = usbmisc_imx7d_set_wakeup, 1135 1116 .charger_detection = imx7d_charger_detection, 1136 1117 .power_lost_check = usbmisc_imx7d_power_lost_check, 1118 + .pullup = usbmisc_imx7d_pullup, 1137 1119 .vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on, 1138 1120 }; 1139 1121 ··· 1151 1131 .set_wakeup = usbmisc_imx95_set_wakeup, 1152 1132 .charger_detection = imx7d_charger_detection, 1153 1133 .power_lost_check = usbmisc_imx7d_power_lost_check, 1134 + .pullup = usbmisc_imx7d_pullup, 1154 1135 .vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on, 1155 1136 }; 1156 1137