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.

AM5728: USB2.0 LPM issue

Part Number: AM5728

In the previous thread, the USB driver software required patching since the AM5728 does not support USB2.0 LPM.

In the latest USB driver source code, it doesn't seem to check that the USB port (host) supports USB2.0 LPM before enabling USB2.0 hardware LPM.

https://elixir.bootlin.com/linux/v5.3.12/source/drivers/usb/core/hub.c#L4468

 /*
  * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM
  * when they're plugged into a USB 2.0 port, but they don't work when LPM is
  * enabled.
  *
  * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the
  * device says it supports the new USB 2.0 Link PM errata by setting the BESL
  * support bit in the BOS descriptor.
  */
 static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
 {
  struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent);
  int connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN;
 
  if (!udev->usb2_hw_lpm_capable || !udev->bos)
   return;
 
  if (hub)
   connect_type = hub->ports[udev->portnum - 1]->connect_type;
 
  if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) ||
    connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
   udev->usb2_hw_lpm_allowed = 1;
   usb_enable_usb2_hardware_lpm(udev);
  }
 }

Should the above source code be changed to not enable USB 2.0 hardware LPM in all cases?

Are there any changes required other than the above source code?

Our customer has a problem that some USB flash drive does not work with WEC7 on a custom board. If the WEC7 USB driver has the same issue, it will be changed with reference to the Linux USB driver.

Best regards,

Daisuke

  • Hi Daisuke,

    Daisuke Maeda said:
    In the previous thread, the USB driver software required patching since the AM5728 does not support USB2.0 LPM.

    The issue is not that AM5728 does not support USB2.0 LPM, rather than that the LPM negotiation failed between AM5728 and certain USB3.0 devices. The root cause is unknown, so the kernel patch to disalbe LPM is just a workaround to bypass the issue.

    Daisuke Maeda said:
    In the latest USB driver source code, it doesn't seem to check that the USB port (host) supports USB2.0 LPM before enabling USB2.0 hardware LPM.

    Since the software patch is just a workaround, it won't be in mainline kernel.

    Daisuke Maeda said:
    Should the above source code be changed to not enable USB 2.0 hardware LPM in all cases?

    No, some users might still want LPM with USB devices which don't have such LPM issue.

    Daisuke Maeda said:
    Are there any changes required other than the above source code?

    Yes, it would be fixed once the root cause is understood.

  • Hi Bin Liu-san,

    Thank you for your reply.

    Bin Liu said:

    The issue is not that AM5728 does not support USB2.0 LPM, rather than that the LPM negotiation failed between AM5728 and certain USB3.0 devices.

    Is the issue the same as the report that is commented in the source code?

     /*
      * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM
      * when they're plugged into a USB 2.0 port, but they don't work when LPM is
      * enabled.
      *

    Bin Liu said:

    Since the software patch is just a workaround, it won't be in mainline kernel.


    Bin Liu said:

    No, some users might still want LPM with USB devices which don't have such LPM issue.

    Since AM5728 does not support USB2.0 LPM, should the software patch be applied for AM5728?

    Daisuke Maeda said:

    Our customer has a problem that some USB flash drive does not work with WEC7 on a custom board. If the WEC7 USB driver has the same issue, it will be changed with reference to the Linux USB driver.

    Our customer already has the USB controller (Synopsys DWC3) documentation under NDA.

    Can I ask questions for the USB controller through a private message on E2E?

    Best regards,

    Daisuke

  • Hi Daisuke-san,

    Daisuke Maeda said:

    Is the issue the same as the report that is commented in the source code?

     /*
      * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM
      * when they're plugged into a USB 2.0 port, but they don't work when LPM is
      * enabled.
      *

    We don't know if it is the same or not, since we don't know the root cause of the issue with AM5728 yet.

    Daisuke Maeda said:
    Since AM5728 does not support USB2.0 LPM, should the software patch be applied for AM5728?

    Again, it is not that "AM5728 does not support USB2.0 LPM", rather than "the LPM handshake fails between AM5728 and some USB devices". I am not sure which patch you refer to, but if any USB device is failed in enumeration or data transfer with AM5728 due to LPM, the patch which disable xHCI host LPM can be applied to workaround the issue.

    Daisuke Maeda said:

    Our customer already has the USB controller (Synopsys DWC3) documentation under NDA.

    Can I ask questions for the USB controller through a private message on E2E?

    The E2E private message is not our support channel, so please don't ask technical questions there.

    We don't provide technical support on the Synopsis documents, but if you have any questions related to the controller registers, please ask on this e2e forum, we will do our best to support.

  • Hi Bin Liu-san,

    Thank you for your reply.

    Bin Liu said:

    Again, it is not that "AM5728 does not support USB2.0 LPM", rather than "the LPM handshake fails between AM5728 and some USB devices". I am not sure which patch you refer to, but if any USB device is failed in enumeration or data transfer with AM5728 due to LPM, the patch which disable xHCI host LPM can be applied to workaround the issue.

    I understand that the Linux USB driver does not need any patches for the AM5728 which does not support USB2.0 LPM.

    Could you tell me how to configure the registers to disable xHCI host LPM?

    Our customer wants to modify the WEC7 USB driver to disable the hardware LPM, and thinks it is not enough to refer to the Linux USB driver since WEC7 driver and Linux driver are not the same.

    Best regards,

    Daisuke

  • Hi Daisuke,

    USB2.0 LPM can be disabled with xHCI USB2 port PORTPMSC register. Please refer to the xHCI Spec for details.

  • Hi Bin Liu-san,

    Thank you for your reply.

    Bin Liu said:

    USB2.0 LPM can be disabled with xHCI USB2 port PORTPMSC register. Please refer to the xHCI Spec for details.

    For the USB 2.0 dedicated ports (USB2, USB3, USB4), the WEC7 USB driver will be modified to not set the Hardware LPM Enable (HLE) in USB2 PORTPMSC register if the Hardware LPM Capability (HLC) equal '1' in USB2 xHCI Supported Protocol Capability structure.

    I understand that USB2.0 LPM is not supported by USB2.0 dedicated ports (USB2, USB3, USB4) but is supported by USB3.0 port (USB1).

    For the USB3.0 port (USB1), if a USB2.0 device that supports USB2.0 LPM is plugged in the port, does LPM work fine?

    Best regards,

    Daisuke

  • Hi Daisuke-san,

    Daisuke Maeda said:
    For the USB3.0 port (USB1), if a USB2.0 device that supports USB2.0 LPM is plugged in the port, does LPM work fine?

    The question is invalid. A xHCI physical port (USB1 in this case) has two logical ports - a USB2.0 port and a USB3.x port. When a USB2.0 device is attached to the physical port, it is only connected to the USB2.0 logical port, and the USB2.0 logical port is the one which LPM can be disabled using the register I mentioned previously. The USB2.0 LPM is not applicable to the USB3.x logical port.

  • Hi Bin Liu-san,

    Thank you for your reply.

    I checked the values of the registers with Linux on EVM.

    USB3.0 port (USB1): USB2.0 PORTPMSC register

    root@am57xx-evm:~# omapconf dump 0x48890420 0x4889043C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x48890420    | 0x0C000E63 |
    | 0x48890424    | 0x00000000 |
    | 0x48890428    | 0x00000000 |
    | 0x4889042C    | 0x00000000 |
    | 0x48890430    | 0x0C001263 |
    | 0x48890434    | 0x00000000 |
    | 0x48890438    | 0x00000000 |
    | 0x4889043C    | 0x00000000 |
    |----------------------------|

    USB3.0 port (USB1): USB2.0 xHCI Supported Protocol Capability structure

    root@am57xx-evm:~# omapconf dump 0x488908F0 0x4889090C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x488908F0    | 0x00000000 |
    | 0x488908F4    | 0x00000000 |
    | 0x488908F8    | 0x00000000 |
    | 0x488908FC    | 0x00000000 |
    | 0x48890900    | 0x00000000 |
    | 0x48890904    | 0x00000000 |
    | 0x48890908    | 0x00000000 |
    | 0x4889090C    | 0x00000000 |
    |----------------------------|

    USB 2.0 dedicated port (USB2): USB2.0 PORTPMSC register

    root@am57xx-evm:~# omapconf dump 0x488D0420 0x488D043C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x488D0420    | 0x00000280 |
    | 0x488D0424    | 0x00000000 |
    | 0x488D0428    | 0x00000000 |
    | 0x488D042C    | 0x00000000 |
    | 0x488D0430    | 0x00000280 |
    | 0x488D0434    | 0x00000000 |
    | 0x488D0438    | 0x00000000 |
    | 0x488D043C    | 0x00000000 |
    |----------------------------|

    USB 2.0 dedicated port (USB2): USB2.0 xHCI Supported Protocol Capability structure

    root@am57xx-evm:~# omapconf dump 0x488D08F0 0x488D090C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x488D08F0    | 0x00000000 |
    | 0x488D08F4    | 0x00000000 |
    | 0x488D08F8    | 0x00000000 |
    | 0x488D08FC    | 0x00000000 |
    | 0x488D0900    | 0x00000000 |
    | 0x488D0904    | 0x00000000 |
    | 0x488D0908    | 0x00000000 |
    | 0x488D090C    | 0x00000000 |
    |----------------------------|

    The address information for the registers can be found in the RTOS SDK.

    \pdk_am57xx_1_0_16\packages\ti\drv\usb\soc\am572x\hw_usb.h

    #define USB0_DWC_WRAPPER_BASE_ADDR      ((uint32_t)0x48880000U)
    #define USB1_DWC_WRAPPER_BASE_ADDR      ((uint32_t)0x488C0000U)
    #define USB_DWC_CORE_OFFSET             ((uint32_t)0x10000U)

    \pdk_am57xx_1_0_16\packages\ti\drv\usb\src\dwc\hw_dwc_usb.h

    #define DWC_USB_PORTPMSC1                                       (0x424u)

    #define DWC_USB_PORTPMSC1_HLE_SHIFT                             (16U)
    #define DWC_USB_PORTPMSC1_HLE_MASK                              (0x00010000U)

    #define DWC_USB_SUPTPRT2_DW2                                    (0x8F8u)

    #define DWC_USB_SUPTPRT2_DW2_HLC_SHIFT                          (19U)
    #define DWC_USB_SUPTPRT2_DW2_HLC_MASK                           (0x00080000U)

    The USB driver will be modified for the USB 2.0 software transition LPM and will be left unmodified for the USB 2.0 hardware LPM since the USB2.0 Hardware LPM is not supported (HLC = '0') by all ports (USB1, USB2...).

    Is my understanding correct?

    Best regards,

    Daisuke

  • Hi Bin Liu-san,

    I correct for the USB2.0 xHCI Supported Protocol Capability structure.

    USB3.0 port (USB1): HCCPARAMS1 register

    root@am57xx-evm:~# omapconf dump 0x48890000 0x4889001C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x48890000    | 0x01000020 |
    | 0x48890004    | 0x02000140 |
    | 0x48890008    | 0x0C0000F1 |
    | 0x4889000C    | 0x07FF000A |
    | 0x48890010    | 0x0220F04C |
    | 0x48890014    | 0x00000480 |
    | 0x48890018    | 0x00000440 |
    | 0x4889001C    | 0x00000000 |
    |----------------------------|

    USB3.0 port (USB1): USB2.0 xHCI Supported Protocol Capability structure

    root@am57xx-evm:~# omapconf dump 0x48890880 0x4889089C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x48890880    | 0x00000401 |
    | 0x48890884    | 0x00000000 |
    | 0x48890888    | 0x00000000 |
    | 0x4889088C    | 0x00000000 |
    | 0x48890890    | 0x02000402 |
    | 0x48890894    | 0x20425355 |
    | 0x48890898    | 0x00080101 |
    | 0x4889089C    | 0x00000000 |
    |----------------------------|

    USB 2.0 dedicated port (USB2): HCCPARAMS1 register

    root@am57xx-evm:~# omapconf dump 0x488D0000 0x488D001C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x488D0000    | 0x01000020 |
    | 0x488D0004    | 0x02000140 |
    | 0x488D0008    | 0x0C0000F1 |
    | 0x488D000C    | 0x07FF000A |
    | 0x488D0010    | 0x0220F04C |
    | 0x488D0014    | 0x00000480 |
    | 0x488D0018    | 0x00000440 |
    | 0x488D001C    | 0x00000000 |
    |----------------------------|

    USB 2.0 dedicated port (USB2): USB2.0 xHCI Supported Protocol Capability structure

    root@am57xx-evm:~# omapconf dump 0x488D0880 0x488D089C
    |----------------------------|
    | Address (hex) | Data (hex) |
    |----------------------------|
    | 0x488D0880    | 0x00000401 |
    | 0x488D0884    | 0x00000000 |
    | 0x488D0888    | 0x00000000 |
    | 0x488D088C    | 0x00000000 |
    | 0x488D0890    | 0x02000402 |
    | 0x488D0894    | 0x20425355 |
    | 0x488D0898    | 0x00080101 |
    | 0x488D089C    | 0x00000000 |
    |----------------------------|

    The address information for the registers can be found in the RTOS SDK.

    \pdk_am57xx_1_0_16\packages\ti\drv\usb\soc\am572x\hw_usb.h

    #define USB0_DWC_WRAPPER_BASE_ADDR      ((uint32_t)0x48880000U)
    #define USB1_DWC_WRAPPER_BASE_ADDR      ((uint32_t)0x488C0000U)
    #define USB_DWC_CORE_OFFSET             ((uint32_t)0x10000U)

    \pdk_am57xx_1_0_16\packages\ti\drv\usb\src\dwc\hw_dwc_usb.h

    #define DWC_USB_HCCPARAMS                                       (0x10u)

    #define DWC_USB_HCCPARAMS_XECP_SHIFT                            (16U)
    #define DWC_USB_HCCPARAMS_XECP_MASK                             (0xffff0000U)

    For all ports (USB1, USB2), the USB driver will be modified to not set the Hardware LPM Enable (HLE) in USB2 PORTPMSC register since the Hardware LPM Capability (HLC) equal '1' in USB2 xHCI Supported Protocol Capability structure.

    Please tell me if my understanding is incorrect.

    Best regards,

    Daisuke