Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
[pandora-kernel.git] / arch / sh / boards / se / 7751 / led.c
1 /*
2  * linux/arch/sh/boards/se/7751/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 #include <linux/sched.h>
12 #include <asm/se7751.h>
13
14 /* Cycle the LED's in the clasic Knightrider/Sun pattern */
15 void heartbeat_7751se(void)
16 {
17         static unsigned int cnt = 0, period = 0;
18         volatile unsigned short* p = (volatile unsigned short*)PA_LED;
19         static unsigned bit = 0, up = 1;
20
21         cnt += 1;
22         if (cnt < period) {
23                 return;
24         }
25
26         cnt = 0;
27
28         /* Go through the points (roughly!):
29          * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
30          */
31         period = 110 - ( (300<<FSHIFT)/
32                          ((avenrun[0]/5) + (3<<FSHIFT)) );
33
34         if (up) {
35                 if (bit == 7) {
36                         bit--;
37                         up=0;
38                 } else {
39                         bit ++;
40                 }
41         } else {
42                 if (bit == 0) {
43                         bit++;
44                         up=1;
45                 } else {
46                         bit--;
47                 }
48         }
49         *p = 1<<(bit+8);
50
51 }