]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: heartbeat consolidation for banked LEDs.
authorPaul Mundt <lethal@linux-sh.org>
Tue, 13 Feb 2007 06:42:28 +0000 (15:42 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Tue, 13 Feb 2007 06:42:28 +0000 (15:42 +0900)
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>
32 files changed:
arch/sh/Kconfig
arch/sh/boards/mpc1211/Makefile
arch/sh/boards/mpc1211/led.c [deleted file]
arch/sh/boards/mpc1211/setup.c
arch/sh/boards/renesas/r7780rp/Makefile
arch/sh/boards/renesas/r7780rp/led.c [deleted file]
arch/sh/boards/renesas/r7780rp/setup.c
arch/sh/boards/renesas/rts7751r2d/Makefile
arch/sh/boards/renesas/rts7751r2d/led.c [deleted file]
arch/sh/boards/renesas/rts7751r2d/setup.c
arch/sh/boards/se/7206/Makefile
arch/sh/boards/se/7206/led.c [deleted file]
arch/sh/boards/se/7206/setup.c
arch/sh/boards/se/7300/Makefile
arch/sh/boards/se/7300/led.c [deleted file]
arch/sh/boards/se/7300/setup.c
arch/sh/boards/se/73180/Makefile
arch/sh/boards/se/73180/led.c [deleted file]
arch/sh/boards/se/73180/setup.c
arch/sh/boards/se/7343/Makefile
arch/sh/boards/se/7343/led.c [deleted file]
arch/sh/boards/se/7343/setup.c
arch/sh/boards/se/770x/Makefile
arch/sh/boards/se/770x/led.c [deleted file]
arch/sh/boards/se/770x/setup.c
arch/sh/boards/se/7751/Makefile
arch/sh/boards/se/7751/led.c [deleted file]
arch/sh/boards/se/7751/setup.c
arch/sh/boards/sh03/Makefile
arch/sh/boards/sh03/led.c [deleted file]
arch/sh/boards/sh03/setup.c
arch/sh/drivers/Makefile

index d18310ab4c70767757c617878ab28f4b4a47c065..90c8c42e7e8b080a6ec6e882eb8632cc71ab8c2c 100644 (file)
@@ -512,7 +512,8 @@ config HEARTBEAT
        bool "Heartbeat LED"
        depends on SH_MPC1211 || SH_SH03 || \
                   SH_BIGSUR || SOLUTION_ENGINE || \
-                  SH_RTS7751R2D || SH_SH4202_MICRODEV || SH_LANDISK
+                  SH_RTS7751R2D || SH_SH4202_MICRODEV || SH_LANDISK || \
+                  SH_R7780RP
        help
          Use the power-on LED on your machine as a load meter.  The exact
          behavior is platform-dependent, but normally the flash frequency is
index 1644ebed78cb68ce732009ad2ef5e7ddd40ec6fa..8cd31b5d200b026372f852a76ffb4d93ac0203c7 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the Interface (CTP/PCI/MPC-SH02) specific parts of the kernel
 #
 
-obj-y   := setup.o rtc.o led.o
+obj-y   := setup.o rtc.o
 
 obj-$(CONFIG_PCI) += pci.o
 
diff --git a/arch/sh/boards/mpc1211/led.c b/arch/sh/boards/mpc1211/led.c
deleted file mode 100644 (file)
index 8df1591..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * linux/arch/sh/boards/mpc1211/led.c
- *
- * Copyright (C) 2001  Saito.K & Jeanne
- *
- * This file contains Interface MPC-1211 specific LED code.
- */
-
-
-static void mach_led(int position, int value)
-{
-       volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
-
-       if (value) {
-               *p |= 1;
-       } else {
-               *p &= ~1;
-       }
-}
-
-#ifdef CONFIG_HEARTBEAT
-
-#include <linux/sched.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_mpc1211(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ( (300<<FSHIFT)/
-                        ((avenrun[0]/5) + (3<<FSHIFT)) );
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up=0;
-               } else {
-                       bit ++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up=1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1<<bit;
-
-}
-#endif /* CONFIG_HEARTBEAT */
index 7c3d1d304157f48d70555fa4dc71bdc199aeb00d..1a0604b23ce0f4bac86f65fa1e783d8e372cdb04 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/interrupt.h>
+#include <linux/platform_device.h>
 #include <asm/io.h>
 #include <asm/machvec.h>
 #include <asm/mpc1211/mpc1211.h>
@@ -281,6 +282,32 @@ static int put_smb_blk(unsigned char *p, int address, int command, int no)
        return 0;
 }
 
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = 0xa2000000,
+               .end    = 0xa2000000 + 8 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *mpc1211_devices[] __initdata = {
+       &heartbeat_device,
+};
+
+static int __init mpc1211_devices_setup(void)
+{
+       return platform_add_devices(mpc1211_devices,
+                                   ARRAY_SIZE(mpc1211_devices));
+}
+__initcall(mpc1211_devices_setup);
+
 /* arch/sh/boards/mpc1211/rtc.c */
 void mpc1211_time_init(void);
 
@@ -317,9 +344,5 @@ struct sh_machine_vector mv_mpc1211 __initmv = {
        .mv_nr_irqs             = 48,
        .mv_irq_demux           = mpc1211_irq_demux,
        .mv_init_irq            = init_mpc1211_IRQ,
-
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_mpc1211,
-#endif
 };
 ALIAS_MV(mpc1211)
index 574b0316ed564ace61bd0ca0ce5364f2d38e1741..3c93012e91a33cdd36d2816e849e936bae6b0163 100644 (file)
@@ -4,5 +4,4 @@
 
 obj-y   := setup.o io.o irq.o
 
-obj-$(CONFIG_HEARTBEAT)                += led.o
 obj-$(CONFIG_PUSH_SWITCH)      += psw.o
diff --git a/arch/sh/boards/renesas/r7780rp/led.c b/arch/sh/boards/renesas/r7780rp/led.c
deleted file mode 100644 (file)
index 6a00a25..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) Atom Create Engineering Co., Ltd.
- *
- * May be copied or modified under the terms of GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Renesas Solutions HIGHLANDER R7780RP-1 specific LED code.
- */
-#include <linux/sched.h>
-#include <asm/io.h>
-#include <asm/r7780rp/r7780rp.h>
-
-/* Cycle the LED's in the clasic Knightriger/Sun pattern */
-void heartbeat_r7780rp(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short *p = (volatile unsigned short *)PA_OBLED;
-       static unsigned bit = 0, up = 1;
-       unsigned bit_pos[] = {2, 1, 0, 3, 6, 5, 4, 7};
-
-       cnt += 1;
-       if (cnt < period)
-               return;
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
-        */
-       period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
-
-       *p = 1 << bit_pos[bit];
-       if (up)
-               if (bit == 7) {
-                       bit--;
-                       up = 0;
-               } else
-                       bit++;
-       else if (bit == 0)
-               up = 1;
-       else
-               bit--;
-}
index b48f19f512ca1a80bd78b59e544699251f343728..c40f85cc3e5e460552e864eab2bec98df00414b5 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/clock.h>
 #include <asm/io.h>
 
-extern void heartbeat_r7780rp(void);
 extern void init_r7780rp_IRQ(void);
 
 static struct resource m66596_usb_host_resources[] = {
@@ -72,9 +71,30 @@ static struct platform_device cf_ide_device  = {
        .resource       = cf_ide_resources,
 };
 
+static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
+
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_OBLED,
+               .end    = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = heartbeat_bit_pos,
+       },
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
 static struct platform_device *r7780rp_devices[] __initdata = {
        &m66596_usb_host_device,
        &cf_ide_device,
+       &heartbeat_device,
 };
 
 static int __init r7780rp_devices_setup(void)
@@ -185,8 +205,5 @@ struct sh_machine_vector mv_r7780rp __initmv = {
 
        .mv_ioport_map          = r7780rp_ioport_map,
        .mv_init_irq            = init_r7780rp_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_r7780rp,
-#endif
 };
 ALIAS_MV(r7780rp)
index 686fc9ea5989c01e1968c739eb8d1bd091c5bb5f..833de1eac0e863ec7c29c9a3b475d252896a66c5 100644 (file)
@@ -3,4 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/renesas/rts7751r2d/led.c b/arch/sh/boards/renesas/rts7751r2d/led.c
deleted file mode 100644 (file)
index 509f548..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * linux/arch/sh/boards/renesas/rts7751r2d/led.c
- *
- * Copyright (C) Atom Create Engineering Co., Ltd.
- *
- * May be copied or modified under the terms of GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Renesas Technology Sales RTS7751R2D specific LED code.
- */
-#include <linux/io.h>
-#include <linux/sched.h>
-#include <asm/rts7751r2d.h>
-
-/* Cycle the LED's in the clasic Knightriger/Sun pattern */
-void heartbeat_rts7751r2d(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short *p = (volatile unsigned short *)PA_OUTPORT;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period)
-               return;
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
-        */
-       period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
-
-       *p = 1 << bit;
-       if (up)
-               if (bit == 7) {
-                       bit--;
-                       up = 0;
-               } else
-                       bit++;
-       else if (bit == 0)
-               up = 1;
-       else
-               bit--;
-}
index 5c042d35ec91768d5255d2cba2ddf8c48f59fcb8..d97be1202245059f3b3d82465e88f83814b06cc5 100644 (file)
@@ -69,8 +69,24 @@ static struct platform_device uart_device = {
        },
 };
 
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_OUTPORT,
+               .end    = PA_OUTPORT + 8 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
 static struct platform_device *rts7751r2d_devices[] __initdata = {
        &uart_device,
+       &heartbeat_device,
 };
 
 static int __init rts7751r2d_devices_setup(void)
@@ -129,9 +145,6 @@ struct sh_machine_vector mv_rts7751r2d __initmv = {
        .mv_outsl               = rts7751r2d_outsl,
 
        .mv_init_irq            = init_rts7751r2d_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_rts7751r2d,
-#endif
        .mv_irq_demux           = rts7751r2d_irq_demux,
 
 #ifdef CONFIG_USB_SM501
index 63950f4f24533e54949b5bb49bec81de58af7175..63e7ed699f39b3c41d8578daa8b57ce31807c689 100644 (file)
@@ -3,5 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-obj-$(CONFIG_HEARTBEAT) += led.o
-
diff --git a/arch/sh/boards/se/7206/led.c b/arch/sh/boards/se/7206/led.c
deleted file mode 100644 (file)
index ef79460..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * linux/arch/sh/kernel/led_se.c
- *
- * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Solution Engine specific LED code.
- */
-
-#include <linux/config.h>
-#include <asm/se7206.h>
-
-#ifdef CONFIG_HEARTBEAT
-
-#include <linux/sched.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short* p = (volatile unsigned short*)PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ( (300<<FSHIFT)/
-                        ((avenrun[0]/5) + (3<<FSHIFT)) );
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up=0;
-               } else {
-                       bit ++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up=1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1<<(bit+8);
-
-}
-#endif /* CONFIG_HEARTBEAT */
index 0f42e91a3238b20bdd25026bdc3dff0155b54f6c..ca714879f55972bba43862ba70073702c9612d22 100644 (file)
@@ -3,6 +3,7 @@
  * linux/arch/sh/boards/se/7206/setup.c
  *
  * Copyright (C) 2006  Yoshinori Sato
+ * Copyright (C) 2007  Paul Mundt
  *
  * Hitachi 7206 SolutionEngine Support.
  *
@@ -34,15 +35,37 @@ static struct platform_device smc91x_device = {
        .resource       = smc91x_resources,
 };
 
+static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
+
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = heartbeat_bit_pos,
+       },
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *se7206_devices[] __initdata = {
+       &smc91x_device,
+       &heartbeat_device,
+};
+
 static int __init se7206_devices_setup(void)
 {
-       return platform_device_register(&smc91x_device);
+       return platform_add_devices(se7206_devices, ARRAY_SIZE(se7206_devices));
 }
-
 __initcall(se7206_devices_setup);
 
-void heartbeat_se(void);
-
 /*
  * The Machine Vector
  */
@@ -72,8 +95,5 @@ struct sh_machine_vector mv_se __initmv = {
        .mv_outsl               = se7206_outsl,
 
        .mv_init_irq            = init_se7206_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_se,
-#endif
 };
 ALIAS_MV(se)
index 0fbd4f47815cdb1bc8defab1433b204f26912671..46247368f14be7d19c9e2ced2d90e154a134cef6 100644 (file)
@@ -3,5 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/7300/led.c b/arch/sh/boards/se/7300/led.c
deleted file mode 100644 (file)
index 4d03bb7..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * linux/arch/sh/boards/se/7300/led.c
- *
- * Derived from linux/arch/sh/boards/se/770x/led.c
- *
- * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Solution Engine specific LED code.
- */
-
-#include <linux/sched.h>
-#include <asm/se7300.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_7300se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short *p = (volatile unsigned short *) PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up = 0;
-               } else {
-                       bit++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up = 1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1 << (bit + 8);
-
-}
-
index 6f082a722d42842f5502ff9b0a7497f3f35fd659..f1960956bad051f282ec74638432415eb985781a 100644 (file)
@@ -6,14 +6,43 @@
  * SH-Mobile SolutionEngine 7300 Support.
  *
  */
-
 #include <linux/init.h>
+#include <linux/platform_device.h>
 #include <asm/machvec.h>
 #include <asm/se7300.h>
 
-void heartbeat_7300se(void);
 void init_7300se_IRQ(void);
 
+static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
+
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = heartbeat_bit_pos,
+       },
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *se7300_devices[] __initdata = {
+       &heartbeat_device,
+};
+
+static int __init se7300_devices_setup(void)
+{
+       return platform_add_devices(se7300_devices, ARRAY_SIZE(se7300_devices));
+}
+__initcall(se7300_devices_setup);
+
 /*
  * The Machine Vector
  */
@@ -42,8 +71,5 @@ struct sh_machine_vector mv_7300se __initmv = {
        .mv_outsl = sh7300se_outsl,
 
        .mv_init_irq = init_7300se_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat = heartbeat_7300se,
-#endif
 };
 ALIAS_MV(7300se)
index 8f63886a0f3f12f2322fe50106d9af079dbd76b6..e7c09967c529e424cd6b45f8597b097bcb8a2835 100644 (file)
@@ -3,5 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/73180/led.c b/arch/sh/boards/se/73180/led.c
deleted file mode 100644 (file)
index 4b72e9a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * arch/sh/boards/se/73180/led.c
- *
- * Derived from arch/sh/boards/se/770x/led.c
- *
- * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Solution Engine specific LED code.
- */
-
-#include <linux/sched.h>
-#include <asm/mach/se73180.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_73180se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short *p = (volatile unsigned short *) PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up = 0;
-               } else {
-                       bit++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up = 1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1 << (bit + LED_SHIFT);
-
-}
index b38ef50a160a2114b4c7a290d420797de3871e12..911ce1cdbd7f86865bb903ac054b359f0f6be82b 100644 (file)
  */
 
 #include <linux/init.h>
+#include <linux/platform_device.h>
 #include <asm/machvec.h>
 #include <asm/se73180.h>
 #include <asm/irq.h>
 
-void heartbeat_73180se(void);
 void init_73180se_IRQ(void);
 
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + 8 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *se73180_devices[] __initdata = {
+       &heartbeat_device,
+};
+
+static int __init se73180_devices_setup(void)
+{
+       return platform_add_devices(sh7343se_platform_devices,
+                                   ARRAY_SIZE(sh7343se_platform_devices));
+}
+__initcall(se73180_devices_setup);
+
 /*
  * The Machine Vector
  */
@@ -46,8 +72,5 @@ struct sh_machine_vector mv_73180se __initmv = {
 
        .mv_init_irq = init_73180se_IRQ,
        .mv_irq_demux = shmse_irq_demux,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat = heartbeat_73180se,
-#endif
 };
 ALIAS_MV(73180se)
index 4291069c0b4f79e3304cb69cb4212b9c45c51228..3024796c6203b61771592cd6de0c701d4d367c41 100644 (file)
@@ -3,5 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/7343/led.c b/arch/sh/boards/se/7343/led.c
deleted file mode 100644 (file)
index 6b39e19..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * arch/sh/boards/se/7343/led.c
- *
- */
-#include <linux/sched.h>
-#include <asm/mach/se7343.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_7343se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short *p = (volatile unsigned short *) PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up = 0;
-               } else {
-                       bit++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up = 1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1 << (bit + LED_SHIFT);
-
-}
index c7d17fe7764ed2cbabd145726ea31b75912df125..3fdb16f2cef1dfd400677bfd7b9d623706e79ef2 100644 (file)
@@ -4,7 +4,6 @@
 #include <asm/mach/se7343.h>
 #include <asm/irq.h>
 
-void heartbeat_7343se(void);
 void init_7343se_IRQ(void);
 
 static struct resource smc91x_resources[] = {
@@ -31,14 +30,30 @@ static struct platform_device smc91x_device = {
        .resource       = smc91x_resources,
 };
 
-static struct platform_device *smc91x_platform_devices[] __initdata = {
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + 8 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *sh7343se_platform_devices[] __initdata = {
        &smc91x_device,
+       &heartbeat_device,
 };
 
 static int __init sh7343se_devices_setup(void)
 {
-       return platform_add_devices(smc91x_platform_devices,
-                                   ARRAY_SIZE(smc91x_platform_devices));
+       return platform_add_devices(sh7343se_platform_devices,
+                                   ARRAY_SIZE(sh7343se_platform_devices));
 }
 
 static void __init sh7343se_setup(char **cmdline_p)
@@ -76,8 +91,5 @@ struct sh_machine_vector mv_7343se __initmv = {
 
        .mv_init_irq = init_7343se_IRQ,
        .mv_irq_demux = shmse_irq_demux,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat = heartbeat_7343se,
-#endif
 };
 ALIAS_MV(7343se)
index 9a5035f80ec03987aadf37f3e72623a76c6ed179..8e624b06d5ea67efc746ecab0716485d9a4742bc 100644 (file)
@@ -3,4 +3,3 @@
 #
 
 obj-y   := setup.o io.o irq.o
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/770x/led.c b/arch/sh/boards/se/770x/led.c
deleted file mode 100644 (file)
index d93dd83..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * linux/arch/sh/boards/se/770x/led.c
- *
- * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Solution Engine specific LED code.
- */
-
-#include <linux/sched.h>
-#include <asm/se.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short* p = (volatile unsigned short*)PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ( (300<<FSHIFT)/
-                        ((avenrun[0]/5) + (3<<FSHIFT)) );
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up=0;
-               } else {
-                       bit ++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up=1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1<<(bit+8);
-
-}
index 84f2e4857c63da083bcbdaf36895720c8c1d840e..45cbc36b9fb70780e820cba14f05e6ec1b5164f8 100644 (file)
@@ -7,12 +7,12 @@
  *
  */
 #include <linux/init.h>
+#include <linux/platform_device.h>
 #include <asm/machvec.h>
 #include <asm/se.h>
 #include <asm/io.h>
 #include <asm/smc37c93x.h>
 
-void heartbeat_se(void);
 void init_se_IRQ(void);
 
 /*
@@ -63,6 +63,36 @@ static void __init smsc_setup(char **cmdline_p)
        outb_p(CONFIG_EXIT, CONFIG_PORT);
 }
 
+static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
+
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = heartbeat_bit_pos,
+       },
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *se_devices[] __initdata = {
+       &heartbeat_device,
+};
+
+static int __init se_devices_setup(void)
+{
+       return platform_add_devices(se_devices, ARRAY_SIZE(se_devices));
+}
+__initcall(se_devices_setup);
+
 /*
  * The Machine Vector
  */
@@ -101,8 +131,5 @@ struct sh_machine_vector mv_se __initmv = {
        .mv_outsl               = se_outsl,
 
        .mv_init_irq            = init_se_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_se,
-#endif
 };
 ALIAS_MV(se)
index 188900c48321335bca050c9d1b8b161d9fec7c3a..dbc29f3a9de50be179088eb1f1e69f5fb9fc2cfe 100644 (file)
@@ -5,4 +5,3 @@
 obj-y   := setup.o io.o irq.o
 
 obj-$(CONFIG_PCI) += pci.o
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/7751/led.c b/arch/sh/boards/se/7751/led.c
deleted file mode 100644 (file)
index de4194d..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * linux/arch/sh/boards/se/7751/led.c
- *
- * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
- *
- * May be copied or modified under the terms of the GNU General Public
- * License.  See linux/COPYING for more information.
- *
- * This file contains Solution Engine specific LED code.
- */
-#include <linux/sched.h>
-#include <asm/se7751.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_7751se(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned short* p = (volatile unsigned short*)PA_LED;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ( (300<<FSHIFT)/
-                        ((avenrun[0]/5) + (3<<FSHIFT)) );
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up=0;
-               } else {
-                       bit ++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up=1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1<<(bit+8);
-
-}
index f7e1dd39c8364c30db40874a04e391144f249b17..e3feae6ec0bfe503f7ec66340f6cffe731adc89e 100644 (file)
@@ -9,11 +9,11 @@
  * Ian da Silva and Jeremy Siegel, 2001.
  */
 #include <linux/init.h>
+#include <linux/platform_device.h>
 #include <asm/machvec.h>
 #include <asm/se7751.h>
 #include <asm/io.h>
 
-void heartbeat_7751se(void);
 void init_7751se_IRQ(void);
 
 #ifdef CONFIG_SH_KGDB
@@ -161,11 +161,40 @@ static int kgdb_uart_setup(void)
 }
 #endif /* CONFIG_SH_KGDB */
 
+static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
+
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = PA_LED,
+               .end    = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = heartbeat_bit_pos,
+       },
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *se7751_devices[] __initdata = {
+       &smc91x_device,
+       &heartbeat_device,
+};
+
+static int __init se7751_devices_setup(void)
+{
+       return platform_add_devices(se7751_devices, ARRAY_SIZE(se7751_devices));
+}
+__initcall(se7751_devices_setup);
 
 /*
  * The Machine Vector
  */
-
 struct sh_machine_vector mv_7751se __initmv = {
        .mv_name                = "7751 SolutionEngine",
        .mv_setup               = sh7751se_setup,
@@ -189,8 +218,5 @@ struct sh_machine_vector mv_7751se __initmv = {
        .mv_outsl               = sh7751se_outsl,
 
        .mv_init_irq            = init_7751se_IRQ,
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_7751se,
-#endif
 };
 ALIAS_MV(7751se)
index 321be50e36a5aeaa23db1e44130941dbca66ea72..400306a796ec5427f9554b5a78074d1f10302495 100644 (file)
@@ -3,4 +3,3 @@
 #
 
 obj-y   := setup.o rtc.o
-obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/sh03/led.c b/arch/sh/boards/sh03/led.c
deleted file mode 100644 (file)
index d38562a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * linux/arch/sh/boards/sh03/led.c
- *
- * Copyright (C) 2004  Saito.K Interface Corporation.
- *
- * This file contains Interface CTP/PCI-SH03 specific LED code.
- */
-
-#include <linux/sched.h>
-
-/* Cycle the LED's in the clasic Knightrider/Sun pattern */
-void heartbeat_sh03(void)
-{
-       static unsigned int cnt = 0, period = 0;
-       volatile unsigned char* p = (volatile unsigned char*)0xa0800000;
-       static unsigned bit = 0, up = 1;
-
-       cnt += 1;
-       if (cnt < period) {
-               return;
-       }
-
-       cnt = 0;
-
-       /* Go through the points (roughly!):
-        * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
-        */
-       period = 110 - ( (300<<FSHIFT)/
-                        ((avenrun[0]/5) + (3<<FSHIFT)) );
-
-       if (up) {
-               if (bit == 7) {
-                       bit--;
-                       up=0;
-               } else {
-                       bit ++;
-               }
-       } else {
-               if (bit == 0) {
-                       bit++;
-                       up=1;
-               } else {
-                       bit--;
-               }
-       }
-       *p = 1<<bit;
-
-}
index 5ad1e19771be79cdcd924d0dda701a54253a8f65..c069c444b4eca13663f4f645a592e555720ac7f2 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/platform_device.h>
 #include <asm/io.h>
 #include <asm/rtc.h>
 #include <asm/sh03/io.h>
@@ -48,15 +49,36 @@ static void __init sh03_setup(char **cmdline_p)
        board_time_init = sh03_time_init;
 }
 
+static struct resource heartbeat_resources[] = {
+       [0] = {
+               .start  = 0xa0800000,
+               .end    = 0xa0800000 + 8 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device heartbeat_device = {
+       .name           = "heartbeat",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(heartbeat_resources),
+       .resource       = heartbeat_resources,
+};
+
+static struct platform_device *sh03_devices[] __initdata = {
+       &heartbeat_device,
+};
+
+static int __init sh03_devices_setup(void)
+{
+       return platform_add_devices(sh03_devices, ARRAY_SIZE(sh03_devices));
+}
+__initcall(sh03_devices_setup);
+
 struct sh_machine_vector mv_sh03 __initmv = {
        .mv_name                = "Interface (CTP/PCI-SH03)",
        .mv_setup               = sh03_setup,
        .mv_nr_irqs             = 48,
        .mv_ioport_map          = sh03_ioport_map,
        .mv_init_irq            = init_sh03_IRQ,
-
-#ifdef CONFIG_HEARTBEAT
-       .mv_heartbeat           = heartbeat_sh03,
-#endif
 };
 ALIAS_MV(sh03)
index bf18dbfb6787db618d339e082b08bd0a8d6e2713..6cb92676c5fc4a51178a72524a61ee6d93ac7f11 100644 (file)
@@ -6,3 +6,4 @@ obj-$(CONFIG_PCI)               += pci/
 obj-$(CONFIG_SH_DMA)           += dma/
 obj-$(CONFIG_SUPERHYWAY)       += superhyway/
 obj-$(CONFIG_PUSH_SWITCH)      += push-switch.o
+obj-$(CONFIG_HEARTBEAT)                += heartbeat.o