* [PATCH 0/3] implement workaround for ERR051725
@ 2025-06-14 12:56 Xu Yang
2025-06-14 12:56 ` [PATCH 1/3] usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event Xu Yang
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Xu Yang @ 2025-06-14 12:56 UTC (permalink / raw)
To: peter.chen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: jun.li, linux-usb, imx, linux-arm-kernel
Currently, the USB2.0 phy on some imx7d compliant Soc has below issue.
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
This will add workaround for it.
Xu Yang (3):
usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event
usb: chipidea: imx: add imx_usbmisc_pullup() hook
usb: chipidea: imx: implement workaround for ERR051725
drivers/usb/chipidea/ci_hdrc_imx.c | 5 ++++
drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
drivers/usb/chipidea/udc.c | 5 ++++
drivers/usb/chipidea/usbmisc_imx.c | 39 ++++++++++++++++++++++++++++++
include/linux/usb/chipidea.h | 1 +
5 files changed, 51 insertions(+)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event
2025-06-14 12:56 [PATCH 0/3] implement workaround for ERR051725 Xu Yang
@ 2025-06-14 12:56 ` 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
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2025-06-14 12:56 UTC (permalink / raw)
To: peter.chen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: jun.li, linux-usb, imx, linux-arm-kernel
The device controller will send CI_HDRC_CONTROLLER_PULLUP_EVENT event
when it's going to pullup or pulldown data line.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/usb/chipidea/udc.c | 5 +++++
include/linux/usb/chipidea.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 1a48e6440e6c..64a421ae0f05 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1970,6 +1970,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
else
hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
+
+ if (ci->platdata->notify_event) {
+ _gadget->connected = is_on;
+ ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_PULLUP_EVENT);
+ }
pm_runtime_put_sync(ci->dev);
return 0;
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ebdfef124b2b..e17ebeee24e3 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -72,6 +72,7 @@ struct ci_hdrc_platform_data {
#define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2
#define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3
#define CI_HDRC_CONTROLLER_VBUS_EVENT 4
+#define CI_HDRC_CONTROLLER_PULLUP_EVENT 5
int (*notify_event) (struct ci_hdrc *ci, unsigned event);
struct regulator *reg_vbus;
struct usb_otg_caps ci_otg_caps;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] usb: chipidea: imx: add imx_usbmisc_pullup() hook
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-14 12:56 ` 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-17 8:19 ` [PATCH 0/3] " Peter Chen (CIX)
3 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2025-06-14 12:56 UTC (permalink / raw)
To: peter.chen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: jun.li, linux-usb, imx, linux-arm-kernel
It's used to do other pullup related operations if needs.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
drivers/usb/chipidea/usbmisc_imx.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h
index 88b8da79d518..cb95c84d0322 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.h
+++ b/drivers/usb/chipidea/ci_hdrc_imx.h
@@ -37,5 +37,6 @@ int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data);
int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect);
int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup);
int imx_usbmisc_resume(struct imx_usbmisc_data *data, bool wakeup);
+int imx_usbmisc_pullup(struct imx_usbmisc_data *data, bool on);
#endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 118b9a68496b..9db67d6d0ec4 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -170,6 +170,9 @@ struct usbmisc_ops {
int (*charger_detection)(struct imx_usbmisc_data *data);
/* It's called when system resume from usb power lost */
int (*power_lost_check)(struct imx_usbmisc_data *data);
+ /* It's called when device controller changed pullup status */
+ void (*pullup)(struct imx_usbmisc_data *data, bool on);
+ /* It's called during suspend/resume to save power */
void (*vbus_comparator_on)(struct imx_usbmisc_data *data, bool on);
};
@@ -1225,6 +1228,21 @@ int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect)
}
EXPORT_SYMBOL_GPL(imx_usbmisc_charger_detection);
+int imx_usbmisc_pullup(struct imx_usbmisc_data *data, bool on)
+{
+ struct imx_usbmisc *usbmisc;
+
+ if (!data)
+ return 0;
+
+ usbmisc = dev_get_drvdata(data->dev);
+ if (usbmisc->ops->pullup)
+ usbmisc->ops->pullup(data, on);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(imx_usbmisc_pullup);
+
int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup)
{
struct imx_usbmisc *usbmisc;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] usb: chipidea: imx: implement workaround for ERR051725
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-14 12:56 ` [PATCH 2/3] usb: chipidea: imx: add imx_usbmisc_pullup() hook Xu Yang
@ 2025-06-14 12:56 ` Xu Yang
2025-06-18 10:40 ` Peter Chen (CIX)
2025-06-17 8:19 ` [PATCH 0/3] " Peter Chen (CIX)
3 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2025-06-14 12:56 UTC (permalink / raw)
To: peter.chen, gregkh, shawnguo, s.hauer, kernel, festevam
Cc: jun.li, linux-usb, imx, linux-arm-kernel
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>
---
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
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] implement workaround for ERR051725
2025-06-14 12:56 [PATCH 0/3] implement workaround for ERR051725 Xu Yang
` (2 preceding siblings ...)
2025-06-14 12:56 ` [PATCH 3/3] usb: chipidea: imx: implement workaround for ERR051725 Xu Yang
@ 2025-06-17 8:19 ` Peter Chen (CIX)
2025-06-18 6:06 ` Xu Yang
3 siblings, 1 reply; 9+ messages in thread
From: Peter Chen (CIX) @ 2025-06-17 8:19 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, kernel, festevam, jun.li, linux-usb,
imx, linux-arm-kernel
On 25-06-14 20:56:42, Xu Yang wrote:
> Currently, the USB2.0 phy on some imx7d compliant Soc has below issue.
>
> 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
>
> This will add workaround for it.
Is it imx7d specific PHY issue, since other i.mx SoCs which use chipidea
IP don't have such issue?
Peter
>
> Xu Yang (3):
> usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event
> usb: chipidea: imx: add imx_usbmisc_pullup() hook
> usb: chipidea: imx: implement workaround for ERR051725
>
> drivers/usb/chipidea/ci_hdrc_imx.c | 5 ++++
> drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
> drivers/usb/chipidea/udc.c | 5 ++++
> drivers/usb/chipidea/usbmisc_imx.c | 39 ++++++++++++++++++++++++++++++
> include/linux/usb/chipidea.h | 1 +
> 5 files changed, 51 insertions(+)
>
> --
> 2.34.1
>
--
Best regards,
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] implement workaround for ERR051725
2025-06-17 8:19 ` [PATCH 0/3] " Peter Chen (CIX)
@ 2025-06-18 6:06 ` Xu Yang
0 siblings, 0 replies; 9+ messages in thread
From: Xu Yang @ 2025-06-18 6:06 UTC (permalink / raw)
To: Peter Chen (CIX)
Cc: gregkh, shawnguo, s.hauer, kernel, festevam, jun.li, linux-usb,
imx, linux-arm-kernel
On Tue, Jun 17, 2025 at 04:19:45PM +0800, Peter Chen (CIX) wrote:
> On 25-06-14 20:56:42, Xu Yang wrote:
> > Currently, the USB2.0 phy on some imx7d compliant Soc has below issue.
> >
> > 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
> >
> > This will add workaround for it.
>
> Is it imx7d specific PHY issue, since other i.mx SoCs which use chipidea
> IP don't have such issue?
Only SNPS USB PHY combined with ChipIdea USB controller has such issue,
such as imx7d/8mm/93/95, if it's NXP USB PHY then no such issue, such
as imx7ulp/8ulp.
Therefore, patch #3 add ".pullup = usbmisc_imx7d_pullup" for imx7d and
imx95.
Thanks,
Xu Yang
>
> Peter
> >
> > Xu Yang (3):
> > usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event
> > usb: chipidea: imx: add imx_usbmisc_pullup() hook
> > usb: chipidea: imx: implement workaround for ERR051725
> >
> > drivers/usb/chipidea/ci_hdrc_imx.c | 5 ++++
> > drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
> > drivers/usb/chipidea/udc.c | 5 ++++
> > drivers/usb/chipidea/usbmisc_imx.c | 39 ++++++++++++++++++++++++++++++
> > include/linux/usb/chipidea.h | 1 +
> > 5 files changed, 51 insertions(+)
> >
> > --
> > 2.34.1
> >
>
> --
>
> Best regards,
> Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] usb: chipidea: udc: add CI_HDRC_CONTROLLER_PULLUP_EVENT event
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)
0 siblings, 0 replies; 9+ messages in thread
From: Peter Chen (CIX) @ 2025-06-18 10:35 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, kernel, festevam, jun.li, linux-usb,
imx, linux-arm-kernel
On 25-06-14 20:56:43, Xu Yang wrote:
> The device controller will send CI_HDRC_CONTROLLER_PULLUP_EVENT event
> when it's going to pullup or pulldown data line.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Peter
> ---
> drivers/usb/chipidea/udc.c | 5 +++++
> include/linux/usb/chipidea.h | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 1a48e6440e6c..64a421ae0f05 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1970,6 +1970,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
> hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
> else
> hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
> +
> + if (ci->platdata->notify_event) {
> + _gadget->connected = is_on;
> + ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_PULLUP_EVENT);
> + }
> pm_runtime_put_sync(ci->dev);
>
> return 0;
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index ebdfef124b2b..e17ebeee24e3 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -72,6 +72,7 @@ struct ci_hdrc_platform_data {
> #define CI_HDRC_IMX_HSIC_ACTIVE_EVENT 2
> #define CI_HDRC_IMX_HSIC_SUSPEND_EVENT 3
> #define CI_HDRC_CONTROLLER_VBUS_EVENT 4
> +#define CI_HDRC_CONTROLLER_PULLUP_EVENT 5
> int (*notify_event) (struct ci_hdrc *ci, unsigned event);
> struct regulator *reg_vbus;
> struct usb_otg_caps ci_otg_caps;
> --
> 2.34.1
>
--
Best regards,
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] usb: chipidea: imx: add imx_usbmisc_pullup() hook
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)
0 siblings, 0 replies; 9+ messages in thread
From: Peter Chen (CIX) @ 2025-06-18 10:36 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, kernel, festevam, jun.li, linux-usb,
imx, linux-arm-kernel
On 25-06-14 20:56:44, Xu Yang wrote:
> It's used to do other pullup related operations if needs.
>
> 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.h | 1 +
> drivers/usb/chipidea/usbmisc_imx.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h
> index 88b8da79d518..cb95c84d0322 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.h
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.h
> @@ -37,5 +37,6 @@ int imx_usbmisc_hsic_set_connect(struct imx_usbmisc_data *data);
> int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect);
> int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup);
> int imx_usbmisc_resume(struct imx_usbmisc_data *data, bool wakeup);
> +int imx_usbmisc_pullup(struct imx_usbmisc_data *data, bool on);
>
> #endif /* __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_H */
> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
> index 118b9a68496b..9db67d6d0ec4 100644
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -170,6 +170,9 @@ struct usbmisc_ops {
> int (*charger_detection)(struct imx_usbmisc_data *data);
> /* It's called when system resume from usb power lost */
> int (*power_lost_check)(struct imx_usbmisc_data *data);
> + /* It's called when device controller changed pullup status */
> + void (*pullup)(struct imx_usbmisc_data *data, bool on);
> + /* It's called during suspend/resume to save power */
> void (*vbus_comparator_on)(struct imx_usbmisc_data *data, bool on);
> };
>
> @@ -1225,6 +1228,21 @@ int imx_usbmisc_charger_detection(struct imx_usbmisc_data *data, bool connect)
> }
> EXPORT_SYMBOL_GPL(imx_usbmisc_charger_detection);
>
> +int imx_usbmisc_pullup(struct imx_usbmisc_data *data, bool on)
> +{
> + struct imx_usbmisc *usbmisc;
> +
> + if (!data)
> + return 0;
> +
> + usbmisc = dev_get_drvdata(data->dev);
> + if (usbmisc->ops->pullup)
> + usbmisc->ops->pullup(data, on);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(imx_usbmisc_pullup);
> +
> int imx_usbmisc_suspend(struct imx_usbmisc_data *data, bool wakeup)
> {
> struct imx_usbmisc *usbmisc;
> --
> 2.34.1
>
--
Best regards,
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] usb: chipidea: imx: implement workaround for ERR051725
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)
0 siblings, 0 replies; 9+ messages in thread
From: Peter Chen (CIX) @ 2025-06-18 10:40 UTC (permalink / raw)
To: Xu Yang
Cc: gregkh, shawnguo, s.hauer, kernel, festevam, jun.li, linux-usb,
imx, linux-arm-kernel
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-06-18 12:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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)
2025-06-17 8:19 ` [PATCH 0/3] " Peter Chen (CIX)
2025-06-18 6:06 ` Xu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).