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
11 #include <linux/sched.h>
12 #include <linux/sched/loadavg.h>
15 #include <asm/setup.h>
19 static unsigned int base_addr
;
21 void microblaze_heartbeat(void)
23 static unsigned int cnt
, period
, dist
;
26 if (cnt
== 0 || cnt
== dist
)
27 out_be32(base_addr
, 1);
28 else if (cnt
== 7 || cnt
== dist
+ 7)
29 out_be32(base_addr
, 0);
34 * The hyperbolic function below modifies the heartbeat
35 * period length in dependency of the current (5min)
36 * load. It goes through the points f(0)=126, f(1)=86,
37 * f(5)=51, f(inf)->30.
39 period
= ((672 << FSHIFT
) / (5 * avenrun
[0] +
46 void microblaze_setup_heartbeat(void)
48 struct device_node
*gpio
= NULL
;
51 const char * const gpio_list
[] = {
52 "xlnx,xps-gpio-1.00.a",
56 for (j
= 0; gpio_list
[j
] != NULL
; j
++) {
57 gpio
= of_find_compatible_node(NULL
, NULL
, gpio_list
[j
]);
63 base_addr
= be32_to_cpup(of_get_property(gpio
, "reg", NULL
));
64 base_addr
= (unsigned long) ioremap(base_addr
, PAGE_SIZE
);
65 pr_notice("Heartbeat GPIO at 0x%x\n", base_addr
);
67 /* GPIO is configured as output */
68 prop
= (int *) of_get_property(gpio
, "xlnx,is-bidir", NULL
);
70 out_be32(base_addr
+ 4, 0);