aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/overdrive/led.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/boards/overdrive/led.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
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 */