Browse Source

[ehci] Allow UHCI/OHCI controllers to locate the EHCI companion controller

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
9ea8a2daa7
3 changed files with 29 additions and 0 deletions
  1. 26
    0
      src/drivers/usb/ehci.c
  2. 2
    0
      src/drivers/usb/ehci.h
  3. 1
    0
      src/include/ipxe/pci.h

+ 26
- 0
src/drivers/usb/ehci.c View File

@@ -337,6 +337,32 @@ static void ehci_poll_companions ( struct ehci_device *ehci ) {
337 337
 	}
338 338
 }
339 339
 
340
+/**
341
+ * Locate EHCI companion controller
342
+ *
343
+ * @v pci		PCI device
344
+ * @ret busdevfn	EHCI companion controller bus:dev.fn (if any)
345
+ */
346
+unsigned int ehci_companion ( struct pci_device *pci ) {
347
+	struct pci_device tmp;
348
+	unsigned int busdevfn;
349
+	int rc;
350
+
351
+	/* Look for an EHCI function on the same PCI device */
352
+	busdevfn = pci->busdevfn;
353
+	while ( ++busdevfn <= PCI_LAST_FUNC ( pci->busdevfn ) ) {
354
+		pci_init ( &tmp, busdevfn );
355
+		if ( ( rc = pci_read_config ( &tmp ) ) != 0 )
356
+			continue;
357
+		if ( tmp.class == PCI_CLASS ( PCI_CLASS_SERIAL,
358
+					      PCI_CLASS_SERIAL_USB,
359
+					      PCI_CLASS_SERIAL_USB_EHCI ) )
360
+			return busdevfn;
361
+	}
362
+
363
+	return 0;
364
+}
365
+
340 366
 /******************************************************************************
341 367
  *
342 368
  * Run / stop / reset

+ 2
- 0
src/drivers/usb/ehci.h View File

@@ -537,4 +537,6 @@ struct ehci_endpoint {
537 537
 	struct ehci_ring ring;
538 538
 };
539 539
 
540
+extern unsigned int ehci_companion ( struct pci_device *pci );
541
+
540 542
 #endif /* _IPXE_EHCI_H */

+ 1
- 0
src/include/ipxe/pci.h View File

@@ -239,6 +239,7 @@ struct pci_driver {
239 239
 #define PCI_BUSDEVFN( bus, slot, func )	\
240 240
 	( ( (bus) << 8 ) | ( (slot) << 3 ) | ( (func) << 0 ) )
241 241
 #define PCI_FIRST_FUNC( busdevfn )	( (busdevfn) & ~0x07 )
242
+#define PCI_LAST_FUNC( busdevfn )	( (busdevfn) | 0x07 )
242 243
 
243 244
 #define PCI_BASE_CLASS( class )		( (class) >> 16 )
244 245
 #define PCI_SUB_CLASS( class )		( ( (class) >> 8 ) & 0xff )

Loading…
Cancel
Save