Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / arch / sh / boards / sh03 / led.c
1 /*
2  * linux/arch/sh/boards/sh03/led.c
3  *
4  * Copyright (C) 2004  Saito.K Interface Corporation.
5  *
6  * This file contains Interface CTP/PCI-SH03 specific LED code.
7  */
8
9 #include <linux/sched.h>
10
11 /* Cycle the LED's in the clasic Knightrider/Sun pattern */
12 void heartbeat_sh03(void)
13 {
14         static unsigned int cnt = 0, period = 0;
15         volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
16         static unsigned bit = 0, up = 1;
17
18         cnt += 1;
19         if (cnt < period) {
20                 return;
21         }
22
23         cnt = 0;
24
25         /* Go through the points (roughly!):
26          * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
27          */
28         period = 110 - ( (300<<FSHIFT)/
29                          ((avenrun[0]/5) + (3<<FSHIFT)) );
30
31         if (up) {
32                 if (bit == 7) {
33                         bit--;
34                         up=0;
35                 } else {
36                         bit ++;
37                 }
38         } else {
39                 if (bit == 0) {
40                         bit++;
41                         up=1;
42                 } else {
43                         bit--;
44                 }
45         }
46         *p = 1<<bit;
47
48 }