]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ehci] Allow UHCI/OHCI controllers to locate the EHCI companion controller
authorMichael Brown <mcb30@ipxe.org>
Fri, 8 May 2015 15:51:12 +0000 (16:51 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sat, 9 May 2015 19:09:08 +0000 (20:09 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/usb/ehci.c
src/drivers/usb/ehci.h
src/include/ipxe/pci.h

index e847c6b75a65d2b818cb597b9254a08201baf0bd..516ffd8c15a11e0a17d19fd0a8f59fdcda02cd9f 100644 (file)
@@ -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
index d8814ec709f6dbfcca49d2fe37191ab5fd06d405..f35a07ce673fcba6d66dfd30284b2fe0d94e9d15 100644 (file)
@@ -537,4 +537,6 @@ struct ehci_endpoint {
        struct ehci_ring ring;
 };
 
+extern unsigned int ehci_companion ( struct pci_device *pci );
+
 #endif /* _IPXE_EHCI_H */
index ccc42fee6cf3729719e125ba1cdf6cbf944b5cd2..a841e00ff79ed6ce1f78d54ecc254d07c0985cc1 100644 (file)
@@ -239,6 +239,7 @@ struct pci_driver {
 #define PCI_BUSDEVFN( bus, slot, func )        \
        ( ( (bus) << 8 ) | ( (slot) << 3 ) | ( (func) << 0 ) )
 #define PCI_FIRST_FUNC( busdevfn )     ( (busdevfn) & ~0x07 )
+#define PCI_LAST_FUNC( busdevfn )      ( (busdevfn) | 0x07 )
 
 #define PCI_BASE_CLASS( class )                ( (class) >> 16 )
 #define PCI_SUB_CLASS( class )         ( ( (class) >> 8 ) & 0xff )