diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-05-10 14:44:43 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-05-10 14:44:43 +0000 |
commit | be700cb31669b73a1f90a83f992c3248c711640c (patch) | |
tree | 782f45882d54077d51c8acbd11510887fa570e95 | |
parent | 344a2b71e8b6eb11177c15418fbfb117fc61d278 (diff) |
change agp driver attach so that the driver passes in the base address
of its aperture, instead of the BAR and memory type. This is a little
larger, but allows the driver to know it's aperture address. Needed for
some future stuff.
-rw-r--r-- | sys/dev/pci/agp.c | 28 | ||||
-rw-r--r-- | sys/dev/pci/agp_ali.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/agp_amd.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/agp_i810.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/agp_intel.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/agp_sis.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/agp_via.c | 55 | ||||
-rw-r--r-- | sys/dev/pci/agpvar.h | 7 |
8 files changed, 80 insertions, 63 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c index d392c386be0..59dfc602b48 100644 --- a/sys/dev/pci/agp.c +++ b/sys/dev/pci/agp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp.c,v 1.29 2009/04/20 01:28:45 oga Exp $ */ +/* $OpenBSD: agp.c,v 1.30 2009/05/10 14:44:42 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson * All rights reserved. @@ -115,14 +115,13 @@ agpvga_match(struct pci_attach_args *pa) struct device * agp_attach_bus(struct pci_attach_args *pa, const struct agp_methods *methods, - int bar, pcireg_t type, struct device *dev) + bus_addr_t apaddr, struct device *dev) { struct agpbus_attach_args arg; arg.aa_methods = methods; arg.aa_pa = pa; - arg.aa_bar = bar; - arg.aa_type = type; + arg.aa_apaddr = apaddr; printf("\n"); /* newline from the driver that called us */ return (config_found(dev, &arg, agpdev_print)); @@ -149,6 +148,7 @@ agp_attach(struct device *parent, struct device *self, void *aux) sc->sc_chipc = parent; sc->sc_methods = aa->aa_methods; + sc->sc_apaddr = aa->aa_apaddr; static const int agp_max[][2] = { {0, 0}, @@ -191,14 +191,7 @@ agp_attach(struct device *parent, struct device *self, void *aux) pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_AGP, &sc->sc_capoff, NULL); - printf(": "); - if (agp_map_aperture(pa, sc, aa->aa_bar, aa->aa_type) != 0) { - printf("can't map aperture\n"); - sc->sc_chipc = NULL; - return; - } - - printf("aperture at 0x%lx, size 0x%lx\n", (u_long)sc->sc_apaddr, + printf(": aperture at 0x%lx, size 0x%lx\n", (u_long)sc->sc_apaddr, (u_long)sc->sc_methods->get_aperture(sc->sc_chipc)); } @@ -329,17 +322,6 @@ agp_find_memory(struct agp_softc *sc, int id) return (0); } -int -agp_map_aperture(struct pci_attach_args *pa, struct agp_softc *sc, u_int32_t bar, u_int32_t memtype) -{ - /* Find the aperture. Don't map it (yet), this would eat KVA */ - if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, bar, memtype, - &sc->sc_apaddr, NULL, NULL) != 0) - return (ENXIO); - - return (0); -} - struct agp_gatt * agp_alloc_gatt(bus_dma_tag_t dmat, u_int32_t apsize) { diff --git a/sys/dev/pci/agp_ali.c b/sys/dev/pci/agp_ali.c index 5891cbcb743..7591370a19e 100644 --- a/sys/dev/pci/agp_ali.c +++ b/sys/dev/pci/agp_ali.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_ali.c,v 1.7 2008/11/09 22:47:54 oga Exp $ */ +/* $OpenBSD: agp_ali.c,v 1.8 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agp_ali.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ @@ -55,6 +55,7 @@ struct agp_ali_softc { struct agp_gatt *gatt; pci_chipset_tag_t asc_pc; pcitag_t asc_tag; + bus_addr_t asc_apaddr; bus_size_t initial_aperture; }; @@ -107,6 +108,12 @@ agp_ali_attach(struct device *parent, struct device *self, void *aux) asc->asc_pc = pa->pa_pc; asc->initial_aperture = agp_ali_get_aperture(asc); + if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, AGP_APBASE, + PCI_MAPREG_TYPE_MEM, &asc->asc_apaddr, NULL, NULL) != 0) { + printf(": can't get aperture info\n"); + return; + } + for (;;) { bus_size_t size = agp_ali_get_aperture(asc); gatt = agp_alloc_gatt(pa->pa_dmat, size); @@ -134,7 +141,7 @@ agp_ali_attach(struct device *parent, struct device *self, void *aux) pci_conf_write(asc->asc_pc, asc->asc_tag, AGP_ALI_TLBCTRL, reg); asc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_ali_methods, - AGP_APBASE, PCI_MAPREG_TYPE_MEM, &asc->dev); + asc->asc_apaddr, &asc->dev); return; } diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c index e33573e789e..710062ed054 100644 --- a/sys/dev/pci/agp_amd.c +++ b/sys/dev/pci/agp_amd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_amd.c,v 1.10 2009/04/20 01:28:45 oga Exp $ */ +/* $OpenBSD: agp_amd.c,v 1.11 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */ /*- @@ -72,6 +72,7 @@ struct agp_amd_softc { pcitag_t asc_tag; bus_space_handle_t ioh; bus_space_tag_t iot; + bus_addr_t asc_apaddr; bus_size_t initial_aperture; }; @@ -192,6 +193,12 @@ agp_amd_attach(struct device *parent, struct device *self, void *aux) asc->asc_pc = pa->pa_pc; asc->asc_tag = pa->pa_tag; + if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, AGP_APBASE, + PCI_MAPREG_TYPE_MEM, &asc->asc_apaddr, NULL, NULL) != 0) { + printf(": can't get aperture info\n"); + return; + } + error = pci_mapreg_map(pa, AGP_AMD751_REGISTERS, PCI_MAPREG_TYPE_MEM, 0, &asc->iot, &asc->ioh, NULL, NULL, 0); if (error != 0) { @@ -232,7 +239,7 @@ agp_amd_attach(struct device *parent, struct device *self, void *aux) agp_amd_flush_tlb(asc); asc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_amd_methods, - AGP_APBASE, PCI_MAPREG_TYPE_MEM, &asc->dev); + asc->asc_apaddr, &asc->dev); return; } diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 39bf0de8b7b..2e3e3a1059e 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.49 2009/04/29 22:03:09 oga Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.50 2009/05/10 14:44:42 oga Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -68,8 +68,9 @@ struct agp_i810_softc { struct agp_gatt *gatt; struct vga_pci_bar *map; struct vga_pci_bar *gtt_map; - int chiptype; /* i810-like or i830 */ + bus_addr_t isc_apaddr; bus_size_t aperture; /* current aperture size */ + int chiptype; /* i810-like or i830 */ u_int32_t dcache_size; /* i810 only */ u_int32_t stolen; /* number of i830/845 gtt entries for stolen memory */ @@ -230,7 +231,7 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) } if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, gmaddr, memtype, - NULL, &isc->aperture, NULL) != 0) { + &isc->isc_apaddr, &isc->aperture, NULL) != 0) { printf("can't get aperture size\n"); return; } @@ -458,7 +459,7 @@ agp_i810_attach(struct device *parent, struct device *self, void *aux) agp_flush_cache(); isc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_i810_methods, - gmaddr, memtype, &isc->dev); + isc->isc_apaddr, &isc->dev); return; out: diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c index d6e99b19b1d..011bd1512a8 100644 --- a/sys/dev/pci/agp_intel.c +++ b/sys/dev/pci/agp_intel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_intel.c,v 1.12 2008/11/09 15:11:19 oga Exp $ */ +/* $OpenBSD: agp_intel.c,v 1.13 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agp_intel.c,v 1.3 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -53,6 +53,7 @@ struct agp_intel_softc { struct agp_gatt *gatt; pci_chipset_tag_t isc_pc; pcitag_t isc_tag; + bus_addr_t isc_apaddr; u_int aperture_mask; enum { CHIP_INTEL, @@ -163,6 +164,12 @@ agp_intel_attach(struct device *parent, struct device *self, void *aux) isc->chiptype = CHIP_INTEL; } + if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, AGP_APBASE, + PCI_MAPREG_TYPE_MEM, &isc->isc_apaddr, NULL, NULL) != 0) { + printf(": can't get aperture info\n"); + return; + } + /* Determine maximum supported aperture size. */ value = pci_conf_read(pa->pa_pc, pa->pa_tag, AGP_INTEL_APSIZE); pci_conf_write(pa->pa_pc, pa->pa_tag, AGP_INTEL_APSIZE, APSIZE_MASK); @@ -248,7 +255,7 @@ agp_intel_attach(struct device *parent, struct device *self, void *aux) } isc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_intel_methods, - AGP_APBASE, PCI_MAPREG_TYPE_MEM, &isc->dev); + isc->isc_apaddr, &isc->dev); return; } diff --git a/sys/dev/pci/agp_sis.c b/sys/dev/pci/agp_sis.c index 079809cf24c..b9f610e5ff0 100644 --- a/sys/dev/pci/agp_sis.c +++ b/sys/dev/pci/agp_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_sis.c,v 1.10 2008/11/09 22:54:01 oga Exp $ */ +/* $OpenBSD: agp_sis.c,v 1.11 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agp_sis.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -54,6 +54,7 @@ struct agp_sis_softc { struct agp_gatt *gatt; pci_chipset_tag_t ssc_pc; pcitag_t ssc_tag; + bus_addr_t ssc_apaddr; bus_size_t initial_aperture; }; @@ -104,6 +105,12 @@ agp_sis_attach(struct device *parent, struct device *self, void *aux) struct agp_gatt *gatt; pcireg_t reg; + if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, AGP_APBASE, + PCI_MAPREG_TYPE_MEM, &ssc->ssc_apaddr, NULL, NULL) != 0) { + printf(": can't get aperture info\n"); + return; + } + ssc->ssc_pc = pa->pa_pc; ssc->ssc_tag = pa->pa_tag; ssc->initial_aperture = agp_sis_get_aperture(ssc); @@ -135,7 +142,7 @@ agp_sis_attach(struct device *parent, struct device *self, void *aux) pci_conf_write(ssc->ssc_pc, ssc->ssc_tag, AGP_SIS_WINCTRL, reg); ssc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_sis_methods, - AGP_APBASE, PCI_MAPREG_TYPE_MEM, &ssc->dev); + ssc->ssc_apaddr, &ssc->dev); return; } diff --git a/sys/dev/pci/agp_via.c b/sys/dev/pci/agp_via.c index 0c8effd07fe..a1a01ee6f02 100644 --- a/sys/dev/pci/agp_via.c +++ b/sys/dev/pci/agp_via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_via.c,v 1.11 2009/01/04 20:47:35 grange Exp $ */ +/* $OpenBSD: agp_via.c,v 1.12 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agp_via.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -70,6 +70,7 @@ struct agp_via_softc { int *regs; pci_chipset_tag_t vsc_pc; pcitag_t vsc_tag; + bus_addr_t vsc_apaddr; bus_size_t initial_aperture; }; @@ -110,35 +111,41 @@ agp_via_probe(struct device *parent, void *match, void *aux) void agp_via_attach(struct device *parent, struct device *self, void *aux) { - struct agp_via_softc *asc = (struct agp_via_softc *)self; + struct agp_via_softc *vsc = (struct agp_via_softc *)self; struct agp_attach_args *aa = aux; struct pci_attach_args *pa = aa->aa_pa; struct agp_gatt *gatt; pcireg_t agpsel, capval; - asc->vsc_pc = pa->pa_pc; - asc->vsc_tag = pa->pa_tag; + vsc->vsc_pc = pa->pa_pc; + vsc->vsc_tag = pa->pa_tag; pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP, NULL, &capval); + if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, AGP_APBASE, + PCI_MAPREG_TYPE_MEM, &vsc->vsc_apaddr, NULL, NULL) != 0) { + printf(": can't get aperture info\n"); + return; + } + if (AGP_CAPID_GET_MAJOR(capval) >= 3) { agpsel = pci_conf_read(pa->pa_pc, pa->pa_tag, AGP_VIA_AGPSEL); if ((agpsel & (1 << 1)) == 0) { - asc->regs = via_v3_regs; + vsc->regs = via_v3_regs; printf(": v3"); } else { - asc->regs = via_v2_regs; + vsc->regs = via_v2_regs; printf(": v2 compat mode"); } } else { - asc->regs = via_v2_regs; + vsc->regs = via_v2_regs; printf(": v2"); } - asc->initial_aperture = agp_via_get_aperture(asc); + vsc->initial_aperture = agp_via_get_aperture(vsc); for (;;) { - bus_size_t size = agp_via_get_aperture(asc); + bus_size_t size = agp_via_get_aperture(vsc); gatt = agp_alloc_gatt(pa->pa_dmat, size); if (gatt != NULL) break; @@ -147,33 +154,33 @@ agp_via_attach(struct device *parent, struct device *self, void *aux) * Probably failed to alloc congigious memory. Try reducing the * aperture so that the gatt size reduces. */ - if (agp_via_set_aperture(asc, size / 2)) { + if (agp_via_set_aperture(vsc, size / 2)) { printf(", can't set aperture size\n"); return; } } - asc->gatt = gatt; + vsc->gatt = gatt; - if (asc->regs == via_v2_regs) { + if (vsc->regs == via_v2_regs) { /* Install the gatt. */ - pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_ATTBASE], + pci_conf_write(pa->pa_pc, pa->pa_tag, vsc->regs[REG_ATTBASE], gatt->ag_physical | 3); /* Enable the aperture. */ - pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_GARTCTRL], + pci_conf_write(pa->pa_pc, pa->pa_tag, vsc->regs[REG_GARTCTRL], 0x0000000f); } else { pcireg_t gartctrl; /* Install the gatt. */ - pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_ATTBASE], + pci_conf_write(pa->pa_pc, pa->pa_tag, vsc->regs[REG_ATTBASE], gatt->ag_physical); /* Enable the aperture. */ gartctrl = pci_conf_read(pa->pa_pc, pa->pa_tag, - asc->regs[REG_ATTBASE]); - pci_conf_write(pa->pa_pc, pa->pa_tag, asc->regs[REG_GARTCTRL], + vsc->regs[REG_ATTBASE]); + pci_conf_write(pa->pa_pc, pa->pa_tag, vsc->regs[REG_GARTCTRL], gartctrl | (3 << 7)); } - asc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_via_methods, - AGP_APBASE, PCI_MAPREG_TYPE_MEM, &asc->dev); + vsc->agpdev = (struct agp_softc *)agp_attach_bus(pa, &agp_via_methods, + vsc->vsc_apaddr, &vsc->dev); return; } @@ -182,17 +189,17 @@ agp_via_attach(struct device *parent, struct device *self, void *aux) int agp_via_detach(struct agp_softc *sc) { - struct agp_via_softc *asc = sc->sc_chipc; + struct agp_via_softc *vsc = sc->sc_chipc; int error; error = agp_generic_detach(sc); if (error) return (error); - pci_conf_write(sc->as_pc, sc->as_tag, asc->regs[REG_GARTCTRL], 0); - pci_conf_write(sc->as_pc, sc->as_tag, asc->regs[REG_ATTBASE], 0); - AGP_SET_APERTURE(sc, asc->initial_aperture); - agp_free_gatt(sc, asc->gatt); + pci_conf_write(sc->as_pc, sc->as_tag, vsc->regs[REG_GARTCTRL], 0); + pci_conf_write(sc->as_pc, sc->as_tag, vsc->regs[REG_ATTBASE], 0); + AGP_SET_APERTURE(sc, vsc->initial_aperture); + agp_free_gatt(sc, vsc->gatt); return (0); } diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h index 4e810649b23..5e270ca205e 100644 --- a/sys/dev/pci/agpvar.h +++ b/sys/dev/pci/agpvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: agpvar.h,v 1.16 2009/04/20 01:28:45 oga Exp $ */ +/* $OpenBSD: agpvar.h,v 1.17 2009/05/10 14:44:42 oga Exp $ */ /* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */ /*- @@ -52,8 +52,7 @@ struct agpbus_attach_args { char *aa_busname; /*so pci doesn't conflict*/ struct pci_attach_args *aa_pa; const struct agp_methods *aa_methods; - int aa_bar; - pcireg_t aa_type; + bus_addr_t aa_apaddr; }; enum agp_acquire_state { @@ -150,7 +149,7 @@ struct agp_gatt { * Functions private to the AGP code. */ struct device *agp_attach_bus(struct pci_attach_args *, - const struct agp_methods *, int, pcireg_t, + const struct agp_methods *, bus_addr_t, struct device *); int agp_map_aperture(struct pci_attach_args *, struct agp_softc *, u_int32_t, u_int32_t); |