From owner-p4-projects@FreeBSD.ORG Wed Sep 9 23:41:03 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BEDEE1065679; Wed, 9 Sep 2009 23:41:02 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B3CE1065670 for ; Wed, 9 Sep 2009 23:41:02 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4FBC78FC0C for ; Wed, 9 Sep 2009 23:41:02 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n89Nf25U027279 for ; Wed, 9 Sep 2009 23:41:02 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n89Nf26J027277 for perforce@freebsd.org; Wed, 9 Sep 2009 23:41:02 GMT (envelope-from hselasky@FreeBSD.org) Date: Wed, 9 Sep 2009 23:41:02 GMT Message-Id: <200909092341.n89Nf26J027277@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 168389 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2009 23:41:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=168389 Change 168389 by hselasky@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: