summaryrefslogtreecommitdiff
path: root/disk/part_dos.h
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2015-08-05 03:19:22 +0200
committerMarek Vasut <marex@denx.de>2015-08-05 17:22:43 +0200
commitdcc7dbc73169bb4e39f27c1d95bbf031ccfc1744 (patch)
tree9f2599156b1075a0b9e7728a2402dff9b3e3b326 /disk/part_dos.h
parent147271209a9d328203cf1663de17abdad23412b4 (diff)
downloadu-boot-imx-dcc7dbc73169bb4e39f27c1d95bbf031ccfc1744.zip
u-boot-imx-dcc7dbc73169bb4e39f27c1d95bbf031ccfc1744.tar.gz
u-boot-imx-dcc7dbc73169bb4e39f27c1d95bbf031ccfc1744.tar.bz2
usb: Fix device detection code
The code in question polls an USB port status via USB_REQ_GET_STATUS to determine whether there is a device on the port or not. The way to figure that out is to check two bits. Those are wPortChange[0] and wPortStatus[0]. The wPortChange[0] indicates whether some kind of a connection status change happened on a port (a device was plugged or unplugged). The wPortStatus[0] bit indicates the status of the connection (plugged or unplugged). The current code tests whether wPortChange[0] == wPortStatus[0] and if that's the case, considers the loop polling for the presence of a USB device on port finished. This works for most USB sticks, since they come up really quickly and trigger the USB port change detection before the first iteration of the detection loop happens. Thus, both wPortChange[0] and wPortStatus[0] are set to 1 and thus equal. The loop is existed in it's first iteration and the stick is detected correctly. The problem is with some obscure USB sticks, which take some time before they pop up on the bus after the port was enabled. In this case, both the wPortChange[0] and wPortStatus[0] are 0. They are equal again, so the loop again exits in the first iteration, but this is incorrect, as such USB stick didn't have the opportunity to get detected on the bus. Rework the code such, that it checks for wPortChange[0] first to test if any connection change happened at all. If no change occured, keep polling. If a change did occur, test the wPortStatus[0] to see there is some device present on the port and only if this is the case, break out of the polling loop. This patch also trims down the duration of the polling loop from 10s per port to 1s per port. This is still annoyingly long, but there is no better option in case of U-Boot unfortunatelly. This change will most likely increase the duration of 'usb start' on some platforms, but this is needed to fix a bug. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'disk/part_dos.h')
0 files changed, 0 insertions, 0 deletions