|
|||||||||||
|
Re: A driver for i830M
From: Todd C. Miller <Todd.Miller(at)courtesan.com>
Date: Tue Mar 18 2003 - 19:19:52 EST
Index: arch/i386/pci/agp_machdep.c RCS file: /cvs/src/sys/arch/i386/pci/agp_machdep.c,v retrieving revision 1.1 diff -u -r1.1 agp_machdep.c --- arch/i386/pci/agp_machdep.c 12 Jul 2002 20:17:03 -0000 1.1 +++ arch/i386/pci/agp_machdep.c 18 Mar 2003 19:34:00 -0000Index: dev/pci/agp_i810.c RCS file: /cvs/src/sys/dev/pci/agp_i810.c,v retrieving revision 1.4 diff -u -r1.4 agp_i810.c --- dev/pci/agp_i810.c 13 Feb 2003 20:07:33 -0000 1.4 +++ dev/pci/agp_i810.c 18 Mar 2003 20:39:18 -0000 /*-
#include <machine/bus.h> #define READ1(off) bus_space_read_1(isc->bst, isc->bsh, off) +#define READ4(off) bus_space_read_4(isc->bst, isc->bsh, off) #define WRITE4(off,v) bus_space_write_4(isc->bst, isc->bsh, off, v) +#define CHIP_I810 0 /* i810/i815 */ +#define CHIP_I830 1 /* i830/i845 */ + struct agp_i810_softc { - u_int32_t initial_aperture; /* aperture size at startup */ + u_int32_t initial_aperture; /* aperture size at startup */ struct agp_gatt *gatt; - u_int32_t dcache_size; - bus_space_tag_t bst; /* bus_space tag */ - bus_space_handle_t bsh; /* bus_space handle */ + 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 */ + bus_space_tag_t bst; /* bus_space tag */ + bus_space_handle_t bsh; /* bus_space handle */ + struct pci_attach_args bridge_pa; };
u_int32_t agp_i810_get_aperture(struct vga_pci_softc *);
agp_i810_unbind_memory,
-
-agp_i810_attach(struct vga_pci_softc* sc, struct pci_attach_args *pa,
+agp_i810_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa,
struct pci_attach_args *pchb_pa)
{
struct agp_i810_softc *isc;
@@ -122,29 +141,78 @@ isc->initial_aperture = AGP_GET_APERTURE(sc);
/* * Make sure the chipset can see everything. @@ -157,54 +225,115 @@ u_int32_t agp_i810_get_aperture(struct vga_pci_softc *sc) {
- u_int16_t miscc;
+ struct agp_i810_softc *isc = sc->sc_chipc;
+ pcireg_t reg;
- miscc = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM) >> 16;
- if ((miscc & AGP_I810_MISCC_WINSIZE) == AGP_I810_MISCC_WINSIZE_32)
- return (32 * 1024 * 1024);
- else
- return (64 * 1024 * 1024);
+ if (isc->chiptype == CHIP_I810) {
+ u_int16_t miscc;
+
+ reg = pci_conf_read(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I810_SMRAM);
+ miscc = (u_int16_t)(reg >> 16);
+ if ((miscc & AGP_I810_MISCC_WINSIZE) ==
+ AGP_I810_MISCC_WINSIZE_32)
+ return (32 * 1024 * 1024);
+ else
+ return (64 * 1024 * 1024);
+ } else { /* I830 */
+ u_int16_t gcc1;
+
+ reg = pci_conf_read(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I830_GCC0);
+ gcc1 = (u_int16_t)(reg >> 16);
+ if ((gcc1 & AGP_I830_GCC1_GMASIZE) == AGP_I830_GCC1_GMASIZE_64)
+ return (64 * 1024 * 1024);
+ else
+ return (128 * 1024 * 1024);
+ }
}
int
- pcireg_t reg, miscc;
+ struct agp_i810_softc *isc = sc->sc_chipc;
+ pcireg_t reg;
- /*
- * Double check for sanity.
- */
- if (aperture != 32 * 1024 * 1024 && aperture != 64 * 1024 * 1024) {
- printf("AGP: bad aperture size %d\n", aperture);
- return (EINVAL);
- }
+ if (isc->chiptype == CHIP_I810) {
+ u_int16_t miscc;
- reg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM);
- miscc = reg >> 16;
- miscc &= ~AGP_I810_MISCC_WINSIZE;
- if (aperture == 32 * 1024 * 1024)
- miscc |= AGP_I810_MISCC_WINSIZE_32;
- else
- miscc |= AGP_I810_MISCC_WINSIZE_64;
-
- reg &= 0x0000ffff;
- reg |= (miscc << 16);
- pci_conf_write(sc->sc_pc, sc->sc_pcitag, AGP_I810_SMRAM, miscc);
+ /*
+ * Double check for sanity.
+ */
+ if (aperture != (32 * 1024 * 1024) &&
+ aperture != (64 * 1024 * 1024)) {
+ printf("agp: bad aperture size %d\n", aperture);
+ return (EINVAL);
+ }
+
+ reg = pci_conf_read(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I810_SMRAM);
+ miscc = (u_int16_t)(reg >> 16);
+ miscc &= ~AGP_I810_MISCC_WINSIZE;
+ if (aperture == 32 * 1024 * 1024)
+ miscc |= AGP_I810_MISCC_WINSIZE_32;
+ else
+ miscc |= AGP_I810_MISCC_WINSIZE_64;
+
+ reg &= 0x0000ffff;
+ reg |= ((pcireg_t)miscc) << 16;
+ pci_conf_write(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I810_SMRAM, reg);
+ } else { /* I830 */
+ u_int16_t gcc1;
+
+ if (aperture != (64 * 1024 * 1024) &&
+ aperture != (128 * 1024 * 1024)) {
+ printf("agp: bad aperture size %d\n", aperture);
+ return (EINVAL);
+ }
+ reg = pci_conf_read(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I830_GCC0);
+ gcc1 = (u_int16_t)(reg >> 16);
+ gcc1 &= ~AGP_I830_GCC1_GMASIZE;
+ if (aperture == 64 * 1024 * 1024)
+ gcc1 |= AGP_I830_GCC1_GMASIZE_64;
+ else
+ gcc1 |= AGP_I830_GCC1_GMASIZE_128;
+
+ reg &= 0x0000ffff;
+ reg |= ((pcireg_t)gcc1) << 16;
+ pci_conf_write(isc->bridge_pa.pa_pc,
+ isc->bridge_pa.pa_tag, AGP_I830_GCC0, reg);
+ }
return (0);
}
int
struct agp_i810_softc *isc = sc->sc_chipc;
+ WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, + physical | 1); return (0); }
@@ -216,6 +345,15 @@
if (offset < 0 || offset >= (isc->gatt->ag_entries << AGP_PAGE_SHIFT))
return (EINVAL);
+ if (isc->chiptype == CHIP_I830 ) {
+ if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
+#ifdef DEBUG
+ printf("agp: trying to unbind from stolen memory\n");
+#endif
+ return (EINVAL);
+ }
+ }
+
WRITE4(AGP_I810_GTT + (u_int32_t)(offset >> AGP_PAGE_SHIFT) * 4, 0);
return (0);
} @@ -245,6 +383,8 @@
/*
* Mapping local DRAM into GATT.
*/
+ if (isc->chiptype == CHIP_I830 )
+ return (NULL);
if (size != isc->dcache_size)
return (NULL);
} else if (type == 2) {
- +
if (type == 2) {
+ /*
+ * Allocate and wire down the page now so that we can
+ * get its physical address.
+ */
mem->am_dmaseg = malloc(sizeof *mem->am_dmaseg, M_DEVBUF,
M_WAITOK);
-
if ((error = agp_alloc_dmamem(sc->sc_dmat, size, 0,
&mem->am_dmamap, &mem->am_virtual, &mem->am_physical,
mem->am_dmaseg, 1, &mem->am_nseg)) != 0) {
@@ -294,7 +437,7 @@ { if (mem->am_is_bound) return (EBUSY); - +
if (mem->am_type == 2) {
agp_free_dmamem(sc->sc_dmat, mem->am_size, mem->am_dmamap,
mem->am_virtual, mem->am_dmaseg, mem->am_nseg);
}
@@ -365,8 +512,11 @@
if (mem->am_type != 1) return (agp_generic_unbind_memory(sc, mem)); + if (isc->chiptype == CHIP_I830) + return (EINVAL); + for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) WRITE4(AGP_I810_GTT + (i >> AGP_PAGE_SHIFT) * 4, 0); - + mem->am_is_bound = 0; return (0); } Index: dev/pci/agpreg.h RCS file: /cvs/src/sys/dev/pci/agpreg.h,v retrieving revision 1.1 diff -u -r1.1 agpreg.h --- dev/pci/agpreg.h 12 Jul 2002 20:17:03 -0000 1.1 +++ dev/pci/agpreg.h 18 Mar 2003 19:34:00 -0000+ #endif /* !_PCI_AGPREG_H_ */ Index: dev/pci/pcidevs RCS file: /cvs/src/sys/dev/pci/pcidevs,v retrieving revision 1.606 diff -u -r1.606 pcidevs --- dev/pci/pcidevs 12 Mar 2003 21:44:09 -0000 1.606 +++ dev/pci/pcidevs 18 Mar 2003 19:34:41 -0000Index: dev/pci/pcidevs.h RCS file: /cvs/src/sys/dev/pci/pcidevs.h,v retrieving revision 1.607 diff -u -r1.607 pcidevs.h --- dev/pci/pcidevs.h 12 Mar 2003 21:44:43 -0000 1.607 +++ dev/pci/pcidevs.h 18 Mar 2003 19:34:48 -0000Index: dev/pci/pcidevs_data.h RCS file: /cvs/src/sys/dev/pci/pcidevs_data.h,v retrieving revision 1.607 diff -u -r1.607 pcidevs_data.h --- dev/pci/pcidevs_data.h 12 Mar 2003 21:44:43 -0000 1.607 +++ dev/pci/pcidevs_data.h 18 Mar 2003 19:34:48 -0000Received on Tue Mar 18 19:21:44 2003 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:48:37 EDT |
||||||||||
|
|||||||||||