public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: John Lenz <lenz@cs.wisc.edu>
Cc: Ben Dooks <ben@fluff.org.uk>,
	vojtech@suse.cz, rpurdie@rpsys.net,
	kernel list <linux-kernel@vger.kernel.org>,
	Russell King <rmk@arm.linux.org.uk>
Subject: Re: best way to handle LEDs
Date: Tue, 8 Nov 2005 00:30:00 +0100	[thread overview]
Message-ID: <20051107233000.GC2034@elf.ucw.cz> (raw)
In-Reply-To: <43093.192.168.0.12.1130985101.squirrel@192.168.0.2>

Hi!

> >> > I think even slow blinking was used somewhere. I have some code from
> >> > John Lenz (attached); it uses sysfs interface, exports led collor, and
> >> > allows setting different frequencies.
> >> >
> >> > Is that acceptable, or should some other interface be used?
> >>
> >> there is already an LED interface for linux-arm, which is
> >> used by a number of the extant machines in the sa11x0 and
> >> pxa range.
> >
> > Where is that interface? I think that making collie use it is obvious
> > first step...
> 
> I originally wrote the collie led code to use that interface, and you
> might look at some of the old versions of the patch on my web site.  The
> actual code is in arch/arm/kernel/time.c, but this code calls out to an
> individual machine function through say arch/arm/mach-sa1100/leds.c... 
> The problem for collie was that the device model for locomo did not allow
> an easy way to do it... as you can see, in my patch it implements a driver
> for those leds and the driver model takes care of it.
> 
> I just looked, and
> http://www.cs.wisc.edu/~lenz/zaurus/files/patch-2.6.7-jl2.diff.gz contins
> the implementation of the arm led interface for collie.... not sure if it
> will still work anymore, but...

It does, after kconfig fixups. Do you think we could get that merged?
Some led driver is better than none at all.

---

Simple collie LED driver, by John Lenz.

Signed-off-by: Pavel Machek <pavel@suse.cz>

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -408,7 +408,8 @@ config LEDS
 		   ARCH_EBSA285 || ARCH_IMX || ARCH_INTEGRATOR || \
 		   ARCH_LUBBOCK || MACH_MAINSTONE || ARCH_NETWINDER || \
 		   ARCH_OMAP || ARCH_P720T || ARCH_PXA_IDP || \
-		   ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE
+		   ARCH_SA1100 || ARCH_SHARK || ARCH_VERSATILE || \
+		   SA1100_COLLIE
 	help
 	  If you say Y here, the LEDs on your machine will be used
 	  to provide useful information about your current system status.
@@ -422,7 +423,8 @@ config LEDS
 
 config LEDS_TIMER
 	bool "Timer LED" if (!ARCH_CDB89712 && !ARCH_OMAP) || \
-			    MACH_OMAP_H2 || MACH_OMAP_PERSEUS2
+			    MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || \\
+			    SA1100_COLLIE
 	depends on LEDS
 	default y if ARCH_EBSA110
 	help
@@ -438,7 +440,8 @@ config LEDS_TIMER
 
 config LEDS_CPU
 	bool "CPU usage LED" if (!ARCH_CDB89712 && !ARCH_EBSA110 && \
-			!ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2
+			!ARCH_OMAP) || MACH_OMAP_H2 || MACH_OMAP_PERSEUS2 || \
+			SA1100_COLLIE
 	depends on LEDS
 	help
 	  If you say Y here, the red LED will be used to give a good real
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -26,6 +26,7 @@ led-$(CONFIG_SA1100_CERF)		+= leds-cerf.
 obj-$(CONFIG_SA1100_COLLIE)		+= collie.o
 #obj-$(CONFIG_SA1100_COLLIE)		+= battery-collie.o
 obj-$(CONFIG_SA1100_COLLIE)		+= collie_batswitch.o
+obj-$(CONFIG_SA1100_COLLIE)		+= leds-collie.o
 
 obj-$(CONFIG_SA1100_H3600)		+= h3600.o
 
diff --git a/arch/arm/mach-sa1100/leds-collie.c b/arch/arm/mach-sa1100/leds-collie.c
new file mode 100644
--- /dev/null
+++ b/arch/arm/mach-sa1100/leds-collie.c
@@ -0,0 +1,126 @@
+/*
+ * linux/arch/arm/mach-sa1100/leds-collie.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ChangeLog:
+ * 	- John Lenz <4/27/04> - added support for new locomo device model
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/device.h>
+
+#include <asm/hardware.h>
+#include <asm/hardware/locomo.h>
+#include <asm/leds.h>
+#include <asm/system.h>
+
+#include "leds.h"
+
+#define LED_STATE_ENABLED	1
+#define LED_STATE_CLAIMED	2
+
+static struct locomo_dev *locomo_dev;
+static unsigned int led_state;
+static unsigned int hw_led0_state;
+static unsigned int hw_led1_state;
+
+#define	LED_ONOFF_MASK	(LOCOMO_LPT_TOFL|LOCOMO_LPT_TOFH)
+#define	LED_OFF(REG)	((REG)|=LOCOMO_LPT_TOFL)
+#define	LED_ON(REG)	((REG)=((REG)&~LED_ONOFF_MASK)|LOCOMO_LPT_TOFH)
+#define	LED_FLIP(REG)	((REG)^=LED_ONOFF_MASK)
+
+void collie_leds_event(led_event_t evt)
+{
+        unsigned long flags;
+
+	local_irq_save(flags);
+
+        switch (evt) {
+        case led_start:
+                led_state = LED_STATE_ENABLED;
+		LED_ON(hw_led0_state);
+		LED_ON(hw_led1_state);
+                break;
+
+        case led_stop:
+                led_state &= ~LED_STATE_ENABLED;
+                break;
+
+        case led_claim:
+                led_state |= LED_STATE_CLAIMED;
+		LED_ON(hw_led0_state);
+		LED_ON(hw_led1_state);
+                break;
+
+        case led_release:
+                led_state &= ~LED_STATE_CLAIMED;
+		LED_ON(hw_led0_state);
+		LED_ON(hw_led1_state);
+                break;
+
+#ifdef CONFIG_LEDS_TIMER
+        case led_timer:
+                if (!(led_state & LED_STATE_CLAIMED)) {
+			LED_FLIP(hw_led0_state);
+		}
+                break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+        case led_idle_start:
+		/* LED off when system is idle */
+                if (!(led_state & LED_STATE_CLAIMED))
+			LED_OFF(hw_led1_state);
+                break;
+
+        case led_idle_end:
+                if (!(led_state & LED_STATE_CLAIMED))
+			LED_ON(hw_led1_state);
+                break;
+#endif
+
+	default:
+		break;
+        }
+
+        if  (locomo_dev && led_state & LED_STATE_ENABLED) {
+		locomo_writel(hw_led0_state, locomo_dev->mapbase + LOCOMO_LPT0);
+		locomo_writel(hw_led1_state, locomo_dev->mapbase + LOCOMO_LPT1);
+        }
+
+	local_irq_restore(flags);
+}
+
+static int collieled_probe(struct locomo_dev *dev)
+{
+	locomo_dev = dev;
+	return 0;
+}
+
+static int collieled_remove(struct locomo_dev *dev) {
+	locomo_dev = NULL;
+	return 0;
+}
+
+static struct locomo_driver collieled_driver = {
+	.drv = {
+		.name = "locomoled"
+	},
+	.devid	= LOCOMO_DEVID_LED,
+	.probe	= collieled_probe,
+	.remove	= collieled_remove,
+};
+
+static int __init collieled_init(void) {
+	return locomo_driver_register(&collieled_driver);
+}
+
+device_initcall(collieled_init);
+
+MODULE_AUTHOR("John Lenz <jelenz@wisc.edu>, Chris Larson <kergoth@digitalnemesis.net>");
+MODULE_DESCRIPTION("LoCoMo Collie LED driver");
+MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c
--- a/arch/arm/mach-sa1100/leds.c
+++ b/arch/arm/mach-sa1100/leds.c
@@ -26,6 +26,8 @@ sa1100_leds_init(void)
 		leds_event = brutus_leds_event;
 	if (machine_is_cerf())
 		leds_event = cerf_leds_event;
+	if (machine_is_collie())
+		leds_event = collie_leds_event;
 	if (machine_is_flexanet())
 		leds_event = flexanet_leds_event;
 	if (machine_is_graphicsclient())
diff --git a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h
--- a/arch/arm/mach-sa1100/leds.h
+++ b/arch/arm/mach-sa1100/leds.h
@@ -3,6 +3,7 @@ extern void badge4_leds_event(led_event_
 extern void consus_leds_event(led_event_t evt);
 extern void brutus_leds_event(led_event_t evt);
 extern void cerf_leds_event(led_event_t evt);
+extern void collie_leds_event(led_event_t evt);
 extern void flexanet_leds_event(led_event_t evt);
 extern void graphicsclient_leds_event(led_event_t evt);
 extern void hackkit_leds_event(led_event_t evt);


-- 
Thanks, Sharp!

  reply	other threads:[~2005-11-07 23:31 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-01 23:44 best way to handle LEDs Pavel Machek
2005-11-02  0:39 ` Richard Purdie
2005-11-02  1:03   ` John Lenz
2005-11-02  8:01   ` Chase Venters
2005-11-02 13:56   ` Pavel Machek
2005-11-02 14:38     ` Richard Purdie
2005-11-02 21:11       ` Pavel Machek
2005-11-02 22:05         ` Richard Purdie
2005-11-02  1:57 ` root
2005-11-02 11:40   ` Geert Uytterhoeven
2005-11-02  2:47 ` Ben Dooks
2005-11-02  9:48   ` Alessandro Zummo
2005-11-02  9:51   ` Pavel Machek
2005-11-03  2:31     ` John Lenz
2005-11-07 23:30       ` Pavel Machek [this message]
2005-11-08  0:27         ` John Lenz
2005-11-08  9:28           ` Pavel Machek
2005-11-08 12:07             ` Richard Purdie
2005-11-08 13:14               ` Pavel Machek
2005-11-02 10:18 ` Paul Mundt
2005-11-02 20:26 ` Robert Schwebel
2005-11-02 21:13   ` Pavel Machek
2005-11-02 21:33     ` Robert Schwebel
2005-11-03  2:52       ` John Lenz
2005-11-03  6:21         ` Robert Schwebel
2005-11-03  8:15         ` Russell King
2005-11-03  9:57           ` Pavel Machek
2005-11-03 14:49             ` Russell King
2005-11-03 15:34               ` Vojtech Pavlik
2005-11-03 16:01                 ` Russell King
2005-11-03 16:11                   ` Vojtech Pavlik
2005-11-03 16:38                   ` linux-os (Dick Johnson)
2005-11-03 16:35               ` Pavel Machek
2005-11-04  0:41                 ` Stefan Smietanowski
2005-11-03 14:26           ` Rich Walker
2005-11-03  3:09       ` Rob Landley
2005-11-03  8:37     ` Geert Uytterhoeven
2005-11-03  9:59       ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051107233000.GC2034@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=ben@fluff.org.uk \
    --cc=lenz@cs.wisc.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=rpurdie@rpsys.net \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox