[PATCH] LED: add LED device support for the zaurus corgi and spitz models
authorRichard Purdie <rpurdie@rpsys.net>
Fri, 31 Mar 2006 10:31:09 +0000 (02:31 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 31 Mar 2006 20:18:57 +0000 (12:18 -0800)
Adds LED drivers for LEDs found on the Sharp Zaurus c7x0 (corgi, shepherd,
husky) and cxx00 (akita, spitz, borzoi) models.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/arm/mach-pxa/corgi.c
arch/arm/mach-pxa/spitz.c
drivers/leds/Kconfig
drivers/leds/Makefile
drivers/leds/leds-corgi.c [new file with mode: 0644]
drivers/leds/leds-spitz.c [new file with mode: 0644]

index 68923b1d2b62b1f1a2490a90d3033c45c2f1d269..99604a544629dfa75907bb4ddba00ad330d1b3b2 100644 (file)
@@ -163,6 +163,14 @@ static struct platform_device corgikbd_device = {
 };
 
 
+/*
+ * Corgi LEDs
+ */
+static struct platform_device corgiled_device = {
+       .name           = "corgi-led",
+       .id             = -1,
+};
+
 /*
  * Corgi Touch Screen Device
  */
@@ -297,6 +305,7 @@ static struct platform_device *devices[] __initdata = {
        &corgikbd_device,
        &corgibl_device,
        &corgits_device,
+       &corgiled_device,
 };
 
 static void __init corgi_init(void)
index 0dbb079ecd251fef8d580db87cc1031614dd6378..ebe4730533920d9ba3ac570aeb8221067ec8d7ec 100644 (file)
@@ -241,6 +241,14 @@ static struct platform_device spitzkbd_device = {
 };
 
 
+/*
+ * Spitz LEDs
+ */
+static struct platform_device spitzled_device = {
+       .name           = "spitz-led",
+       .id             = -1,
+};
+
 /*
  * Spitz Touch Screen Device
  */
@@ -418,6 +426,7 @@ static struct platform_device *devices[] __initdata = {
        &spitzkbd_device,
        &spitzts_device,
        &spitzbl_device,
+       &spitzled_device,
 };
 
 static void __init common_init(void)
index fda44df5921feda586c71264ce74e9139449980b..f7846b40c842a98907d5b10b538ffa0554e536e7 100644 (file)
@@ -22,6 +22,20 @@ config LEDS_TRIGGERS
          These triggers allow kernel events to drive the LEDs and can
          be configured via sysfs. If unsure, say Y.
 
+config LEDS_CORGI
+       tristate "LED Support for the Sharp SL-C7x0 series"
+       depends LEDS_CLASS && PXA_SHARP_C7xx
+       help
+         This option enables support for the LEDs on Sharp Zaurus
+         SL-C7x0 series (C700, C750, C760, C860).
+
+config LEDS_SPITZ
+       tristate "LED Support for the Sharp SL-Cxx00 series"
+       depends LEDS_CLASS && PXA_SHARP_Cxx00
+       help
+         This option enables support for the LEDs on Sharp Zaurus
+         SL-Cxx00 series (C1000, C3000, C3100).
+
 config LEDS_TRIGGER_TIMER
        tristate "LED Timer Trigger"
        depends LEDS_TRIGGERS
index 81e4abb9dcb0b27bc03e2b8dc8c36c37e78ef5ee..cb5d0ada6a8c072f7cdd4609953d0308713a239f 100644 (file)
@@ -4,5 +4,9 @@ obj-$(CONFIG_NEW_LEDS)                  += led-core.o
 obj-$(CONFIG_LEDS_CLASS)               += led-class.o
 obj-$(CONFIG_LEDS_TRIGGERS)            += led-triggers.o
 
+# LED Platform Drivers
+obj-$(CONFIG_LEDS_CORGI)               += leds-corgi.o
+obj-$(CONFIG_LEDS_SPITZ)               += leds-spitz.o
+
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)       += ledtrig-timer.o
diff --git a/drivers/leds/leds-corgi.c b/drivers/leds/leds-corgi.c
new file mode 100644 (file)
index 0000000..bb7d84d
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * LED Triggers Core
+ *
+ * Copyright 2005-2006 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <rpurdie@openedhand.com>
+ *
+ * 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/platform_device.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/arch/corgi.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/hardware/scoop.h>
+
+static void corgiled_amber_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+       if (value)
+               GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+       else
+               GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
+}
+
+static void corgiled_green_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+       if (value)
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
+}
+
+static struct led_classdev corgi_amber_led = {
+       .name                   = "corgi:amber",
+       .default_trigger        = "sharpsl-charge",
+       .brightness_set         = corgiled_amber_set,
+};
+
+static struct led_classdev corgi_green_led = {
+       .name                   = "corgi:green",
+       .default_trigger        = "nand-disk",
+       .brightness_set         = corgiled_green_set,
+};
+
+#ifdef CONFIG_PM
+static int corgiled_suspend(struct platform_device *dev, pm_message_t state)
+{
+#ifdef CONFIG_LEDS_TRIGGERS
+       if (corgi_amber_led.trigger && strcmp(corgi_amber_led.trigger->name, "sharpsl-charge"))
+#endif
+               led_classdev_suspend(&corgi_amber_led);
+       led_classdev_suspend(&corgi_green_led);
+       return 0;
+}
+
+static int corgiled_resume(struct platform_device *dev)
+{
+       led_classdev_resume(&corgi_amber_led);
+       led_classdev_resume(&corgi_green_led);
+       return 0;
+}
+#endif
+
+static int corgiled_probe(struct platform_device *pdev)
+{
+       int ret;
+
+       ret = led_classdev_register(&pdev->dev, &corgi_amber_led);
+       if (ret < 0)
+               return ret;
+
+       ret = led_classdev_register(&pdev->dev, &corgi_green_led);
+       if (ret < 0)
+               led_classdev_unregister(&corgi_amber_led);
+
+       return ret;
+}
+
+static int corgiled_remove(struct platform_device *pdev)
+{
+       led_classdev_unregister(&corgi_amber_led);
+       led_classdev_unregister(&corgi_green_led);
+       return 0;
+}
+
+static struct platform_driver corgiled_driver = {
+       .probe          = corgiled_probe,
+       .remove         = corgiled_remove,
+#ifdef CONFIG_PM
+       .suspend        = corgiled_suspend,
+       .resume         = corgiled_resume,
+#endif
+       .driver         = {
+               .name           = "corgi-led",
+       },
+};
+
+static int __init corgiled_init(void)
+{
+       return platform_driver_register(&corgiled_driver);
+}
+
+static void __exit corgiled_exit(void)
+{
+       platform_driver_unregister(&corgiled_driver);
+}
+
+module_init(corgiled_init);
+module_exit(corgiled_exit);
+
+MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
+MODULE_DESCRIPTION("Corgi LED driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-spitz.c b/drivers/leds/leds-spitz.c
new file mode 100644 (file)
index 0000000..65bbef4
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * LED Triggers Core
+ *
+ * Copyright 2005-2006 Openedhand Ltd.
+ *
+ * Author: Richard Purdie <rpurdie@openedhand.com>
+ *
+ * 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/platform_device.h>
+#include <linux/leds.h>
+#include <asm/hardware/scoop.h>
+#include <asm/mach-types.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/spitz.h>
+
+static void spitzled_amber_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+       if (value)
+               set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
+       else
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
+}
+
+static void spitzled_green_set(struct led_classdev *led_cdev, enum led_brightness value)
+{
+       if (value)
+               set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
+       else
+               reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
+}
+
+static struct led_classdev spitz_amber_led = {
+       .name                   = "spitz:amber",
+       .default_trigger        = "sharpsl-charge",
+       .brightness_set         = spitzled_amber_set,
+};
+
+static struct led_classdev spitz_green_led = {
+       .name                   = "spitz:green",
+       .default_trigger        = "ide-disk",
+       .brightness_set         = spitzled_green_set,
+};
+
+#ifdef CONFIG_PM
+static int spitzled_suspend(struct platform_device *dev, pm_message_t state)
+{
+#ifdef CONFIG_LEDS_TRIGGERS
+       if (spitz_amber_led.trigger && strcmp(spitz_amber_led.trigger->name, "sharpsl-charge"))
+#endif
+               led_classdev_suspend(&spitz_amber_led);
+       led_classdev_suspend(&spitz_green_led);
+       return 0;
+}
+
+static int spitzled_resume(struct platform_device *dev)
+{
+       led_classdev_resume(&spitz_amber_led);
+       led_classdev_resume(&spitz_green_led);
+       return 0;
+}
+#endif
+
+static int spitzled_probe(struct platform_device *pdev)
+{
+       int ret;
+
+       if (machine_is_akita())
+               spitz_green_led.default_trigger = "nand-disk";
+
+       ret = led_classdev_register(&pdev->dev, &spitz_amber_led);
+       if (ret < 0)
+               return ret;
+
+       ret = led_classdev_register(&pdev->dev, &spitz_green_led);
+       if (ret < 0)
+               led_classdev_unregister(&spitz_amber_led);
+
+       return ret;
+}
+
+static int spitzled_remove(struct platform_device *pdev)
+{
+       led_classdev_unregister(&spitz_amber_led);
+       led_classdev_unregister(&spitz_green_led);
+
+       return 0;
+}
+
+static struct platform_driver spitzled_driver = {
+       .probe          = spitzled_probe,
+       .remove         = spitzled_remove,
+#ifdef CONFIG_PM
+       .suspend        = spitzled_suspend,
+       .resume         = spitzled_resume,
+#endif
+       .driver         = {
+               .name           = "spitz-led",
+       },
+};
+
+static int __init spitzled_init(void)
+{
+       return platform_driver_register(&spitzled_driver);
+}
+
+static void __exit spitzled_exit(void)
+{
+       platform_driver_unregister(&spitzled_driver);
+}
+
+module_init(spitzled_init);
+module_exit(spitzled_exit);
+
+MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
+MODULE_DESCRIPTION("Spitz LED driver");
+MODULE_LICENSE("GPL");