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 static int sanity_failed
;
46 static unsigned int fast_timer_running
;
47 static unsigned int fast_timers_added
;
48 static unsigned int fast_timers_started
;
49 static unsigned int fast_timers_expired
;
50 static unsigned int fast_timers_deleted
;
51 static unsigned int fast_timer_is_init
;
52 static unsigned int fast_timer_ints
;
54 struct fast_timer
*fast_timer_list
= NULL
;
56 #ifdef DEBUG_LOG_INCLUDED
57 #define DEBUG_LOG_MAX 128
58 static const char * debug_log_string
[DEBUG_LOG_MAX
];
59 static unsigned long debug_log_value
[DEBUG_LOG_MAX
];
60 static unsigned int debug_log_cnt
;
61 static unsigned int debug_log_cnt_wrapped
;
63 #define DEBUG_LOG(string, value) \
65 unsigned long log_flags; \
66 local_irq_save(log_flags); \
67 debug_log_string[debug_log_cnt] = (string); \
68 debug_log_value[debug_log_cnt] = (unsigned long)(value); \
69 if (++debug_log_cnt >= DEBUG_LOG_MAX) \
71 debug_log_cnt = debug_log_cnt % DEBUG_LOG_MAX; \
72 debug_log_cnt_wrapped = 1; \
74 local_irq_restore(log_flags); \
77 #define DEBUG_LOG(string, value)
81 /* The frequencies for index = clkselx number in R_TIMER_CTRL */
82 #define NUM_TIMER_FREQ 15
83 #define MAX_USABLE_TIMER_FREQ 7
84 #define MAX_DELAY_US 853333L
85 const unsigned long timer_freq_100
[NUM_TIMER_FREQ
] =
87 3, /* 0 3333 - 853333 us */
88 6, /* 1 1666 - 426666 us */
89 12, /* 2 833 - 213333 us */
90 24, /* 3 416 - 106666 us */
91 48, /* 4 208 - 53333 us */
92 96, /* 5 104 - 26666 us */
93 192, /* 6 52 - 13333 us */
94 384, /* 7 26 - 6666 us */
104 #define NUM_TIMER_STATS 16
105 #ifdef FAST_TIMER_LOG
106 struct fast_timer timer_added_log
[NUM_TIMER_STATS
];
107 struct fast_timer timer_started_log
[NUM_TIMER_STATS
];
108 struct fast_timer timer_expired_log
[NUM_TIMER_STATS
];
111 int timer_div_settings
[NUM_TIMER_STATS
];
112 int timer_freq_settings
[NUM_TIMER_STATS
];
113 int timer_delay_settings
[NUM_TIMER_STATS
];
115 /* Not true gettimeofday, only checks the jiffies (uptime) + useconds */
116 inline void do_gettimeofday_fast(struct fasttime_t
*tv
)
118 tv
->tv_jiff
= jiffies
;
119 tv
->tv_usec
= GET_JIFFIES_USEC();
122 inline int fasttime_cmp(struct fasttime_t
*t0
, struct fasttime_t
*t1
)
124 /* Compare jiffies. Takes care of wrapping */
125 if (time_before(t0
->tv_jiff
, t1
->tv_jiff
))
127 else if (time_after(t0
->tv_jiff
, t1
->tv_jiff
))
131 if (t0
->tv_usec
< t1
->tv_usec
)
133 else if (t0
->tv_usec
> t1
->tv_usec
)
138 inline void start_timer1(unsigned long delay_us
)
140 int freq_index
= 0; /* This is the lowest resolution */
141 unsigned long upper_limit
= MAX_DELAY_US
;
144 /* Start/Restart the timer to the new shorter value */
145 /* t = 1/freq = 1/19200 = 53us
146 * T=div*t, div = T/t = delay_us*freq/1000000
148 #if 1 /* Adaptive timer settings */
149 while (delay_us
< upper_limit
&& freq_index
< MAX_USABLE_TIMER_FREQ
)
152 upper_limit
>>= 1; /* Divide by 2 using shift */
161 div
= delay_us
* timer_freq_100
[freq_index
]/10000;
164 /* Maybe increase timer freq? */
169 div
= 0; /* This means 256, the max the timer takes */
170 /* If a longer timeout than the timer can handle is used,
171 * then we must restart it when it goes off.
175 timer_div_settings
[fast_timers_started
% NUM_TIMER_STATS
] = div
;
176 timer_freq_settings
[fast_timers_started
% NUM_TIMER_STATS
] = freq_index
;
177 timer_delay_settings
[fast_timers_started
% NUM_TIMER_STATS
] = delay_us
;
179 D1(printk(KERN_DEBUG
"start_timer1 : %d us freq: %i div: %i\n",
180 delay_us
, freq_index
, div
));
181 /* Clear timer1 irq */
182 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
184 /* Set timer values */
185 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
186 (r_timer_ctrl_shadow
&
187 ~IO_MASK(R_TIMER_CTRL
, timerdiv1
) &
188 ~IO_MASK(R_TIMER_CTRL
, tm1
) &
189 ~IO_MASK(R_TIMER_CTRL
, clksel1
)) |
190 IO_FIELD(R_TIMER_CTRL
, timerdiv1
, div
) |
191 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
) |
192 IO_FIELD(R_TIMER_CTRL
, clksel1
, freq_index
); /* 6=c19k2Hz */
195 *R_TIMER_CTRL
= r_timer_ctrl_shadow
|
196 IO_STATE(R_TIMER_CTRL
, i1
, clr
);
199 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
200 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
201 IO_STATE(R_TIMER_CTRL
, tm1
, run
);
203 /* Enable timer1 irq */
204 *R_IRQ_MASK0_SET
= IO_STATE(R_IRQ_MASK0_SET
, timer1
, set
);
205 fast_timers_started
++;
206 fast_timer_running
= 1;
209 /* In version 1.4 this function takes 27 - 50 us */
210 void start_one_shot_timer(struct fast_timer
*t
,
211 fast_timer_function_type
*function
,
213 unsigned long delay_us
,
217 struct fast_timer
*tmp
;
219 D1(printk("sft %s %d us\n", name
, delay_us
));
221 local_irq_save(flags
);
223 do_gettimeofday_fast(&t
->tv_set
);
224 tmp
= fast_timer_list
;
226 #ifdef FAST_TIMER_SANITY_CHECKS
227 /* Check so this is not in the list already... */
228 while (tmp
!= NULL
) {
230 printk(KERN_WARNING
"timer name: %s data: "
231 "0x%08lX already in list!\n", name
, data
);
237 tmp
= fast_timer_list
;
240 t
->delay_us
= delay_us
;
241 t
->function
= function
;
245 t
->tv_expires
.tv_usec
= t
->tv_set
.tv_usec
+ delay_us
% 1000000;
246 t
->tv_expires
.tv_jiff
= t
->tv_set
.tv_jiff
+ delay_us
/ 1000000 / HZ
;
247 if (t
->tv_expires
.tv_usec
> 1000000)
249 t
->tv_expires
.tv_usec
-= 1000000;
250 t
->tv_expires
.tv_jiff
+= HZ
;
252 #ifdef FAST_TIMER_LOG
253 timer_added_log
[fast_timers_added
% NUM_TIMER_STATS
] = *t
;
257 /* Check if this should timeout before anything else */
258 if (tmp
== NULL
|| fasttime_cmp(&t
->tv_expires
, &tmp
->tv_expires
) < 0)
260 /* Put first in list and modify the timer value */
262 t
->next
= fast_timer_list
;
265 fast_timer_list
->prev
= t
;
268 #ifdef FAST_TIMER_LOG
269 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
271 start_timer1(delay_us
);
273 /* Put in correct place in list */
274 while (tmp
->next
&& fasttime_cmp(&t
->tv_expires
,
275 &tmp
->next
->tv_expires
) > 0)
279 /* Insert t after tmp */
289 D2(printk("start_one_shot_timer: %d us done\n", delay_us
));
292 local_irq_restore(flags
);
293 } /* start_one_shot_timer */
295 static inline int fast_timer_pending (const struct fast_timer
* t
)
297 return (t
->next
!= NULL
) || (t
->prev
!= NULL
) || (t
== fast_timer_list
);
300 static inline int detach_fast_timer (struct fast_timer
*t
)
302 struct fast_timer
*next
, *prev
;
303 if (!fast_timer_pending(t
))
312 fast_timer_list
= next
;
313 fast_timers_deleted
++;
317 int del_fast_timer(struct fast_timer
* t
)
322 local_irq_save(flags
);
323 ret
= detach_fast_timer(t
);
324 t
->next
= t
->prev
= NULL
;
325 local_irq_restore(flags
);
327 } /* del_fast_timer */
330 /* Interrupt routines or functions called in interrupt context */
332 /* Timer 1 interrupt handler */
335 timer1_handler(int irq
, void *dev_id
)
337 struct fast_timer
*t
;
340 /* We keep interrupts disabled not only when we modify the
341 * fast timer list, but any time we hold a reference to a
342 * timer in the list, since del_fast_timer may be called
343 * from (another) interrupt context. Thus, the only time
344 * when interrupts are enabled is when calling the timer
347 local_irq_save(flags
);
349 /* Clear timer1 irq */
350 *R_IRQ_MASK0_CLR
= IO_STATE(R_IRQ_MASK0_CLR
, timer1
, clr
);
352 /* First stop timer, then ack interrupt */
354 *R_TIMER_CTRL
= r_timer_ctrl_shadow
=
355 (r_timer_ctrl_shadow
& ~IO_MASK(R_TIMER_CTRL
, tm1
)) |
356 IO_STATE(R_TIMER_CTRL
, tm1
, stop_ld
);
359 *R_TIMER_CTRL
= r_timer_ctrl_shadow
| IO_STATE(R_TIMER_CTRL
, i1
, clr
);
361 fast_timer_running
= 0;
367 struct fasttime_t tv
;
368 fast_timer_function_type
*f
;
371 /* Has it really expired? */
372 do_gettimeofday_fast(&tv
);
373 D1(printk(KERN_DEBUG
"t: %is %06ius\n",
374 tv
.tv_jiff
, tv
.tv_usec
));
376 if (fasttime_cmp(&t
->tv_expires
, &tv
) <= 0)
378 /* Yes it has expired */
379 #ifdef FAST_TIMER_LOG
380 timer_expired_log
[fast_timers_expired
% NUM_TIMER_STATS
] = *t
;
382 fast_timers_expired
++;
384 /* Remove this timer before call, since it may reuse the timer */
387 t
->prev
->next
= t
->next
;
391 fast_timer_list
= t
->next
;
395 t
->next
->prev
= t
->prev
;
400 /* Save function callback data before enabling
401 * interrupts, since the timer may be removed and
402 * we don't know how it was allocated
403 * (e.g. ->function and ->data may become overwritten
404 * after deletion if the timer was stack-allocated).
410 /* Run callback with interrupts enabled. */
411 local_irq_restore(flags
);
413 local_irq_save(flags
);
415 DEBUG_LOG("!timer1 %i function==NULL!\n", fast_timer_ints
);
419 /* Timer is to early, let's set it again using the normal routines */
423 if ((t
= fast_timer_list
) != NULL
)
425 /* Start next timer.. */
427 struct fasttime_t tv
;
429 do_gettimeofday_fast(&tv
);
431 /* time_after_eq takes care of wrapping */
432 if (time_after_eq(t
->tv_expires
.tv_jiff
, tv
.tv_jiff
))
433 us
= ((t
->tv_expires
.tv_jiff
- tv
.tv_jiff
) *
434 1000000 / HZ
+ t
->tv_expires
.tv_usec
-
439 if (!fast_timer_running
)
441 #ifdef FAST_TIMER_LOG
442 timer_started_log
[fast_timers_started
% NUM_TIMER_STATS
] = *t
;
450 /* Timer already expired, let's handle it better late than never.
451 * The normal loop handles it
453 D1(printk("e! %d\n", us
));
458 local_irq_restore(flags
);
462 D1(printk("t1 stop!\n"));
468 static void wake_up_func(unsigned long data
)
470 #ifdef DECLARE_WAITQUEUE
471 wait_queue_head_t
*sleep_wait_p
= (wait_queue_head_t
*)data
;
473 struct wait_queue
**sleep_wait_p
= (struct wait_queue
**)data
;
475 wake_up(sleep_wait_p
);
481 void schedule_usleep(unsigned long us
)
484 wait_queue_head_t sleep_wait
;
485 init_waitqueue_head(&sleep_wait
);
487 D1(printk("schedule_usleep(%d)\n", us
));
488 start_one_shot_timer(&t
, wake_up_func
, (unsigned long)&sleep_wait
, us
,
490 /* Uninterruptible sleep on the fast timer. (The condition is somewhat
491 * redundant since the timer is what wakes us up.) */
492 wait_event(sleep_wait
, !fast_timer_pending(&t
));
494 D1(printk("done schedule_usleep(%d)\n", us
));
497 #ifdef CONFIG_PROC_FS
498 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
499 ,int *eof
, void *data_unused
);
500 static struct proc_dir_entry
*fasttimer_proc_entry
;
501 #endif /* CONFIG_PROC_FS */
503 #ifdef CONFIG_PROC_FS
505 /* This value is very much based on testing */
506 #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300)
508 static int proc_fasttimer_read(char *buf
, char **start
, off_t offset
, int len
509 ,int *eof
, void *data_unused
)
514 struct fasttime_t tv
;
515 struct fast_timer
*t
, *nextt
;
516 static char *bigbuf
= NULL
;
517 static unsigned long used
;
519 if (!bigbuf
&& !(bigbuf
= vmalloc(BIG_BUF_SIZE
)))
527 if (!offset
|| !used
)
529 do_gettimeofday_fast(&tv
);
532 used
+= sprintf(bigbuf
+ used
, "Fast timers added: %i\n",
534 used
+= sprintf(bigbuf
+ used
, "Fast timers started: %i\n",
535 fast_timers_started
);
536 used
+= sprintf(bigbuf
+ used
, "Fast timer interrupts: %i\n",
538 used
+= sprintf(bigbuf
+ used
, "Fast timers expired: %i\n",
539 fast_timers_expired
);
540 used
+= sprintf(bigbuf
+ used
, "Fast timers deleted: %i\n",
541 fast_timers_deleted
);
542 used
+= sprintf(bigbuf
+ used
, "Fast timer running: %s\n",
543 fast_timer_running
? "yes" : "no");
544 used
+= sprintf(bigbuf
+ used
, "Current time: %lu.%06lu\n",
545 (unsigned long)tv
.tv_jiff
,
546 (unsigned long)tv
.tv_usec
);
547 #ifdef FAST_TIMER_SANITY_CHECKS
548 used
+= sprintf(bigbuf
+ used
, "Sanity failed: %i\n",
551 used
+= sprintf(bigbuf
+ used
, "\n");
553 #ifdef DEBUG_LOG_INCLUDED
555 int end_i
= debug_log_cnt
;
558 if (debug_log_cnt_wrapped
)
563 while ((i
!= end_i
|| (debug_log_cnt_wrapped
&& !used
)) &&
564 used
+100 < BIG_BUF_SIZE
)
566 used
+= sprintf(bigbuf
+ used
, debug_log_string
[i
],
568 i
= (i
+1) % DEBUG_LOG_MAX
;
571 used
+= sprintf(bigbuf
+ used
, "\n");
574 num_to_show
= (fast_timers_started
< NUM_TIMER_STATS
? fast_timers_started
:
576 used
+= sprintf(bigbuf
+ used
, "Timers started: %i\n", fast_timers_started
);
577 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
) ; i
++)
579 int cur
= (fast_timers_started
- i
- 1) % NUM_TIMER_STATS
;
581 #if 1 //ndef FAST_TIMER_LOG
582 used
+= sprintf(bigbuf
+ used
, "div: %i freq: %i delay: %i"
584 timer_div_settings
[cur
],
585 timer_freq_settings
[cur
],
586 timer_delay_settings
[cur
]
589 #ifdef FAST_TIMER_LOG
590 t
= &timer_started_log
[cur
];
591 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
592 "d: %6li us data: 0x%08lX"
595 (unsigned long)t
->tv_set
.tv_jiff
,
596 (unsigned long)t
->tv_set
.tv_usec
,
597 (unsigned long)t
->tv_expires
.tv_jiff
,
598 (unsigned long)t
->tv_expires
.tv_usec
,
604 used
+= sprintf(bigbuf
+ used
, "\n");
606 #ifdef FAST_TIMER_LOG
607 num_to_show
= (fast_timers_added
< NUM_TIMER_STATS
? fast_timers_added
:
609 used
+= sprintf(bigbuf
+ used
, "Timers added: %i\n", fast_timers_added
);
610 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
612 t
= &timer_added_log
[(fast_timers_added
- i
- 1) % NUM_TIMER_STATS
];
613 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
614 "d: %6li us data: 0x%08lX"
617 (unsigned long)t
->tv_set
.tv_jiff
,
618 (unsigned long)t
->tv_set
.tv_usec
,
619 (unsigned long)t
->tv_expires
.tv_jiff
,
620 (unsigned long)t
->tv_expires
.tv_usec
,
625 used
+= sprintf(bigbuf
+ used
, "\n");
627 num_to_show
= (fast_timers_expired
< NUM_TIMER_STATS
? fast_timers_expired
:
629 used
+= sprintf(bigbuf
+ used
, "Timers expired: %i\n", fast_timers_expired
);
630 for (i
= 0; i
< num_to_show
&& (used
+100 < BIG_BUF_SIZE
); i
++)
632 t
= &timer_expired_log
[(fast_timers_expired
- i
- 1) % NUM_TIMER_STATS
];
633 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
634 "d: %6li us data: 0x%08lX"
637 (unsigned long)t
->tv_set
.tv_jiff
,
638 (unsigned long)t
->tv_set
.tv_usec
,
639 (unsigned long)t
->tv_expires
.tv_jiff
,
640 (unsigned long)t
->tv_expires
.tv_usec
,
645 used
+= sprintf(bigbuf
+ used
, "\n");
648 used
+= sprintf(bigbuf
+ used
, "Active timers:\n");
649 local_irq_save(flags
);
651 while (t
!= NULL
&& (used
+100 < BIG_BUF_SIZE
))
654 local_irq_restore(flags
);
655 used
+= sprintf(bigbuf
+ used
, "%-14s s: %6lu.%06lu e: %6lu.%06lu "
656 "d: %6li us data: 0x%08lX"
657 /* " func: 0x%08lX" */
660 (unsigned long)t
->tv_set
.tv_jiff
,
661 (unsigned long)t
->tv_set
.tv_usec
,
662 (unsigned long)t
->tv_expires
.tv_jiff
,
663 (unsigned long)t
->tv_expires
.tv_usec
,
668 local_irq_save(flags
);
669 if (t
->next
!= nextt
)
671 printk(KERN_WARNING
"timer removed!\n");
675 local_irq_restore(flags
);
678 if (used
- offset
< len
)
683 memcpy(buf
, bigbuf
+ offset
, len
);
691 #ifdef FAST_TIMER_TEST
692 static volatile unsigned long i
= 0;
693 static volatile int num_test_timeout
= 0;
694 static struct fast_timer tr
[10];
695 static int exp_num
[10];
697 static struct fasttime_t tv_exp
[100];
699 static void test_timeout(unsigned long data
)
701 do_gettimeofday_fast(&tv_exp
[data
]);
702 exp_num
[data
] = num_test_timeout
;
707 static void test_timeout1(unsigned long data
)
709 do_gettimeofday_fast(&tv_exp
[data
]);
710 exp_num
[data
] = num_test_timeout
;
713 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 1000, "timeout1");
720 static char buf0
[2000];
721 static char buf1
[2000];
722 static char buf2
[2000];
723 static char buf3
[2000];
724 static char buf4
[2000];
727 static char buf5
[6000];
728 static int j_u
[1000];
730 static void fast_timer_test(void)
735 struct fasttime_t tv
, tv0
, tv1
, tv2
;
737 printk("fast_timer_test() start\n");
738 do_gettimeofday_fast(&tv
);
740 for (j
= 0; j
< 1000; j
++)
742 j_u
[j
] = GET_JIFFIES_USEC();
744 for (j
= 0; j
< 100; j
++)
746 do_gettimeofday_fast(&tv_exp
[j
]);
748 printk(KERN_DEBUG
"fast_timer_test() %is %06i\n",
749 tv
.tv_jiff
, tv
.tv_usec
);
751 for (j
= 0; j
< 1000; j
++)
753 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]);
756 for (j
= 0; j
< 100; j
++)
758 printk(KERN_DEBUG
"%i.%i %i.%i %i.%i %i.%i %i.%i\n",
759 tv_exp
[j
].tv_jiff
, tv_exp
[j
].tv_usec
,
760 tv_exp
[j
+1].tv_jiff
, tv_exp
[j
+1].tv_usec
,
761 tv_exp
[j
+2].tv_jiff
, tv_exp
[j
+2].tv_usec
,
762 tv_exp
[j
+3].tv_jiff
, tv_exp
[j
+3].tv_usec
,
763 tv_exp
[j
+4].tv_jiff
, tv_exp
[j
+4].tv_usec
);
766 do_gettimeofday_fast(&tv0
);
767 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 50000, "test0");
768 DP(proc_fasttimer_read(buf0
, NULL
, 0, 0, 0));
770 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 70000, "test1");
771 DP(proc_fasttimer_read(buf1
, NULL
, 0, 0, 0));
773 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 40000, "test2");
774 DP(proc_fasttimer_read(buf2
, NULL
, 0, 0, 0));
776 start_one_shot_timer(&tr
[i
], test_timeout
, i
, 60000, "test3");
777 DP(proc_fasttimer_read(buf3
, NULL
, 0, 0, 0));
779 start_one_shot_timer(&tr
[i
], test_timeout1
, i
, 55000, "test4xx");
780 DP(proc_fasttimer_read(buf4
, NULL
, 0, 0, 0));
782 do_gettimeofday_fast(&tv1
);
784 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
786 prev_num
= num_test_timeout
;
787 while (num_test_timeout
< i
)
789 if (num_test_timeout
!= prev_num
)
791 prev_num
= num_test_timeout
;
794 do_gettimeofday_fast(&tv2
);
795 printk(KERN_DEBUG
"Timers started %is %06i\n",
796 tv0
.tv_jiff
, tv0
.tv_usec
);
797 printk(KERN_DEBUG
"Timers started at %is %06i\n",
798 tv1
.tv_jiff
, tv1
.tv_usec
);
799 printk(KERN_DEBUG
"Timers done %is %06i\n",
800 tv2
.tv_jiff
, tv2
.tv_usec
);
801 DP(printk("buf0:\n");
815 printk("timers set:\n");
818 struct fast_timer
*t
= &tr
[j
];
819 printk("%-10s set: %6is %06ius exp: %6is %06ius "
820 "data: 0x%08X func: 0x%08X\n",
824 t
->tv_expires
.tv_jiff
,
825 t
->tv_expires
.tv_usec
,
830 printk(" del: %6ius did exp: %6is %06ius as #%i error: %6li\n",
835 (tv_exp
[j
].tv_jiff
- t
->tv_expires
.tv_jiff
) *
836 1000000 + tv_exp
[j
].tv_usec
-
837 t
->tv_expires
.tv_usec
);
839 proc_fasttimer_read(buf5
, NULL
, 0, 0, 0);
840 printk("buf5 after all done:\n");
842 printk("fast_timer_test() done\n");
847 int fast_timer_init(void)
849 /* For some reason, request_irq() hangs when called froom time_init() */
850 if (!fast_timer_is_init
)
852 #if 0 && defined(FAST_TIMER_TEST)
856 printk(KERN_INFO
"fast_timer_init()\n");
858 #if 0 && defined(FAST_TIMER_TEST)
859 for (i
= 0; i
<= TIMER0_DIV
; i
++)
861 /* We must be careful not to get overflow... */
862 printk("%3i %6u\n", i
, timer0_value_us
[i
]);
865 #ifdef CONFIG_PROC_FS
866 if ((fasttimer_proc_entry
= create_proc_entry( "fasttimer", 0, 0 )))
867 fasttimer_proc_entry
->read_proc
= proc_fasttimer_read
;
869 if(request_irq(TIMER1_IRQ_NBR
, timer1_handler
, 0,
870 "fast timer int", NULL
))
872 printk("err: timer1 irq\n");
874 fast_timer_is_init
= 1;
875 #ifdef FAST_TIMER_TEST
882 __initcall(fast_timer_init
);