Fredrik Moller

USB Host: Problem with detecting disconnects

Discussion created by Fredrik Moller on May 6, 2012

I'm working on a USB Host mode software driver for the USB1 hardware block in i.MX28. The hardware works fine except that when removing the USB Device from the port, the removal is not detected. My interpretation is that this issue is a hardware error which should be documented in the reference manual or errata.


On the other hand, Device disconnects are detected if one turns on the ENHOSTDISCONDETECT bit in the HW_USBPHY_CTRL register. The description of the bit in the reference manual says 

For host mode, enables high-speed disconnect detector. This signal allows the override of
enabling the detection that is normally done in the UTMI controller.The UTMI controller enables
this circuit whenever the host sends a start-of-frame packet.

As I interpret this, enabling of disconnect detection should really be automatic and setting the ENHOSTDISCONDETECT shouldn't be needed, although the wording is ambigious.


The fix triggers another problem though, as subsequent insertion of Device fails (reset of port fails). As a fix for this issue, turning off ENHOSTDISCONDETECT after the removal of the Device enables subsequently inserted Devices to be successfully enumerated.


These two fixes is what is done in the BSPHostDisconDetect() function in the WinCE BSP code. The comment in the code says

// we should turn on this logic after BUS RESET and turn off
// this logic after device detach
// turn on this logic before device attach will cause attach failure



Could it be confirmed that this is indeed a hardware issue?

Is the trick with setting/clearing the ENHOSTDISCONDETECT bit the proper way to solve the issue?