Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / sh / boards / se / 7343 / led.c
1 /*
2  * arch/sh/boards/se/7343/led.c
3  *
4  */
5
6 #include <linux/config.h>
7 #include <linux/sched.h>
8 #include <asm/mach/se7343.h>
9
10 /* Cycle the LED's in the clasic Knightrider/Sun pattern */
11 void heartbeat_7343se(void)
12 {
13         static unsigned int cnt = 0, period = 0;
14         volatile unsigned short *p = (volatile unsigned short *) PA_LED;
15         static unsigned bit = 0, up = 1;
16
17         cnt += 1;
18         if (cnt < period) {
19                 return;
20         }
21
22         cnt = 0;
23
24         /* Go through the points (roughly!):
25          * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
26          */
27         period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
28
29         if (up) {
30                 if (bit == 7) {
31                         bit--;
32                         up = 0;
33                 } else {
34                         bit++;
35                 }
36         } else {
37                 if (bit == 0) {
38                         bit++;
39                         up = 1;
40                 } else {
41                         bit--;
42                 }
43         }
44         *p = 1 << (bit + LED_SHIFT);
45
46 }