summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-07-10 17:48:26 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-07-10 17:48:26 +0000
commitdcb3b20241324ce552270b8b2db7762b0d4700d6 (patch)
treef11a0a1fc82e697955ed03ad8baa2f7f23886ec8
parent9322bdcd1c966462a2618a62b8f4d63538989f21 (diff)
Register the Heart clock as a timecounter on Octane systems.
-rw-r--r--sys/arch/sgi/xbow/xheart.c31
-rw-r--r--sys/arch/sgi/xbow/xheartreg.h14
2 files changed, 40 insertions, 5 deletions
diff --git a/sys/arch/sgi/xbow/xheart.c b/sys/arch/sgi/xbow/xheart.c
index 5cf2916462a..d729b5a52d0 100644
--- a/sys/arch/sgi/xbow/xheart.c
+++ b/sys/arch/sgi/xbow/xheart.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xheart.c,v 1.22 2011/04/17 17:44:24 miod Exp $ */
+/* $OpenBSD: xheart.c,v 1.23 2011/07/10 17:48:25 miod Exp $ */
/*
* Copyright (c) 2008 Miodrag Vallat.
@@ -26,7 +26,7 @@
#include <sys/device.h>
#include <sys/evcount.h>
#include <sys/malloc.h>
-#include <sys/queue.h>
+#include <sys/timetc.h>
#include <machine/atomic.h>
#include <machine/autoconf.h>
@@ -74,6 +74,17 @@ void xheart_intr_makemasks(void);
void xheart_setintrmask(int);
void xheart_splx(int);
+u_int xheart_get_timecount(struct timecounter *);
+
+struct timecounter xheart_timecounter = {
+ .tc_get_timecount = xheart_get_timecount,
+ .tc_poll_pps = NULL,
+ .tc_counter_mask = 0xffffffff, /* truncate 52-bit counter to 32-bit */
+ .tc_frequency = 12500000,
+ .tc_name = "heart",
+ .tc_quality = 100
+};
+
extern uint32_t ip30_lights_frob(uint32_t, struct trap_frame *);
/*
@@ -145,7 +156,7 @@ xheart_attach(struct device *parent, struct device *self, void *aux)
* Acknowledge and disable all interrupts.
*/
heart = PHYS_TO_XKPHYS(HEART_PIU_BASE, CCA_NC);
- *(volatile uint64_t*)(heart + HEART_ISR_CLR) = 0xffffffffffffffff;
+ *(volatile uint64_t*)(heart + HEART_ISR_CLR) = 0xffffffffffffffffUL;
*(volatile uint64_t*)(heart + HEART_IMR(0)) = 0UL;
*(volatile uint64_t*)(heart + HEART_IMR(1)) = 0UL;
*(volatile uint64_t*)(heart + HEART_IMR(2)) = 0UL;
@@ -164,6 +175,8 @@ xheart_attach(struct device *parent, struct device *self, void *aux)
set_intr(INTPRI_HEART_LEDS, CR_INT_5, ip30_lights_frob);
register_splx_handler(xheart_splx);
+
+ tc_init(&xheart_timecounter);
}
/*
@@ -458,3 +471,15 @@ xheart_setintrmask(int level)
*(volatile uint64_t *)(heart + HEART_IMR(cpuid)) =
xheart_intem[cpuid] & ~xheart_imask[cpuid][level];
}
+
+/*
+ * Timecounter interface.
+ */
+
+uint
+xheart_get_timecount(struct timecounter *tc)
+{
+ paddr_t heart = PHYS_TO_XKPHYS(HEART_PIU_BASE, CCA_NC);
+
+ return (u_int)*(volatile uint64_t *)(heart + HEART_CTR_VALUE);
+}
diff --git a/sys/arch/sgi/xbow/xheartreg.h b/sys/arch/sgi/xbow/xheartreg.h
index 1b3ba2968c7..854a0816659 100644
--- a/sys/arch/sgi/xbow/xheartreg.h
+++ b/sys/arch/sgi/xbow/xheartreg.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: xheartreg.h,v 1.3 2009/10/22 22:08:54 miod Exp $ */
+/* $OpenBSD: xheartreg.h,v 1.4 2011/07/10 17:48:25 miod Exp $ */
/*
- * Copyright (c) 2008 Miodrag Vallat.
+ * Copyright (c) 2008, 2011 Miodrag Vallat.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -102,3 +102,13 @@
#define HEART_INTR_WIDGET_MIN 3
#define HEART_NINTS 64
+
+/*
+ * Crossbow clock, as a free-running counter.
+ * The clock rate is 400 MHz, with the counter running at 1/32 of the clock,
+ * i.e. 12.5 MHz (80 nS period)
+ */
+
+#define HEART_CTR_VALUE 0x00020000 /* 52-bit counter value, r/o */
+#define HEART_CTR_LIMIT 0x00030000 /* 24-bit limit value */
+#define HEART_CTR_TRIGGER 0x00040000