Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[pandora-kernel.git] / arch / sh / boards / se / 770x / led.c
1 /*
2  * linux/arch/sh/kernel/led_se.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 <asm/se/se.h>
13
14 static void mach_led(int position, int value)
15 {
16         volatile unsigned short* p = (volatile unsigned short*)PA_LED;
17
18         if (value) {
19                 *p |= (1<<8);
20         } else {
21                 *p &= ~(1<<8);
22         }
23 }
24
25 #ifdef CONFIG_HEARTBEAT
26
27 #include <linux/sched.h>
28
29 /* Cycle the LED's in the clasic Knightrider/Sun pattern */
30 void heartbeat_se(void)
31 {
32         static unsigned int cnt = 0, period = 0;
33         volatile unsigned short* p = (volatile unsigned short*)PA_LED;
34         static unsigned bit = 0, up = 1;
35
36         cnt += 1;
37         if (cnt < period) {
38                 return;
39         }
40
41         cnt = 0;
42
43         /* Go through the points (roughly!):
44          * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
45          */
46         period = 110 - ( (300<<FSHIFT)/
47                          ((avenrun[0]/5) + (3<<FSHIFT)) );
48
49         if (up) {
50                 if (bit == 7) {
51                         bit--;
52                         up=0;
53                 } else {
54                         bit ++;
55                 }
56         } else {
57                 if (bit == 0) {
58                         bit++;
59                         up=1;
60                 } else {
61                         bit--;
62                 }
63         }
64         *p = 1<<(bit+8);
65
66 }
67 #endif /* CONFIG_HEARTBEAT */