-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 143020 b: refs/heads/master c: ecc6dfc h: refs/heads/master v: v3
- Loading branch information
Michal Simek
committed
Mar 27, 2009
1 parent
a7e2664
commit acf6700
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 2660663ff2d34a3665381a2591bbc3ce0cdbd69c | ||
refs/heads/master: ecc6dfc8adfc76d323c513bc88cb260344c11139 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu> | ||
* Copyright (C) 2007-2009 PetaLogix | ||
* 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 <linux/io.h> | ||
|
||
#include <asm/setup.h> | ||
#include <asm/page.h> | ||
#include <asm/prom.h> | ||
|
||
static unsigned int base_addr; | ||
|
||
void heartbeat(void) | ||
{ | ||
static unsigned int cnt, period, dist; | ||
|
||
if (base_addr) { | ||
if (cnt == 0 || cnt == dist) | ||
out_be32(base_addr, 1); | ||
else if (cnt == 7 || cnt == dist + 7) | ||
out_be32(base_addr, 0); | ||
|
||
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; | ||
} | ||
} | ||
} | ||
|
||
void setup_heartbeat(void) | ||
{ | ||
struct device_node *gpio = NULL; | ||
int j; | ||
char *gpio_list[] = { | ||
"xlnx,xps-gpio-1.00.a", | ||
"xlnx,opb-gpio-1.00.a", | ||
NULL | ||
}; | ||
|
||
for (j = 0; gpio_list[j] != NULL; j++) { | ||
gpio = of_find_compatible_node(NULL, NULL, gpio_list[j]); | ||
if (gpio) | ||
break; | ||
} | ||
|
||
base_addr = *(int *) of_get_property(gpio, "reg", NULL); | ||
base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE); | ||
printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr); | ||
|
||
if (*(int *) of_get_property(gpio, "xlnx,is-bidir", NULL)) | ||
out_be32(base_addr + 4, 0); /* GPIO is configured as output */ | ||
} |