From: John Lenz <lenz@cs.wisc.edu>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.8.1 2/2] leds: new class for led devices
Date: Thu, 02 Sep 2004 20:38:28 +0000 [thread overview]
Message-ID: <1094157508l.4235l.4l@hydra> (raw)
In-Reply-To: <1094157190l.4235l.2l@hydra>
[-- Attachment #1: Type: text/plain, Size: 128 bytes --]
This is an example driver for the leds on the Sharp Zaurus using the
locomo bus.
Signed-off-by: John Lenz <lenz@cs.wisc.edu>
[-- Attachment #2: locomo_led.patch --]
[-- Type: text/x-patch, Size: 3301 bytes --]
#
# Patch managed by http://www.holgerschurig.de/patcher.html
#
--- /dev/null
+++ linux/drivers/leds/locomo.c
@@ -0,0 +1,112 @@
+/*
+ * linux/drivers/leds/locomo.c
+ *
+ * Copyright (C) 2004 John Lenz <lenz@cs.wisc.edu>
+ *
+ * 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.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/leds.h>
+
+#include <asm/hardware.h>
+#include <asm/hardware/locomo.h>
+
+struct locomoled_data {
+ unsigned long offset;
+ int registered;
+ struct led_properties props;
+};
+#define to_locomoled_data(d) container_of(d, struct locomoled_data, props)
+
+void locomoled_light(struct device *dev, struct led_properties *props)
+{
+ struct locomo_dev *locomo_dev = LOCOMO_DEV(dev);
+ struct locomoled_data *data = to_locomoled_data(props);
+
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (props->light_state)
+ locomo_writel(LOCOMO_LPT_TOFH, locomo_dev->mapbase + data->offset);
+ else
+ locomo_writel(LOCOMO_LPT_TOFL, locomo_dev->mapbase + data->offset);
+ local_irq_restore(flags);
+}
+
+static struct locomoled_data leds[] = {
+ {
+ .offset = LOCOMO_LPT0,
+ .props = {
+ .owner = THIS_MODULE,
+ .color = "amber",
+ .light_state = 0,
+
+ .light = locomoled_light,
+
+ .function = leds_timer,
+ }
+ },
+ {
+ .offset = LOCOMO_LPT1,
+ .props = {
+ .owner = THIS_MODULE,
+ .color = "green",
+ .light_state = 0,
+
+ .light = locomoled_light,
+
+ .function = leds_idle,
+ }
+ },
+};
+
+static int locomoled_probe(struct locomo_dev *dev)
+{
+ int i, ret = 0;
+
+ for (i = 0; i < ARRAY_SIZE(leds); i++) {
+ ret = leds_device_register(&dev->dev, &leds[i].props);
+ leds[i].registered = 1;
+ if (unlikely(ret)) {
+ printk(KERN_WARNING "Unable to register locomo led %s\n", leds[i].props.color);
+ leds[i].registered = 0;
+ }
+ }
+
+ return ret;
+}
+
+static int locomoled_remove(struct locomo_dev *dev) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(leds); i++) {
+ if (leds[i].registered) {
+ leds_device_unregister(&leds[i].props);
+ }
+ }
+ return 0;
+}
+
+static struct locomo_driver locomoled_driver = {
+ .drv = {
+ .name = "locomoled"
+ },
+ .devid = LOCOMO_DEVID_LED,
+ .probe = locomoled_probe,
+ .remove = locomoled_remove,
+};
+
+static int __init locomoled_init(void) {
+ return locomo_driver_register(&locomoled_driver);
+}
+module_init(locomoled_init);
+
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
+MODULE_DESCRIPTION("Locomo LED driver");
+MODULE_LICENSE("GPL");
--- linux/drivers/leds/Kconfig~locomo_led
+++ linux/drivers/leds/Kconfig
@@ -15,4 +15,11 @@
This option enables support for the old leds_event interface used by
the arm port. This driver can not be compiled as a module.
+config LEDS_LOCOMO
+ tristate "LED Support for Locomo device"
+ depends CLASS_LEDS && SHARP_LOCOMO
+ help
+ This option enables support for the LEDs on Sharp Locomo.
+
+
endmenu
--- linux/drivers/leds/Makefile~locomo_led
+++ linux/drivers/leds/Makefile
@@ -1,3 +1,6 @@
# Core functionality.
obj-$(CONFIG_CLASS_LEDS) += ledscore.o
+
+# drivers
+obj-$(CONFIG_LEDS_LOCOMO) += locomo.o
next prev parent reply other threads:[~2004-09-02 20:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-02 20:33 [PATCH 2.6.8.1 0/2] leds: new class for led devices John Lenz
2004-09-02 20:34 ` [PATCH 2.6.8.1 1/2] " John Lenz
2004-09-02 20:38 ` John Lenz [this message]
2004-09-03 4:54 ` [PATCH 2.6.8.1 0/2] " Kalin KOZHUHAROV
2004-09-03 11:32 ` Geert Uytterhoeven
2004-09-03 12:06 ` Jan-Benedict Glaw
2004-09-03 18:47 ` John Lenz
2004-09-03 22:25 ` Russell King
2004-09-03 23:19 ` John Lenz
2004-09-04 11:12 ` Pavel Machek
2004-09-04 20:53 ` Russell King
2004-09-04 21:41 ` Pavel Machek
2004-09-06 7:36 ` John Lenz
2004-09-03 13:17 ` Robert Schwebel
2004-09-03 13:31 ` Robert Schwebel
2004-09-03 8:00 ` Oliver Neukum
2004-09-03 13:51 ` Pavel Machek
2004-09-03 18:38 ` John Lenz
2004-09-03 18:55 ` Russell King
2004-09-03 19:09 ` John Lenz
2004-09-03 19:51 ` Russell King
2004-09-03 20:35 ` John Lenz
2004-09-04 11:09 ` 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=1094157508l.4235l.4l@hydra \
--to=lenz@cs.wisc.edu \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.