PERFORCE change 168389 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Sep 9 23:41:03 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=168389
Change 168389 by hselasky at hselasky_laptop001 on 2009/09/09 23:41:00
USB EHCI:
- correct ATI/AMD EHCI quirk.
- make one function for each quirk.
- reported by: Andriy Gapon
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/ehci_pci.c#12 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/ehci_pci.c#12 (text+ko) ====
@@ -241,32 +241,46 @@
}
static void
-ehci_pci_ati_quirk(device_t dev, uint8_t match_dev)
+ehci_pci_ati_quirk(device_t self, uint8_t is_sb700)
{
- uint32_t temp;
- uint16_t b;
- uint16_t f;
- uint16_t s;
+ device_t smbdev;
+ uint32_t val;
+
+ if (is_sb700) {
+ /* Lookup SMBUS PCI device */
+ smbdev = pci_find_device(PCI_EHCI_VENDORID_ATI, 0x4385);
+ if (smbdev == NULL)
+ return;
+ val = pci_get_revid(smbdev);
+ if (val != 0x3a && val != 0x3b)
+ return;
+ }
+
+ /*
+ * Note: this bit is described as reserved in SB700
+ * Register Reference Guide.
+ */
+ val = pci_read_config(self, 0x53, 1);
+ if (!(val & 0x8)) {
+ val |= 0x8;
+ pci_write_config(self, 0x53, val, 1);
+ device_printf(self, "AMD SB600/700 quirk applied\n");
+ }
+}
- /* Look for ATI SMB PCI controller */
+static void
+ehci_pci_via_quirk(device_t self)
+{
+ uint32_t val;
- 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");
- }
- }
- }
- }
- }
+ if ((pci_get_device(self) == 0x3104) &&
+ ((pci_get_revid(self) & 0xf0) == 0x60)) {
+ /* Correct schedule sleep time to 10us */
+ val = pci_read_config(self, 0x4b, 1);
+ if (val & 0x20)
+ return;
+ pci_write_config(self, 0x4b, val, 1);
+ device_printf(self, "VIA-quirk applied\n");
}
}
@@ -405,13 +419,13 @@
switch (pci_get_vendor(self)) {
case PCI_EHCI_VENDORID_ATI:
- /* SB600 and SB700 EHCI quirk through SMB PCI device */
+ /* SB600 and SB700 EHCI quirk */
switch (pci_get_device(self)) {
case 0x4386:
- ehci_pci_ati_quirk(self, 1);
+ ehci_pci_ati_quirk(self, 0);
break;
case 0x4396:
- ehci_pci_ati_quirk(self, 0);
+ ehci_pci_ati_quirk(self, 1);
break;
default:
break;
@@ -419,16 +433,7 @@
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");
- }
+ ehci_pci_via_quirk(self);
break;
default:
More information about the p4-projects
mailing list