Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Decode AGP capability.
details: https://anonhg.NetBSD.org/src/rev/5651fe532c95
branches: trunk
changeset: 351803:5651fe532c95
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Mon Feb 27 14:13:56 2017 +0000
description:
Decode AGP capability.
diffstat:
sys/dev/pci/agp.c | 30 +++++++++--------
sys/dev/pci/agpreg.h | 5 +--
sys/dev/pci/pci_subr.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++-
sys/dev/pci/pcireg.h | 22 ++++++++++++-
sys/sys/agpio.h | 53 ++++++++++++++++--------------
5 files changed, 148 insertions(+), 47 deletions(-)
diffs (truncated from 335 to 300 lines):
diff -r 52b8f802faf8 -r 5651fe532c95 sys/dev/pci/agp.c
--- a/sys/dev/pci/agp.c Mon Feb 27 12:38:00 2017 +0000
+++ b/sys/dev/pci/agp.c Mon Feb 27 14:13:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: agp.c,v 1.83 2014/07/25 08:10:38 dholland Exp $ */
+/* $NetBSD: agp.c,v 1.84 2017/02/27 14:13:56 msaitoh Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
@@ -65,7 +65,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.83 2014/07/25 08:10:38 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp.c,v 1.84 2017/02/27 14:13:56 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -471,9 +471,9 @@
}
tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_STATUS);
+ sc->as_capoff + PCI_AGP_STATUS);
mstatus = pci_conf_read(pa.pa_pc, pa.pa_tag,
- capoff + AGP_STATUS);
+ capoff + PCI_AGP_STATUS);
if (AGP_MODE_GET_MODE_3(mode) &&
AGP_MODE_GET_MODE_3(tstatus) &&
@@ -492,9 +492,9 @@
int rq, sba, fw, rate;
tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_STATUS);
+ sc->as_capoff + PCI_AGP_STATUS);
mstatus = pci_conf_read(pa->pa_pc, pa->pa_tag,
- capoff + AGP_STATUS);
+ capoff + PCI_AGP_STATUS);
/* Set RQ to the min of mode, tstatus and mstatus */
rq = AGP_MODE_GET_RQ(mode);
@@ -531,8 +531,9 @@
command = AGP_MODE_SET_RATE(command, rate);
command = AGP_MODE_SET_AGP(command, 1);
pci_conf_write(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_COMMAND, command);
- pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + AGP_COMMAND, command);
+ sc->as_capoff + PCI_AGP_COMMAND, command);
+ pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + PCI_AGP_COMMAND,
+ command);
return 0;
}
@@ -546,9 +547,9 @@
int rq, sba, fw, rate, arqsz, cal;
tstatus = pci_conf_read(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_STATUS);
+ sc->as_capoff + PCI_AGP_STATUS);
mstatus = pci_conf_read(pa->pa_pc, pa->pa_tag,
- capoff + AGP_STATUS);
+ capoff + PCI_AGP_STATUS);
/* Set RQ to the min of mode, tstatus and mstatus */
rq = AGP_MODE_GET_RQ(mode);
@@ -598,8 +599,9 @@
command = AGP_MODE_SET_RATE(command, rate);
command = AGP_MODE_SET_AGP(command, 1);
pci_conf_write(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_COMMAND, command);
- pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + AGP_COMMAND, command);
+ sc->as_capoff + PCI_AGP_COMMAND, command);
+ pci_conf_write(pa->pa_pc, pa->pa_tag, capoff + PCI_AGP_COMMAND,
+ command);
return 0;
}
@@ -895,7 +897,7 @@
info->bridge_id = sc->as_id;
if (sc->as_capoff != 0)
info->agp_mode = pci_conf_read(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_STATUS);
+ sc->as_capoff + PCI_AGP_STATUS);
else
info->agp_mode = 0; /* i810 doesn't have real AGP */
info->aper_base = sc->as_apaddr;
@@ -1148,7 +1150,7 @@
struct agp_softc *sc = devcookie;
info->ai_mode = pci_conf_read(sc->as_pc, sc->as_tag,
- sc->as_capoff + AGP_STATUS);
+ sc->as_capoff + PCI_AGP_STATUS);
info->ai_aperture_base = sc->as_apaddr;
info->ai_aperture_size = sc->as_apsize; /* XXXfvdl inconsistent */
info->ai_memory_allowed = sc->as_maxmem;
diff -r 52b8f802faf8 -r 5651fe532c95 sys/dev/pci/agpreg.h
--- a/sys/dev/pci/agpreg.h Mon Feb 27 12:38:00 2017 +0000
+++ b/sys/dev/pci/agpreg.h Mon Feb 27 14:13:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: agpreg.h,v 1.23 2016/05/01 04:22:50 nonaka Exp $ */
+/* $NetBSD: agpreg.h,v 1.24 2017/02/27 14:13:56 msaitoh Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
@@ -36,9 +36,6 @@
*/
#define AGP_APBASE 0x10
-#define AGP_STATUS 0x4
-#define AGP_COMMAND 0x8
-
/*
* Config registers for Intel AGP chipsets.
*/
diff -r 52b8f802faf8 -r 5651fe532c95 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c Mon Feb 27 12:38:00 2017 +0000
+++ b/sys/dev/pci/pci_subr.c Mon Feb 27 14:13:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_subr.c,v 1.160 2017/02/26 05:41:47 msaitoh Exp $ */
+/* $NetBSD: pci_subr.c,v 1.161 2017/02/27 14:13:56 msaitoh Exp $ */
/*
* Copyright (c) 1997 Zubin D. Dittia. All rights reserved.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.160 2017/02/26 05:41:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.161 2017/02/27 14:13:56 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_pci.h"
@@ -1006,10 +1006,52 @@
printf("\n");
}
+static const char *
+pci_conf_print_agp_calcycle(uint8_t cal)
+{
+
+ switch (cal) {
+ case 0x0:
+ return "4ms";
+ case 0x1:
+ return "16ms";
+ case 0x2:
+ return "64ms";
+ case 0x3:
+ return "256ms";
+ case 0x7:
+ return "Calibration Cycle Not Needed";
+ default:
+ return "(reserved)";
+ }
+}
+
+static void
+pci_conf_print_agp_datarate(pcireg_t reg, bool isagp3)
+{
+ if (isagp3) {
+ /* AGP 3.0 */
+ if (reg & AGP_MODE_V3_RATE_4x)
+ printf("x4");
+ if (reg & AGP_MODE_V3_RATE_8x)
+ printf("x8");
+ } else {
+ /* AGP 2.0 */
+ if (reg & AGP_MODE_V2_RATE_1x)
+ printf("x1");
+ if (reg & AGP_MODE_V2_RATE_2x)
+ printf("x2");
+ if (reg & AGP_MODE_V2_RATE_4x)
+ printf("x4");
+ }
+ printf("\n");
+}
+
static void
pci_conf_print_agp_cap(const pcireg_t *regs, int capoff)
{
pcireg_t rval;
+ bool isagp3;
printf("\n AGP Capabilities Register\n");
@@ -1017,7 +1059,44 @@
printf(" Revision: %d.%d\n",
PCI_CAP_AGP_MAJOR(rval), PCI_CAP_AGP_MINOR(rval));
- /* XXX need more */
+ rval = regs[o2i(capoff + PCI_AGP_STATUS)];
+ printf(" Status register: 0x%04x\n", rval);
+ printf(" RQ: %d\n",
+ (unsigned int)__SHIFTOUT(rval, AGP_MODE_RQ) + 1);
+ printf(" ARQSZ: %d\n",
+ (unsigned int)__SHIFTOUT(rval, AGP_MODE_ARQSZ));
+ printf(" CAL cycle: %s\n",
+ pci_conf_print_agp_calcycle(__SHIFTOUT(rval, AGP_MODE_CAL)));
+ onoff("SBA", rval, AGP_MODE_SBA);
+ onoff("htrans#", rval, AGP_MODE_HTRANS);
+ onoff("Over 4G", rval, AGP_MODE_4G);
+ onoff("Fast Write", rval, AGP_MODE_FW);
+ onoff("AGP 3.0 Mode", rval, AGP_MODE_MODE_3);
+ isagp3 = rval & AGP_MODE_MODE_3;
+ printf(" Data Rate Support: ");
+ pci_conf_print_agp_datarate(rval, isagp3);
+
+ rval = regs[o2i(capoff + PCI_AGP_COMMAND)];
+ printf(" Command register: 0x%08x\n", rval);
+ printf(" PRQ: %d\n",
+ (unsigned int)__SHIFTOUT(rval, AGP_MODE_RQ) + 1);
+ printf(" PARQSZ: %d\n",
+ (unsigned int)__SHIFTOUT(rval, AGP_MODE_ARQSZ));
+ printf(" PCAL cycle: %s\n",
+ pci_conf_print_agp_calcycle(__SHIFTOUT(rval, AGP_MODE_CAL)));
+ onoff("SBA", rval, AGP_MODE_SBA);
+ onoff("AGP", rval, AGP_MODE_AGP);
+ onoff("Over 4G", rval, AGP_MODE_4G);
+ onoff("Fast Write", rval, AGP_MODE_FW);
+ if (isagp3) {
+ printf(" Data Rate Enable: ");
+ /*
+ * The Data Rate Enable bits are used only on 3.0 and the
+ * Command register has no AGP_MODE_MODE_3 bit, so pass the
+ * flag to print correctly.
+ */
+ pci_conf_print_agp_datarate(rval, isagp3);
+ }
}
static const char *
diff -r 52b8f802faf8 -r 5651fe532c95 sys/dev/pci/pcireg.h
--- a/sys/dev/pci/pcireg.h Mon Feb 27 12:38:00 2017 +0000
+++ b/sys/dev/pci/pcireg.h Mon Feb 27 14:13:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcireg.h,v 1.120 2017/02/15 06:53:55 msaitoh Exp $ */
+/* $NetBSD: pcireg.h,v 1.121 2017/02/27 14:13:56 msaitoh Exp $ */
/*
* Copyright (c) 1995, 1996, 1999, 2000
@@ -598,6 +598,26 @@
*/
#define PCI_CAP_AGP_MAJOR(cr) (((cr) >> 20) & 0xf)
#define PCI_CAP_AGP_MINOR(cr) (((cr) >> 16) & 0xf)
+#define PCI_AGP_STATUS 0x04
+#define PCI_AGP_COMMAND 0x08
+/* Definitions for STATUS and COMMAND register bits */
+#define AGP_MODE_RQ __BITS(31, 24)
+#define AGP_MODE_ARQSZ __BITS(15, 13)
+#define AGP_MODE_CAL __BITS(12, 10)
+#define AGP_MODE_SBA __BIT(9)
+#define AGP_MODE_AGP __BIT(8)
+#define AGP_MODE_HTRANS __BIT(6)
+#define AGP_MODE_4G __BIT(5)
+#define AGP_MODE_FW __BIT(4)
+#define AGP_MODE_MODE_3 __BIT(3)
+#define AGP_MODE_RATE __BITS(2, 0)
+#define AGP_MODE_V2_RATE_1x 0x1
+#define AGP_MODE_V2_RATE_2x 0x2
+#define AGP_MODE_V2_RATE_4x 0x4
+#define AGP_MODE_V3_RATE_4x 0x1
+#define AGP_MODE_V3_RATE_8x 0x2
+#define AGP_MODE_V3_RATE_RSVD 0x4
+
/*
* Capability ID: 0x03
diff -r 52b8f802faf8 -r 5651fe532c95 sys/sys/agpio.h
--- a/sys/sys/agpio.h Mon Feb 27 12:38:00 2017 +0000
+++ b/sys/sys/agpio.h Mon Feb 27 14:13:56 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: agpio.h,v 1.11 2015/09/06 06:01:02 dholland Exp $ */
+/* $NetBSD: agpio.h,v 1.12 2017/02/27 14:13:56 msaitoh Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
@@ -42,30 +42,33 @@
/*
* Macros to manipulate AGP mode words.
*/
-#define AGP_MODE_GET_RQ(x) (((x) & 0xff000000U) >> 24)
-#define AGP_MODE_GET_ARQSZ(x) (((x) & 0x0000e000U) >> 13)
-#define AGP_MODE_GET_CAL(x) (((x) & 0x00001c00U) >> 10)
-#define AGP_MODE_GET_SBA(x) (((x) & 0x00000200U) >> 9)
-#define AGP_MODE_GET_AGP(x) (((x) & 0x00000100U) >> 8)
-#define AGP_MODE_GET_4G(x) (((x) & 0x00000020U) >> 5)
-#define AGP_MODE_GET_FW(x) (((x) & 0x00000010U) >> 4)
-#define AGP_MODE_GET_MODE_3(x) (((x) & 0x00000008U) >> 3)
-#define AGP_MODE_GET_RATE(x) ((x) & 0x00000007U)
-#define AGP_MODE_SET_RQ(x,v) (((x) & ~0xff000000U) | ((v) << 24))
-#define AGP_MODE_SET_ARQSZ(x,v) (((x) & ~0x0000e000U) | ((v) << 13))
-#define AGP_MODE_SET_CAL(x,v) (((x) & ~0x00001c00U) | ((v) << 10))
-#define AGP_MODE_SET_SBA(x,v) (((x) & ~0x00000200U) | ((v) << 9))
-#define AGP_MODE_SET_AGP(x,v) (((x) & ~0x00000100U) | ((v) << 8))
-#define AGP_MODE_SET_4G(x,v) (((x) & ~0x00000020U) | ((v) << 5))
-#define AGP_MODE_SET_FW(x,v) (((x) & ~0x00000010U) | ((v) << 4))
-#define AGP_MODE_SET_MODE_3(x,v) (((x) & ~0x00000008U) | ((v) << 3))
-#define AGP_MODE_SET_RATE(x,v) (((x) & ~0x00000007U) | (v))
-#define AGP_MODE_V2_RATE_1x 0x00000001
Home |
Main Index |
Thread Index |
Old Index