aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/bigsur/led.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/bigsur/led.c')
-rw-r--r--arch/sh/boards/bigsur/led.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/sh/boards/bigsur/led.c b/arch/sh/boards/bigsur/led.c
new file mode 100644
index 000000000000..0a2339c69440
--- /dev/null
+++ b/arch/sh/boards/bigsur/led.c
@@ -0,0 +1,55 @@
1/*
2 * linux/arch/sh/kernel/led_bigsur.c
3 *
4 * By Dustin McIntire (dustin@sensoria.com) (c)2001
5 * Derived from led_se.c and led.c, which bore the message:
6 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information.
10 *
11 * This file contains Big Sur specific LED code.
12 */
13
14#include <linux/config.h>
15#include <asm/io.h>
16#include <asm/bigsur/bigsur.h>
17
18static void mach_led(int position, int value)
19{
20 int word;
21
22 word = bigsur_inl(BIGSUR_CSLR);
23 if (value) {
24 bigsur_outl(word & ~BIGSUR_LED, BIGSUR_CSLR);
25 } else {
26 bigsur_outl(word | BIGSUR_LED, BIGSUR_CSLR);
27 }
28}
29
30#ifdef CONFIG_HEARTBEAT
31
32#include <linux/sched.h>
33
34/* Cycle the LED on/off */
35void heartbeat_bigsur(void)
36{
37 static unsigned cnt = 0, period = 0, dist = 0;
38
39 if (cnt == 0 || cnt == dist)
40 mach_led( -1, 1);
41 else if (cnt == 7 || cnt == dist+7)
42 mach_led( -1, 0);
43
44 if (++cnt > period) {
45 cnt = 0;
46 /* The hyperbolic function below modifies the heartbeat period
47 * length in dependency of the current (5min) load. It goes
48 * through the points f(0)=126, f(1)=86, f(5)=51,
49 * f(inf)->30. */
50 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
51 dist = period / 4;
52 }
53}
54#endif /* CONFIG_HEARTBEAT */
55