diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-09-14 06:26:54 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-09-14 06:26:54 +0000 |
commit | ba3b6fd23be5f1f900fcff57bc586e08bc524e99 (patch) | |
tree | a0a4367c9b42b0c3205443521e4da25740349ebb /hw/kdrive/ati | |
parent | d9df39ee2b5b462be87718046b16d30c231563ec (diff) |
Add proper PCI/AGP detection, based on Mike Harris's code for Radeon, but
using the MMIO mirror of the bits instead of config space.
Diffstat (limited to 'hw/kdrive/ati')
-rw-r--r-- | hw/kdrive/ati/ati.c | 30 | ||||
-rw-r--r-- | hw/kdrive/ati/ati_reg.h | 11 |
2 files changed, 22 insertions, 19 deletions
diff --git a/hw/kdrive/ati/ati.c b/hw/kdrive/ati/ati.c index 470f66042..7d395be6c 100644 --- a/hw/kdrive/ati/ati.c +++ b/hw/kdrive/ati/ati.c @@ -698,31 +698,23 @@ static Bool ATIIsAGP(ATICardInfo *atic) { char *mmio = atic->reg_base; - CARD32 agp_command; - Bool is_agp = FALSE; + CARD32 cap_ptr, cap_id; if (mmio == NULL) return FALSE; - if (atic->is_radeon) { - /* XXX: Apparently this doesn't work. Maybe it needs to be done - * through the PCI config aperture then. - */ - agp_command = MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND); - MMIO_OUT32(mmio, RADEON_REG_AGP_COMMAND, agp_command | - RADEON_AGP_ENABLE); - if (MMIO_IN32(mmio, RADEON_REG_AGP_COMMAND) & RADEON_AGP_ENABLE) - is_agp = TRUE; - MMIO_OUT32(mmio, RADEON_REG_AGP_COMMAND, agp_command); - } else { - /* Don't know any way to detect R128 AGP automatically, so - * assume AGP for all cards not marked as PCI-only by XFree86. - */ - if ((atic->pci_id->caps & CAP_FEATURESMASK) != CAP_NOAGP) - is_agp = TRUE; + if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) { + cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) & + ATI_CAP_PTR_MASK; + while (cap_ptr != ATI_CAP_ID_NULL) { + cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr); + if ((cap_id & 0xff) == ATI_CAP_ID_AGP) + return TRUE; + cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK; + } } - return is_agp; + return FALSE; } /* This function is required to work around a hardware bug in some (all?) diff --git a/hw/kdrive/ati/ati_reg.h b/hw/kdrive/ati/ati_reg.h index 94bdd7391..17cd4bef5 100644 --- a/hw/kdrive/ati/ati_reg.h +++ b/hw/kdrive/ati/ati_reg.h @@ -283,6 +283,17 @@ # define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22) # define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23) +/* Offset of the PCI config space mirror */ +#define ATI_PCI_CFG_OFFSET 0x0f00 + +#define ATI_REG_PCI_CFG_STATUS 0x0f06 +# define ATI_CAP_LIST 0x0010 + +#define ATI_REG_PCI_CFG_CAPABILITIES_PTR 0x0f34 +# define ATI_CAP_PTR_MASK 0x00fc +# define ATI_CAP_ID_NULL 0x0000 /* End of capability list */ +# define ATI_CAP_ID_AGP 0x0002 /* AGP capability ID */ + #define R128_REG_AGP_COMMAND 0x0f58 # define R128_AGP_ENABLE (1 << 8) |