PERFORCE change 168288 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Sep 7 17:45:27 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=168288
Change 168288 by hselasky at hselasky_laptop001 on 2009/09/07 17:44:26
USB controller:
- import two PCI quirks from Linux
- reported by: Dorian Büttner
- patch by: HPS
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/ehci_pci.c#11 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_pci.h#3 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/ehci_pci.c#11 (text+ko) ====
@@ -240,6 +240,36 @@
}
}
+static void
+ehci_pci_ati_quirk(device_t dev, uint8_t match_dev)
+{
+ uint32_t temp;
+ uint16_t b;
+ uint16_t f;
+ uint16_t s;
+
+ /* Look for ATI SMB PCI controller */
+
+ for (b = 0; b <= PCI_BUSMAX; b++) {
+ for (f = 0; f <= PCI_FUNCMAX; f++) {
+ for (s = 0; s <= PCI_SLOTMAX; s++) {
+ temp = pcib_read_config(dev, b, s, f, PCIR_DEVVENDOR, 4);
+ if (temp == 0x43851002) {
+ temp = pcib_read_config(dev, b, s, f, PCIR_REVID, 1);
+ if (match_dev || (temp == 0x3a) || (temp == 0x3b)) {
+ temp = pcib_read_config(dev, b, s, f, 0x53, 1);
+ if (!(temp & 0x08)) {
+ temp |= 0x08;
+ pcib_write_config(dev, b, s, f, 0x53, temp, 1);
+ device_printf(dev, "ATI-quirk applied\n");
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
static int
ehci_pci_attach(device_t self)
{
@@ -370,6 +400,41 @@
goto error;
}
ehci_pci_takecontroller(self);
+
+ /* Undocumented quirks taken from Linux */
+
+ switch (pci_get_vendor(self)) {
+ case PCI_EHCI_VENDORID_ATI:
+ /* SB600 and SB700 EHCI quirk through SMB PCI device */
+ switch (pci_get_device(self)) {
+ case 0x4386:
+ ehci_pci_ati_quirk(self, 1);
+ break;
+ case 0x4396:
+ ehci_pci_ati_quirk(self, 0);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case PCI_EHCI_VENDORID_VIA:
+ if ((pci_get_device(self) == 0x3104) &&
+ ((pci_get_revid(self) & 0xf0) == 0x60)) {
+ /* Correct schedule sleep time to 10us */
+ uint8_t temp;
+ temp = pci_read_config(self, 0x4b, 1);
+ if (temp & 0x20)
+ break;
+ pci_write_config(self, 0x4b, temp, 1);
+ device_printf(self, "VIA-quirk applied\n");
+ }
+ break;
+
+ default:
+ break;
+ }
+
err = ehci_init(sc);
if (!err) {
err = device_probe_and_attach(sc->sc_bus.bdev);
==== //depot/projects/usb/src/sys/dev/usb/usb_pci.h#3 (text+ko) ====
@@ -33,6 +33,7 @@
*/
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/pcib_private.h>
#include <sys/rman.h>
More information about the p4-projects
mailing list