Merge branch 'gfar' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc...
[pandora-kernel.git] / arch / sh / boards / se / 770x / led.c
1 /*
2  * linux/arch/sh/boards/se/770x/led.c
3  *
4  * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
5  *
6  * May be copied or modified under the terms of the GNU General Public
7  * License.  See linux/COPYING for more information.
8  *
9  * This file contains Solution Engine specific LED code.
10  */
11
12 #include <linux/sched.h>
13 #include <asm/se.h>
14
15 /* Cycle the LED's in the clasic Knightrider/Sun pattern */
16 void heartbeat_se(void)
17 {
18         static unsigned int cnt = 0, period = 0;
19         volatile unsigned short* p = (volatile unsigned short*)PA_LED;
20         static unsigned bit = 0, up = 1;
21
22         cnt += 1;
23         if (cnt < period) {
24                 return;
25         }
26
27         cnt = 0;
28
29         /* Go through the points (roughly!):
30          * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
31          */
32         period = 110 - ( (300<<FSHIFT)/
33                          ((avenrun[0]/5) + (3<<FSHIFT)) );
34
35         if (up) {
36                 if (bit == 7) {
37                         bit--;
38                         up=0;
39                 } else {
40                         bit ++;
41                 }
42         } else {
43                 if (bit == 0) {
44                         bit++;
45                         up=1;
46                 } else {
47                         bit--;
48                 }
49         }
50         *p = 1<<(bit+8);
51
52 }