From 9e84561c8c8671d9e58d1893cc524a71b20c9183 Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Mon, 13 Oct 2008 09:06:10 +0100 Subject: leds: da903x: Add support for LEDs found on DA9030/DA9034 Signed-off-by: Mike Rapoport Signed-off-by: Eric Miao Signed-off-by: Richard Purdie --- drivers/leds/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/leds/Makefile') diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index eb186c351a1..e8714ad3fff 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o obj-$(CONFIG_LEDS_FSG) += leds-fsg.o obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o +obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o # LED Triggers obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o -- cgit v1.2.3-70-g09d2 From 132e9306beedd049bc5de037f1996731a2ca3eed Mon Sep 17 00:00:00 2001 From: Rodolfo Giometti Date: Mon, 13 Oct 2008 09:25:24 +0100 Subject: leds: Add backlight LED trigger This allows LEDs to be controlled as a backlight device where they turn off and on when the display is blanked and unblanked. This is useful where you need various key backlight LEDs to dim at the same time as the backlight. Signed-off-by: Rodolfo Giometti Signed-off-by: Richard Purdie --- drivers/leds/Kconfig | 9 ++++ drivers/leds/Makefile | 1 + drivers/leds/ledtrig-backlight.c | 110 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 drivers/leds/ledtrig-backlight.c (limited to 'drivers/leds/Makefile') diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 14bb57b1659..2a72ce5c6d1 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -200,6 +200,15 @@ config LEDS_TRIGGER_HEARTBEAT load average. If unsure, say Y. +config LEDS_TRIGGER_BACKLIGHT + tristate "LED backlight Trigger" + depends on LEDS_TRIGGERS + help + This allows LEDs to be controlled as a backlight device: they + turn off and on when the display is blanked and unblanked. + + If unsure, say N. + config LEDS_TRIGGER_DEFAULT_ON tristate "LED Default ON Trigger" depends on LEDS_TRIGGERS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index e8714ad3fff..07d937f4651 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -28,4 +28,5 @@ obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o +obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c new file mode 100644 index 00000000000..d3dfcfb417b --- /dev/null +++ b/drivers/leds/ledtrig-backlight.c @@ -0,0 +1,110 @@ +/* + * Backlight emulation LED trigger + * + * Copyright 2008 (C) Rodolfo Giometti + * Copyright 2008 (C) Eurotech S.p.A. + * + * 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 +#include +#include +#include +#include +#include "leds.h" + +#define BLANK 1 +#define UNBLANK 0 + +struct bl_trig_notifier { + struct led_classdev *led; + int brightness; + int old_status; + struct notifier_block notifier; +}; + +static int fb_notifier_callback(struct notifier_block *p, + unsigned long event, void *data) +{ + struct bl_trig_notifier *n = container_of(p, + struct bl_trig_notifier, notifier); + struct led_classdev *led = n->led; + struct fb_event *fb_event = data; + int *blank = fb_event->data; + + switch (event) { + case FB_EVENT_BLANK : + if (*blank && n->old_status == UNBLANK) { + n->brightness = led->brightness; + led_set_brightness(led, LED_OFF); + n->old_status = BLANK; + } else if (!*blank && n->old_status == BLANK) { + led_set_brightness(led, n->brightness); + n->old_status = UNBLANK; + } + break; + } + + return 0; +} + +static void bl_trig_activate(struct led_classdev *led) +{ + int ret; + + struct bl_trig_notifier *n; + + n = kzalloc(sizeof(struct bl_trig_notifier), GFP_KERNEL); + led->trigger_data = n; + if (!n) { + dev_err(led->dev, "unable to allocate backlight trigger\n"); + return; + } + + n->led = led; + n->brightness = led->brightness; + n->old_status = UNBLANK; + n->notifier.notifier_call = fb_notifier_callback; + + ret = fb_register_client(&n->notifier); + if (ret) + dev_err(led->dev, "unable to register backlight trigger\n"); +} + +static void bl_trig_deactivate(struct led_classdev *led) +{ + struct bl_trig_notifier *n = + (struct bl_trig_notifier *) led->trigger_data; + + if (n) { + fb_unregister_client(&n->notifier); + kfree(n); + } +} + +static struct led_trigger bl_led_trigger = { + .name = "backlight", + .activate = bl_trig_activate, + .deactivate = bl_trig_deactivate +}; + +static int __init bl_trig_init(void) +{ + return led_trigger_register(&bl_led_trigger); +} + +static void __exit bl_trig_exit(void) +{ + led_trigger_unregister(&bl_led_trigger); +} + +module_init(bl_trig_init); +module_exit(bl_trig_exit); + +MODULE_AUTHOR("Rodolfo Giometti "); +MODULE_DESCRIPTION("Backlight emulation LED trigger"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3-70-g09d2 From 85b064b66400abf626b0e9754118c2a8a212c19b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 20 Oct 2008 22:55:00 +0100 Subject: leds: Remove uneeded leds-cm-x270 driver The cm-x270 board uses leds-gpio so remove the now unneeded driver. Acked-by: Mike Rapoport Signed-off-by: Richard Purdie --- drivers/leds/Kconfig | 6 --- drivers/leds/Makefile | 1 - drivers/leds/leds-cm-x270.c | 124 -------------------------------------------- 3 files changed, 131 deletions(-) delete mode 100644 drivers/leds/leds-cm-x270.c (limited to 'drivers/leds/Makefile') diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 2a72ce5c6d1..a4f7a3ab3b2 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -113,12 +113,6 @@ config LEDS_GPIO outputs. To be useful the particular board must have LEDs and they must be connected to the GPIO lines. -config LEDS_CM_X270 - tristate "LED Support for the CM-X270 LEDs" - depends on LEDS_CLASS && MACH_ARMCORE - help - This option enables support for the CM-X270 LEDs. - config LEDS_CLEVO_MAIL tristate "Mail LED on Clevo notebook (EXPERIMENTAL)" depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 07d937f4651..64e21e44980 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -17,7 +17,6 @@ obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o -obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o obj-$(CONFIG_LEDS_FSG) += leds-fsg.o diff --git a/drivers/leds/leds-cm-x270.c b/drivers/leds/leds-cm-x270.c deleted file mode 100644 index 836a43d776e..00000000000 --- a/drivers/leds/leds-cm-x270.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * drivers/leds/leds-cm-x270.c - * - * Copyright 2007 CompuLab Ltd. - * Author: Mike Rapoport - * - * Based on leds-corgi.c - * Author: Richard Purdie - * - * 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 -#include -#include -#include - -#include -#include - -#define GPIO_RED_LED (93) -#define GPIO_GREEN_LED (94) - -static void cmx270_red_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - if (value) - GPCR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED); - else - GPSR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED); -} - -static void cmx270_green_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - if (value) - GPCR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED); - else - GPSR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED); -} - -static struct led_classdev cmx270_red_led = { - .name = "cm-x270:red", - .default_trigger = "nand-disk", - .brightness_set = cmx270_red_set, -}; - -static struct led_classdev cmx270_green_led = { - .name = "cm-x270:green", - .default_trigger = "heartbeat", - .brightness_set = cmx270_green_set, -}; - -#ifdef CONFIG_PM -static int cmx270led_suspend(struct platform_device *dev, pm_message_t state) -{ - led_classdev_suspend(&cmx270_red_led); - led_classdev_suspend(&cmx270_green_led); - return 0; -} - -static int cmx270led_resume(struct platform_device *dev) -{ - led_classdev_resume(&cmx270_red_led); - led_classdev_resume(&cmx270_green_led); - return 0; -} -#endif - -static int cmx270led_probe(struct platform_device *pdev) -{ - int ret; - - ret = led_classdev_register(&pdev->dev, &cmx270_red_led); - if (ret < 0) - return ret; - - ret = led_classdev_register(&pdev->dev, &cmx270_green_led); - if (ret < 0) - led_classdev_unregister(&cmx270_red_led); - - return ret; -} - -static int cmx270led_remove(struct platform_device *pdev) -{ - led_classdev_unregister(&cmx270_red_led); - led_classdev_unregister(&cmx270_green_led); - return 0; -} - -static struct platform_driver cmx270led_driver = { - .probe = cmx270led_probe, - .remove = cmx270led_remove, -#ifdef CONFIG_PM - .suspend = cmx270led_suspend, - .resume = cmx270led_resume, -#endif - .driver = { - .name = "cm-x270-led", - .owner = THIS_MODULE, - }, -}; - -static int __init cmx270led_init(void) -{ - return platform_driver_register(&cmx270led_driver); -} - -static void __exit cmx270led_exit(void) -{ - platform_driver_unregister(&cmx270led_driver); -} - -module_init(cmx270led_init); -module_exit(cmx270led_exit); - -MODULE_AUTHOR("Mike Rapoport "); -MODULE_DESCRIPTION("CM-x270 LED driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:cm-x270-led"); -- cgit v1.2.3-70-g09d2 From 9c78ff6e65cad9f9fcf0bbde2bfbbf3a544fb704 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 20 Oct 2008 23:02:43 +0100 Subject: leds: Add driver for HP harddisk protection LEDs HP notebooks contain accelerometer-based disk protection subsystem, and LED that indicates hard disk is protected. This is driver for the LED part. Signed-off-by: Pavel Machek Signed-off-by: Richard Purdie --- drivers/leds/Kconfig | 7 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-hp-disk.c | 156 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 drivers/leds/leds-hp-disk.c (limited to 'drivers/leds/Makefile') diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a4f7a3ab3b2..33ff1cbeebd 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -113,6 +113,13 @@ config LEDS_GPIO outputs. To be useful the particular board must have LEDs and they must be connected to the GPIO lines. +config LEDS_HP_DISK + tristate "LED Support for disk protection LED on HP notebooks" + depends on LEDS_CLASS && ACPI + help + This option enable support for disk protection LED, found on + newer HP notebooks. + config LEDS_CLEVO_MAIL tristate "Mail LED on Clevo notebook (EXPERIMENTAL)" depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 64e21e44980..e1967a29850 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o obj-$(CONFIG_LEDS_FSG) += leds-fsg.o obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o +obj-$(CONFIG_LEDS_HP_DISK) += leds-hp-disk.o # LED Triggers obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o diff --git a/drivers/leds/leds-hp-disk.c b/drivers/leds/leds-hp-disk.c new file mode 100644 index 00000000000..d636280198a --- /dev/null +++ b/drivers/leds/leds-hp-disk.c @@ -0,0 +1,156 @@ +/* + * leds-hp-disk.c - driver for HP "hard disk protection" LED + * + * Copyright (C) 2008 Pavel Machek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "leds-hp-disk" +#define ACPI_MDPS_CLASS "led" + +/* For automatic insertion of the module */ +static struct acpi_device_id hpled_device_ids[] = { + {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */ + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, hpled_device_ids); + +struct acpi_hpled { + struct acpi_device *device; /* The ACPI device */ +}; + +static struct acpi_hpled adev; + +static acpi_status hpled_acpi_write(acpi_handle handle, int reg) +{ + unsigned long ret; /* Not used when writing */ + union acpi_object in_obj[1]; + struct acpi_object_list args = { 1, in_obj }; + + in_obj[0].type = ACPI_TYPE_INTEGER; + in_obj[0].integer.value = reg; + + return acpi_evaluate_integer(handle, "ALED", &args, &ret); +} + +static void hpled_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + hpled_acpi_write(adev.device->handle, !!value); +} + +static struct led_classdev hpled_led = { + .name = "hp:red:hddprotection", + .default_trigger = "heartbeat", + .brightness_set = hpled_set, +}; + +#ifdef CONFIG_PM +static int hpled_suspend(struct acpi_device *dev, pm_message_t state) +{ + led_classdev_suspend(&hpled_led); + return 0; +} + +static int hpled_resume(struct acpi_device *dev) +{ + led_classdev_resume(&hpled_led); + return 0; +} +#else +#define hpled_suspend NULL +#define hpled_resume NULL +#endif + +static int hpled_add(struct acpi_device *device) +{ + int ret; + + if (!device) + return -EINVAL; + + adev.device = device; + strcpy(acpi_device_name(device), DRIVER_NAME); + strcpy(acpi_device_class(device), ACPI_MDPS_CLASS); + acpi_driver_data(device) = &adev; + + ret = led_classdev_register(NULL, &hpled_led); + return ret; +} + +static int hpled_remove(struct acpi_device *device, int type) +{ + if (!device) + return -EINVAL; + + led_classdev_unregister(&hpled_led); + return 0; +} + + + +static struct acpi_driver leds_hp_driver = { + .name = DRIVER_NAME, + .class = ACPI_MDPS_CLASS, + .ids = hpled_device_ids, + .ops = { + .add = hpled_add, + .remove = hpled_remove, + .suspend = hpled_suspend, + .resume = hpled_resume, + } +}; + +static int __init hpled_init_module(void) +{ + int ret; + + if (acpi_disabled) + return -ENODEV; + + ret = acpi_bus_register_driver(&leds_hp_driver); + if (ret < 0) + return ret; + + printk(KERN_INFO DRIVER_NAME " driver loaded.\n"); + + return 0; +} + +static void __exit hpled_exit_module(void) +{ + acpi_bus_unregister_driver(&leds_hp_driver); +} + +MODULE_DESCRIPTION("Driver for HP disk protection LED"); +MODULE_AUTHOR("Pavel Machek "); +MODULE_LICENSE("GPL"); + +module_init(hpled_init_module); +module_exit(hpled_exit_module); -- cgit v1.2.3-70-g09d2