ieee1394: raw1394: arm functions slept in atomic context
[pandora-kernel.git] / arch / sh / boards / harp / led.c
1 /*
2  * linux/arch/sh/stboards/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 ST40STB1 HARP and compatible code.
10  */
11
12 #include <asm/io.h>
13 #include <asm/harp/harp.h>
14
15 /* Harp: Flash LD10 (front pannel) connected to EPLD (IC8) */
16 /* Overdrive: Flash LD1 (front panel) connected to EPLD (IC4) */
17 /* Works for HARP and overdrive */
18 static void mach_led(int position, int value)
19 {
20         if (value) {
21                 ctrl_outl(EPLD_LED_ON, EPLD_LED);
22         } else {
23                 ctrl_outl(EPLD_LED_OFF, EPLD_LED);
24         }
25 }
26
27 #ifdef CONFIG_HEARTBEAT
28
29 #include <linux/sched.h>
30
31 /* acts like an actual heart beat -- ie thump-thump-pause... */
32 void heartbeat_harp(void)
33 {
34         static unsigned cnt = 0, period = 0, dist = 0;
35
36         if (cnt == 0 || cnt == dist)
37                 mach_led( -1, 1);
38         else if (cnt == 7 || cnt == dist+7)
39                 mach_led( -1, 0);
40
41         if (++cnt > period) {
42                 cnt = 0;
43                 /* The hyperbolic function below modifies the heartbeat period
44                  * length in dependency of the current (5min) load. It goes
45                  * through the points f(0)=126, f(1)=86, f(5)=51,
46                  * f(inf)->30. */
47                 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
48                 dist = period / 4;
49         }
50 }
51 #endif