libpayload: Add timeouts in the UHCI USB driver
We should always have some timeout when we wait for the hardware. This adds missing timeouts to the UHCI driver. Change-Id: Ic37b95ce12ff3ff5efe3e7ca346090946f6ee7de Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: http://review.coreboot.org/1073 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
c43e736c0c
commit
bb1c42b920
|
@ -102,13 +102,18 @@ static void
|
||||||
uhci_reset (hci_t *controller)
|
uhci_reset (hci_t *controller)
|
||||||
{
|
{
|
||||||
/* reset */
|
/* reset */
|
||||||
uhci_reg_write16 (controller, USBCMD, 4);
|
uhci_reg_write16 (controller, USBCMD, 4); /* Global Reset */
|
||||||
mdelay (50);
|
mdelay (50); /* uhci spec 2.1.1: at least 10ms */
|
||||||
uhci_reg_write16 (controller, USBCMD, 0);
|
uhci_reg_write16 (controller, USBCMD, 0);
|
||||||
mdelay (10);
|
mdelay (10);
|
||||||
uhci_reg_write16 (controller, USBCMD, 2);
|
uhci_reg_write16 (controller, USBCMD, 2); /* Host Controller Reset */
|
||||||
while ((uhci_reg_read16 (controller, USBCMD) & 2) != 0)
|
/* wait for controller to finish reset */
|
||||||
mdelay (1);
|
/* TOTEST: how long to wait? 100ms for now */
|
||||||
|
int timeout = 200; /* time out after 200 * 500us == 100ms */
|
||||||
|
while (((uhci_reg_read16 (controller, USBCMD) & 2) != 0) && timeout--)
|
||||||
|
udelay (500);
|
||||||
|
if (timeout < 0)
|
||||||
|
debug ("Warning: uhci: host controller reset timed out.\n");
|
||||||
|
|
||||||
uhci_reg_write32 (controller, FLBASEADD,
|
uhci_reg_write32 (controller, FLBASEADD,
|
||||||
(u32) virt_to_phys (UHCI_INST (controller)->
|
(u32) virt_to_phys (UHCI_INST (controller)->
|
||||||
|
|
|
@ -65,10 +65,15 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
|
||||||
|
|
||||||
uhci_reg_write16(controller, port,
|
uhci_reg_write16(controller, port,
|
||||||
uhci_reg_read16(controller, port) | 1 << 2); /* enable */
|
uhci_reg_read16(controller, port) | 1 << 2); /* enable */
|
||||||
|
/* wait for controller to enable port */
|
||||||
|
/* TOTEST: how long to wait? 100ms for now */
|
||||||
|
int timeout = 200; /* time out after 200 * 500us == 100ms */
|
||||||
do {
|
do {
|
||||||
value = uhci_reg_read16 (controller, port);
|
value = uhci_reg_read16 (controller, port);
|
||||||
mdelay (1);
|
udelay(500); timeout--;
|
||||||
} while (((value & (1 << 2)) == 0) && (value & 0x01));
|
} while (((value & (1 << 2)) == 0) && (value & 0x01) && timeout);
|
||||||
|
if (!timeout)
|
||||||
|
debug("Warning: uhci_rh: port enabling timed out.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable root hub */
|
/* disable root hub */
|
||||||
|
@ -82,10 +87,15 @@ uhci_rh_disable_port (usbdev_t *dev, int port)
|
||||||
uhci_reg_write16(controller, port,
|
uhci_reg_write16(controller, port,
|
||||||
uhci_reg_read16(controller, port) & ~4);
|
uhci_reg_read16(controller, port) & ~4);
|
||||||
int value;
|
int value;
|
||||||
|
/* wait for controller to disable port */
|
||||||
|
/* TOTEST: how long to wait? 100ms for now */
|
||||||
|
int timeout = 200; /* time out after 200 * 500us == 100ms */
|
||||||
do {
|
do {
|
||||||
value = uhci_reg_read16 (controller, port);
|
value = uhci_reg_read16 (controller, port);
|
||||||
mdelay (1);
|
udelay(500); timeout--;
|
||||||
} while ((value & (1 << 2)) != 0);
|
} while (((value & (1 << 2)) != 0) && timeout);
|
||||||
|
if (!timeout)
|
||||||
|
debug("Warning: uhci_rh: port disabling timed out.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue