summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/i386/pci/geodesc.c34
-rw-r--r--sys/arch/i386/pci/geodescreg.h9
2 files changed, 41 insertions, 2 deletions
diff --git a/sys/arch/i386/pci/geodesc.c b/sys/arch/i386/pci/geodesc.c
index a017c56e73a..a20d148e43b 100644
--- a/sys/arch/i386/pci/geodesc.c
+++ b/sys/arch/i386/pci/geodesc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: geodesc.c,v 1.4 2005/11/19 01:59:36 aaron Exp $ */
+/* $OpenBSD: geodesc.c,v 1.5 2006/02/01 13:08:12 mickey Exp $ */
/*
* Copyright (c) 2003 Markus Friedl <markus@openbsd.org>
@@ -25,6 +25,9 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
+#ifdef __HAVE_TIMECOUNTER
+#include <sys/timetc.h>
+#endif
#include <machine/bus.h>
@@ -51,6 +54,19 @@ struct cfdriver geodesc_cd = {
NULL, "geodesc", DV_DULL
};
+#ifdef __HAVE_TIMECOUNTER
+u_int geodesc_get_timecount(struct timecounter *tc);
+
+struct timecounter geodesc_timecounter = {
+ geodesc_get_timecount, /* get_timecount */
+ 0, /* no poll_pps */
+ 0xffffffff, /* counter_mask */
+ 27000000, /* frequency */
+ "GEOTSC", /* name */
+ 2000 /* quality */
+};
+#endif /* __HAVE_TIMECOUNTER */
+
int
geodesc_match(struct device *parent, void *match, void *aux)
{
@@ -102,6 +118,12 @@ geodesc_attach(struct device *parent, struct device *self, void *aux)
bus_space_write_2(sc->sc_iot, sc->sc_ioh, GCB_WDCNFG, cnfg);
wdog_register(sc, geodesc_wdogctl_cb);
+#ifdef __HAVE_TIMECOUNTER
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, GCB_TSCNFG, TSC_ENABLE);
+ /* Hook into the kern_tc */
+ geodesc_timecounter.tc_priv = sc;
+ tc_init(&geodesc_timecounter);
+#endif /* __HAVE_TIMECOUNTER */
}
int
@@ -114,3 +136,13 @@ geodesc_wdogctl_cb(void *self, int period)
bus_space_write_2(sc->sc_iot, sc->sc_ioh, GCB_WDTO, period * 64);
return (period);
}
+
+#ifdef __HAVE_TIMECOUNTER
+u_int
+geodesc_get_timecount(struct timecounter *tc)
+{
+ struct geodesc_softc *sc = tc->tc_priv;
+
+ return (bus_space_read_4(sc->sc_iot, sc->sc_ioh, GCB_TSC));
+}
+#endif /* __HAVE_TIMECOUNTER */
diff --git a/sys/arch/i386/pci/geodescreg.h b/sys/arch/i386/pci/geodescreg.h
index 9af05ba1ced..0f480b944d3 100644
--- a/sys/arch/i386/pci/geodescreg.h
+++ b/sys/arch/i386/pci/geodescreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: geodescreg.h,v 1.2 2003/08/07 16:59:37 mickey Exp $ */
+/* $OpenBSD: geodescreg.h,v 1.3 2006/02/01 13:08:12 mickey Exp $ */
/*
* Copyright (c) 2003 Markus Friedl <markus@openbsd.org>
@@ -28,6 +28,8 @@
#define GCB_WDTO 0x0000 /* WATCHDOG Timeout */
#define GCB_WDCNFG 0x0002 /* WATCHDOG Configuration */
#define GCB_WDSTS 0x0004 /* WATCHDOG Status */
+#define GCB_TSC 0x0008 /* Cyclecounter at 27MHz */
+#define GCB_TSCNFG 0x000c /* config for the above */
#define GCB_IID 0x003c /* IA On a Chip ID */
#define GCB_REV 0x003d /* Revision */
#define GCB_CBA 0x003e /* Configuration Base Address */
@@ -42,3 +44,8 @@
#define WDPRES_DIV_8192 0x000d
#define WDCNFG_MASK 0x00ff
#define WDOVF_CLEAR 0x0001
+
+/* cyclecounter */
+
+#define TSC_ENABLE 0x0200
+