From owner-svn-src-head@FreeBSD.ORG Mon Dec 21 03:28:05 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7056F106566B; Mon, 21 Dec 2009 03:28:05 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F8E08FC0A; Mon, 21 Dec 2009 03:28:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBL3S5Rx082712; Mon, 21 Dec 2009 03:28:05 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBL3S5fg082710; Mon, 21 Dec 2009 03:28:05 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200912210328.nBL3S5fg082710@svn.freebsd.org> From: Robert Noland Date: Mon, 21 Dec 2009 03:28:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200764 - head/sys/dev/agp X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2009 03:28:05 -0000 Author: rnoland Date: Mon Dec 21 03:28:05 2009 New Revision: 200764 URL: http://svn.freebsd.org/changeset/base/200764 Log: Fix a handful of issues with via agp support. * Read the pci capability register to identify AGP 3 support * Add missing smaller aperture sizes for AGP3 chips. * Fix the aperture size calculation on AGP2 chips. All sizes between 32M and 256M reported as 256M. * Add \n to error string. This all seems to get the CLE266 EPIA-M board agp working properly, now back to work on drm. MFC after: 2 weeks Modified: head/sys/dev/agp/agp_via.c Modified: head/sys/dev/agp/agp_via.c ============================================================================== --- head/sys/dev/agp/agp_via.c Mon Dec 21 03:11:21 2009 (r200763) +++ head/sys/dev/agp/agp_via.c Mon Dec 21 03:28:05 2009 (r200764) @@ -165,39 +165,16 @@ agp_via_attach(device_t dev) struct agp_gatt *gatt; int error; u_int32_t agpsel; + u_int32_t capid; - /* XXX: This should be keying off of whether the bridge is AGP3 capable, - * rather than a bunch of device ids for chipsets that happen to do 8x. - */ - switch (pci_get_devid(dev)) { - case 0x01981106: - case 0x02591106: - case 0x02691106: - case 0x02961106: - case 0x03141106: - case 0x03241106: - case 0x03271106: - case 0x03641106: - case 0x31231106: - case 0x31681106: - case 0x31891106: - case 0x32051106: - case 0x32581106: - case 0xb1981106: - /* The newer VIA chipsets will select the AGP version based on - * what AGP versions the card supports. We still have to - * program it using the v2 registers if it has chosen to use - * compatibility mode. - */ + sc->regs = via_v2_regs; + + /* Look at the capability register to see if we handle AGP3 */ + capid = pci_read_config(dev, agp_find_caps(dev) + AGP_CAPID, 4); + if (((capid >> 20) & 0x0f) >= 3) { agpsel = pci_read_config(dev, AGP_VIA_AGPSEL, 1); if ((agpsel & (1 << 1)) == 0) sc->regs = via_v3_regs; - else - sc->regs = via_v2_regs; - break; - default: - sc->regs = via_v2_regs; - break; } error = agp_generic_attach(dev); @@ -235,7 +212,7 @@ agp_via_attach(device_t dev) pci_write_config(dev, sc->regs[REG_ATTBASE], gatt->ag_physical, 4); /* Enable the aperture. */ - gartctrl = pci_read_config(dev, sc->regs[REG_ATTBASE], 4); + gartctrl = pci_read_config(dev, sc->regs[REG_GARTCTRL], 4); pci_write_config(dev, sc->regs[REG_GARTCTRL], gartctrl | (3 << 7), 4); } @@ -268,7 +245,7 @@ agp_via_get_aperture(device_t dev) u_int32_t apsize; if (sc->regs == via_v2_regs) { - apsize = pci_read_config(dev, sc->regs[REG_APSIZE], 1) & 0x1f; + apsize = pci_read_config(dev, sc->regs[REG_APSIZE], 1); /* * The size is determined by the number of low bits of @@ -295,8 +272,14 @@ agp_via_get_aperture(device_t dev) return 0x04000000; case 0xf38: return 0x02000000; + case 0xf3c: + return 0x01000000; + case 0xf3e: + return 0x00800000; + case 0xf3f: + return 0x00400000; default: - device_printf(dev, "Invalid aperture setting 0x%x", + device_printf(dev, "Invalid aperture setting 0x%x\n", pci_read_config(dev, sc->regs[REG_APSIZE], 2)); return 0; } @@ -345,6 +328,15 @@ agp_via_set_aperture(device_t dev, u_int case 0x02000000: key = 0xf38; break; + case 0x01000000: + key = 0xf3c; + break; + case 0x00800000: + key = 0xf3e; + break; + case 0x00400000: + key = 0xf3f; + break; default: device_printf(dev, "Invalid aperture size (%dMb)\n", aperture / 1024 / 1024);