conn reset/free, struct skb_procstate reduction
[cor_2_6_31.git] / arch / microblaze / kernel / heartbeat.c
blob1bdf20222b92ba0ecdb0fe8b35488f7653ab6909
1 /*
2 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2007-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
11 #include <linux/sched.h>
12 #include <linux/io.h>
14 #include <asm/setup.h>
15 #include <asm/page.h>
16 #include <asm/prom.h>
18 static unsigned int base_addr;
20 void heartbeat(void)
22 static unsigned int cnt, period, dist;
24 if (base_addr) {
25 if (cnt == 0 || cnt == dist)
26 out_be32(base_addr, 1);
27 else if (cnt == 7 || cnt == dist + 7)
28 out_be32(base_addr, 0);
30 if (++cnt > period) {
31 cnt = 0;
33 * The hyperbolic function below modifies the heartbeat
34 * period length in dependency of the current (5min)
35 * load. It goes through the points f(0)=126, f(1)=86,
36 * f(5)=51, f(inf)->30.
38 period = ((672 << FSHIFT) / (5 * avenrun[0] +
39 (7 << FSHIFT))) + 30;
40 dist = period / 4;
45 void setup_heartbeat(void)
47 struct device_node *gpio = NULL;
48 int j;
49 char *gpio_list[] = {
50 "xlnx,xps-gpio-1.00.a",
51 "xlnx,opb-gpio-1.00.a",
52 NULL
55 for (j = 0; gpio_list[j] != NULL; j++) {
56 gpio = of_find_compatible_node(NULL, NULL, gpio_list[j]);
57 if (gpio)
58 break;
61 base_addr = *(int *) of_get_property(gpio, "reg", NULL);
62 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE);
63 printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr);
65 if (*(int *) of_get_property(gpio, "xlnx,is-bidir", NULL))
66 out_be32(base_addr + 4, 0); /* GPIO is configured as output */