2006-03-11 05:35:06 +03:00
|
|
|
/* $NetBSD: agp_intel.c,v 1.18 2006/03/11 02:35:06 jmcneill Exp $ */
|
2001-09-10 14:01:00 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Doug Rabson
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD: src/sys/pci/agp_intel.c,v 1.4 2001/07/05 21:28:47 jhb Exp $
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:48:40 +03:00
|
|
|
#include <sys/cdefs.h>
|
2006-03-11 05:35:06 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: agp_intel.c,v 1.18 2006/03/11 02:35:06 jmcneill Exp $");
|
2001-11-13 10:48:40 +03:00
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/agpio.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/agpio.h>
|
|
|
|
|
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
2003-06-09 16:16:42 +04:00
|
|
|
#include <dev/pci/pcidevs.h>
|
2001-09-10 14:01:00 +04:00
|
|
|
#include <dev/pci/agpvar.h>
|
|
|
|
#include <dev/pci/agpreg.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
struct agp_intel_softc {
|
2003-06-09 16:16:42 +04:00
|
|
|
u_int32_t initial_aperture;
|
|
|
|
/* aperture size at startup */
|
|
|
|
struct agp_gatt *gatt;
|
2003-06-26 00:33:59 +04:00
|
|
|
struct pci_attach_args vga_pa;
|
|
|
|
u_int aperture_mask;
|
|
|
|
int chiptype; /* Chip type */
|
2003-06-14 15:40:20 +04:00
|
|
|
#define CHIP_INTEL 0x0
|
|
|
|
#define CHIP_I443 0x1
|
|
|
|
#define CHIP_I840 0x2
|
|
|
|
#define CHIP_I845 0x3
|
|
|
|
#define CHIP_I850 0x4
|
2003-08-26 22:43:54 +04:00
|
|
|
#define CHIP_I865 0x5
|
2006-03-11 05:35:06 +03:00
|
|
|
|
|
|
|
void *sc_powerhook;
|
|
|
|
struct pci_conf_state sc_pciconf;
|
2001-09-10 14:01:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static u_int32_t agp_intel_get_aperture(struct agp_softc *);
|
|
|
|
static int agp_intel_set_aperture(struct agp_softc *, u_int32_t);
|
|
|
|
static int agp_intel_bind_page(struct agp_softc *, off_t, bus_addr_t);
|
|
|
|
static int agp_intel_unbind_page(struct agp_softc *, off_t);
|
|
|
|
static void agp_intel_flush_tlb(struct agp_softc *);
|
2006-03-11 05:35:06 +03:00
|
|
|
static void agp_intel_powerhook(int, void *);
|
2001-09-10 14:01:00 +04:00
|
|
|
|
2005-06-28 04:28:41 +04:00
|
|
|
static struct agp_methods agp_intel_methods = {
|
2001-09-10 14:01:00 +04:00
|
|
|
agp_intel_get_aperture,
|
|
|
|
agp_intel_set_aperture,
|
|
|
|
agp_intel_bind_page,
|
|
|
|
agp_intel_unbind_page,
|
|
|
|
agp_intel_flush_tlb,
|
|
|
|
agp_generic_enable,
|
|
|
|
agp_generic_alloc_memory,
|
|
|
|
agp_generic_free_memory,
|
|
|
|
agp_generic_bind_memory,
|
|
|
|
agp_generic_unbind_memory,
|
|
|
|
};
|
|
|
|
|
2003-06-09 16:16:42 +04:00
|
|
|
static int
|
|
|
|
agp_intel_vgamatch(struct pci_attach_args *pa)
|
|
|
|
{
|
|
|
|
switch (PCI_PRODUCT(pa->pa_id)) {
|
|
|
|
case PCI_PRODUCT_INTEL_82855PM_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82443LX_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82443BX_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82443GX_AGP:
|
2003-06-26 00:33:59 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82850_AGP: /* i850/i860 */
|
2003-06-09 16:16:42 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82845_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82840_AGP:
|
2003-07-06 16:39:41 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82865_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82875P_AGP:
|
2003-06-09 16:16:42 +04:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
int
|
|
|
|
agp_intel_attach(struct device *parent, struct device *self, void *aux)
|
|
|
|
{
|
|
|
|
struct agp_softc *sc = (struct agp_softc *)self;
|
|
|
|
struct pci_attach_args *pa= aux;
|
|
|
|
struct agp_intel_softc *isc;
|
|
|
|
struct agp_gatt *gatt;
|
|
|
|
pcireg_t reg;
|
2003-06-26 00:33:59 +04:00
|
|
|
u_int32_t value;
|
2001-09-10 14:01:00 +04:00
|
|
|
|
2002-01-12 19:17:05 +03:00
|
|
|
isc = malloc(sizeof *isc, M_AGP, M_NOWAIT|M_ZERO);
|
2001-09-10 14:01:00 +04:00
|
|
|
if (isc == NULL) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error(": can't allocate chipset-specific softc\n");
|
2001-09-10 14:01:00 +04:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
2001-09-11 10:30:38 +04:00
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
sc->as_methods = &agp_intel_methods;
|
2001-09-11 10:30:38 +04:00
|
|
|
sc->as_chipc = isc;
|
|
|
|
|
2003-06-09 16:16:42 +04:00
|
|
|
if (pci_find_device(&isc->vga_pa, agp_intel_vgamatch) == 0) {
|
2003-06-26 00:33:59 +04:00
|
|
|
aprint_normal(": using generic initialization for Intel AGP\n");
|
2003-07-22 15:59:55 +04:00
|
|
|
aprint_normal("%s", sc->as_dev.dv_xname);
|
2003-06-26 00:33:59 +04:00
|
|
|
isc->chiptype = CHIP_INTEL;
|
2003-06-09 16:16:42 +04:00
|
|
|
}
|
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP, &sc->as_capoff,
|
|
|
|
NULL);
|
|
|
|
|
2006-01-17 01:59:36 +03:00
|
|
|
if (agp_map_aperture(pa, sc, AGP_APBASE) != 0) {
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error(": can't map aperture\n");
|
2001-09-10 14:01:00 +04:00
|
|
|
free(isc, M_AGP);
|
2001-09-11 10:30:38 +04:00
|
|
|
sc->as_chipc = NULL;
|
2001-09-10 14:01:00 +04:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2003-06-09 16:16:42 +04:00
|
|
|
switch (PCI_PRODUCT(isc->vga_pa.pa_id)) {
|
2003-08-26 22:43:54 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82443LX_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82443BX_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82443GX_AGP:
|
|
|
|
isc->chiptype = CHIP_I443;
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
|
|
|
case PCI_PRODUCT_INTEL_82840_AGP:
|
|
|
|
isc->chiptype = CHIP_I840;
|
|
|
|
break;
|
2003-08-26 22:43:54 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82855PM_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82845_AGP:
|
|
|
|
isc->chiptype = CHIP_I845;
|
|
|
|
break;
|
2003-06-14 15:40:20 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82850_AGP:
|
|
|
|
isc->chiptype = CHIP_I850;
|
|
|
|
break;
|
2003-08-26 22:43:54 +04:00
|
|
|
case PCI_PRODUCT_INTEL_82865_AGP:
|
|
|
|
case PCI_PRODUCT_INTEL_82875P_AGP:
|
|
|
|
isc->chiptype = CHIP_I865;
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-06-26 00:33:59 +04:00
|
|
|
/* Determine maximum supported aperture size. */
|
|
|
|
value = pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_APSIZE);
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_APSIZE, APSIZE_MASK);
|
|
|
|
isc->aperture_mask = pci_conf_read(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_APSIZE) & APSIZE_MASK;
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_APSIZE, value);
|
2001-09-10 14:01:00 +04:00
|
|
|
isc->initial_aperture = AGP_GET_APERTURE(sc);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
gatt = agp_alloc_gatt(sc);
|
|
|
|
if (gatt)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Probably contigmalloc failure. Try reducing the
|
|
|
|
* aperture so that the gatt size reduces.
|
|
|
|
*/
|
|
|
|
if (AGP_SET_APERTURE(sc, AGP_GET_APERTURE(sc) / 2)) {
|
|
|
|
agp_generic_detach(sc);
|
2003-01-31 03:07:39 +03:00
|
|
|
aprint_error(": failed to set aperture\n");
|
2001-09-10 14:01:00 +04:00
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isc->gatt = gatt;
|
|
|
|
|
|
|
|
/* Install the gatt. */
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_ATTBASE,
|
|
|
|
gatt->ag_physical);
|
2003-06-14 15:40:20 +04:00
|
|
|
|
|
|
|
/* Enable the GLTB and setup the control register. */
|
|
|
|
switch (isc->chiptype) {
|
|
|
|
case CHIP_I443:
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
|
|
|
AGPCTRL_AGPRSE | AGPCTRL_GTLB);
|
|
|
|
|
|
|
|
default:
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
2003-06-14 15:44:51 +04:00
|
|
|
pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL)
|
|
|
|
| AGPCTRL_GTLB);
|
2003-06-14 15:40:20 +04:00
|
|
|
}
|
2003-06-26 00:33:59 +04:00
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
/* Enable things, clear errors etc. */
|
2003-06-09 16:16:42 +04:00
|
|
|
switch (isc->chiptype) {
|
|
|
|
case CHIP_I845:
|
2003-08-26 22:43:54 +04:00
|
|
|
case CHIP_I865:
|
2003-06-09 16:16:42 +04:00
|
|
|
{
|
2003-08-26 22:43:54 +04:00
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_I840_MCHCFG);
|
|
|
|
reg |= MCHCFG_AAGN;
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_I840_MCHCFG, reg);
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CHIP_I840:
|
2003-06-14 15:40:20 +04:00
|
|
|
case CHIP_I850:
|
2003-06-09 16:16:42 +04:00
|
|
|
{
|
2003-06-26 00:33:59 +04:00
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCMD);
|
|
|
|
reg |= AGPCMD_AGPEN;
|
2003-06-09 16:16:42 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCMD,
|
2003-06-26 00:33:59 +04:00
|
|
|
reg);
|
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_I840_MCHCFG);
|
|
|
|
reg |= MCHCFG_AAGN;
|
2003-06-14 15:40:20 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_I840_MCHCFG,
|
2003-06-26 00:33:59 +04:00
|
|
|
reg);
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-06-14 15:40:20 +04:00
|
|
|
default:
|
2003-06-09 16:16:42 +04:00
|
|
|
{
|
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_NBXCFG);
|
|
|
|
reg &= ~NBXCFG_APAE;
|
|
|
|
reg |= NBXCFG_AAGN;
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_NBXCFG, reg);
|
2003-06-14 15:40:20 +04:00
|
|
|
}
|
|
|
|
}
|
2003-06-09 16:16:42 +04:00
|
|
|
|
2003-06-14 15:40:20 +04:00
|
|
|
/* Clear Error status */
|
2003-06-14 15:44:51 +04:00
|
|
|
switch (isc->chiptype) {
|
2003-06-14 15:40:20 +04:00
|
|
|
case CHIP_I840:
|
2003-06-14 15:44:51 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_I8XX_ERRSTS, 0xc000);
|
2003-06-14 15:40:20 +04:00
|
|
|
break;
|
2003-06-09 16:16:42 +04:00
|
|
|
|
2003-06-26 00:33:59 +04:00
|
|
|
case CHIP_I845:
|
2003-08-26 22:43:54 +04:00
|
|
|
case CHIP_I850:
|
|
|
|
case CHIP_I865:
|
2003-06-14 15:44:51 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_I8XX_ERRSTS, 0x00ff);
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
2003-06-14 15:40:20 +04:00
|
|
|
|
|
|
|
default:
|
2003-06-14 15:44:51 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_ERRSTS, 0x70);
|
2003-06-09 16:16:42 +04:00
|
|
|
}
|
2001-09-10 14:01:00 +04:00
|
|
|
|
2006-03-11 05:35:06 +03:00
|
|
|
isc->sc_powerhook = powerhook_establish(agp_intel_powerhook, sc);
|
|
|
|
if (isc->sc_powerhook == NULL)
|
|
|
|
aprint_error("%s: couldn't establish powerhook\n",
|
|
|
|
sc->as_dev.dv_xname);
|
|
|
|
|
2003-06-26 00:33:59 +04:00
|
|
|
return (0);
|
2001-09-10 14:01:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static int
|
|
|
|
agp_intel_detach(struct agp_softc *sc)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
pcireg_t reg;
|
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
|
|
|
|
2006-03-11 05:35:06 +03:00
|
|
|
if (isc->sc_powerhook)
|
|
|
|
powerhook_disestablish(isc->sc_powerhook);
|
|
|
|
|
2001-09-10 14:01:00 +04:00
|
|
|
error = agp_generic_detach(sc);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
2003-06-09 16:16:42 +04:00
|
|
|
/* XXX i845/i855PM/i840/i850E */
|
2001-09-10 14:01:00 +04:00
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_NBXCFG);
|
|
|
|
reg &= ~(1 << 9);
|
|
|
|
printf("%s: set NBXCFG to %x\n", __FUNCTION__, reg);
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_NBXCFG, reg);
|
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_ATTBASE, 0);
|
|
|
|
AGP_SET_APERTURE(sc, isc->initial_aperture);
|
|
|
|
agp_free_gatt(sc, isc->gatt);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static u_int32_t
|
|
|
|
agp_intel_get_aperture(struct agp_softc *sc)
|
|
|
|
{
|
2003-06-26 00:33:59 +04:00
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
2001-09-10 14:01:00 +04:00
|
|
|
u_int32_t apsize;
|
|
|
|
|
2003-06-09 16:16:42 +04:00
|
|
|
apsize = pci_conf_read(sc->as_pc, sc->as_tag,
|
2003-06-26 00:33:59 +04:00
|
|
|
AGP_INTEL_APSIZE) & isc->aperture_mask;
|
2001-09-10 14:01:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The size is determined by the number of low bits of
|
|
|
|
* register APBASE which are forced to zero. The low 22 bits
|
|
|
|
* are always forced to zero and each zero bit in the apsize
|
|
|
|
* field just read forces the corresponding bit in the 27:22
|
|
|
|
* to be zero. We calculate the aperture size accordingly.
|
|
|
|
*/
|
2003-06-26 00:33:59 +04:00
|
|
|
return (((apsize ^ isc->aperture_mask) << 22) | ((1 << 22) - 1)) + 1;
|
2001-09-10 14:01:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
agp_intel_set_aperture(struct agp_softc *sc, u_int32_t aperture)
|
|
|
|
{
|
2003-06-26 00:33:59 +04:00
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
2001-09-10 14:01:00 +04:00
|
|
|
u_int32_t apsize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reverse the magic from get_aperture.
|
|
|
|
*/
|
2003-06-26 00:33:59 +04:00
|
|
|
apsize = ((aperture - 1) >> 22) ^ isc->aperture_mask;
|
2001-09-10 14:01:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Double check for sanity.
|
|
|
|
*/
|
2003-06-26 00:33:59 +04:00
|
|
|
if ((((apsize ^ isc->aperture_mask) << 22) |
|
2003-06-09 16:16:42 +04:00
|
|
|
((1 << 22) - 1)) + 1 != aperture)
|
2001-09-10 14:01:00 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
2003-06-26 00:33:59 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag,
|
|
|
|
AGP_INTEL_APSIZE, apsize);
|
2001-09-10 14:01:00 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
agp_intel_bind_page(struct agp_softc *sc, off_t offset, bus_addr_t physical)
|
|
|
|
{
|
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
|
|
|
|
|
|
|
if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
isc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = physical | 0x17;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
agp_intel_unbind_page(struct agp_softc *sc, off_t offset)
|
|
|
|
{
|
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
|
|
|
|
|
|
|
if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
isc->gatt->ag_virtual[offset >> AGP_PAGE_SHIFT] = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
agp_intel_flush_tlb(struct agp_softc *sc)
|
|
|
|
{
|
2003-06-09 16:16:42 +04:00
|
|
|
struct agp_intel_softc *isc = sc->as_chipc;
|
2003-06-26 00:33:59 +04:00
|
|
|
pcireg_t reg;
|
2003-06-09 16:16:42 +04:00
|
|
|
|
|
|
|
switch (isc->chiptype) {
|
2003-08-26 22:43:54 +04:00
|
|
|
case CHIP_I865:
|
2003-08-26 21:28:13 +04:00
|
|
|
case CHIP_I850:
|
|
|
|
case CHIP_I845:
|
|
|
|
case CHIP_I840:
|
2003-06-26 00:33:59 +04:00
|
|
|
case CHIP_I443:
|
|
|
|
{
|
|
|
|
reg = pci_conf_read(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL);
|
2003-08-26 21:28:13 +04:00
|
|
|
reg &= ~AGPCTRL_GTLB;
|
2003-06-09 16:16:42 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
2003-06-26 00:33:59 +04:00
|
|
|
reg);
|
2003-06-09 16:16:42 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
2003-06-26 00:33:59 +04:00
|
|
|
reg | AGPCTRL_GTLB);
|
2003-06-09 16:16:42 +04:00
|
|
|
break;
|
2003-06-26 00:33:59 +04:00
|
|
|
}
|
|
|
|
default: /* XXX */
|
|
|
|
{
|
2003-06-09 16:16:42 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
2003-06-26 00:33:59 +04:00
|
|
|
0x2200);
|
2003-06-09 16:16:42 +04:00
|
|
|
pci_conf_write(sc->as_pc, sc->as_tag, AGP_INTEL_AGPCTRL,
|
2003-06-26 00:33:59 +04:00
|
|
|
0x2280);
|
|
|
|
}
|
2003-06-09 16:16:42 +04:00
|
|
|
}
|
2001-09-10 14:01:00 +04:00
|
|
|
}
|
2006-03-11 05:35:06 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
agp_intel_powerhook(int why, void *opaque)
|
|
|
|
{
|
|
|
|
struct agp_softc *sc;
|
|
|
|
struct agp_intel_softc *isc;
|
|
|
|
|
|
|
|
sc = (struct agp_softc *)opaque;
|
|
|
|
isc = (struct agp_intel_softc *)sc->as_chipc;
|
|
|
|
|
|
|
|
switch (why) {
|
|
|
|
case PWR_SUSPEND:
|
|
|
|
case PWR_STANDBY:
|
|
|
|
pci_conf_capture(sc->as_pc, sc->as_tag, &isc->sc_pciconf);
|
|
|
|
break;
|
|
|
|
case PWR_RESUME:
|
|
|
|
pci_conf_restore(sc->as_pc, sc->as_tag, &isc->sc_pciconf);
|
|
|
|
agp_flush_cache();
|
|
|
|
break;
|
|
|
|
case PWR_SOFTSUSPEND:
|
|
|
|
case PWR_SOFTSTANDBY:
|
|
|
|
case PWR_SOFTRESUME:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|