aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/sh03
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-02-13 01:42:28 -0500
committerPaul Mundt <lethal@linux-sh.org>2007-02-13 01:42:28 -0500
commit3b4d9539628502768fe7f8fd4b48f2fbf2426255 (patch)
tree2bc27b9b57ed3f768a40cedc7c44b95da4025526 /arch/sh/boards/sh03
parentc7666e72cff1a2793055486340ac5f5137494c08 (diff)
sh: heartbeat consolidation for banked LEDs.
This consolidates the various board heartbeat LED implementations, used for strobing the load average across a LED bank. Those boards not implementing a full bank can hook in via the LED class. We leave the compat hook in the machvec for now until those non-banked boards are able to migrate to the drivers/leds. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/sh03')
-rw-r--r--arch/sh/boards/sh03/Makefile1
-rw-r--r--arch/sh/boards/sh03/led.c48
-rw-r--r--arch/sh/boards/sh03/setup.c30
3 files changed, 26 insertions, 53 deletions
diff --git a/arch/sh/boards/sh03/Makefile b/arch/sh/boards/sh03/Makefile
index 321be50e36a5..400306a796ec 100644
--- a/arch/sh/boards/sh03/Makefile
+++ b/arch/sh/boards/sh03/Makefile
@@ -3,4 +3,3 @@
3# 3#
4 4
5obj-y := setup.o rtc.o 5obj-y := setup.o rtc.o
6obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/sh03/led.c b/arch/sh/boards/sh03/led.c
deleted file mode 100644
index d38562ad6be8..000000000000
--- a/arch/sh/boards/sh03/led.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * linux/arch/sh/boards/sh03/led.c
3 *
4 * Copyright (C) 2004 Saito.K Interface Corporation.
5 *
6 * This file contains Interface CTP/PCI-SH03 specific LED code.
7 */
8
9#include <linux/sched.h>
10
11/* Cycle the LED's in the clasic Knightrider/Sun pattern */
12void heartbeat_sh03(void)
13{
14 static unsigned int cnt = 0, period = 0;
15 volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
16 static unsigned bit = 0, up = 1;
17
18 cnt += 1;
19 if (cnt < period) {
20 return;
21 }
22
23 cnt = 0;
24
25 /* Go through the points (roughly!):
26 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
27 */
28 period = 110 - ( (300<<FSHIFT)/
29 ((avenrun[0]/5) + (3<<FSHIFT)) );
30
31 if (up) {
32 if (bit == 7) {
33 bit--;
34 up=0;
35 } else {
36 bit ++;
37 }
38 } else {
39 if (bit == 0) {
40 bit++;
41 up=1;
42 } else {
43 bit--;
44 }
45 }
46 *p = 1<<bit;
47
48}
diff --git a/arch/sh/boards/sh03/setup.c b/arch/sh/boards/sh03/setup.c
index 5ad1e19771be..c069c444b4ec 100644
--- a/arch/sh/boards/sh03/setup.c
+++ b/arch/sh/boards/sh03/setup.c
@@ -8,6 +8,7 @@
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/platform_device.h>
11#include <asm/io.h> 12#include <asm/io.h>
12#include <asm/rtc.h> 13#include <asm/rtc.h>
13#include <asm/sh03/io.h> 14#include <asm/sh03/io.h>
@@ -48,15 +49,36 @@ static void __init sh03_setup(char **cmdline_p)
48 board_time_init = sh03_time_init; 49 board_time_init = sh03_time_init;
49} 50}
50 51
52static struct resource heartbeat_resources[] = {
53 [0] = {
54 .start = 0xa0800000,
55 .end = 0xa0800000 + 8 - 1,
56 .flags = IORESOURCE_MEM,
57 },
58};
59
60static struct platform_device heartbeat_device = {
61 .name = "heartbeat",
62 .id = -1,
63 .num_resources = ARRAY_SIZE(heartbeat_resources),
64 .resource = heartbeat_resources,
65};
66
67static struct platform_device *sh03_devices[] __initdata = {
68 &heartbeat_device,
69};
70
71static int __init sh03_devices_setup(void)
72{
73 return platform_add_devices(sh03_devices, ARRAY_SIZE(sh03_devices));
74}
75__initcall(sh03_devices_setup);
76
51struct sh_machine_vector mv_sh03 __initmv = { 77struct sh_machine_vector mv_sh03 __initmv = {
52 .mv_name = "Interface (CTP/PCI-SH03)", 78 .mv_name = "Interface (CTP/PCI-SH03)",
53 .mv_setup = sh03_setup, 79 .mv_setup = sh03_setup,
54 .mv_nr_irqs = 48, 80 .mv_nr_irqs = 48,
55 .mv_ioport_map = sh03_ioport_map, 81 .mv_ioport_map = sh03_ioport_map,
56 .mv_init_irq = init_sh03_IRQ, 82 .mv_init_irq = init_sh03_IRQ,
57
58#ifdef CONFIG_HEARTBEAT
59 .mv_heartbeat = heartbeat_sh03,
60#endif
61}; 83};
62ALIAS_MV(sh03) 84ALIAS_MV(sh03)