Index: agp_i810.c =================================================================== RCS file: /home/dhd-cvs/agp/freebsd/agp_i810.c,v retrieving revision 1.5 retrieving revision 1.7 diff -u -r1.5 -r1.7 --- agp_i810.c 2002/09/16 01:15:24 1.5 +++ agp_i810.c 2003/02/12 22:30:14 1.7 @@ -29,6 +29,7 @@ /* * Fixes for 830/845G support: David Dawes + * 852GM/855GM/865G support added by David Dawes */ #include "opt_bus.h" @@ -63,7 +64,8 @@ #define WRITE4(off,v) bus_space_write_4(sc->bst, sc->bsh, off, v) #define CHIP_I810 0 /* i810/i815 */ -#define CHIP_I830 1 /* i830/i845 */ +#define CHIP_I830 1 /* 830M/845G */ +#define CHIP_I855 2 /* 852GM/855GM/865G */ struct agp_i810_softc { struct agp_softc agp; @@ -99,10 +101,31 @@ return ("Intel 82815 (i815 GMCH) SVGA controller"); case 0x35778086: - return ("Intel 82830 (i830M GMCH) SVGA controller"); + return ("Intel(R) 82830M (830M GMCH) SVGA controller"); case 0x25628086: - return ("Intel 82845 (i845 GMCH) SVGA controller"); + return ("Intel(R) 82845G (845G GMCH) SVGA controller"); + + case 0x35828086: + switch (pci_read_config(dev, AGP_I85X_CAPID, 1)) { + case AGP_I855_GME: + return ("Intel(R) 82855GME (855GME GMCH) SVGA controller"); + + case AGP_I855_GM: + return ("Intel(R) 82855GM (855GM GMCH) SVGA controller"); + + case AGP_I852_GME: + return ("Intel(R) 82852GME (852GME GMCH) SVGA controller"); + + case AGP_I852_GM: + return ("Intel(R) 82852GM (852GM GMCH) SVGA controller"); + + default: + return ("Intel(R) 8285xM (85xGM GMCH) SVGA controller"); + } + + case 0x25728086: + return ("Intel 82865G (865G GMCH) SVGA controller"); }; return NULL; @@ -132,6 +155,8 @@ case 0x11328086: case 0x35778086: case 0x25628086: + case 0x35828086: + case 0x25728086: devid -= 0x20000; break; }; @@ -171,8 +196,10 @@ /* * checking whether internal graphics device has been activated. */ - if ( (devid != 0x35778086 ) && - (devid != 0x25628086 ) ) { + if ( (devid == 0x71218086 ) || + (devid == 0x71238086 ) || + (devid == 0x71258086 ) || + (devid == 0x11328086 ) ) { smram = pci_read_config(bdev, AGP_I810_SMRAM, 1); if ((smram & AGP_I810_SMRAM_GMS) == AGP_I810_SMRAM_GMS_DISABLED) { @@ -224,6 +251,10 @@ case 0x25628086: sc->chiptype = CHIP_I830; break; + case 0x35828086: + case 0x25728086: + sc->chiptype = CHIP_I855; + break; }; /* Same for i810 and i830 */ @@ -271,7 +302,7 @@ agp_flush_cache(); /* Install the GATT. */ WRITE4(AGP_I810_PGTBL_CTL, gatt->ag_physical | 1); - } else { + } else if ( sc->chiptype == CHIP_I830 ) { /* The i830 automatically initializes the 128k gatt on boot. */ unsigned int gcc1, pgtblctl; @@ -305,6 +336,46 @@ WRITE4(AGP_I810_PGTBL_CTL, pgtblctl); gatt->ag_physical = pgtblctl & ~1; + } else { /* CHIP_I855 */ + /* The 855GM automatically initializes the 128k gatt on boot. */ + unsigned int gcc1, pgtblctl; + + gcc1 = pci_read_config(sc->bdev, AGP_I855_GCC1, 1); + switch (gcc1 & AGP_I855_GCC1_GMS) { + case AGP_I855_GCC1_GMS_STOLEN_1M: + sc->stolen = (1024 - 132) * 1024 / 4096; + break; + case AGP_I855_GCC1_GMS_STOLEN_4M: + sc->stolen = (4096 - 132) * 1024 / 4096; + break; + case AGP_I855_GCC1_GMS_STOLEN_8M: + sc->stolen = (8192 - 132) * 1024 / 4096; + break; + case AGP_I855_GCC1_GMS_STOLEN_16M: + sc->stolen = (16384 - 132) * 1024 / 4096; + break; + case AGP_I855_GCC1_GMS_STOLEN_32M: + sc->stolen = (32768 - 132) * 1024 / 4096; + break; + default: + sc->stolen = 0; + device_printf(dev, "unknown memory configuration, disabling\n"); + agp_generic_detach(dev); + return EINVAL; + } + if (sc->stolen > 0) + device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); + device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); + + /* GATT address is already in there, make sure it's enabled */ + pgtblctl = READ4(AGP_I810_PGTBL_CTL); +#if 0 + device_printf(dev, "PGTBL_CTL is 0x%08x\n", pgtblctl); +#endif + pgtblctl |= 1; + WRITE4(AGP_I810_PGTBL_CTL, pgtblctl); + + gatt->ag_physical = pgtblctl & ~1; } /* @@ -361,7 +432,7 @@ return 32 * 1024 * 1024; else return 64 * 1024 * 1024; - } else { /* I830 */ + } else if ( sc->chiptype == CHIP_I830 ) { unsigned int gcc1; gcc1 = pci_read_config(sc->bdev, AGP_I830_GCC1, 2); @@ -369,6 +440,8 @@ return 64 * 1024 * 1024; else return 128 * 1024 * 1024; + } else { /* CHIP_I855 */ + return 128 * 1024 * 1024; } } @@ -395,7 +468,7 @@ miscc |= AGP_I810_MISCC_WINSIZE_64; pci_write_config(sc->bdev, AGP_I810_MISCC, miscc, 2); - } else { /* I830 */ + } else if ( sc->chiptype == CHIP_I830 ) { unsigned int gcc1; if (aperture != 64 * 1024 * 1024 && aperture != 128 * 1024 * 1024) { @@ -410,6 +483,11 @@ gcc1 |= AGP_I830_GCC1_GMASIZE_128; pci_write_config(sc->bdev, AGP_I830_GCC1, gcc1, 2); + } else { /* CHIP_I855 */ + if (aperture != 128 * 1024 * 1024) { + device_printf(dev, "bad aperture size %d\n", aperture); + return EINVAL; + } } return 0; @@ -425,7 +503,7 @@ return EINVAL; } - if ( sc->chiptype == CHIP_I830 ) { + if ( sc->chiptype != CHIP_I810 ) { if ( (offset >> AGP_PAGE_SHIFT) < sc->stolen ) { device_printf(dev, "trying to bind into stolen memory"); return EINVAL; @@ -444,7 +522,7 @@ if (offset < 0 || offset >= (sc->gatt->ag_entries << AGP_PAGE_SHIFT)) return EINVAL; - if ( sc->chiptype == CHIP_I830 ) { + if ( sc->chiptype != CHIP_I810 ) { if ( (offset >> AGP_PAGE_SHIFT) < sc->stolen ) { device_printf(dev, "trying to unbind from stolen memory"); return EINVAL; @@ -486,7 +564,7 @@ /* * Mapping local DRAM into GATT. */ - if ( sc->chiptype == CHIP_I830 ) + if ( sc->chiptype != CHIP_I810 ) return 0; if (size != sc->dcache_size) return 0; @@ -566,7 +644,7 @@ if (mem->am_type != 1) return agp_generic_bind_memory(dev, mem, offset); - if ( sc->chiptype == CHIP_I830 ) + if ( sc->chiptype != CHIP_I810 ) return EINVAL; for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) { @@ -586,7 +664,7 @@ if (mem->am_type != 1) return agp_generic_unbind_memory(dev, mem); - if ( sc->chiptype == CHIP_I830 ) + if ( sc->chiptype != CHIP_I810 ) return EINVAL; for (i = 0; i < mem->am_size; i += AGP_PAGE_SIZE) Index: agpreg.h =================================================================== RCS file: /home/dhd-cvs/agp/freebsd/agpreg.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- agpreg.h 2002/09/10 17:19:21 1.2 +++ agpreg.h 2003/02/12 22:29:33 1.3 @@ -176,4 +176,30 @@ #define AGP_I830_GCC1_GMASIZE_64 0x01 #define AGP_I830_GCC1_GMASIZE_128 0x00 +/* + * Config registers for 852GM/855GM/865G device 0 + */ +#define AGP_I855_GCC1 0x52 +#define AGP_I855_GCC1_DEV2 0x08 +#define AGP_I855_GCC1_DEV2_ENABLED 0x00 +#define AGP_I855_GCC1_DEV2_DISABLED 0x08 +#define AGP_I855_GCC1_GMS 0x70 +#define AGP_I855_GCC1_GMS_STOLEN_0M 0x00 +#define AGP_I855_GCC1_GMS_STOLEN_1M 0x10 +#define AGP_I855_GCC1_GMS_STOLEN_4M 0x20 +#define AGP_I855_GCC1_GMS_STOLEN_8M 0x30 +#define AGP_I855_GCC1_GMS_STOLEN_16M 0x40 +#define AGP_I855_GCC1_GMS_STOLEN_32M 0x50 + +/* + * 852GM/855GM variant identification + */ +#define AGP_I85X_CAPID 0x44 +#define AGP_I85X_VARIANT_MASK 0x7 +#define AGP_I85X_VARIANT_SHIFT 5 +#define AGP_I855_GME 0x0 +#define AGP_I855_GM 0x4 +#define AGP_I852_GME 0x2 +#define AGP_I852_GM 0x5 + #endif /* !_PCI_AGPREG_H_ */