From c6caa5cec4d8ac426588be27ec3809097cda187e Mon Sep 17 00:00:00 2001 From: riastradh Date: Thu, 12 Jun 2014 18:46:32 +0000 Subject: [PATCH] Get GTT size from PGTBL_CTL on G4X chipsets. --- sys/dev/pci/agp_i810.c | 30 +++++++++++++++++++++++++++--- sys/dev/pci/agpreg.h | 10 +++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index 4aa8426da324..231cd4489176 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $NetBSD: agp_i810.c,v 1.102 2014/06/12 18:41:46 riastradh Exp $ */ +/* $NetBSD: agp_i810.c,v 1.103 2014/06/12 18:46:32 riastradh Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.102 2014/06/12 18:41:46 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.103 2014/06/12 18:46:32 riastradh Exp $"); #include #include @@ -844,7 +844,31 @@ agp_i810_init(struct agp_softc *sc) } break; case CHIP_G4X: - gtt_size = 256; + switch (isc->pgtblctl & AGP_G4X_PGTBL_SIZE_MASK) { + case AGP_G4X_PGTBL_SIZE_512K: + gtt_size = 512; + break; + case AGP_G4X_PGTBL_SIZE_256K: + gtt_size = 256; + break; + case AGP_G4X_PGTBL_SIZE_128K: + gtt_size = 128; + break; + case AGP_G4X_PGTBL_SIZE_1M: + gtt_size = 1*1024; + break; + case AGP_G4X_PGTBL_SIZE_2M: + gtt_size = 2*1024; + break; + case AGP_G4X_PGTBL_SIZE_1_5M: + gtt_size = 1*1024 + 512; + break; + default: + aprint_error_dev(sc->as_dev, + "bad PGTBL size\n"); + error = ENXIO; + goto fail0; + } break; default: panic("impossible chiptype %d", isc->chiptype); diff --git a/sys/dev/pci/agpreg.h b/sys/dev/pci/agpreg.h index c86855bcfcb6..adc6a97e7464 100644 --- a/sys/dev/pci/agpreg.h +++ b/sys/dev/pci/agpreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: agpreg.h,v 1.21 2014/05/23 22:58:56 riastradh Exp $ */ +/* $NetBSD: agpreg.h,v 1.22 2014/06/12 18:46:32 riastradh Exp $ */ /*- * Copyright (c) 2000 Doug Rabson @@ -286,6 +286,14 @@ #define AGP_G4X_GTT (2*1024*1024) +#define AGP_G4X_PGTBL_SIZE_MASK 0x0000000e +#define AGP_G4X_PGTBL_SIZE_512K (0 << 1) +#define AGP_G4X_PGTBL_SIZE_256K (1 << 1) +#define AGP_G4X_PGTBL_SIZE_128K (2 << 1) +#define AGP_G4X_PGTBL_SIZE_1M (3 << 1) +#define AGP_G4X_PGTBL_SIZE_2M (4 << 1) +#define AGP_G4X_PGTBL_SIZE_1_5M (5 << 1) + #define AGP_G4X_GCC1_GMS_STOLEN_96M 0xa0 #define AGP_G4X_GCC1_GMS_STOLEN_160M 0xb0 #define AGP_G4X_GCC1_GMS_STOLEN_224M 0xc0