This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/TUSB8041: Issue redetecting USB3 devices after Hub Port Power off/on event

Part Number: TUSB8041

Tool/software: Linux

Hello,

We are utilising a TUSB8041 hub in a new product design.  There is an issue we are experiencing when the PWRCTL signals lines are toggled. 

Basically after a Hub port power "off" and then "on" event (PWRCTL signals first made to go low and then high), any USB2 device plugged into the Hub is automatically redetected.  However USB3 devices are not being detected.  In order for us to detect the USB3 device, we have to physically unplug it and then plug it back it for it to be detected.

To turn the Hub power "off" and then back "on" we are using the commands below in the Linux Kernel:

usb_hub_set_port_power(hub2->hdev, hub2, port, true/false);  // turn port power on/off for usb2 hub

usb_hub_set_port_power(hub3->hdev, hub3, port, true/false); //  turn port power on/off for usb3 hub

 

Could you please shed some light on why a USB3 device is not being redetected after a power off/on event, but a USB2 device is being redetected automatically?

Thank you,

Nikhil

  • HI Nikhil,

    Can you confirm that this command:

    usb_hub_set_port_power(hub3->hdev, hub3, port, true/false); // turn port power on/off for usb3 hub

    is actually turning the physical port power off? The way USB 3.0 hubs are designed requires the USB 2.0 hub instance and the USB 3.0 hub instance to share port power control, so it is possible that turning port power off for the USB 3.0 hub port may not be enough, you may have to turn it off on the USB 2.0 hub instance as well to get it to actually turn off.

    Regards,
    JMMN
  • Hello JMMN,

    Yes as per your previous suggestion (on 13 Aug 2018) we had to send the Power off command to both the USB2 and USB3 instances. By doing so we were able to successfully power off the USB ports.

    To re-enable the power to the port we sent a power on command to the USB3 instance followed by the USB2 instance. I have checked on our prototype boards and we can clearly see the 5V Bus Power being shutdown and then turned back on by issuing the commands in Linux to both the USB2 and USB3 Hub instances.

    We tried to alter the turn on command sequence by turning on Hub2 first and then Hub3. We also tried adding some delays between the commands, but it made no difference. Each time power was re-enabled, USB2 devices on the Hub would be redetected. However all USB3 devices were not. The only way for us to redetect the USB3 device was to physically unplug it and then plug it back into the port. This is not ideal in our application and hence any other suggestions would be most welcome.

    Thank you,

    Nikhil
  • Hi Nikhil,

    Can you read back the port status on the ports where the USB 3.0 devices are connected? Can you tell if the ports are going into compliance mode?

    Thanks,
    JMMN
  • Hi JMMN, 

    Sorry for the delay in responding.  I have worked with one of my software engineering colleagues to carry out the port status check.  Below is a summary of our findings:

    For a USB 2 device plugged in:

    1, Read port status: USB2 port gives 0x103, USB3 port gives 0x6A0.

    2, send port command to turn port power off.

    3,  send port command to turn port power on.

    4, wait 5 seconds, read port status: USB2 port gives 0x103, USB3 port gives 0x6A0.     And device is re-detected and enumerated.

     

    For a USB 3 device plugged in:

    1, Read port status: USB2 port gives 0x100, USB3 port gives 0x203.

    2, send port command to turn port power off.

    3,  send port command to turn port power on.

    4, wait 5 seconds, read port status: USB2 port gives 0x100, USB3 port gives 0x203.     And device is NOT re-detected.

     

     

    Below is the definition for each bit in port status:

    /*

    * wPortStatus bit field

    * See USB 2.0 spec Table 11-21

    */

    #define USB_PORT_STAT_CONNECTION      0x0001

    #define USB_PORT_STAT_ENABLE          0x0002

    #define USB_PORT_STAT_SUSPEND         0x0004

    #define USB_PORT_STAT_OVERCURRENT     0x0008

    #define USB_PORT_STAT_RESET           0x0010

    #define USB_PORT_STAT_L1              0x0020

    /* bits 6 to 7 are reserved */

    #define USB_PORT_STAT_POWER           0x0100

    #define USB_PORT_STAT_LOW_SPEED               0x0200

    #define USB_PORT_STAT_HIGH_SPEED        0x0400

    #define USB_PORT_STAT_TEST              0x0800

    #define USB_PORT_STAT_INDICATOR         0x1000

    /* bits 13 to 15 are reserved */

     

    /*

    * Additions to wPortStatus bit field from USB 3.0

    * See USB 3.0 spec Table 10-10

    */

    #define USB_PORT_STAT_LINK_STATE      0x01e0

    #define USB_SS_PORT_STAT_POWER        0x0200

    #define USB_SS_PORT_STAT_SPEED        0x1c00

    #define USB_PORT_STAT_SPEED_5GBPS     0x0000

    /* Valid only if port is enabled */

    /* Bits that are the same from USB 2.0 */

    #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION |        \

                                   USB_PORT_STAT_ENABLE |     \

                                   USB_PORT_STAT_OVERCURRENT | \

                                   USB_PORT_STAT_RESET)

     

    The USB2 device is 0x103: USB_PORT_STAT_POWER | USB_PORT_STAT_ENABLE | USB_PORT_STAT_CONNECTION

    The USB3 device is 0x203: USB_SS_PORT_STAT_POWER | USB_PORT_STAT_ENABLE | USB_PORT_STAT_CONNECTION

    They values above make sense to me. 

     

    ###########################################################################################################

     

    I did another test.   Just plug in and out a USB 3 device, and print out what message host gets from hub. 

    When plugged in, host reads status 0x203, and change status 0x1.

    When pull out, host reads status 0x6A0, change status 0x1.   

    Both status values are same as my port command, but hub indicates a port change to the host CPU to trigger host CPU to do the rest.   

     

    0x1 means port connection change:

    /*
     * wPortChange bit field
     * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
     * Bits 0 to 5 shown, bits 6 to 15 are reserved
     */
    #define USB_PORT_STAT_C_CONNECTION    0x0001

     

     

    It seems to me that after the port power is re-enabled by the command, hub doesn’t send port change to host for a USB3 device, bit it sends it for USB2 device.    

    So even though all port status is correct, but host doesn’t know there is any change in the port, so does nothing to redetect a USB3 device.

     

    Do you have any further thoughts about why the host CPU isn't being informed by the Hub about a port change status? 

     

    Thank you,

     

    Nikhil

  • Hi Nikhil,

    Can you check port status between steps #2 and #3 below? I want to be sure that the host sees the USB 3.0 device is disconnected. If the hub is reporting a port status change but the host doesn't see the interim disconnect, it will assume USB 3.0 device is still connected.

    For a USB 3 device plugged in:

    1, Read port status: USB2 port gives 0x100, USB3 port gives 0x203.

    2, send port command to turn port power off.

    3, send port command to turn port power on.

    4, wait 5 seconds, read port status: USB2 port gives 0x100, USB3 port gives 0x203. And device is NOT re-detected.

    Regards,
    JMMN
  • Hi JMMN, 

     

    We have spotted why the USB3 device is not re-detected.  But not sure what goes wrong.  We have tried reading the port status between steps 2 and 3 and also immediately after step 3.  After this we read the port status in step 4 as well. The test below was done with a USB3 device, but was also repeated with a USB2 device. Please see the detailed info below from my colleague. 

      

    For a USB 3 device plugged in:

    1, Read port status: USB3 port gives 0x203.

    2, send port command to turn port power off.

     

    2.5. wait 5 seconds, read status:  0x4A0



    3, send port command to turn port power on.

     

    3.5. Hub sends in port change notification:  port status 0x203, port change 0x1.

    (It is this 0x203 causing the issue, it should be 0x201, without the USB_PORT_STAT_ENABLE set.)

    I have checked the driver code, if the USB_PORT_STAT_ENABLE is set, driver does nothing.    

    For USB2 devices, in step 3.5, hub sends in 0x101, which is correct.



    4, wait 5 seconds, read port status: USB3 port gives 0x203. And device is NOT re-detected.

    I hope the above makes sense.  We think it is this unexpected 0x203 instead of 0x201, which is why the port is not being redetected. 

     

    Kind Regards,

     

    Nikhil

  • Hi Nikhil,

    There should be a change bit set between step 2 and step 2.5, is that not occurring?

    The reported port status is correct, USB 3.0 port enable works a bit differently than USB 2.0 port enable. It is set automatically when the link between the hub and the device enters U0, unlike USB 2.0 port enable which is set by the host.

    Regards,
    JMMN
  • Hi JMMN,

    We have tried once more to check this out. My colleague has confirmed the findings below:

    -----

    JMMN is correct, between step 2 and 2.5, there is no notification at all from hub.   Basically after the command is sent to turn power off, hub did the job, but didn’t notify host anything about it.     It is same for both USB2 and USB3 devices.   

     

    Later on, when power is back on again, hub reports port ENABLE for USB3, but not for USB2 devices.   Host driver does nothing when it sees ENABLE bit is set.   That is about the whole story I guess.

     

    It seems like this is some kind of mismatch between host driver and USB3 protocol.   Can you ask TI anything they recommend for this case; we can’t physically unplug device, but want to power it off/on by software only and the USB3 device must be automatically redetected ?

    -------

    Unfortunately if we find ourselves in a situation where we have to power off a USB3 device and then later power it on (thru the TUSB8041 hub), it is not possible for our customers to physically unplug the USB3 device from our product. 

    Hence it would really be useful we if can come up with some solution here, otherwise we will have to make a hardware design change to implement an alternative method (which would not be our preferable route, because in all previous generation products we utilised TI USB Hubs to carry out this function). 

    Thank you for your suggestions so far. Please let us know if there is anything else that can be done. 

    Kind Regards,

    Nikhil

     

     

  • HI Nikhil,

    This took me a little while to go read through the spec, but it appears the hub is operating as expected:

    There is no notification between steps 2 and 2.5 because the port is in the powered-off state (see note from USB 2.0 spec):

    11.24.2.7.2.1 C_PORT_CONNECTION
    This bit is set when the PORT_CONNECTION bit changes because of an attach or detach detect event (see
    Section 7.1.7.3). This bit will be cleared to zero by a ClearPortFeature(C_PORT_CONNECTION) request
    or while the port is in the Powered-off state.


    Can you change the code so that at step 3.5 when you get a port change notification and the connect and enable bits are set, you treat this as a new connect event? Or do a port reset to the port and start enumeration again?

    Regards,
    JMMN
  • Hi JMMN, 

    We have made the modifications to the Kernel Hub code as you have suggested and now both USB2 and USB3 devices can be redetected each time after a power off/on event.  Thank you for your help. 

    Here is a response from my colleague who made the change:

    I have tried the TI suggestion, and it is working now. 

    I modified the kernel hub code so that it will ignore the ENABLE bit, and does enumeration anyway. 

    It is working for both USB2 and USB3 devices, they can all be re-detected. 

    The modification doesn’t affect the physical plug/unplug enumeration. 

    So I guess we can close this ticket with TI, they gave great help to understand the problem. Thanks!

    Thank you for your help in resolving this issue. 

    Kind Regards,

    Nikhil