Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 26 Feb 2007 19:45:50 +0000 (11:45 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 26 Feb 2007 19:45:50 +0000 (11:45 -0800)
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds:
  leds: Add support for Cobalt Server front LED
  leds: Add IPAQ h1940 LEDs support

drivers/leds/Kconfig
drivers/leds/Makefile
drivers/leds/leds-cobalt.c [new file with mode: 0644]
drivers/leds/leds-h1940.c [new file with mode: 0644]

index 7399ba791116d882ecceae66fa7e9535cfea1404..80acd08f0e97bd3b9cf940e5a25ccb2d31fce312 100644 (file)
@@ -82,6 +82,18 @@ config LEDS_WRAP
        help
          This option enables support for the PCEngines WRAP programmable LEDs.
 
+config LEDS_H1940
+       tristate "LED Support for iPAQ H1940 device"
+       depends LEDS_CLASS && ARCH_H1940
+       help
+         This option enables support for the LEDs on the h1940.
+
+config LEDS_COBALT
+       tristate "LED Support for Cobalt Server front LED"
+       depends on LEDS_CLASS && MIPS_COBALT
+       help
+         This option enables support for the front LED on Cobalt Server
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
index 500de3dc962adedcb2576e543754f6d54d439988..aa2c18efa5b2f150dffbfbf81a96669bb9d4fb45 100644 (file)
@@ -14,6 +14,8 @@ obj-$(CONFIG_LEDS_S3C24XX)            += leds-s3c24xx.o
 obj-$(CONFIG_LEDS_AMS_DELTA)           += leds-ams-delta.o
 obj-$(CONFIG_LEDS_NET48XX)             += leds-net48xx.o
 obj-$(CONFIG_LEDS_WRAP)                        += leds-wrap.o
+obj-$(CONFIG_LEDS_H1940)               += leds-h1940.o
+obj-$(CONFIG_LEDS_COBALT)              += leds-cobalt.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)       += ledtrig-timer.o
diff --git a/drivers/leds/leds-cobalt.c b/drivers/leds/leds-cobalt.c
new file mode 100644 (file)
index 0000000..d16439c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
+ *
+ * Control the Cobalt Qube/RaQ front LED
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/leds.h>
+#include <asm/mach-cobalt/cobalt.h>
+
+static void cobalt_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
+{
+       if (brightness)
+               COBALT_LED_PORT = COBALT_LED_BAR_LEFT | COBALT_LED_BAR_RIGHT;
+       else
+               COBALT_LED_PORT = 0;
+}
+
+static struct led_classdev cobalt_led = {
+       .name = "cobalt-front-led",
+       .brightness_set = cobalt_led_set,
+       .default_trigger = "ide-disk",
+};
+
+static int __init cobalt_led_init(void)
+{
+       return led_classdev_register(NULL, &cobalt_led);
+}
+
+static void __exit cobalt_led_exit(void)
+{
+       led_classdev_unregister(&cobalt_led);
+}
+
+module_init(cobalt_led_init);
+module_exit(cobalt_led_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Front LED support for Cobalt Server");
+MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c
new file mode 100644 (file)
index 0000000..1d49d2a
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * drivers/leds/h1940-leds.c
+ * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * 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.
+ *
+ * H1940 leds driver
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/leds.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/hardware.h>
+#include <asm/arch/h1940-latch.h>
+
+/*
+ * Green led.
+ */
+void h1940_greenled_set(struct led_classdev *led_dev, enum led_brightness value)
+{
+       switch (value) {
+               case LED_HALF:
+                       h1940_latch_control(0,H1940_LATCH_LED_FLASH);
+                       s3c2410_gpio_setpin(S3C2410_GPA7,1);
+                       break;
+               case LED_FULL:
+                       h1940_latch_control(0,H1940_LATCH_LED_GREEN);
+                       s3c2410_gpio_setpin(S3C2410_GPA7,1);
+                       break;
+               default:
+               case LED_OFF:
+                       h1940_latch_control(H1940_LATCH_LED_FLASH,0);
+                       h1940_latch_control(H1940_LATCH_LED_GREEN,0);
+                       s3c2410_gpio_setpin(S3C2410_GPA7,0);
+                       break;
+       }
+}
+
+static struct led_classdev h1940_greenled = {
+       .name                   = "h1940:green",
+       .brightness_set         = h1940_greenled_set,
+       .default_trigger        = "h1940-charger",
+};
+
+/*
+ * Red led.
+ */
+void h1940_redled_set(struct led_classdev *led_dev, enum led_brightness value)
+{
+       switch (value) {
+               case LED_HALF:
+                       h1940_latch_control(0,H1940_LATCH_LED_FLASH);
+                       s3c2410_gpio_setpin(S3C2410_GPA1,1);
+                       break;
+               case LED_FULL:
+                       h1940_latch_control(0,H1940_LATCH_LED_RED);
+                       s3c2410_gpio_setpin(S3C2410_GPA1,1);
+                       break;
+               default:
+               case LED_OFF:
+                       h1940_latch_control(H1940_LATCH_LED_FLASH,0);
+                       h1940_latch_control(H1940_LATCH_LED_RED,0);
+                       s3c2410_gpio_setpin(S3C2410_GPA1,0);
+                       break;
+       }
+}
+
+static struct led_classdev h1940_redled = {
+       .name                   = "h1940:red",
+       .brightness_set         = h1940_redled_set,
+       .default_trigger        = "h1940-charger",
+};
+
+/*
+ * Blue led.
+ * (it can only be blue flashing led)
+ */
+void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value)
+{
+       if (value) {
+               /* flashing Blue */
+               h1940_latch_control(0,H1940_LATCH_LED_FLASH);
+               s3c2410_gpio_setpin(S3C2410_GPA3,1);
+       } else {
+               h1940_latch_control(H1940_LATCH_LED_FLASH,0);
+               s3c2410_gpio_setpin(S3C2410_GPA3,0);
+       }
+
+}
+
+static struct led_classdev h1940_blueled = {
+       .name                   = "h1940:blue",
+       .brightness_set         = h1940_blueled_set,
+       .default_trigger        = "h1940-bluetooth",
+};
+
+static int __init h1940leds_probe(struct platform_device *pdev)
+{
+       int ret;
+
+       ret = led_classdev_register(&pdev->dev, &h1940_greenled);
+       if (ret)
+               goto err_green;
+
+       ret = led_classdev_register(&pdev->dev, &h1940_redled);
+       if (ret)
+               goto err_red;
+
+       ret = led_classdev_register(&pdev->dev, &h1940_blueled);
+       if (ret)
+               goto err_blue;
+
+       return 0;
+
+err_blue:
+       led_classdev_unregister(&h1940_redled);
+err_red:
+       led_classdev_unregister(&h1940_greenled);
+err_green:
+       return ret;
+}
+
+static int h1940leds_remove(struct platform_device *pdev)
+{
+       led_classdev_unregister(&h1940_greenled);
+       led_classdev_unregister(&h1940_redled);
+       led_classdev_unregister(&h1940_blueled);
+       return 0;
+}
+
+
+static struct platform_driver h1940leds_driver = {
+       .driver         = {
+               .name   = "h1940-leds",
+       },
+       .probe          = h1940leds_probe,
+       .remove         = h1940leds_remove,
+};
+
+
+static int __init h1940leds_init(void)
+{
+       return platform_driver_register(&h1940leds_driver);
+}
+
+static void __exit h1940leds_exit(void)
+{
+       platform_driver_unregister(&h1940leds_driver);
+}
+
+module_init(h1940leds_init);
+module_exit(h1940leds_exit);
+
+MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
+MODULE_DESCRIPTION("LED driver for the iPAQ H1940");
+MODULE_LICENSE("GPL");