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.

AM335x USB Device Cable Connect Check

Other Parts Discussed in Thread: AM3358

Hello.

I use ti-processor-sdk-linux-am335x-evm-01.00.00.03 in the BBB.

I use g_printer device mode.

I want to check of USB Cable Connect.

How do I ?

Help !

  • Hi,

    If the AM335x USB PHY detects valid VBUS voltage on the USBx_VBUS pin, the USB driver will start attachment and enumeration procedures. This is done by the Linux OS.
  • Hi Biser.
    Thank you for reply.

    Lan cable can check through /sys/class/net/eth0/carrier file.
    I want to check USB device cable connect through system file.

    If USB device cable connect system file not exist, Do I have to modify g_printer driver.

    Help !
  • I have asked the software experts to comment. They will respond here.
  • There is no direct report of the cable connect status from the kernel, but I think you use the following sysfs entry, which reports the otg state.

    /sys/bus/platform/devices/musb-hdrc.0.auto/mode

  • Hi, Bin.

    I tested /sys/bus/platform/devices/musb-hdrc.0.auto/mode.
    But, USB Cable Connect Status is incorrect.

    After Power-On.
    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_idle

    After USB Cable Connect.
    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_peripheral

    After USB Cable Disconnect.
    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_peripheral

    mode value is continuously b_peripheral.

    How I do ?

    Help !
  • Hi, Bin.

    I tested in the BBB.
    I checked USB Cable Connect Status.

    Cable Connect.
    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_periphera

    Cable Disconnect.
    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_idle

    VBus state is important.
    I have to modify my PCB.

    Thank you.
  • Hi, Bin.

    I use HUB IC CY7C65642 between AM3358 and USB connector.
    VBUS Signal Level of My PCB.
    Connect == Hgh, 5V
    Disconnect == Low, 0V

    But, /sys/bus/platform/devices/musb-hdrc.0.auto/mode is incorrect.

    cat /sys/bus/platform/devices/musb-hdrc.0.auto/mode
    b_periphera ---> No Change.

    Do /sys/bus/platform/devices/musb-hdrc.0.auto/mode check D+/D- State, too ?
    How modify My PCB ?

    At Disconnect, Do D+/D- State make floating state ?
    At use HUB IC, Send to me reference schematic.

    How I do ?
  • I am not sure what is wrong on your board. the sysfs mode entry is controlled by the otg state machine in the musb driver.
    The HUB IC is on your board? Your musb0 is in device mode, then why you need a hub? what else is connected to the hub?
  • Hi, Bin.

    VBUS is work correctly on my board.
    But, /sys/bus/platform/devices/musb-hdrc.0.auto/mode is not operating correctly.
    b_periphera ---> No Change.

    Current Status.

    HUB IC CY7C65642 is in my PCB

    PC ------------------- UpStream HUB DownStream#1 ------------------- AM3358, USB0 ( g_printer driver )

    DownStream#2 -------------------- Reserved ( Open )

    DownStream#3 -------------------- Reserved ( Open )

    DownStream#4 -------------------- Reserved ( Open )

    How I do ?

    Help ?

  • Hi, Bin.

    I try to read USB0STAT register through /dev/mem device file.
    I think that USB cable connect status is express DRVVBUS bit of USB0STAT register.

    But, Value of USB0STAT register is only 0x00000002.
    What's wrong ?

    Help !
  • Hi, Bin.

    I read USB0STAT register through /dev/mem device file.
    I think that USB cable connect status is appear DRVVBUS bit of USB0STAT register.

    But, Value of USB0STAT register is only 0x00000002.
    What's wrong ?

    Help !
  • hoyoun lyu said:
    But, /sys/bus/platform/devices/musb-hdrc.0.auto/mode is not operating correctly.
    b_periphera ---> No Change.

    Current Status.

    HUB IC CY7C65642 is in my PCB

    PC ------------------- UpStream HUB DownStream#1 ------------------- AM3358, USB0 ( g_printer driver )

    I am able to replicate this using an external hub, the sysfs mode does not change when disconnect the hub from the PC.

    This seems like a sw bug, but I am not sure when it will be fixed, since the issue is minor. no usb function is affected. To get your project moving forward, I recommend a couple alternatives.

    1. modify musb driver to export bit3,4 of usb0_devctl register to userspace, bit3,4=0h means vbus is off, while bit3,4=11b means vbus on.

    2. use discrete circuit to detect vbus line on the hub upstream port using GPIO.

  • hoyoun lyu said:
    I think that USB cable connect status is appear DRVVBUS bit of USB0STAT register.

    No, USB0STAT register and DRVVBUS are irrelevant to device mode, which is what you use.

  • Hi, Bin.

    I will use GPIO for VBUS level check.

    Thank you for reply.
  • GPIOs are not fail-safe, which means they cannot have a voltage applied when the processor is not powered. If you use a GPIO to detect VBUS, you must buffer VBUS with a circuit that never applies a voltage greater than the voltage being applied to is respective VDD terminal + 0.3 volts. For example, VBUS must never apply a voltage greater than 0.3 volts if the processor power is turned off, or greater than 2.1 volts when operating at 1.8 volts, or greater than 3.6 volts when operating at 3.3 volts.

    Regards,
    Paul
  • Bin Liu said:

    I am able to replicate this using an external hub, the sysfs mode does not change when disconnect the hub from the PC.

    This seems like a sw bug, but I am not sure when it will be fixed, since the issue is minor. no usb function is affected.

    Here is the explanation of the behavior - AM335x USB controller, while working in peripheral mode, relies on VBUS voltage to detect the disconnect event. So if the hub turns off VBUS of the downstream port when disconnected from the PC, AM335x USB will move to b_idle state as expected. But if the hub keeps VBUS of the downstream port on while disconnected from the PC, AM335x USB controller will not generate the disconnect event, then the Linux driver is unable to change the state to b_idle.

    So this isn't a sw bug. You just have to ensure that the hw turns off the hub downstream port VBUS if VBUS of the hub upstream port is gone.