From 9ea8a2daa7ffd489898318c038fcfd7edc810adc Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 8 May 2015 16:51:12 +0100 Subject: [ehci] Allow UHCI/OHCI controllers to locate the EHCI companion controller Signed-off-by: Michael Brown --- src/drivers/usb/ehci.c | 26 ++++++++++++++++++++++++++ src/drivers/usb/ehci.h | 2 ++ 2 files changed, 28 insertions(+) (limited to 'src/drivers') diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index e847c6b75..516ffd8c1 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -337,6 +337,32 @@ static void ehci_poll_companions ( struct ehci_device *ehci ) { } } +/** + * Locate EHCI companion controller + * + * @v pci PCI device + * @ret busdevfn EHCI companion controller bus:dev.fn (if any) + */ +unsigned int ehci_companion ( struct pci_device *pci ) { + struct pci_device tmp; + unsigned int busdevfn; + int rc; + + /* Look for an EHCI function on the same PCI device */ + busdevfn = pci->busdevfn; + while ( ++busdevfn <= PCI_LAST_FUNC ( pci->busdevfn ) ) { + pci_init ( &tmp, busdevfn ); + if ( ( rc = pci_read_config ( &tmp ) ) != 0 ) + continue; + if ( tmp.class == PCI_CLASS ( PCI_CLASS_SERIAL, + PCI_CLASS_SERIAL_USB, + PCI_CLASS_SERIAL_USB_EHCI ) ) + return busdevfn; + } + + return 0; +} + /****************************************************************************** * * Run / stop / reset diff --git a/src/drivers/usb/ehci.h b/src/drivers/usb/ehci.h index d8814ec70..f35a07ce6 100644 --- a/src/drivers/usb/ehci.h +++ b/src/drivers/usb/ehci.h @@ -537,4 +537,6 @@ struct ehci_endpoint { struct ehci_ring ring; }; +extern unsigned int ehci_companion ( struct pci_device *pci ); + #endif /* _IPXE_EHCI_H */ -- cgit v1.2.3-55-g7522