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>
25 #include <arch/svinto.h>
26 #include <asm/fasttimer.h>
27 #include <linux/proc_fs.h>
30 #define DEBUG_LOG_INCLUDED
31 #define FAST_TIMER_LOG
32 /* #define FAST_TIMER_TEST */
34 #define FAST_TIMER_SANITY_CHECKS
36 #ifdef FAST_TIMER_SANITY_CHECKS
37 static int sanity_failed
;
44 static unsigned int fast_timer_running
;
45 static unsigned int fast_timers_added
;
46 static unsigned int fast_timers_started
;
47 static unsigned int fast_timers_expired
;
48 static unsigned int fast_timers_deleted
;
49 static unsigned int fast_timer_is_init
;
50 static unsigned int fast_timer_ints
;
52 struct fast_timer
*fast_timer_list
= NULL
;
54 #ifdef DEBUG_LOG_INCLUDED
55 #define DEBUG_LOG_MAX 128
56 static const char * debug_log_string
[DEBUG_LOG_MAX
];
57 static unsigned long debug_log_value
[DEBUG_LOG_MAX
];
58 static unsigned int debug_log_cnt
;
59 static unsigned int debug_log_cnt_wrapped
;
61 #define DEBUG_LOG(string, value) \
63 unsigned long log_flags; \
64 local_irq_save(log_flags); \
65 debug_log_string[debug_log_cnt] = (string); \
66 debug_log_value[debug_log_cnt] = (unsigned long)(value); \
67 if (++debug_log_cnt >= DEBUG_LOG_MAX) \
69 debug_log_cnt = debug_log_cnt % DEBUG_LOG_MAX; \
70 debug_log_cnt_wrapped = 1; \
72 local_irq_restore(log_flags); \
75 #define DEBUG_LOG(string, value)
79 /* The frequencies for index = clkselx number in R_TIMER_CTRL */
80 #define NUM_TIMER_FREQ 15
81 #define MAX_USABLE_TIMER_FREQ 7
82 #define MAX_DELAY_US 853333L
83 const unsigned long timer_freq_100
[NUM_TIMER_FREQ
] =
85 3, /* 0 3333 - 853333 us */
86 6, /* 1 1666 - 426666 us */
87 12, /* 2 833 - 213333 us */
88 24, /* 3 416 - 106666 us */
89 48, /* 4 208 - 53333 us */
90 96, /* 5 104 - 26666 us */
91 192, /* 6 52 - 13333 us */
92 384, /* 7 26 - 6666 us */
102 #define NUM_TIMER_STATS 16
103 #ifdef FAST_TIMER_LOG
104 struct fast_timer timer_added_log
[NUM_TIMER_STATS
];
105 struct fast_timer timer_started_log
[NUM_TIMER_STATS
];
106 struct fast_timer timer_expired_log
[NUM_TIMER_STATS
];
109 int timer_div_settings
[NUM_TIMER_STATS
];
110 int timer_freq_settings
[NUM_TIMER_STATS
];
111 int timer_delay_settings
[NUM_TIMER_STATS
];
113 /* Not true gettimeofday, only checks the jiffies (uptime) + useconds */
114 inline void do_gettimeofday_fast(struct fasttime_t
*tv
)
116 tv
->tv_jiff
= jiffies
;
117 tv
->tv_usec
= GET_JIFFIES_USEC();
120 inline int fasttime_cmp(struct fasttime_t
*t0
, struct fasttime_t
*t1
)
122 /* Compare jiffies. Takes care of wrapping */
123 if (time_before(t0
->tv_jiff
, t1
->tv_jiff
))
125 else if (time_after(t0
->tv_jiff
, t1
->tv_jiff
))
129 if (t0
->tv_usec
< t1
->tv_usec
)
131 else if (t0
->tv_usec
> t1
->tv_usec
)
136 inline void start_timer1(unsigned long delay_us
)
138 int freq_index
= 0; /* This is the lowest resolution */
139 unsigned long upper_limit
= MAX_DELAY_US
;
142 /* Start/Restart the timer to the new shorter value */
143 /* t = 1/freq = 1/19200 = 53us
144 * T=div*t, div = T/t = delay_us*freq/1000000
146 #if 1 /* Adaptive timer settings */
147 while (delay_us
< upper_limit
&& freq_index
< MAX_USABLE_TIMER_FREQ
)
150 upper_limit
>>= 1; /* Divide by 2 using shift */
159 div
= delay_us
* timer_freq_100
[freq_index
]/10000;
162 /* Maybe increase timer freq? */
167 div
= 0; /* This means 256, the max the timer takes */
168 /* If a longer timeout than the timer can handle is used,
169 * then we must restart it when it goes off.
173 timer_div_settings
[fast_timers_started
% NUM_TIMER_STATS
] = div
;
174 timer_freq_settings
[fast_timers_started
% NUM_TIMER_STATS
] = freq_index
;
175 timer_delay_settings
[fast_timers_started
% NUM_TIMER_STATS
] = delay_us
;
177 D1(printk(KERN_DEBUG
"start_timer1 : %d us freq: %i div: %i\n",
178 delay_us
, freq_index
, div
));
179 /* Clear timer1 irq */
180 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
182 /* Set timer values */
183 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
184 (r_timer_ctrl_shadow
&
185 ~IO_MASK(R_TIMER_CTRL
, timerdiv1
) &
186 ~IO_MASK(R_TIMER_CTRL
, tm1
) &
187 ~IO_MASK(R_TIMER_CTRL
, clksel1
)) |
188 IO_FIELD(R_TIMER_CTRL
, timerdiv1
, div
) |
189 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
) |
190 IO_FIELD(R_TIMER_CTRL
, clksel1
, freq_index
); /* 6=c19k2Hz */
193 *R_TIMER_CTRL
= r_timer_ctrl_shadow
|
194 IO_STATE(R_TIMER_CTRL
, i1
, clr
);
197 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
198 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
199 IO_STATE(R_TIMER_CTRL
, tm1
, run
);
201 /* Enable timer1 irq */
202 *R_IRQ_MASK0_SET
= IO_STATE(R_IRQ_MASK0_SET
, timer1
, set
);
203 fast_timers_started
++;
204 fast_timer_running
= 1;
207 /* In version 1.4 this function takes 27 - 50 us */
208 void start_one_shot_timer(struct fast_timer
*t
,
209 fast_timer_function_type
*function
,
211 unsigned long delay_us
,
215 struct fast_timer
*tmp
;
217 D1(printk("sft %s %d us\n", name
, delay_us
));
219 local_irq_save(flags
);
221 do_gettimeofday_fast(&t
->tv_set
);
222 tmp
= fast_timer_list
;
224 #ifdef FAST_TIMER_SANITY_CHECKS
225 /* Check so this is not in the list already... */
226 while (tmp
!= NULL
) {
228 printk(KERN_WARNING
"timer name: %s data: "
229 "0x%08lX already in list!\n", name
, data
);
235 tmp
= fast_timer_list
;
238 t
->delay_us
= delay_us
;
239 t
->function
= function
;
243 t
->tv_expires
.tv_usec
= t
->tv_set
.tv_usec
+ delay_us
% 1000000;
244 t
->tv_expires
.tv_jiff
= t
->tv_set
.tv_jiff
+ delay_us
/ 1000000 / HZ
;
245 if (t
->tv_expires
.tv_usec
> 1000000)
247 t
->tv_expires
.tv_usec
-= 1000000;
248 t
->tv_expires
.tv_jiff
+= HZ
;
250 #ifdef FAST_TIMER_LOG
251 timer_added_log
[fast_timers_added
% NUM_TIMER_STATS
] = *t
;
255 /* Check if this should timeout before anything else */
256 if (tmp
== NULL
|| fasttime_cmp(&t
->tv_expires
, &tmp
->tv_expires
) < 0)
258 /* Put first in list and modify the timer value */
260 t
->next
= fast_timer_list
;
263 fast_timer_list
->prev
= t
;
266 #ifdef FAST_TIMER_LOG
267 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
269 start_timer1(delay_us
);
271 /* Put in correct place in list */
272 while (tmp
->next
&& fasttime_cmp(&t
->tv_expires
,
273 &tmp
->next
->tv_expires
) > 0)
277 /* Insert t after tmp */
287 D2(printk("start_one_shot_timer: %d us done\n", delay_us
));
290 local_irq_restore(flags
);
291 } /* start_one_shot_timer */
293 static inline int fast_timer_pending (const struct fast_timer
* t
)
295 return (t
->next
!= NULL
) || (t
->prev
!= NULL
) || (t
== fast_timer_list
);
298 static inline int detach_fast_timer (struct fast_timer
*t
)
300 struct fast_timer
*next
, *prev
;
301 if (!fast_timer_pending(t
))
310 fast_timer_list
= next
;
311 fast_timers_deleted
++;
315 int del_fast_timer(struct fast_timer
* t
)
320 local_irq_save(flags
);
321 ret
= detach_fast_timer(t
);
322 t
->next
= t
->prev
= NULL
;
323 local_irq_restore(flags
);
325 } /* del_fast_timer */
328 /* Interrupt routines or functions called in interrupt context */
330 /* Timer 1 interrupt handler */
333 timer1_handler(int irq
, void *dev_id
)
335 struct fast_timer
*t
;
338 /* We keep interrupts disabled not only when we modify the
339 * fast timer list, but any time we hold a reference to a
340 * timer in the list, since del_fast_timer may be called
341 * from (another) interrupt context. Thus, the only time
342 * when interrupts are enabled is when calling the timer
345 local_irq_save(flags
);
347 /* Clear timer1 irq */
348 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
350 /* First stop timer, then ack interrupt */
352 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
353 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
354 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
);
357 *R_TIMER_CTRL
= r_timer_ctrl_shadow
| IO_STATE(R_TIMER_CTRL
, i1
, clr
);
359 fast_timer_running
= 0;
365 struct fasttime_t tv
;
366 fast_timer_function_type
*f
;
369 /* Has it really expired? */
370 do_gettimeofday_fast(&tv
);
371 D1(printk(KERN_DEBUG
"t: %is %06ius\n",
372 tv
.tv_jiff
, tv
.tv_usec
));
374 if (fasttime_cmp(&t
->tv_expires
, &tv
) <= 0)
376 /* Yes it has expired */
377 #ifdef FAST_TIMER_LOG
378 timer_expired_log
[fast_timers_expired
% NUM_TIMER_STATS
] = *t
;
380 fast_timers_expired
++;
382 /* Remove this timer before call, since it may reuse the timer */
385 t
->prev
->next
= t
->next
;
389 fast_timer_list
= t
->next
;
393 t
->next
->prev
= t
->prev
;
398 /* Save function callback data before enabling
399 * interrupts, since the timer may be removed and
400 * we don't know how it was allocated
401 * (e.g. ->function and ->data may become overwritten
402 * after deletion if the timer was stack-allocated).
408 /* Run callback with interrupts enabled. */
409 local_irq_restore(flags
);
411 local_irq_save(flags
);
413 DEBUG_LOG("!timer1 %i function==NULL!\n", fast_timer_ints
);
417 /* Timer is to early, let's set it again using the normal routines */
421 if ((t
= fast_timer_list
) != NULL
)
423 /* Start next timer.. */
425 struct fasttime_t tv
;
427 do_gettimeofday_fast(&tv
);
429 /* time_after_eq takes care of wrapping */
430 if (time_after_eq(t
->tv_expires
.tv_jiff
, tv
.tv_jiff
))
431 us
= ((t
->tv_expires
.tv_jiff
- tv
.tv_jiff
) *
432 1000000 / HZ
+ t
->tv_expires
.tv_usec
-
437 if (!fast_timer_running
)
439 #ifdef FAST_TIMER_LOG
440 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
448 /* Timer already expired, let's handle it better late than never.
449 * The normal loop handles it
451 D1(printk("e! %d\n", us
));
456 local_irq_restore(flags
);
460 D1(printk("t1 stop!\n"));
466 static void wake_up_func(unsigned long data
)
468 wait_queue_head_t
*sleep_wait_p
= (wait_queue_head_t
*)data
;
469 wake_up(sleep_wait_p
);
475 void schedule_usleep(unsigned long us
)
478 wait_queue_head_t sleep_wait
;
479 init_waitqueue_head(&sleep_wait
);
481 D1(printk("schedule_usleep(%d)\n", us
));
482 start_one_shot_timer(&t
, wake_up_func
, (unsigned long)&sleep_wait
, us
,
484 /* Uninterruptible sleep on the fast timer. (The condition is somewhat
485 * redundant since the timer is what wakes us up.) */
486 wait_event(sleep_wait
, !fast_timer_pending(&t
));
488 D1(printk("done schedule_usleep(%d)\n", us
));
491 #ifdef CONFIG_PROC_FS
492 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
493 ,int *eof
, void *data_unused
);
494 static struct proc_dir_entry
*fasttimer_proc_entry
;
495 #endif /* CONFIG_PROC_FS */
497 #ifdef CONFIG_PROC_FS
499 /* This value is very much based on testing */
500 #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
502 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
503 ,int *eof
, void *data_unused
)
508 struct fasttime_t tv
;
509 struct fast_timer
*t
, *nextt
;
510 static char *bigbuf
= NULL
;
511 static unsigned long used
;
513 if (!bigbuf
&& !(bigbuf
= vmalloc(BIG_BUF_SIZE
)))
521 if (!offset
|| !used
)
523 do_gettimeofday_fast(&tv
);
526 used
+= sprintf(bigbuf
+ used
, "Fast timers added: %i\n",
528 used
+= sprintf(bigbuf
+ used
, "Fast timers started: %i\n",
529 fast_timers_started
);
530 used
+= sprintf(bigbuf
+ used
, "Fast timer interrupts: %i\n",
532 used
+= sprintf(bigbuf
+ used
, "Fast timers expired: %i\n",
533 fast_timers_expired
);
534 used
+= sprintf(bigbuf
+ used
, "Fast timers deleted: %i\n",
535 fast_timers_deleted
);
536 used
+= sprintf(bigbuf
+ used
, "Fast timer running: %s\n",
537 fast_timer_running
? "yes" : "no");
538 used
+= sprintf(bigbuf
+ used
, "Current time: %lu.%06lu\n",
539 (unsigned long)tv
.tv_jiff
,
540 (unsigned long)tv
.tv_usec
);
541 #ifdef FAST_TIMER_SANITY_CHECKS
542 used
+= sprintf(bigbuf
+ used
, "Sanity failed: %i\n",
545 used
+= sprintf(bigbuf
+ used
, "\n");
547 #ifdef DEBUG_LOG_INCLUDED
549 int end_i
= debug_log_cnt
;
552 if (debug_log_cnt_wrapped
)
557 while ((i
!= end_i
|| (debug_log_cnt_wrapped
&& !used
)) &&
558 used
+100 < BIG_BUF_SIZE
)
560 used
+= sprintf(bigbuf
+ used
, debug_log_string
[i
],
562 i
= (i
+1) % DEBUG_LOG_MAX
;
565 used
+= sprintf(bigbuf
+ used
, "\n");
568 num_to_show
= (fast_timers_started
< NUM_TIMER_STATS
? fast_timers_started
:
570 used
+= sprintf(bigbuf
+ used
, "Timers started: %i\n", fast_timers_started
);
571 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
) ; i
++)
573 int cur
= (fast_timers_started
- i
- 1) % NUM_TIMER_STATS
;
575 #if 1 //ndef FAST_TIMER_LOG
576 used
+= sprintf(bigbuf
+ used
, "div: %i freq: %i delay: %i"
578 timer_div_settings
[cur
],
579 timer_freq_settings
[cur
],
580 timer_delay_settings
[cur
]
583 #ifdef FAST_TIMER_LOG
584 t
= &timer_started_log
[cur
];
585 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
586 "d: %6li us data: 0x%08lX"
589 (unsigned long)t
->tv_set
.tv_jiff
,
590 (unsigned long)t
->tv_set
.tv_usec
,
591 (unsigned long)t
->tv_expires
.tv_jiff
,
592 (unsigned long)t
->tv_expires
.tv_usec
,
598 used
+= sprintf(bigbuf
+ used
, "\n");
600 #ifdef FAST_TIMER_LOG
601 num_to_show
= (fast_timers_added
< NUM_TIMER_STATS
? fast_timers_added
:
603 used
+= sprintf(bigbuf
+ used
, "Timers added: %i\n", fast_timers_added
);
604 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
606 t
= &timer_added_log
[(fast_timers_added
- i
- 1) % NUM_TIMER_STATS
];
607 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
608 "d: %6li us data: 0x%08lX"
611 (unsigned long)t
->tv_set
.tv_jiff
,
612 (unsigned long)t
->tv_set
.tv_usec
,
613 (unsigned long)t
->tv_expires
.tv_jiff
,
614 (unsigned long)t
->tv_expires
.tv_usec
,
619 used
+= sprintf(bigbuf
+ used
, "\n");
621 num_to_show
= (fast_timers_expired
< NUM_TIMER_STATS
? fast_timers_expired
:
623 used
+= sprintf(bigbuf
+ used
, "Timers expired: %i\n", fast_timers_expired
);
624 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
626 t
= &timer_expired_log
[(fast_timers_expired
- i
- 1) % NUM_TIMER_STATS
];
627 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
628 "d: %6li us data: 0x%08lX"
631 (unsigned long)t
->tv_set
.tv_jiff
,
632 (unsigned long)t
->tv_set
.tv_usec
,
633 (unsigned long)t
->tv_expires
.tv_jiff
,
634 (unsigned long)t
->tv_expires
.tv_usec
,
639 used
+= sprintf(bigbuf
+ used
, "\n");
642 used
+= sprintf(bigbuf
+ used
, "Active timers:\n");
643 local_irq_save(flags
);
645 while (t
!= NULL
&& (used
+100 < BIG_BUF_SIZE
))
648 local_irq_restore(flags
);
649 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
650 "d: %6li us data: 0x%08lX"
651 /* " func: 0x%08lX" */
654 (unsigned long)t
->tv_set
.tv_jiff
,
655 (unsigned long)t
->tv_set
.tv_usec
,
656 (unsigned long)t
->tv_expires
.tv_jiff
,
657 (unsigned long)t
->tv_expires
.tv_usec
,
662 local_irq_save(flags
);
663 if (t
->next
!= nextt
)
665 printk(KERN_WARNING
"timer removed!\n");
669 local_irq_restore(flags
);
672 if (used
- offset
< len
)
677 memcpy(buf
, bigbuf
+ offset
, len
);
685 #ifdef FAST_TIMER_TEST
686 static volatile unsigned long i
= 0;
687 static volatile int num_test_timeout
= 0;
688 static struct fast_timer tr
[10];
689 static int exp_num
[10];
691 static struct fasttime_t tv_exp
[100];
693 static void test_timeout(unsigned long data
)
695 do_gettimeofday_fast(&tv_exp
[data
]);
696 exp_num
[data
] = num_test_timeout
;
701 static void test_timeout1(unsigned long data
)
703 do_gettimeofday_fast(&tv_exp
[data
]);
704 exp_num
[data
] = num_test_timeout
;
707 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 1000, "timeout1");
714 static char buf0
[2000];
715 static char buf1
[2000];
716 static char buf2
[2000];
717 static char buf3
[2000];
718 static char buf4
[2000];
721 static char buf5
[6000];
722 static int j_u
[1000];
724 static void fast_timer_test(void)
729 struct fasttime_t tv
, tv0
, tv1
, tv2
;
731 printk("fast_timer_test() start\n");
732 do_gettimeofday_fast(&tv
);
734 for (j
= 0; j
< 1000; j
++)
736 j_u
[j
] = GET_JIFFIES_USEC();
738 for (j
= 0; j
< 100; j
++)
740 do_gettimeofday_fast(&tv_exp
[j
]);
742 printk(KERN_DEBUG
"fast_timer_test() %is %06i\n",
743 tv
.tv_jiff
, tv
.tv_usec
);
745 for (j
= 0; j
< 1000; j
++)
747 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]);
750 for (j
= 0; j
< 100; j
++)
752 printk(KERN_DEBUG
"%i.%i %i.%i %i.%i %i.%i %i.%i\n",
753 tv_exp
[j
].tv_jiff
, tv_exp
[j
].tv_usec
,
754 tv_exp
[j
+1].tv_jiff
, tv_exp
[j
+1].tv_usec
,
755 tv_exp
[j
+2].tv_jiff
, tv_exp
[j
+2].tv_usec
,
756 tv_exp
[j
+3].tv_jiff
, tv_exp
[j
+3].tv_usec
,
757 tv_exp
[j
+4].tv_jiff
, tv_exp
[j
+4].tv_usec
);
760 do_gettimeofday_fast(&tv0
);
761 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 50000, "test0");
762 DP(proc_fasttimer_read(buf0
, NULL
, 0, 0, 0));
764 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 70000, "test1");
765 DP(proc_fasttimer_read(buf1
, NULL
, 0, 0, 0));
767 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 40000, "test2");
768 DP(proc_fasttimer_read(buf2
, NULL
, 0, 0, 0));
770 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 60000, "test3");
771 DP(proc_fasttimer_read(buf3
, NULL
, 0, 0, 0));
773 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 55000, "test4xx");
774 DP(proc_fasttimer_read(buf4
, NULL
, 0, 0, 0));
776 do_gettimeofday_fast(&tv1
);
778 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
780 prev_num
= num_test_timeout
;
781 while (num_test_timeout
< i
)
783 if (num_test_timeout
!= prev_num
)
785 prev_num
= num_test_timeout
;
788 do_gettimeofday_fast(&tv2
);
789 printk(KERN_DEBUG
"Timers started %is %06i\n",
790 tv0
.tv_jiff
, tv0
.tv_usec
);
791 printk(KERN_DEBUG
"Timers started at %is %06i\n",
792 tv1
.tv_jiff
, tv1
.tv_usec
);
793 printk(KERN_DEBUG
"Timers done %is %06i\n",
794 tv2
.tv_jiff
, tv2
.tv_usec
);
795 DP(printk("buf0:\n");
809 printk("timers set:\n");
812 struct fast_timer
*t
= &tr
[j
];
813 printk("%-10s set: %6is %06ius exp: %6is %06ius "
814 "data: 0x%08X func: 0x%08X\n",
818 t
->tv_expires
.tv_jiff
,
819 t
->tv_expires
.tv_usec
,
824 printk(" del: %6ius did exp: %6is %06ius as #%i error: %6li\n",
829 (tv_exp
[j
].tv_jiff
- t
->tv_expires
.tv_jiff
) *
830 1000000 + tv_exp
[j
].tv_usec
-
831 t
->tv_expires
.tv_usec
);
833 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
834 printk("buf5 after all done:\n");
836 printk("fast_timer_test() done\n");
841 int fast_timer_init(void)
843 /* For some reason, request_irq() hangs when called froom time_init() */
844 if (!fast_timer_is_init
)
846 #if 0 && defined(FAST_TIMER_TEST)
850 printk(KERN_INFO
"fast_timer_init()\n");
852 #if 0 && defined(FAST_TIMER_TEST)
853 for (i
= 0; i
<= TIMER0_DIV
; i
++)
855 /* We must be careful not to get overflow... */
856 printk("%3i %6u\n", i
, timer0_value_us
[i
]);
859 #ifdef CONFIG_PROC_FS
860 if ((fasttimer_proc_entry
= create_proc_entry( "fasttimer", 0, 0 )))
861 fasttimer_proc_entry
->read_proc
= proc_fasttimer_read
;
863 if(request_irq(TIMER1_IRQ_NBR
, timer1_handler
, 0,
864 "fast timer int", NULL
))
866 printk("err: timer1 irq\n");
868 fast_timer_is_init
= 1;
869 #ifdef FAST_TIMER_TEST
876 __initcall(fast_timer_init
);