-/* $OpenBSD: psycho.c,v 1.60 2008/07/12 10:07:25 kettenis Exp $ */
+/* $OpenBSD: psycho.c,v 1.61 2008/07/20 10:37:43 kettenis Exp $ */
/* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */
/*
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/timetc.h>
#include <sys/reboot.h>
#include <uvm/uvm_extern.h>
/* base pci_chipset */
extern struct sparc_pci_chipset _sparc_pci_chipset;
+u_int stick_get_timecount(struct timecounter *);
+
+struct timecounter stick_timecounter = {
+ stick_get_timecount, NULL, ~0u, 0, "stick", 1000, NULL
+};
+
/*
* autoconfiguration
*/
int psycho_br[2], n;
struct psycho_type *ptype;
char buf[32];
+ u_int stick_rate;
sc->sc_node = ma->ma_node;
sc->sc_bustag = ma->ma_bustag;
printf("\n");
}
+ /*
+ * The UltraSPARC IIe has new STICK logic that provides a
+ * timebase counter that doesn't scale with processor
+ * frequency. Use it to provide a timecounter.
+ */
+ stick_rate = getpropint(findroot(), "stick-frequency", 0);
+ if (stick_rate > 0 && sc->sc_mode == PSYCHO_MODE_SABRE) {
+ stick_timecounter.tc_frequency = stick_rate;
+ stick_timecounter.tc_priv = sc;
+ tc_init(&stick_timecounter);
+ }
+
/*
* attach the pci.. note we pass PCI A tags, etc., for the sabre here.
*/
if (ops & (BUS_DMASYNC_POSTREAD | BUS_DMASYNC_PREWRITE))
membar(MemIssue);
}
+
+u_int
+stick_get_timecount(struct timecounter *tc)
+{
+ struct psycho_softc *sc = tc->tc_priv;
+
+ return psycho_psychoreg_read(sc, stick_reg_low);
+}
-/* $OpenBSD: psychoreg.h,v 1.12 2008/07/12 13:08:04 kettenis Exp $ */
+/* $OpenBSD: psychoreg.h,v 1.13 2008/07/20 10:37:43 kettenis Exp $ */
/* $NetBSD: psychoreg.h,v 1.6.4.2 2001/09/13 01:14:40 thorpej Exp $ */
/*
u_int64_t pad19[208];
} psy_strbufdiag[2]; /* For PCI a and b */
+ u_int64_t pad18[1036];
+
+ u_int64_t stick_cmp_low; /* STICK comparison low reg */ /* 1fe.0000.f060 */
+ u_int64_t stick_cmp_high; /* STICK comparison high reg */ /* 1fe.0000.f068 */
+ u_int64_t stick_reg_low; /* STICK counter low reg */ /* 1fe.0000.f070 */
+ u_int64_t stick_reg_high; /* STICK counter high reg */ /* 1fe.0000.f078 */
+
/*
* Here is the rest of the map, which we're not specifying:
*