How to disconnect a specific USB device using musb_hdrc Linux driver?

Viewed 10413

First, i am new to the Linux USB stack and i am trying to understand it a little bit more in order to achieve the following result : i need to reconnect/disconnect a specific USB device because sometimes, tough not often, this device does not respond anymore and the only solution is to physically disconnect/reconnect the USB cable from the device.

On my board (AM33x Sitara), there are 2 usb controllers with musb-hdrc drivers bind to them :

# pwd /sys/bus/platform/drivers/musb-hdrc

# ls -lrth
total 0
--w-------    1 root     root        4.0K Jul 11 10:11 uevent
--w-------    1 root     root        4.0K Jul 11 10:13 unbind
lrwxrwxrwx    1 root     root           0 Jul 11 10:13 musb-hdrc.1.auto -> ../../../../devices/ocp.2/47400000.usb/47401c00.usb/musb-hdrc.1.auto
lrwxrwxrwx    1 root     root           0 Jul 11 10:13 musb-hdrc.0.auto -> ../../../../devices/ocp.2/47400000.usb/47401400.usb/musb-hdrc.0.auto
lrwxrwxrwx    1 root     root           0 Jul 11 10:13 module -> ../../../../module/musb_hdrc
--w-------    1 root     root        4.0K Jul 11 10:13 bind

From dmesg, i can see that my device is using driver musb-hdrc :

usb 2-1.4: new full-speed USB device number 17 using musb-hdrc

But looking at the device node, i cannot find this driver :

    # ls -lrth /sys/bus/usb/devices/2-1.4:1.0/
    total 0
    -rw-r--r--    1 root     root        4.0K Jul 11 12:03 uevent
    -r--r--r--    1 root     root        4.0K Jul 11 12:05 supports_autosuspend
    lrwxrwxrwx    1 root     root           0 Jul 11 12:05 subsystem -> ../../../../../../../../../bus/usb
    drwxr-xr-x    2 root     root           0 Jul 11 12:05 power
...
...
    -r--r--r--    1 root     root        4.0K Jul 11 12:05 bAlternateSetting
    lrwxrwxrwx    1 root     root           0 Jul 11 12:07 driver -> ../../../../../../../../../bus/usb/drivers/usbfs

According to https://www.kernel.org/doc/Documentation/usb/power-management.txt, it is possible to suspend usb devices by doing : echo "auto" > /sys/bus/usb/devices/2-1.4/power/control and echo 0 > /sys/bus/usb/devices/2-1.4/power/autosuspend_delay_ms, plus unbinding the driver with echo "2-1.4:1.0" > /sys/bus/usb/devices/2-1.4:1.0/driver/unbind

I can see in dmesg that the device is disconnected, but for some reason the device is automatically bind just after that.

However, when i do the same procedure using musb-hdrc driver on musb-hdrc.1.auto and musb-hdrc.0.auto devices, it works well except that all my usb devices are turned off/on...and i would like to be more specific about the 2-1.4:1.0 usb devices interface.

An idea is to use the musb-hdrc driver to unbind the 2-1.4:1.0 usb device interface but it says that there is no such device...

I am a bit confused about that because i can see that the device is inside the device tree of musb-hdrc.1.auto :

# ls -lrth /sys/devices/ocp.2/47400000.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1.4/
total 0
-rw-r--r--    1 root     root        4.0K Jul 11 12:03 uevent
-r--r--r--    1 root     root        4.0K Jul 11 12:03 speed
...
...
drwxr-xr-x    6 root     root           0 Jul 11 12:03 2-1.4:1.0
...

Why the unbind command say that the device does not exist then ? Maybe there is a way to indicate, a kind of path inside the device tree to indicate to the driver that i want to unbind to this specific device interface 2-1.4:1.0 ?

Thanks for your help.

1 Answers
Related