Skip to contentSkip to conversation

USB runtime PM issues on i.MX6ULL

PATCH Francesco Dolcini 4 participants 14 messages Oct 28, 2022 – Jan 5, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello all,

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

Focusing on the second interface, USB Host only, what I do experience is the following:

- if there is no USB HUB connected and no device connected at boot, any USB device hotplugged is not working, ci_runtime_suspend is called and it never resume.
- if there is a HUB in between it somehow works, however I have a continuos runtime powermanagement reset loop every 2 seconds

       [ 1026.146360] ci_hdrc ci_hdrc.1: at ci_runtime_suspend
       [ 1026.164725] ci_hdrc ci_hdrc.1: at ci_controller_resume
       [ 1026.487844] usb 1-1: reset high-speed USB device number 2 using ci_hdrc
       [ 1028.326789] ci_hdrc ci_hdrc.1: at ci_runtime_suspend
       [ 1028.335378] ci_hdrc ci_hdrc.1: at ci_controller_resume
       [ 1028.657853] usb 1-1: reset high-speed USB device number 2 using ci_hdrc

I was able to have it fully working disabling the runtime power management in the chipidea driver or using sysfs (echo on > /sys/.../power/control).

drivers/usb/chipidea/ci_hdrc_imx.c +1 -1
@@ -56,7 +56,7 @@ static const struct ci_hdrc_imx_platform_flag imx6sx_usb_data = {
 };
 
 static const struct ci_hdrc_imx_platform_flag imx6ul_usb_data = {
-       .flags = CI_HDRC_SUPPORTS_RUNTIME_PM |
+       .flags =
 

I was digging even more into the topic and I found out that what is happening
is that mxs_phy_disconnect_line() is called. I than tried to remove the MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS flag.

drivers/usb/phy/phy-mxs-usb.c +1 -1
@@ -178,7 +178,7 @@ static const struct mxs_phy_data imx6sx_phy_data = {
 };
 
 static const struct mxs_phy_data imx6ul_phy_data = {
-       .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+       /*.flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,*/
 };
 

This commit from NXP downstream kernel seems somehow related
https://github.com/nxp-imx/linux-imx/commit/89ec73836a9b1347743e406d62dd446dc4365db3
however it builds on other commits that allow to communicate the actual mode to the USB PHY driver and prevent mxs_phy_disconnect_line() to be called for the USB host case.

With that the situation is way better, but while without CI_HDRC_SUPPORTS_RUNTIME_PM it works perfectly, without MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS it does not really work smootly in case there is a hub in between (~20% of the time the device is not enumerated after plugging it in).

When it does not work I see that after plugging in a device runtime resume function is called, but after that the device is not enumerated on the USB bus. It looks like something else is missing.

It seems like having a pure USB Host interface without having a way to re-read the VBUS is not really supported in SW at the moment, am I wrong? Any idea?

One last comment, even the USB dual role port is not working smoothly, however I have not investigated this specific case that much because disabling runtime pm solves everything also in that case.

Francesco

#1 lore raw

Hi Francesco,

Quoted 15 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Friday, October 28, 2022 8:32 PM
To: Peter Chen <[email protected]>; [email protected]; Jun Li <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: USB runtime PM issues on i.MX6ULL

Hello all,

Quoted 8 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second
one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Li Jun

Quoted 80 lines

Focusing on the second interface, USB Host only, what I do experience is the
following:

- if there is no USB HUB connected and no device connected at boot, any
USB
device hotplugged is not working, ci_runtime_suspend is called and it
never
resume.
- if there is a HUB in between it somehow works, however I have a continuos runtime powermanagement reset loop every 2 seconds

       [ 1026.146360] ci_hdrc ci_hdrc.1: at ci_runtime_suspend
       [ 1026.164725] ci_hdrc ci_hdrc.1: at ci_controller_resume
       [ 1026.487844] usb 1-1: reset high-speed USB device number 2 using
ci_hdrc
       [ 1028.326789] ci_hdrc ci_hdrc.1: at ci_runtime_suspend
       [ 1028.335378] ci_hdrc ci_hdrc.1: at ci_controller_resume
       [ 1028.657853] usb 1-1: reset high-speed USB device number 2 using

ci_hdrc

I was able to have it fully working disabling the runtime power management in
the chipidea driver or using sysfs (echo on > /sys/.../power/control).

drivers/usb/chipidea/ci_hdrc_imx.c +1 -1
@@ -56,7 +56,7 @@ static const struct ci_hdrc_imx_platform_flag
 imx6sx_usb_data = {
 };
 
 static const struct ci_hdrc_imx_platform_flag imx6ul_usb_data = {
-       .flags = CI_HDRC_SUPPORTS_RUNTIME_PM |
+       .flags =
 

I was digging even more into the topic and I found out that what is happening is that mxs_phy_disconnect_line() is called. I than tried to remove the MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS flag.

drivers/usb/phy/phy-mxs-usb.c +1 -1
@@ -178,7 +178,7 @@ static const struct mxs_phy_data imx6sx_phy_data = {
 };
 
 static const struct mxs_phy_data imx6ul_phy_data = {
-       .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+       /*.flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,*/
 };
 

This commit from NXP downstream kernel seems somehow related
https://github.com/nxp-imx/linux-imx/commit/89ec73836a9b1347743e406d62d
d446dc4365db3
however it builds on other commits that allow to communicate the actual mode to
the USB PHY driver and prevent mxs_phy_disconnect_line() to be called for the
USB host case.

With that the situation is way better, but while without CI_HDRC_SUPPORTS_RUNTIME_PM it works perfectly, without MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS it does not really work smootly in case there is a hub in between (~20% of the time the device is not enumerated after plugging it in).

When it does not work I see that after plugging in a device runtime resume function is called, but after that the device is not enumerated on the USB bus.
It looks like something else is missing.

It seems like having a pure USB Host interface without having a way to re-read the VBUS is not really supported in SW at the moment, am I wrong? Any idea?

One last comment, even the USB dual role port is not working smoothly, however I have not investigated this specific case that much because disabling runtime pm
solves everything also in that case.

Francesco

#2 lore raw

Hello Li Jun,

Quoted 19 lines · Jun Li (OSS)
Quoted 19 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Friday, October 28, 2022 8:32 PM
To: Peter Chen <[email protected]>; [email protected]; Jun Li <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: USB runtime PM issues on i.MX6ULL

Hello all,

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

Quoted 8 lines
Quoted 4 lines

The HW design has 2 USB interface, the first one is dual-role, while the second
one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

Francesco

#3 lore raw
Quoted 43 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Monday, October 31, 2022 9:54 PM
To: Jun Li (OSS) <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Hello Li Jun,

Quoted 24 lines · Jun Li (OSS)
Quoted 23 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Friday, October 28, 2022 8:32 PM
To: Peter Chen <[email protected]>; [email protected]; Jun Li <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: USB runtime PM issues on i.MX6ULL

Hello all,

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

Quoted 6 lines
Quoted 3 lines

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly, so you need change your HW to meet this: for Host only port, you have to connect USB_OTG2_VBUS to a valid VBUS and make it always present for simple. You can do some quick HW change to prove this.

Li Jun

Quoted 2 lines

Francesco

#4 lore raw

Hello Jun Li,

Quoted 14 lines · Jun Li
Quoted 14 lines · Jun Li (OSS)
Quoted 12 lines
Quoted 8 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected if unused
- downstream NXP kernel seems to work fine ("seems" since we do have some patches there, so I could be wrong)
- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Quoted 3 lines

your HW to meet this: for Host only port, you have to connect USB_OTG2_VBUS to a valid VBUS and make it always present for simple.
You can do some quick HW change to prove this.

We have no way to change the HW in reality, therefore doing a one off test would be pretty much irrelevant.

Said all of that, given what you wrote, I feel like having a specific dts property in the chipidea driver to disable runtime pm might be the way to go.

Something like ci,disable-runtime-pm? I know the DTS is supposed to describe the HW, so maybe a different property name would be required.

What do you think about this?

Francesco

#5 lore raw
Quoted 34 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Wednesday, November 2, 2022 3:51 AM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Hello Jun Li,

Quoted 14 lines · Jun Li
Quoted 14 lines · Jun Li (OSS)
Quoted 12 lines
Quoted 8 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected if unused

I think "unused" here means you do not need/enable the port at all.

Quoted 2 lines

- downstream NXP kernel seems to work fine ("seems" since we do have some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Quoted 6 lines
Quoted 4 lines

your HW to meet this: for Host only port, you have to connect USB_OTG2_VBUS to a valid VBUS and make it always present for simple. You can do some quick HW change to prove this.

We have no way to change the HW in reality, therefore doing a one off test would be pretty much irrelevant.

My intention of doing this HW rework is just for debug.

Quoted 9 lines

Said all of that, given what you wrote, I feel like having a specific dts property in the chipidea driver to disable runtime pm might be the way to go.

Something like ci,disable-runtime-pm? I know the DTS is supposed to describe the HW, so maybe a different property name would be required.

What do you think about this?

This is the last step to consider, we cannot go this way before root cause identified.

Thanks
Li Jun

Quoted 2 lines

Francesco

#6 lore raw
Quoted 73 lines

-----Original Message-----
From: Jun Li <[email protected]>
Sent: Wednesday, November 2, 2022 5:45 PM
To: Francesco Dolcini <[email protected]>
Cc: Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: RE: USB runtime PM issues on i.MX6ULL

Quoted 10 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Wednesday, November 2, 2022 3:51 AM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>;

dl-linux-imx

Quoted 22 lines

<[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Hello Jun Li,

Quoted 14 lines · Jun Li
Quoted 14 lines · Jun Li (OSS)
Quoted 12 lines
Quoted 8 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected if unused

I think "unused" here means you do not need/enable the port at all.

Quoted 2 lines

- downstream NXP kernel seems to work fine ("seems" since we do have some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Quoted 5 lines

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your HW?

Li Jun

#7 lore raw
Quoted 24 lines · Jun Li
Quoted 24 lines
Quoted 23 lines · Jun Li
Quoted 14 lines
Quoted 14 lines · Jun Li (OSS)
Quoted 12 lines
Quoted 8 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read the VBUS (USB_OTG2_VBUS is not really connected, there is just a capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected if unused

Quoted 8 lines
Quoted 8 lines

I think "unused" here means you do not need/enable the port at all.

Quoted 2 lines

- downstream NXP kernel seems to work fine ("seems" since we do have some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your HW?

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Francesco

#8 lore raw
Quoted 66 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Thursday, November 3, 2022 1:59 AM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Quoted 8 lines · Jun Li
Quoted 8 lines
Quoted 8 lines · Jun Li
Quoted 7 lines
Quoted 7 lines · Jun Li (OSS)
Quoted 6 lines
Quoted 6 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

VBUS (USB_OTG2_VBUS is not really connected, there is just

a

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected if unused

Quoted 8 lines
Quoted 8 lines

I think "unused" here means you do not need/enable the port at all.

Quoted 2 lines

- downstream NXP kernel seems to work fine ("seems" since we do have some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 10 lines
Quoted 9 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Quoted 8 lines
Quoted 1 line

Could you please check the voltage of pad of VDD_USB_CAP on your HW?

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Then the HW design should be fine.
I need find time to try the upstream kernel on my iMX6ULL board to check this.

Li Jun

Quoted 2 lines

Francesco

#9 lore raw

Hi Francesco,

Quoted 89 lines

-----Original Message-----
From: Jun Li
Sent: Thursday, November 3, 2022 7:53 PM
To: Francesco Dolcini <[email protected]>
Cc: Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: RE: USB runtime PM issues on i.MX6ULL

Quoted 22 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Thursday, November 3, 2022 1:59 AM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Quoted 6 lines · Jun Li
Quoted 6 lines
Quoted 6 lines · Jun Li
Quoted 5 lines
Quoted 5 lines · Jun Li (OSS)
Quoted 4 lines
Quoted 4 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

Quoted 20 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VBUS (USB_OTG2_VBUS is not really connected, there is just

a

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected

if

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

unused

I think "unused" here means you do not need/enable the port at all.

Quoted 1 line

- downstream NXP kernel seems to work fine ("seems" since we do

have

Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your HW?

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

Quoted 7 lines
Quoted 3 lines

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Then the HW design should be fine.
I need find time to try the upstream kernel on my iMX6ULL board to check this.

My iMX6ULL EVK board cannot reproduce this issue with upstream kernel.

Could you try to set the bits [7,3] of 0x020c8200(for 2nd USB controller OTG2) to be value like 0x1000FC? This may be done at your bootloader(uboot), so make sure those targets bits are set before doing your test, or doing this with below change(not compiled or tested):

drivers/usb/phy/phy-mxs-usb.c +8 -0
index d2836ef5d15c..e390ef534a7c 100644
@@ -89,6 +89,9 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4
@@ -288,6 +291,11 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
        if (ret)
                goto disable_pll;
 
+       if (mxs_phy->regmap_anatop && (mxs_phy->port_id == 1))
+               regmap_write(mxs_phy->regmap_anatop,
+                            ANADIG_USB2_VBUS_DET_SET,
+                            ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE);
+
        /* Power up the PHY */
        writel(0, base + HW_USBPHY_PWD);
 
Quoted 4 lines

Li Jun

Quoted 2 lines

Francesco

#10 lore raw
Quoted 92 lines · Jun Li
Quoted 62 lines

From: Jun Li
Sent: Thursday, November 3, 2022 7:53 PM

Quoted 9 lines

From: Francesco Dolcini <[email protected]>
Sent: Thursday, November 3, 2022 1:59 AM

Quoted 6 lines · Jun Li
Quoted 6 lines
Quoted 6 lines · Jun Li
Quoted 5 lines
Quoted 5 lines · Jun Li (OSS)
Quoted 4 lines
Quoted 4 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

Quoted 20 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VBUS (USB_OTG2_VBUS is not really connected, there is just

a

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand correctly.

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS disconnected

if

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

unused

I think "unused" here means you do not need/enable the port at all.

Quoted 1 line

- downstream NXP kernel seems to work fine ("seems" since we do

have

Quoted 24 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is: only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your HW?

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

Quoted 7 lines
Quoted 3 lines

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Then the HW design should be fine.
I need find time to try the upstream kernel on my iMX6ULL board to check this.

My iMX6ULL EVK board cannot reproduce this issue with upstream kernel.

Could you try to set the bits [7,3] of 0x020c8200(for 2nd USB controller OTG2) to be value like 0x1000FC? This may be done at your bootloader(uboot), so make sure those targets bits are set before doing your test, or doing this with below change(not compiled or tested):

drivers/usb/phy/phy-mxs-usb.c +3 -0
index d2836ef5d15c..e390ef534a7c 100644
@@ -89,6 +89,9 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4

drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) · line 300

Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +5 -0
@@ -288,6 +291,11 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
        if (ret)
                goto disable_pll;
 
+       if (mxs_phy->regmap_anatop && (mxs_phy->port_id == 1))
+               regmap_write(mxs_phy->regmap_anatop,
+                            ANADIG_USB2_VBUS_DET_SET,
+                            ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE);
+
        /* Power up the PHY */
        writel(0, base + HW_USBPHY_PWD);

Hello,
I tested your patch and it does not work. I therefore tested a slightly improved version that really ensure the right register value is written.

[    8.408564] port=0 reg=0x200 val=0x1000fc
[    8.440235] port=1 reg=0x204 val=0x1000fc

but it does not work never the less. Unfortunately bits 7-3 are not documented, so I was not able to do much more.

drivers/usb/phy/phy-mxs-usb.c +14 -0
index d2836ef5d15c..3ff5489d679e 100644
@@ -89,6 +89,10 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB1_VBUS_DET_SET               0x200
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4
@@ -309,6 +313,7 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
                writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
 
        if (mxs_phy->regmap_anatop) {
+               unsigned int val;
                unsigned int reg = mxs_phy->port_id ?
                        ANADIG_USB1_CHRG_DETECT_SET :
                        ANADIG_USB2_CHRG_DETECT_SET;
@@ -319,6 +324,15 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
                regmap_write(mxs_phy->regmap_anatop, reg,
                             ANADIG_USB1_CHRG_DETECT_EN_B |
                             ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
+
+               reg = mxs_phy->port_id ?
+                       ANADIG_USB2_VBUS_DET_SET :
+                       ANADIG_USB1_VBUS_DET_SET;
+
+               regmap_set_bits(mxs_phy->regmap_anatop, reg,
+                            ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE);
+               regmap_read(mxs_phy->regmap_anatop, reg, &val);
+               printk("port=%d reg=0x%x val=0x%x\n", mxs_phy->port_id, reg, val);
        }
 
        mxs_phy_tx_init(mxs_phy);
#11 lore raw
Quoted 169 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Monday, December 26, 2022 11:45 PM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>; Xu Yang <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Quoted 24 lines · Jun Li
Quoted 24 lines

From: Jun Li
Sent: Thursday, November 3, 2022 7:53 PM

Quoted 22 lines

From: Francesco Dolcini <[email protected]>
Sent: Thursday, November 3, 2022 1:59 AM On Wed, Nov 02, 2022 at

Quoted 9 lines · Jun Li
Quoted 9 lines
Quoted 9 lines · Jun Li
Quoted 8 lines
Quoted 8 lines · Jun Li (OSS)
Quoted 7 lines
Quoted 7 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VBUS (USB_OTG2_VBUS is not really connected, there is just

a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand

correctly.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS
disconnected

if

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

unused

I think "unused" here means you do not need/enable the port at

all.

Quoted 17 lines
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- downstream NXP kernel seems to work fine ("seems" since
we do

have

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is:
only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your

HW?

Quoted 35 lines
Quoted 11 lines
Quoted 7 lines

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Then the HW design should be fine.
I need find time to try the upstream kernel on my iMX6ULL board to check this.

My iMX6ULL EVK board cannot reproduce this issue with upstream kernel.

Could you try to set the bits [7,3] of 0x020c8200(for 2nd USB controller OTG2) to be value like 0x1000FC? This may be done at your bootloader(uboot), so make sure those targets bits are set before doing your test, or doing this with below change(not compiled or tested):

(quoted diff) +0 -0

b/drivers/usb/phy/phy-mxs-usb.c index d2836ef5d15c..e390ef534a7c 100644

drivers/usb/phy/phy-mxs-usb.c +3 -0
@@ -89,6 +89,9 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4

drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) · line 300

Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +5 -0
@@ -288,6 +291,11 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
        if (ret)
                goto disable_pll;
 
+       if (mxs_phy->regmap_anatop && (mxs_phy->port_id == 1))
+               regmap_write(mxs_phy->regmap_anatop,
+                            ANADIG_USB2_VBUS_DET_SET,
+                            ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE);
+
        /* Power up the PHY */
        writel(0, base + HW_USBPHY_PWD);

Hello,
I tested your patch and it does not work. I therefore tested a slightly improved version that really ensure the right register value is written.

[    8.408564] port=0 reg=0x200 val=0x1000fc
[    8.440235] port=1 reg=0x204 val=0x1000fc

but it does not work never the less. Unfortunately bits 7-3 are not documented, so I was not able to do much more.

(quoted diff) +0 -0

b/drivers/usb/phy/phy-mxs-usb.c index d2836ef5d15c..3ff5489d679e 100644

drivers/usb/phy/phy-mxs-usb.c +5 -0
@@ -89,6 +89,10 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB1_VBUS_DET_SET               0x200
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4
@@ -309,6 +313,7 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
                writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
 
        if (mxs_phy->regmap_anatop) {
+               unsigned int val;
                unsigned int reg = mxs_phy->port_id ?
                        ANADIG_USB1_CHRG_DETECT_SET :
                        ANADIG_USB2_CHRG_DETECT_SET; @@ -319,6 +324,15 @@

static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)

                regmap_write(mxs_phy->regmap_anatop, reg,
                             ANADIG_USB1_CHRG_DETECT_EN_B |
                             ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
drivers/usb/phy/phy-mxs-usb.c +3 -0
+
+               reg = mxs_phy->port_id ?
+                       ANADIG_USB2_VBUS_DET_SET :

drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) · line 338

Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +7 -0
+                       ANADIG_USB1_VBUS_DET_SET;
+
+               regmap_set_bits(mxs_phy->regmap_anatop, reg,
+                            ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE);
+               regmap_read(mxs_phy->regmap_anatop, reg, &val);
+               printk("port=%d reg=0x%x val=0x%x\n", mxs_phy->port_id,
+ reg, val);
        }
 
        mxs_phy_tx_init(mxs_phy);

Thanks for try those, those bits are for vbus valid override, You can verify if the override real works by checking the OTGSC Registers(a few bits to show the BSV/ASV/AVV) via the debugfs /sys/kernel/debug/usb/ci_hdrc.1/registers.

echo on > /sys/bus/platform/devices/ci_hdrc.1/power/control cat /sys/kernel/debug/usb/ci_hdrc.1/registers

if the BSV/ASV/AVV are all set to be 1, means it works.

Enable runtime PM back:
echo auto > /sys/bus/platform/devices/ci_hdrc.1/power/control then do your issue test.

if this cannot work for your HW, I need a similar HW to reproduce the issue for further debug.

BTW, how is __mxs_phy_disconnect_line() impacting this issue result on your HW? If not called, then the direct plug usb device to the OTG2 port can work, but adding an external hub between still cannot work?

Li Jun

#12 lore raw
Quoted 183 lines · Jun Li
Quoted 167 lines

-----Original Message-----
From: Francesco Dolcini <[email protected]>
Sent: Monday, December 26, 2022 11:45 PM
To: Jun Li <[email protected]>
Cc: Francesco Dolcini <[email protected]>; Jun Li (OSS) <[email protected]>; Peter Chen <[email protected]>; [email protected]; Greg Kroah-Hartman <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Felipe Balbi <[email protected]>; [email protected]; Francesco Dolcini <[email protected]>; Xu Yang <[email protected]>
Subject: Re: USB runtime PM issues on i.MX6ULL

Quoted 24 lines · Jun Li
Quoted 24 lines

From: Jun Li
Sent: Thursday, November 3, 2022 7:53 PM

Quoted 22 lines

From: Francesco Dolcini <[email protected]>
Sent: Thursday, November 3, 2022 1:59 AM On Wed, Nov 02, 2022 at

Quoted 9 lines · Jun Li
Quoted 9 lines
Quoted 9 lines · Jun Li
Quoted 8 lines
Quoted 8 lines · Jun Li (OSS)
Quoted 7 lines
Quoted 7 lines

I am debugging some unexpected USB behavior on a i.MX6ULL SOC, chipidea controller ("fsl,imx6ul-usb") and a fsl mxs usbphy ("fsl,imx6ul-usbphy").

The HW design has 2 USB interface, the first one is dual-role, while the second one is a host port with NO way to re-read

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VBUS (USB_OTG2_VBUS is not really connected, there is just

a

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

capacitor to GND).

How is your USB_OTG1_VBUS status? Can you try to make your USB_OTG1_VBUS pad has a valid VBUS voltage, then run your Host only port test with runtime PM enabled?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

USB_OTG1_VBUS is tied to GND the same way as USB_OTG2_VBUS, not really straightforward to do such a test.

iMX6ULL need at least one valid VBUS(either from OTG1 or OTG2) as input to power the internal USB LDO if I understand

correctly.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This surprise me a little bit, since
- the i.MX6ULL datasheet prescribe to keep the VBUS
disconnected

if

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

unused

I think "unused" here means you do not need/enable the port at

all.

Quoted 17 lines
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- downstream NXP kernel seems to work fine ("seems" since
we do

have

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

some patches there, so I could be wrong)

What do you mean by " downstream NXP kernel seems to work fine"? The downstream kernel can work on your HW? But upstream kernel driver does not?

Correct, NXP downstream kernel is working fine, upstream kernel requires runtime PM disabled to work correctly.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

- disabling runtime pm on upstream Linux kernel make it works perfectly, so there is a way in SW to have this HW configuration working.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Again I want to make sure the both VBUS pads(OTG1 and OTG2) voltage are always at 0v on your HW, can you double check and confirm? I ask this again because such situation should cause the USB port Cannot work at any cases, but your current status is:
only low power wakeup cannot work.

Could you please check the voltage of pad of VDD_USB_CAP on your

HW?

Quoted 35 lines
Quoted 11 lines
Quoted 7 lines

I was about to clarify you this point, it's important and I forgot about it, sorry about that!

VDD_USB_CAP in our design is connected to a 3.0V external LDO, voltage on both VBUS pads is 0V (FYI: this specific hardware design was validated by NXP hardware engineers).

Then the HW design should be fine.
I need find time to try the upstream kernel on my iMX6ULL board to check this.

My iMX6ULL EVK board cannot reproduce this issue with upstream kernel.

Could you try to set the bits [7,3] of 0x020c8200(for 2nd USB controller OTG2) to be value like 0x1000FC? This may be done at your bootloader(uboot), so make sure those targets bits are set before doing your test, or doing this with below change(not compiled or tested):

(quoted diff) +0 -0

b/drivers/usb/phy/phy-mxs-usb.c index d2836ef5d15c..e390ef534a7c 100644

drivers/usb/phy/phy-mxs-usb.c +3 -0
@@ -89,6 +89,9 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4

drivers/usb/phy/phy-mxs-usb.c static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) · line 300

Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +5 -0
@@ -288,6 +291,11 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
        if (ret)
                goto disable_pll;
 
+       if (mxs_phy->regmap_anatop && (mxs_phy->port_id == 1))
+               regmap_write(mxs_phy->regmap_anatop,
+                            ANADIG_USB2_VBUS_DET_SET,
+                            ANADIG_USB2_VBUS_DET_VBUS_OVERRIDE);
+
        /* Power up the PHY */
        writel(0, base + HW_USBPHY_PWD);

Hello,
I tested your patch and it does not work. I therefore tested a slightly improved version that really ensure the right register value is written.

[    8.408564] port=0 reg=0x200 val=0x1000fc
[    8.440235] port=1 reg=0x204 val=0x1000fc

but it does not work never the less. Unfortunately bits 7-3 are not documented, so I was not able to do much more.

(quoted diff) +0 -0

b/drivers/usb/phy/phy-mxs-usb.c index d2836ef5d15c..3ff5489d679e 100644

drivers/usb/phy/phy-mxs-usb.c +5 -0
@@ -89,6 +89,10 @@
 #define ANADIG_USB1_CHRG_DET_STAT_CHRG_DETECTED        BIT(1)
 #define ANADIG_USB1_CHRG_DET_STAT_PLUG_CONTACT BIT(0)
 
+#define ANADIG_USB1_VBUS_DET_SET               0x200
+#define ANADIG_USB2_VBUS_DET_SET               0x204
+#define ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE     GENMASK(7, 3)
+
 #define ANADIG_USB2_VBUS_DET_STAT              0x220
 
 #define ANADIG_USB1_LOOPBACK_SET               0x1e4
@@ -309,6 +313,7 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
                writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
 
        if (mxs_phy->regmap_anatop) {
+               unsigned int val;
                unsigned int reg = mxs_phy->port_id ?
                        ANADIG_USB1_CHRG_DETECT_SET :
                        ANADIG_USB2_CHRG_DETECT_SET; @@ -319,6 +324,15 @@

static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)

                regmap_write(mxs_phy->regmap_anatop, reg,
                             ANADIG_USB1_CHRG_DETECT_EN_B |
                             ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B);
drivers/usb/phy/phy-mxs-usb.c +3 -0
+
+               reg = mxs_phy->port_id ?
+                       ANADIG_USB2_VBUS_DET_SET :

drivers/usb/phy/phy-mxs-usb.c

Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +7 -0
+                       ANADIG_USB1_VBUS_DET_SET;
+
+               regmap_set_bits(mxs_phy->regmap_anatop, reg,
+                            ANADIG_USB1_VBUS_DET_VBUS_OVERRIDE);
+               regmap_read(mxs_phy->regmap_anatop, reg, &val);
+               printk("port=%d reg=0x%x val=0x%x\n", mxs_phy->port_id,
+ reg, val);
        }
 
        mxs_phy_tx_init(mxs_phy);

Thanks for try those, those bits are for vbus valid override, You can verify if the override real works by checking the OTGSC Registers(a few bits to show the BSV/ASV/AVV) via the debugfs /sys/kernel/debug/usb/ci_hdrc.1/registers.

Quoted 8 lines

echo on > /sys/bus/platform/devices/ci_hdrc.1/power/control cat /sys/kernel/debug/usb/ci_hdrc.1/registers

if the BSV/ASV/AVV are all set to be 1, means it works.

Enable runtime PM back:
echo auto > /sys/bus/platform/devices/ci_hdrc.1/power/control then do your issue test.

== Running Linux 6.0.16, WITH the patch shared on this email thread.

[    8.318987] port=0 reg=0x200 val=0x1000fc
[    8.350386] port=1 reg=0x204 val=0x1000fc
# echo on > /sys/bus/platform/devices/ci_hdrc.1/power/control
# cat /sys/kernel/debug/usb/ci_hdrc.1/registers
USBINTR reg: 00000037
USBSTS reg: 000c0088
USBMODE reg: 00005003
USBCMD reg: 00010005
PORTSC reg: 18601a85
OTGSC reg: 00201720

And these the various valid bits - correct me if I'm wrong.
- AVV is set
- ASV is set
- BSP is NOT set

[  268.421848] usb 1-1: reset high-speed USB device number 2 using ci_hdrc
[  270.931732] usb 1-1: reset high-speed USB device number 2 using ci_hdrc

...

and it's not working as already stated.

== WITHOUT any patch, plain v6.0.16 kernel:

root@colibri-imx6ull-emmc-06906487:~# echo on > /sys/bus/platform/devices/ci_hdrc.1/power/control
root@colibri-imx6ull-emmc-06906487:~# cat /sys/kernel/debug/usb/ci_hdrc.1/registers
USBINTR reg: 00000037
USBSTS reg: 00040088
USBMODE reg: 00005003
USBCMD reg: 00010005
PORTSC reg: 18601a85
OTGSC reg: 00200520

And these the various valid bits - correct me if I'm wrong.
- AVV is NOT set
- ASV is set
- BSP is NOT set

Quoted 4 lines

BTW, how is __mxs_phy_disconnect_line() impacting this issue result on your HW? If not called, then the direct plug usb device to the OTG2 port can work, but adding an external hub between still cannot work?

== Running Linux 6.0.16, WITH the patch shared on this email thread.

With NO external HUB:
- it does not work and it does not recover in any way

With external HUB:
- reset high-speed USB every 2 seconds, it stops as soon as I connect something to the USB HUB.

== Running Linux 6.0.16, WITH the patch shared on this email thread

with the following patch in addition

drivers/usb/phy/phy-mxs-usb.c +1 -1
index 3e190638bcae..1a4ec039005b 100644
@@ -424,7 +424,7 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
        if (!mxs_phy->regmap_anatop)
                return;
 
-       vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
+       vbus_is_on = true; // mxs_phy_get_vbus_status(mxs_phy);
 
        if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy))
                __mxs_phy_disconnect_line(mxs_phy, true);

the behavior is greatly improved. It just works fine 95% of the time, but sometime, after doing multiple plug in/out it fails to recognize the device and it does not really recover. I never saw this behavior just disabling runtimepm that is our current workaround.

Francesco

reviewer
#13 lore raw
In reply to Francesco Dolcini

drivers/usb/chipidea/ci_hdrc_imx.c static const struct ci_hdrc_imx_platform_flag imx6sx_usb_data = { · line 59

Quoted 3 lines · Francesco Dolcini

static const struct ci_hdrc_imx_platform_flag imx6ul_usb_data = {

drivers/usb/chipidea/ci_hdrc_imx.c +1 -1
-       .flags = CI_HDRC_SUPPORTS_RUNTIME_PM |
+       .flags =

Not sure if this is related to a problem I was having on imx7d.

I was also disabling runtime pm as you showed above to workaround a USB modem detection problem.

Li Jun suggested I check for the over-current polarity description of the devicetree.

Passing 'disable-over-current' or ''over-current-active-low' made the issue go away.