aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/overdrive/led.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/overdrive/led.c')
-rw-r--r--arch/sh/boards/overdrive/led.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/sh/boards/overdrive/led.c b/arch/sh/boards/overdrive/led.c
new file mode 100644
index 000000000000..734742e92279
--- /dev/null
+++ b/arch/sh/boards/overdrive/led.c
@@ -0,0 +1,59 @@
1/*
2 * linux/arch/sh/overdrive/led.c
3 *
4 * Copyright (C) 1999 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 an Overdrive specific LED feature.
10 */
11
12#include <linux/config.h>
13#include <asm/system.h>
14#include <asm/io.h>
15#include <asm/overdrive/overdrive.h>
16
17static void mach_led(int position, int value)
18{
19 unsigned long flags;
20 unsigned long reg;
21
22 local_irq_save(flags);
23
24 reg = readl(OVERDRIVE_CTRL);
25 if (value) {
26 reg |= (1<<3);
27 } else {
28 reg &= ~(1<<3);
29 }
30 writel(reg, OVERDRIVE_CTRL);
31
32 local_irq_restore(flags);
33}
34
35#ifdef CONFIG_HEARTBEAT
36
37#include <linux/sched.h>
38
39/* acts like an actual heart beat -- ie thump-thump-pause... */
40void heartbeat_od(void)
41{
42 static unsigned cnt = 0, period = 0, dist = 0;
43
44 if (cnt == 0 || cnt == dist)
45 mach_led( -1, 1);
46 else if (cnt == 7 || cnt == dist+7)
47 mach_led( -1, 0);
48
49 if (++cnt > period) {
50 cnt = 0;
51 /* The hyperbolic function below modifies the heartbeat period
52 * length in dependency of the current (5min) load. It goes
53 * through the points f(0)=126, f(1)=86, f(5)=51,
54 * f(inf)->30. */
55 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
56 dist = period / 4;
57 }
58}
59#endif /* CONFIG_HEARTBEAT */