diff options
author | cognet <cognet@FreeBSD.org> | 2006-04-06 17:11:08 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2006-04-06 17:11:08 +0000 |
commit | 067f218bcf494daf59b5f73fbe8ab8164acc28a7 (patch) | |
tree | 46ff98e130d72cef3335ba7807c9d8974407c788 /sys | |
parent | 4c89b5bc10de411075e8b1c192f766c27c609e3c (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/arm/xscale/i80321/i80321_timer.c | 26 | ||||
-rw-r--r-- | sys/conf/options.arm | 1 |
2 files changed, 27 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 } diff --git a/sys/conf/options.arm b/sys/conf/options.arm index d623efa..3bfb5ea 100644 --- a/sys/conf/options.arm +++ b/sys/conf/options.arm @@ -14,3 +14,4 @@ KERNPHYSADDR opt_global.h KERNVIRTADDR opt_global.h STARTUP_PAGETABLE_ADDR opt_global.h XSCALE_CACHE_READ_WRITE_ALLOCATE opt_global.h +XSACLE_DISABLE_CCNT opt_timer.h |