2 * linux/arch/cris/kernel/fasttimer.c
4 * Fast timers for ETRAX100/ETRAX100LX
6 * Copyright (C) 2000-2007 Axis Communications AB, Lund, Sweden
9 #include <linux/errno.h>
10 #include <linux/sched.h>
11 #include <linux/kernel.h>
12 #include <linux/param.h>
13 #include <linux/string.h>
15 #include <linux/vmalloc.h>
16 #include <linux/interrupt.h>
17 #include <linux/time.h>
18 #include <linux/delay.h>
20 #include <asm/segment.h>
23 #include <asm/delay.h>
27 #include <asm/arch/svinto.h>
28 #include <asm/fasttimer.h>
29 #include <linux/proc_fs.h>
32 #define DEBUG_LOG_INCLUDED
33 #define FAST_TIMER_LOG
34 //#define FAST_TIMER_TEST
36 #define FAST_TIMER_SANITY_CHECKS
38 #ifdef FAST_TIMER_SANITY_CHECKS
39 #define SANITYCHECK(x) x
40 static int sanity_failed
;
42 #define SANITYCHECK(x)
49 static unsigned int fast_timer_running
;
50 static unsigned int fast_timers_added
;
51 static unsigned int fast_timers_started
;
52 static unsigned int fast_timers_expired
;
53 static unsigned int fast_timers_deleted
;
54 static unsigned int fast_timer_is_init
;
55 static unsigned int fast_timer_ints
;
57 struct fast_timer
*fast_timer_list
= NULL
;
59 #ifdef DEBUG_LOG_INCLUDED
60 #define DEBUG_LOG_MAX 128
61 static const char * debug_log_string
[DEBUG_LOG_MAX
];
62 static unsigned long debug_log_value
[DEBUG_LOG_MAX
];
63 static unsigned int debug_log_cnt
;
64 static unsigned int debug_log_cnt_wrapped
;
66 #define DEBUG_LOG(string, value) \
68 unsigned long log_flags; \
69 local_irq_save(log_flags); \
70 debug_log_string[debug_log_cnt] = (string); \
71 debug_log_value[debug_log_cnt] = (unsigned long)(value); \
72 if (++debug_log_cnt >= DEBUG_LOG_MAX) \
74 debug_log_cnt = debug_log_cnt % DEBUG_LOG_MAX; \
75 debug_log_cnt_wrapped = 1; \
77 local_irq_restore(log_flags); \
80 #define DEBUG_LOG(string, value)
84 /* The frequencies for index = clkselx number in R_TIMER_CTRL */
85 #define NUM_TIMER_FREQ 15
86 #define MAX_USABLE_TIMER_FREQ 7
87 #define MAX_DELAY_US 853333L
88 const unsigned long timer_freq_100
[NUM_TIMER_FREQ
] =
90 3, /* 0 3333 - 853333 us */
91 6, /* 1 1666 - 426666 us */
92 12, /* 2 833 - 213333 us */
93 24, /* 3 416 - 106666 us */
94 48, /* 4 208 - 53333 us */
95 96, /* 5 104 - 26666 us */
96 192, /* 6 52 - 13333 us */
97 384, /* 7 26 - 6666 us */
107 #define NUM_TIMER_STATS 16
108 #ifdef FAST_TIMER_LOG
109 struct fast_timer timer_added_log
[NUM_TIMER_STATS
];
110 struct fast_timer timer_started_log
[NUM_TIMER_STATS
];
111 struct fast_timer timer_expired_log
[NUM_TIMER_STATS
];
114 int timer_div_settings
[NUM_TIMER_STATS
];
115 int timer_freq_settings
[NUM_TIMER_STATS
];
116 int timer_delay_settings
[NUM_TIMER_STATS
];
118 /* Not true gettimeofday, only checks the jiffies (uptime) + useconds */
119 inline void do_gettimeofday_fast(struct fasttime_t
*tv
)
121 tv
->tv_jiff
= jiffies
;
122 tv
->tv_usec
= GET_JIFFIES_USEC();
125 inline int fasttime_cmp(struct fasttime_t
*t0
, struct fasttime_t
*t1
)
127 /* Compare jiffies. Takes care of wrapping */
128 if (time_before(t0
->tv_jiff
, t1
->tv_jiff
))
130 else if (time_after(t0
->tv_jiff
, t1
->tv_jiff
))
134 if (t0
->tv_usec
< t1
->tv_usec
)
136 else if (t0
->tv_usec
> t1
->tv_usec
)
141 inline void start_timer1(unsigned long delay_us
)
143 int freq_index
= 0; /* This is the lowest resolution */
144 unsigned long upper_limit
= MAX_DELAY_US
;
147 /* Start/Restart the timer to the new shorter value */
148 /* t = 1/freq = 1/19200 = 53us
149 * T=div*t, div = T/t = delay_us*freq/1000000
151 #if 1 /* Adaptive timer settings */
152 while (delay_us
< upper_limit
&& freq_index
< MAX_USABLE_TIMER_FREQ
)
155 upper_limit
>>= 1; /* Divide by 2 using shift */
164 div
= delay_us
* timer_freq_100
[freq_index
]/10000;
167 /* Maybe increase timer freq? */
172 div
= 0; /* This means 256, the max the timer takes */
173 /* If a longer timeout than the timer can handle is used,
174 * then we must restart it when it goes off.
178 timer_div_settings
[fast_timers_started
% NUM_TIMER_STATS
] = div
;
179 timer_freq_settings
[fast_timers_started
% NUM_TIMER_STATS
] = freq_index
;
180 timer_delay_settings
[fast_timers_started
% NUM_TIMER_STATS
] = delay_us
;
182 D1(printk(KERN_DEBUG
"start_timer1 : %d us freq: %i div: %i\n",
183 delay_us
, freq_index
, div
));
184 /* Clear timer1 irq */
185 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
187 /* Set timer values */
188 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
189 (r_timer_ctrl_shadow
&
190 ~IO_MASK(R_TIMER_CTRL
, timerdiv1
) &
191 ~IO_MASK(R_TIMER_CTRL
, tm1
) &
192 ~IO_MASK(R_TIMER_CTRL
, clksel1
)) |
193 IO_FIELD(R_TIMER_CTRL
, timerdiv1
, div
) |
194 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
) |
195 IO_FIELD(R_TIMER_CTRL
, clksel1
, freq_index
); /* 6=c19k2Hz */
198 *R_TIMER_CTRL
= r_timer_ctrl_shadow
|
199 IO_STATE(R_TIMER_CTRL
, i1
, clr
);
202 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
203 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
204 IO_STATE(R_TIMER_CTRL
, tm1
, run
);
206 /* Enable timer1 irq */
207 *R_IRQ_MASK0_SET
= IO_STATE(R_IRQ_MASK0_SET
, timer1
, set
);
208 fast_timers_started
++;
209 fast_timer_running
= 1;
212 /* In version 1.4 this function takes 27 - 50 us */
213 void start_one_shot_timer(struct fast_timer
*t
,
214 fast_timer_function_type
*function
,
216 unsigned long delay_us
,
220 struct fast_timer
*tmp
;
222 D1(printk("sft %s %d us\n", name
, delay_us
));
224 local_irq_save(flags
);
226 do_gettimeofday_fast(&t
->tv_set
);
227 tmp
= fast_timer_list
;
229 SANITYCHECK({ /* Check so this is not in the list already... */
235 "timer name: %s data: 0x%08lX already in list!\n", name
, data
);
244 tmp
= fast_timer_list
;
247 t
->delay_us
= delay_us
;
248 t
->function
= function
;
252 t
->tv_expires
.tv_usec
= t
->tv_set
.tv_usec
+ delay_us
% 1000000;
253 t
->tv_expires
.tv_jiff
= t
->tv_set
.tv_jiff
+ delay_us
/ 1000000 / HZ
;
254 if (t
->tv_expires
.tv_usec
> 1000000)
256 t
->tv_expires
.tv_usec
-= 1000000;
257 t
->tv_expires
.tv_jiff
+= HZ
;
259 #ifdef FAST_TIMER_LOG
260 timer_added_log
[fast_timers_added
% NUM_TIMER_STATS
] = *t
;
264 /* Check if this should timeout before anything else */
265 if (tmp
== NULL
|| fasttime_cmp(&t
->tv_expires
, &tmp
->tv_expires
) < 0)
267 /* Put first in list and modify the timer value */
269 t
->next
= fast_timer_list
;
272 fast_timer_list
->prev
= t
;
275 #ifdef FAST_TIMER_LOG
276 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
278 start_timer1(delay_us
);
280 /* Put in correct place in list */
281 while (tmp
->next
&& fasttime_cmp(&t
->tv_expires
,
282 &tmp
->next
->tv_expires
) > 0)
286 /* Insert t after tmp */
296 D2(printk("start_one_shot_timer: %d us done\n", delay_us
));
299 local_irq_restore(flags
);
300 } /* start_one_shot_timer */
302 static inline int fast_timer_pending (const struct fast_timer
* t
)
304 return (t
->next
!= NULL
) || (t
->prev
!= NULL
) || (t
== fast_timer_list
);
307 static inline int detach_fast_timer (struct fast_timer
*t
)
309 struct fast_timer
*next
, *prev
;
310 if (!fast_timer_pending(t
))
319 fast_timer_list
= next
;
320 fast_timers_deleted
++;
324 int del_fast_timer(struct fast_timer
* t
)
329 local_irq_save(flags
);
330 ret
= detach_fast_timer(t
);
331 t
->next
= t
->prev
= NULL
;
332 local_irq_restore(flags
);
334 } /* del_fast_timer */
337 /* Interrupt routines or functions called in interrupt context */
339 /* Timer 1 interrupt handler */
342 timer1_handler(int irq
, void *dev_id
)
344 struct fast_timer
*t
;
347 /* We keep interrupts disabled not only when we modify the
348 * fast timer list, but any time we hold a reference to a
349 * timer in the list, since del_fast_timer may be called
350 * from (another) interrupt context. Thus, the only time
351 * when interrupts are enabled is when calling the timer
354 local_irq_save(flags
);
356 /* Clear timer1 irq */
357 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
359 /* First stop timer, then ack interrupt */
361 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
362 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
363 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
);
366 *R_TIMER_CTRL
= r_timer_ctrl_shadow
| IO_STATE(R_TIMER_CTRL
, i1
, clr
);
368 fast_timer_running
= 0;
374 struct fasttime_t tv
;
375 fast_timer_function_type
*f
;
378 /* Has it really expired? */
379 do_gettimeofday_fast(&tv
);
380 D1(printk(KERN_DEBUG
"t: %is %06ius\n",
381 tv
.tv_jiff
, tv
.tv_usec
));
383 if (fasttime_cmp(&t
->tv_expires
, &tv
) <= 0)
385 /* Yes it has expired */
386 #ifdef FAST_TIMER_LOG
387 timer_expired_log
[fast_timers_expired
% NUM_TIMER_STATS
] = *t
;
389 fast_timers_expired
++;
391 /* Remove this timer before call, since it may reuse the timer */
394 t
->prev
->next
= t
->next
;
398 fast_timer_list
= t
->next
;
402 t
->next
->prev
= t
->prev
;
407 /* Save function callback data before enabling
408 * interrupts, since the timer may be removed and
409 * we don't know how it was allocated
410 * (e.g. ->function and ->data may become overwritten
411 * after deletion if the timer was stack-allocated).
417 /* Run callback with interrupts enabled. */
418 local_irq_restore(flags
);
420 local_irq_save(flags
);
422 DEBUG_LOG("!timer1 %i function==NULL!\n", fast_timer_ints
);
426 /* Timer is to early, let's set it again using the normal routines */
430 if ((t
= fast_timer_list
) != NULL
)
432 /* Start next timer.. */
434 struct fasttime_t tv
;
436 do_gettimeofday_fast(&tv
);
438 /* time_after_eq takes care of wrapping */
439 if (time_after_eq(t
->tv_expires
.tv_jiff
, tv
.tv_jiff
))
440 us
= ((t
->tv_expires
.tv_jiff
- tv
.tv_jiff
) *
441 1000000 / HZ
+ t
->tv_expires
.tv_usec
-
446 if (!fast_timer_running
)
448 #ifdef FAST_TIMER_LOG
449 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
457 /* Timer already expired, let's handle it better late than never.
458 * The normal loop handles it
460 D1(printk("e! %d\n", us
));
465 local_irq_restore(flags
);
469 D1(printk("t1 stop!\n"));
475 static void wake_up_func(unsigned long data
)
477 #ifdef DECLARE_WAITQUEUE
478 wait_queue_head_t
*sleep_wait_p
= (wait_queue_head_t
*)data
;
480 struct wait_queue
**sleep_wait_p
= (struct wait_queue
**)data
;
482 wake_up(sleep_wait_p
);
488 void schedule_usleep(unsigned long us
)
491 wait_queue_head_t sleep_wait
;
492 init_waitqueue_head(&sleep_wait
);
494 D1(printk("schedule_usleep(%d)\n", us
));
495 start_one_shot_timer(&t
, wake_up_func
, (unsigned long)&sleep_wait
, us
,
497 /* Uninterruptible sleep on the fast timer. (The condition is somewhat
498 * redundant since the timer is what wakes us up.) */
499 wait_event(sleep_wait
, !fast_timer_pending(&t
));
501 D1(printk("done schedule_usleep(%d)\n", us
));
504 #ifdef CONFIG_PROC_FS
505 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
506 ,int *eof
, void *data_unused
);
507 static struct proc_dir_entry
*fasttimer_proc_entry
;
508 #endif /* CONFIG_PROC_FS */
510 #ifdef CONFIG_PROC_FS
512 /* This value is very much based on testing */
513 #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
515 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
516 ,int *eof
, void *data_unused
)
521 struct fasttime_t tv
;
522 struct fast_timer
*t
, *nextt
;
523 static char *bigbuf
= NULL
;
524 static unsigned long used
;
526 if (!bigbuf
&& !(bigbuf
= vmalloc(BIG_BUF_SIZE
)))
534 if (!offset
|| !used
)
536 do_gettimeofday_fast(&tv
);
539 used
+= sprintf(bigbuf
+ used
, "Fast timers added: %i\n",
541 used
+= sprintf(bigbuf
+ used
, "Fast timers started: %i\n",
542 fast_timers_started
);
543 used
+= sprintf(bigbuf
+ used
, "Fast timer interrupts: %i\n",
545 used
+= sprintf(bigbuf
+ used
, "Fast timers expired: %i\n",
546 fast_timers_expired
);
547 used
+= sprintf(bigbuf
+ used
, "Fast timers deleted: %i\n",
548 fast_timers_deleted
);
549 used
+= sprintf(bigbuf
+ used
, "Fast timer running: %s\n",
550 fast_timer_running
? "yes" : "no");
551 used
+= sprintf(bigbuf
+ used
, "Current time: %lu.%06lu\n",
552 (unsigned long)tv
.tv_jiff
,
553 (unsigned long)tv
.tv_usec
);
554 #ifdef FAST_TIMER_SANITY_CHECKS
555 used
+= sprintf(bigbuf
+ used
, "Sanity failed: %i\n",
558 used
+= sprintf(bigbuf
+ used
, "\n");
560 #ifdef DEBUG_LOG_INCLUDED
562 int end_i
= debug_log_cnt
;
565 if (debug_log_cnt_wrapped
)
570 while ((i
!= end_i
|| (debug_log_cnt_wrapped
&& !used
)) &&
571 used
+100 < BIG_BUF_SIZE
)
573 used
+= sprintf(bigbuf
+ used
, debug_log_string
[i
],
575 i
= (i
+1) % DEBUG_LOG_MAX
;
578 used
+= sprintf(bigbuf
+ used
, "\n");
581 num_to_show
= (fast_timers_started
< NUM_TIMER_STATS
? fast_timers_started
:
583 used
+= sprintf(bigbuf
+ used
, "Timers started: %i\n", fast_timers_started
);
584 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
) ; i
++)
586 int cur
= (fast_timers_started
- i
- 1) % NUM_TIMER_STATS
;
588 #if 1 //ndef FAST_TIMER_LOG
589 used
+= sprintf(bigbuf
+ used
, "div: %i freq: %i delay: %i"
591 timer_div_settings
[cur
],
592 timer_freq_settings
[cur
],
593 timer_delay_settings
[cur
]
596 #ifdef FAST_TIMER_LOG
597 t
= &timer_started_log
[cur
];
598 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
599 "d: %6li us data: 0x%08lX"
602 (unsigned long)t
->tv_set
.tv_jiff
,
603 (unsigned long)t
->tv_set
.tv_usec
,
604 (unsigned long)t
->tv_expires
.tv_jiff
,
605 (unsigned long)t
->tv_expires
.tv_usec
,
611 used
+= sprintf(bigbuf
+ used
, "\n");
613 #ifdef FAST_TIMER_LOG
614 num_to_show
= (fast_timers_added
< NUM_TIMER_STATS
? fast_timers_added
:
616 used
+= sprintf(bigbuf
+ used
, "Timers added: %i\n", fast_timers_added
);
617 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
619 t
= &timer_added_log
[(fast_timers_added
- i
- 1) % NUM_TIMER_STATS
];
620 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
621 "d: %6li us data: 0x%08lX"
624 (unsigned long)t
->tv_set
.tv_jiff
,
625 (unsigned long)t
->tv_set
.tv_usec
,
626 (unsigned long)t
->tv_expires
.tv_jiff
,
627 (unsigned long)t
->tv_expires
.tv_usec
,
632 used
+= sprintf(bigbuf
+ used
, "\n");
634 num_to_show
= (fast_timers_expired
< NUM_TIMER_STATS
? fast_timers_expired
:
636 used
+= sprintf(bigbuf
+ used
, "Timers expired: %i\n", fast_timers_expired
);
637 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
639 t
= &timer_expired_log
[(fast_timers_expired
- i
- 1) % NUM_TIMER_STATS
];
640 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
641 "d: %6li us data: 0x%08lX"
644 (unsigned long)t
->tv_set
.tv_jiff
,
645 (unsigned long)t
->tv_set
.tv_usec
,
646 (unsigned long)t
->tv_expires
.tv_jiff
,
647 (unsigned long)t
->tv_expires
.tv_usec
,
652 used
+= sprintf(bigbuf
+ used
, "\n");
655 used
+= sprintf(bigbuf
+ used
, "Active timers:\n");
656 local_irq_save(flags
);
658 while (t
!= NULL
&& (used
+100 < BIG_BUF_SIZE
))
661 local_irq_restore(flags
);
662 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
663 "d: %6li us data: 0x%08lX"
664 /* " func: 0x%08lX" */
667 (unsigned long)t
->tv_set
.tv_jiff
,
668 (unsigned long)t
->tv_set
.tv_usec
,
669 (unsigned long)t
->tv_expires
.tv_jiff
,
670 (unsigned long)t
->tv_expires
.tv_usec
,
675 local_irq_save(flags
);
676 if (t
->next
!= nextt
)
678 printk(KERN_WARNING
"timer removed!\n");
682 local_irq_restore(flags
);
685 if (used
- offset
< len
)
690 memcpy(buf
, bigbuf
+ offset
, len
);
698 #ifdef FAST_TIMER_TEST
699 static volatile unsigned long i
= 0;
700 static volatile int num_test_timeout
= 0;
701 static struct fast_timer tr
[10];
702 static int exp_num
[10];
704 static struct fasttime_t tv_exp
[100];
706 static void test_timeout(unsigned long data
)
708 do_gettimeofday_fast(&tv_exp
[data
]);
709 exp_num
[data
] = num_test_timeout
;
714 static void test_timeout1(unsigned long data
)
716 do_gettimeofday_fast(&tv_exp
[data
]);
717 exp_num
[data
] = num_test_timeout
;
720 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 1000, "timeout1");
727 static char buf0
[2000];
728 static char buf1
[2000];
729 static char buf2
[2000];
730 static char buf3
[2000];
731 static char buf4
[2000];
734 static char buf5
[6000];
735 static int j_u
[1000];
737 static void fast_timer_test(void)
742 struct fasttime_t tv
, tv0
, tv1
, tv2
;
744 printk("fast_timer_test() start\n");
745 do_gettimeofday_fast(&tv
);
747 for (j
= 0; j
< 1000; j
++)
749 j_u
[j
] = GET_JIFFIES_USEC();
751 for (j
= 0; j
< 100; j
++)
753 do_gettimeofday_fast(&tv_exp
[j
]);
755 printk(KERN_DEBUG
"fast_timer_test() %is %06i\n",
756 tv
.tv_jiff
, tv
.tv_usec
);
758 for (j
= 0; j
< 1000; j
++)
760 printk("%i %i %i %i %i\n",j_u
[j
], j_u
[j
+1], j_u
[j
+2], j_u
[j
+3], j_u
[j
+4]);
763 for (j
= 0; j
< 100; j
++)
765 printk(KERN_DEBUG
"%i.%i %i.%i %i.%i %i.%i %i.%i\n",
766 tv_exp
[j
].tv_jiff
, tv_exp
[j
].tv_usec
,
767 tv_exp
[j
+1].tv_jiff
, tv_exp
[j
+1].tv_usec
,
768 tv_exp
[j
+2].tv_jiff
, tv_exp
[j
+2].tv_usec
,
769 tv_exp
[j
+3].tv_jiff
, tv_exp
[j
+3].tv_usec
,
770 tv_exp
[j
+4].tv_jiff
, tv_exp
[j
+4].tv_usec
);
773 do_gettimeofday_fast(&tv0
);
774 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 50000, "test0");
775 DP(proc_fasttimer_read(buf0
, NULL
, 0, 0, 0));
777 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 70000, "test1");
778 DP(proc_fasttimer_read(buf1
, NULL
, 0, 0, 0));
780 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 40000, "test2");
781 DP(proc_fasttimer_read(buf2
, NULL
, 0, 0, 0));
783 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 60000, "test3");
784 DP(proc_fasttimer_read(buf3
, NULL
, 0, 0, 0));
786 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 55000, "test4xx");
787 DP(proc_fasttimer_read(buf4
, NULL
, 0, 0, 0));
789 do_gettimeofday_fast(&tv1
);
791 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
793 prev_num
= num_test_timeout
;
794 while (num_test_timeout
< i
)
796 if (num_test_timeout
!= prev_num
)
798 prev_num
= num_test_timeout
;
801 do_gettimeofday_fast(&tv2
);
802 printk(KERN_DEBUG
"Timers started %is %06i\n",
803 tv0
.tv_jiff
, tv0
.tv_usec
);
804 printk(KERN_DEBUG
"Timers started at %is %06i\n",
805 tv1
.tv_jiff
, tv1
.tv_usec
);
806 printk(KERN_DEBUG
"Timers done %is %06i\n",
807 tv2
.tv_jiff
, tv2
.tv_usec
);
808 DP(printk("buf0:\n");
822 printk("timers set:\n");
825 struct fast_timer
*t
= &tr
[j
];
826 printk("%-10s set: %6is %06ius exp: %6is %06ius "
827 "data: 0x%08X func: 0x%08X\n",
831 t
->tv_expires
.tv_jiff
,
832 t
->tv_expires
.tv_usec
,
837 printk(" del: %6ius did exp: %6is %06ius as #%i error: %6li\n",
842 (tv_exp
[j
].tv_jiff
- t
->tv_expires
.tv_jiff
) *
843 1000000 + tv_exp
[j
].tv_usec
-
844 t
->tv_expires
.tv_usec
);
846 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
847 printk("buf5 after all done:\n");
849 printk("fast_timer_test() done\n");
854 int fast_timer_init(void)
856 /* For some reason, request_irq() hangs when called froom time_init() */
857 if (!fast_timer_is_init
)
859 #if 0 && defined(FAST_TIMER_TEST)
863 printk(KERN_INFO
"fast_timer_init()\n");
865 #if 0 && defined(FAST_TIMER_TEST)
866 for (i
= 0; i
<= TIMER0_DIV
; i
++)
868 /* We must be careful not to get overflow... */
869 printk("%3i %6u\n", i
, timer0_value_us
[i
]);
872 #ifdef CONFIG_PROC_FS
873 if ((fasttimer_proc_entry
= create_proc_entry( "fasttimer", 0, 0 )))
874 fasttimer_proc_entry
->read_proc
= proc_fasttimer_read
;
876 if(request_irq(TIMER1_IRQ_NBR
, timer1_handler
, 0,
877 "fast timer int", NULL
))
879 printk("err: timer1 irq\n");
881 fast_timer_is_init
= 1;
882 #ifdef FAST_TIMER_TEST
889 __initcall(fast_timer_init
);