From: "Peter Chen (CIX)" <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org,
s.hauer@pengutronix.d, kernel@pengutronix.de, festevam@gmail.com,
jun.li@nxp.com, linux-usb@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/3] usb: chipidea: imx: implement workaround for ERR051725
Date: Wed, 18 Jun 2025 18:40:13 +0800 [thread overview]
Message-ID: <20250618104013.GD34284@nchen-desktop> (raw)
In-Reply-To: <20250614125645.207732-4-xu.yang_2@nxp.com>
On 25-06-14 20:56:45, Xu Yang wrote:
> 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>
Peter
> ---
> drivers/usb/chipidea/ci_hdrc_imx.c | 5 +++++
> drivers/usb/chipidea/usbmisc_imx.c | 21 +++++++++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 780f4d151345..79e466e17788 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -331,6 +331,11 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
> if (ci->usb_phy)
> schedule_work(&ci->usb_phy->chg_work);
> break;
> + case CI_HDRC_CONTROLLER_PULLUP_EVENT:
> + if (ci->role == CI_ROLE_GADGET)
> + imx_usbmisc_pullup(data->usbmisc_data,
> + ci->gadget.connected);
> + break;
> default:
> break;
> }
> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
> index 9db67d6d0ec4..415d3ba2e9ad 100644
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -998,6 +998,25 @@ static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data)
> return 0;
> }
>
> +static void usbmisc_imx7d_pullup(struct imx_usbmisc_data *data, bool on)
> +{
> + struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
> + unsigned long flags;
> + u32 val;
> +
> + spin_lock_irqsave(&usbmisc->lock, flags);
> + val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
> + if (!on) {
> + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
> + val |= MX7D_USBNC_USB_CTRL2_OPMODE(1);
> + val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
> + } else {
> + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
> + }
> + writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
> + spin_unlock_irqrestore(&usbmisc->lock, flags);
> +}
> +
> static int usbmisc_imx7d_power_lost_check(struct imx_usbmisc_data *data)
> {
> struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
> @@ -1115,6 +1134,7 @@ static const struct usbmisc_ops imx7d_usbmisc_ops = {
> .set_wakeup = usbmisc_imx7d_set_wakeup,
> .charger_detection = imx7d_charger_detection,
> .power_lost_check = usbmisc_imx7d_power_lost_check,
> + .pullup = usbmisc_imx7d_pullup,
> .vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
> };
>
> @@ -1131,6 +1151,7 @@ static const struct usbmisc_ops imx95_usbmisc_ops = {
> .set_wakeup = usbmisc_imx95_set_wakeup,
> .charger_detection = imx7d_charger_detection,
> .power_lost_check = usbmisc_imx7d_power_lost_check,
> + .pullup = usbmisc_imx7d_pullup,
> .vbus_comparator_on = usbmisc_imx7d_vbus_comparator_on,
> };
>
> --
> 2.34.1
>
--
Best regards,
Peter
next prev parent reply other threads:[~2025-06-18 12:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-14 12:56 [PATCH 0/3] implement workaround for ERR051725 Xu Yang
2025-06-14 12:56 ` [PATCH 1/3] usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event Xu Yang
2025-06-18 10:35 ` Peter Chen (CIX)
2025-06-14 12:56 ` [PATCH 2/3] usb: chipidea: imx: add imx_usbmisc_pullup() hook Xu Yang
2025-06-18 10:36 ` Peter Chen (CIX)
2025-06-14 12:56 ` [PATCH 3/3] usb: chipidea: imx: implement workaround for ERR051725 Xu Yang
2025-06-18 10:40 ` Peter Chen (CIX) [this message]
2025-06-17 8:19 ` [PATCH 0/3] " Peter Chen (CIX)
2025-06-18 6:06 ` Xu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250618104013.GD34284@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=s.hauer@pengutronix.d \
--cc=shawnguo@kernel.org \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox