libpayload: Rework connection state detection for OHCI

The connection state detection in the OHCI root hub driver was broken if
you used more than one device per root hub.

Change-Id: Ica5c735426beac45ef6f591ce68a72d8283a00f5
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: http://review.coreboot.org/1904
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
Nico Huber 2012-11-22 15:45:48 +01:00 committed by Patrick Georgi
parent be58fee28e
commit b9917c2068
1 changed files with 14 additions and 5 deletions

View File

@ -128,15 +128,14 @@ ohci_rh_scanport (usbdev_t *dev, int port)
static int static int
ohci_rh_report_port_changes (usbdev_t *dev) ohci_rh_report_port_changes (usbdev_t *dev)
{ {
int i; ohci_t *const ohcic = OHCI_INST (dev->controller);
if (!(OHCI_INST (dev->controller)->opreg->HcInterruptStatus & RootHubStatusChange)) return -1; int i;
OHCI_INST (dev->controller)->opreg->HcInterruptStatus = RootHubStatusChange;
usb_debug("port change\n");
for (i = 0; i < RH_INST(dev)->numports; i++) { for (i = 0; i < RH_INST(dev)->numports; i++) {
// maybe detach+attach happened between two scans? // maybe detach+attach happened between two scans?
if (OHCI_INST (dev->controller)->opreg->HcRhPortStatus[i] & ConnectStatusChange) { if (ohcic->opreg->HcRhPortStatus[i] & ConnectStatusChange) {
ohcic->opreg->HcRhPortStatus[i] = ConnectStatusChange;
usb_debug("attachment change on port %d\n", i); usb_debug("attachment change on port %d\n", i);
return i; return i;
} }
@ -158,7 +157,17 @@ ohci_rh_destroy (usbdev_t *dev)
static void static void
ohci_rh_poll (usbdev_t *dev) ohci_rh_poll (usbdev_t *dev)
{ {
ohci_t *const ohcic = OHCI_INST (dev->controller);
int port; int port;
/* Check if anything changed. */
if (!(ohcic->opreg->HcInterruptStatus & RootHubStatusChange))
return;
ohcic->opreg->HcInterruptStatus = RootHubStatusChange;
usb_debug("root hub status change\n");
/* Scan ports with changed connection status. */
while ((port = ohci_rh_report_port_changes (dev)) != -1) while ((port = ohci_rh_report_port_changes (dev)) != -1)
ohci_rh_scanport (dev, port); ohci_rh_scanport (dev, port);
} }