title: How to disconnect a specific USB device using musb_hdrc Linux driver?
body: <p>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. </p>
  
  <p>On my board (AM33x Sitara), there are 2 usb controllers with musb-hdrc drivers bind to them :</p>
  
  <p><code># pwd /sys/bus/platform/drivers/musb-hdrc</code></p>
  
  <pre><code># 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 -&gt; ../../../../devices/ocp.2/47400000.usb/47401c00.usb/musb-hdrc.1.auto
  lrwxrwxrwx    1 root     root           0 Jul 11 10:13 musb-hdrc.0.auto -&gt; ../../../../devices/ocp.2/47400000.usb/47401400.usb/musb-hdrc.0.auto
  lrwxrwxrwx    1 root     root           0 Jul 11 10:13 module -&gt; ../../../../module/musb_hdrc
  --w-------    1 root     root        4.0K Jul 11 10:13 bind
  </code></pre>
  
  <p>From dmesg, i can see that my device is using driver musb-hdrc :</p>
  
  <pre><code>usb 2-1.4: new full-speed USB device number 17 using musb-hdrc
  </code></pre>
  
  <p>But looking at the device node, i cannot find this driver : </p>
  
  <pre><code>    # 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 -&gt; ../../../../../../../../../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 -&gt; ../../../../../../../../../bus/usb/drivers/usbfs
  </code></pre>
  
  <p>According to <a href="https://www.kernel.org/doc/Documentation/usb/power-management.txt" rel="noreferrer">https://www.kernel.org/doc/Documentation/usb/power-management.txt</a>, it is possible to suspend usb devices by doing :
  <code>echo "auto" &gt; /sys/bus/usb/devices/2-1.4/power/control</code> and <code>echo 0 &gt; /sys/bus/usb/devices/2-1.4/power/autosuspend_delay_ms</code>, plus unbinding the driver with <code>echo "2-1.4:1.0" &gt; /sys/bus/usb/devices/2-1.4:1.0/driver/unbind</code></p>
  
  <p>I can see in dmesg that the device is disconnected, but for some reason the device is automatically bind just after that.</p>
  
  <p>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. </p>
  
  <p>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...</p>
  
  <p>I am a bit confused about that because i can see that the device is inside the device tree of musb-hdrc.1.auto :</p>
  
  <pre><code># 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
  ...
  </code></pre>
  
  <p>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 ?</p>
  
  <p>Thanks for your help.</p>