Patchwork libpayload: scan all PCI functions for USB

login
register
about
Submitter Jens Rottmann
Date 2010-09-03 14:44:40
Message ID <4C8109D8.1030100@LiPPERTEmbedded.de>
Download mbox | patch
Permalink /patch/1858/
State Accepted
Headers show

Comments

Jens Rottmann - 2010-09-03 14:44:40
The AMD CS5536's USB controllers are located at device 0F, functions 4
and 5.  They're not found if only function 0 is checked.  So if a device
exists at all, try all its functions.  usb_controller_initialize() will
silently skip all device classes != 0C03.

Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
---
Patrick Georgi - 2010-09-03 14:55:15
Am 03.09.2010 16:44, schrieb Jens Rottmann:
> The AMD CS5536's USB controllers are located at device 0F, functions 4
> and 5.  They're not found if only function 0 is checked.  So if a device
> exists at all, try all its functions.  usb_controller_initialize() will
> silently skip all device classes != 0C03.
Oh my.. I suppose that's technically legal. *sigh*
Good catch!

I kept the access at 32bit, as this is not a 16bit value, and somewhere
hidden in some addendum to some obscure PCI standard they certainly
require 32bit accesses, with some hardware out there probably relying on
conformance to that.
If the 32bit access is actually an issue for your hardware, please note
so and we can try the change.

> Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>

and committed in r5774


Thanks,
Patrick

Patch

--- payloads/libpayload/drivers/usb/usbinit.c	(rev 5767)
+++ payloads/libpayload/drivers/usb/usbinit.c	(working copy)
@@ -126,7 +126,7 @@ 
 	 */
 	for (bus = 0; bus < 256; bus++)
 		for (dev = 0; dev < 32; dev++)
-			if (pci_read_config32 (PCI_DEV(bus, dev, 0), 8) >> 16 == 0x0c03)
+			if (pci_read_config16(PCI_DEV(bus, dev, 0), 10) != 0xFFFF)
 				for (func = 7; func >= 0 ; func--)
 					usb_controller_initialize (bus, dev, func);
 	usb_poll();