Blame view
arch/xtensa/kernel/time.c
2.6 KB
5a0015d62 [PATCH] xtensa: A... |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* * arch/xtensa/kernel/time.c * * Timer and clock support. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2005 Tensilica Inc. * * Chris Zankel <chris@zankel.net> */ |
5a0015d62 [PATCH] xtensa: A... |
14 |
#include <linux/errno.h> |
d43c36dc6 headers: remove s... |
15 |
#include <linux/sched.h> |
5a0015d62 [PATCH] xtensa: A... |
16 |
#include <linux/time.h> |
fcc8f0f81 xtensa: ccount cl... |
17 |
#include <linux/clocksource.h> |
5a0015d62 [PATCH] xtensa: A... |
18 19 20 21 22 23 24 25 26 |
#include <linux/interrupt.h> #include <linux/module.h> #include <linux/init.h> #include <linux/irq.h> #include <linux/profile.h> #include <linux/delay.h> #include <asm/timex.h> #include <asm/platform.h> |
5a0015d62 [PATCH] xtensa: A... |
27 28 |
#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT unsigned long ccount_per_jiffy; /* per 1/HZ */ |
2b8aea74e [XTENSA] Fix time... |
29 |
unsigned long nsec_per_ccount; /* nsec per ccount increment */ |
5a0015d62 [PATCH] xtensa: A... |
30 |
#endif |
fcc8f0f81 xtensa: ccount cl... |
31 32 33 34 35 36 37 38 39 40 |
static cycle_t ccount_read(void) { return (cycle_t)get_ccount(); } static struct clocksource ccount_clocksource = { .name = "ccount", .rating = 200, .read = ccount_read, .mask = CLOCKSOURCE_MASK(32), |
fcc8f0f81 xtensa: ccount cl... |
41 |
}; |
fd43fe19b [PATCH] xtensa: f... |
42 |
static irqreturn_t timer_interrupt(int irq, void *dev_id); |
5a0015d62 [PATCH] xtensa: A... |
43 44 |
static struct irqaction timer_irqaction = { .handler = timer_interrupt, |
85ac3ab25 [PATCH] irq-flags... |
45 |
.flags = IRQF_DISABLED, |
5a0015d62 [PATCH] xtensa: A... |
46 47 48 49 50 |
.name = "timer", }; void __init time_init(void) { |
288a60cf4 [PATCH] xtensa: r... |
51 |
#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT |
5a0015d62 [PATCH] xtensa: A... |
52 53 54 55 56 57 |
printk("Calibrating CPU frequency "); platform_calibrate_ccount(); printk("%d.%02d MHz ", (int)ccount_per_jiffy/(1000000/HZ), (int)(ccount_per_jiffy/(10000/HZ))%100); #endif |
a139723be clocksource: xten... |
58 |
clocksource_register_hz(&ccount_clocksource, CCOUNT_PER_JIFFY * HZ); |
5a0015d62 [PATCH] xtensa: A... |
59 60 61 62 63 64 |
/* Initialize the linux timer interrupt. */ setup_irq(LINUX_TIMER_INT, &timer_irqaction); set_linux_timer(get_ccount() + CCOUNT_PER_JIFFY); } |
5a0015d62 [PATCH] xtensa: A... |
65 66 67 |
/* * The timer interrupt is called HZ times per second. */ |
fd43fe19b [PATCH] xtensa: f... |
68 |
irqreturn_t timer_interrupt (int irq, void *dev_id) |
5a0015d62 [PATCH] xtensa: A... |
69 70 71 72 73 74 75 76 |
{ unsigned long next; next = get_linux_timer(); again: while ((signed long)(get_ccount() - next) > 0) { |
fd43fe19b [PATCH] xtensa: f... |
77 |
profile_tick(CPU_PROFILING); |
5a0015d62 [PATCH] xtensa: A... |
78 |
#ifndef CONFIG_SMP |
fd43fe19b [PATCH] xtensa: f... |
79 |
update_process_times(user_mode(get_irq_regs())); |
5a0015d62 [PATCH] xtensa: A... |
80 |
#endif |
d12b0e24c xtensa: Switch do... |
81 |
xtime_update(1); /* Linux handler in kernel/time/timekeeping */ |
2b8aea74e [XTENSA] Fix time... |
82 83 |
/* Note that writing CCOMPARE clears the interrupt. */ |
5a0015d62 [PATCH] xtensa: A... |
84 |
next += CCOUNT_PER_JIFFY; |
2b8aea74e [XTENSA] Fix time... |
85 |
set_linux_timer(next); |
5a0015d62 [PATCH] xtensa: A... |
86 |
} |
2b8aea74e [XTENSA] Fix time... |
87 |
/* Allow platform to do something useful (Wdog). */ |
5a0015d62 [PATCH] xtensa: A... |
88 |
|
2b8aea74e [XTENSA] Fix time... |
89 |
platform_heartbeat(); |
5a0015d62 [PATCH] xtensa: A... |
90 91 92 93 94 |
/* Make sure we didn't miss any tick... */ if ((signed long)(get_ccount() - next) > 0) goto again; |
5a0015d62 [PATCH] xtensa: A... |
95 96 97 98 |
return IRQ_HANDLED; } #ifndef CONFIG_GENERIC_CALIBRATE_DELAY |
6c81c32f9 calibrate_delay()... |
99 |
void __cpuinit calibrate_delay(void) |
5a0015d62 [PATCH] xtensa: A... |
100 101 102 103 104 105 106 107 108 |
{ loops_per_jiffy = CCOUNT_PER_JIFFY; printk("Calibrating delay loop (skipped)... " "%lu.%02lu BogoMIPS preset ", loops_per_jiffy/(1000000/HZ), (loops_per_jiffy/(10000/HZ)) % 100); } #endif |