blob: cf993c4a9fdc0f3241af701481e4a2fc031c9bec [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/sh64/kernel/led.c
3 *
4 * Copyright (C) 2002 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 * Flash the LEDs
10 */
11#include <linux/config.h>
12#include <linux/stddef.h>
13#include <linux/sched.h>
14
15void mach_led(int pos, int val);
16
17/* acts like an actual heart beat -- ie thump-thump-pause... */
18void heartbeat(void)
19{
20 static unsigned int cnt = 0, period = 0, dist = 0;
21
22 if (cnt == 0 || cnt == dist) {
23 mach_led(-1, 1);
24 } else if (cnt == 7 || cnt == dist + 7) {
25 mach_led(-1, 0);
26 }
27
28 if (++cnt > period) {
29 cnt = 0;
30
31 /*
32 * The hyperbolic function below modifies the heartbeat period
33 * length in dependency of the current (5min) load. It goes
34 * through the points f(0)=126, f(1)=86, f(5)=51, f(inf)->30.
35 */
36 period = ((672 << FSHIFT) / (5 * avenrun[0] +
37 (7 << FSHIFT))) + 30;
38 dist = period / 4;
39 }
40}
41