summaryrefslogtreecommitdiffstats
path: root/sys/arm/xscale/i80321/i80321_timer.c
diff options
context:
space:
mode:
authorcognet <cognet@FreeBSD.org>2006-04-06 17:11:08 +0000
committercognet <cognet@FreeBSD.org>2006-04-06 17:11:08 +0000
commit067f218bcf494daf59b5f73fbe8ab8164acc28a7 (patch)
tree46ff98e130d72cef3335ba7807c9d8974407c788 /sys/arm/xscale/i80321/i80321_timer.c
parent4c89b5bc10de411075e8b1c192f766c27c609e3c (diff)
downloadFreeBSD-src-067f218bcf494daf59b5f73fbe8ab8164acc28a7.zip
FreeBSD-src-067f218bcf494daf59b5f73fbe8ab8164acc28a7.tar.gz
Add a new option, XSCALE_DISABLE_CCNT, to not use the xscale ccnt as a
timecounter (because gxemul doesn't emule it yet).
Diffstat (limited to 'sys/arm/xscale/i80321/i80321_timer.c')
-rw-r--r--sys/arm/xscale/i80321/i80321_timer.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/arm/xscale/i80321/i80321_timer.c b/sys/arm/xscale/i80321/i80321_timer.c
index 53a2878..2856ecd 100644
--- a/sys/arm/xscale/i80321/i80321_timer.c
+++ b/sys/arm/xscale/i80321/i80321_timer.c
@@ -76,6 +76,11 @@ static unsigned i80321_timer_get_timecount(struct timecounter *tc);
static uint32_t counts_per_hz;
+#ifdef XSCALE_DISABLE_CCNT
+static uint32_t offset;
+static uint32_t last = -1;
+#endif
+
static int ticked = 0;
#ifndef COUNTS_PER_SEC
@@ -88,7 +93,11 @@ static struct timecounter i80321_timer_timecounter = {
i80321_timer_get_timecount, /* get_timecount */
NULL, /* no poll_pps */
~0u, /* counter_mask */
+#ifdef XSCALE_DISABLE_CCNT
+ COUNTS_PER_SEC,
+#else
COUNTS_PER_SEC * 3, /* frequency */
+#endif
"i80321 timer", /* name */
1000 /* quality */
};
@@ -241,11 +250,26 @@ tisr_read(void)
static unsigned
i80321_timer_get_timecount(struct timecounter *tc)
{
+#ifdef XSCALE_DISABLE_CCNT
+ uint32_t cur = tcr0_read();
+
+ if (cur > last && last != -1) {
+ offset += counts_per_hz;
+ if (ticked > 0)
+ ticked--;
+ }
+ if (ticked) {
+ offset += ticked * counts_per_hz;
+ ticked = 0;
+ }
+ return (counts_per_hz - cur + offset);
+#else
uint32_t ret;
__asm __volatile("mrc p14, 0, %0, c1, c0, 0\n"
: "=r" (ret));
return (ret);
+#endif
}
/*
@@ -327,12 +351,14 @@ cpu_initclocks(void)
tc_init(&i80321_timer_timecounter);
restore_interrupts(oldirqstate);
rid = 0;
+#ifndef XSCALE_DISABLE_CCNT
/* Enable the clock count register. */
__asm __volatile("mrc p14, 0, %0, c0, c0, 0\n" : "=r" (rid));
rid &= ~(1 << 3);
rid |= (1 << 2) | 1;
__asm __volatile("mcr p14, 0, %0, c0, c0, 0\n"
: : "r" (rid));
+#endif
}
OpenPOWER on IntegriCloud