[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <eb0e741f891335df37c3cd19f1a3ce2f7ce8652a.1215517976.git.monstr@monstr.eu>
Date: Tue, 8 Jul 2008 13:59:21 +0200
From: monstr@...str.eu
To: linux-kernel@...r.kernel.org
Cc: monstr@...nam.cz, arnd@...db.de, linux-arch@...r.kernel.org,
stephen.neuendorffer@...inx.com, John.Linn@...inx.com,
john.williams@...alogix.com, matthew@....cx, will.newton@...il.com,
drepper@...hat.com, microblaze-uclinux@...e.uq.edu.au,
grant.likely@...retlab.ca, vapier.adi@...il.com,
alan@...rguk.ukuu.org.uk, hpa@...or.com, lethal@...ux-sh.org,
florian@...nwrt.org, Michal Simek <monstr@...str.eu>
Subject: [PATCH 21/58] microblaze_v5: heartbeat file
From: Michal Simek <monstr@...str.eu>
Acked-by: Stephen Neuendorffer <stephen.neuendorffer@...inx.com>
Signed-off-by: Michal Simek <monstr@...str.eu>
---
arch/microblaze/kernel/heartbeat.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 arch/microblaze/kernel/heartbeat.c
diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
new file mode 100644
index 0000000..5a21c1d
--- /dev/null
+++ b/arch/microblaze/kernel/heartbeat.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2007-2008 Michal Simek <monstr@...str.eu>
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/sched.h>
+#include <asm/page.h>
+#include <asm/io.h>
+#include <asm/setup.h>
+
+void heartbeat(void)
+{
+ static unsigned int cnt, period, dist;
+
+ if (cnt == 0 || cnt == dist)
+ iowrite32(1, CONFIG_HEART_BEAT_ADDRESS);
+ else if (cnt == 7 || cnt == dist + 7)
+ iowrite32(0, CONFIG_HEART_BEAT_ADDRESS);
+
+ if (++cnt > period) {
+ cnt = 0;
+ /*
+ * The hyperbolic function below modifies the heartbeat period
+ * length in dependency of the current (5min) load. It goes
+ * through the points f(0)=126, f(1)=86, f(5)=51, f(inf)->30.
+ */
+ period = ((672 << FSHIFT) / (5 * avenrun[0] +
+ (7 << FSHIFT))) + 30;
+ dist = period / 4;
+ }
+}
--
1.5.4.GIT
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists