1 --- a/drivers/leds/Kconfig
2 +++ b/drivers/leds/Kconfig
4 outputs. To be useful the particular board must have LEDs
5 and they must be connected to the GPIO lines.
8 + tristate "LED Support for Memory Latched LEDs"
9 + depends on LEDS_CLASS
14 tristate "LED Support for the CM-X270 LEDs"
15 depends on LEDS_CLASS && MACH_ARMCORE
17 +++ b/drivers/leds/leds-latch.c
20 + * LEDs driver for Memory Latched Devices
22 + * Copyright (C) 2008 Gateworks Corp.
23 + * Chris Lang <clang@gateworks.com>
25 + * This program is free software; you can redistribute it and/or modify
26 + * it under the terms of the GNU General Public License version 2 as
27 + * published by the Free Software Foundation.
30 +#include <linux/kernel.h>
31 +#include <linux/init.h>
32 +#include <linux/platform_device.h>
33 +#include <linux/leds.h>
34 +#include <linux/workqueue.h>
36 +#include <linux/spinlock.h>
38 +static unsigned int mem_keep = 0xFF;
39 +static spinlock_t mem_lock;
40 +static unsigned char *iobase;
42 +struct latch_led_data {
43 + struct led_classdev cdev;
44 + struct work_struct work;
49 +static void latch_led_set(struct led_classdev *led_cdev,
50 + enum led_brightness value)
52 + struct latch_led_data *led_dat =
53 + container_of(led_cdev, struct latch_led_data, cdev);
55 + spin_lock(mem_lock);
57 + if (value == LED_OFF)
58 + mem_keep |= (0x1 << led_dat->bit);
60 + mem_keep &= ~(0x1 << led_dat->bit);
62 + writeb(mem_keep, iobase);
64 + spin_unlock(mem_lock);
67 +static int latch_led_probe(struct platform_device *pdev)
69 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
70 + struct latch_led *cur_led;
71 + struct latch_led_data *leds_data, *led_dat;
77 + leds_data = kzalloc(sizeof(struct latch_led_data) * pdata->num_leds,
82 + iobase = ioremap_nocache(pdata->mem, 0x1000);
83 + writeb(0xFF, iobase);
85 + for (i = 0; i < pdata->num_leds; i++) {
86 + cur_led = &pdata->leds[i];
87 + led_dat = &leds_data[i];
89 + led_dat->cdev.name = cur_led->name;
90 + led_dat->cdev.default_trigger = cur_led->default_trigger;
91 + led_dat->cdev.brightness_set = latch_led_set;
92 + led_dat->cdev.brightness = LED_OFF;
93 + led_dat->bit = cur_led->bit;
95 + ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
101 + platform_set_drvdata(pdev, leds_data);
107 + for (i = i - 1; i >= 0; i--) {
108 + led_classdev_unregister(&leds_data[i].cdev);
117 +static int __devexit latch_led_remove(struct platform_device *pdev)
120 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
121 + struct latch_led_data *leds_data;
123 + leds_data = platform_get_drvdata(pdev);
125 + for (i = 0; i < pdata->num_leds; i++) {
126 + led_classdev_unregister(&leds_data[i].cdev);
127 + cancel_work_sync(&leds_data[i].work);
135 +static struct platform_driver latch_led_driver = {
136 + .probe = latch_led_probe,
137 + .remove = __devexit_p(latch_led_remove),
139 + .name = "leds-latch",
140 + .owner = THIS_MODULE,
144 +static int __init latch_led_init(void)
146 + return platform_driver_register(&latch_led_driver);
149 +static void __exit latch_led_exit(void)
151 + platform_driver_unregister(&latch_led_driver);
154 +module_init(latch_led_init);
155 +module_exit(latch_led_exit);
157 +MODULE_AUTHOR("Chris Lang <clang@gateworks.com>");
158 +MODULE_DESCRIPTION("Latch LED driver");
159 +MODULE_LICENSE("GPL");
160 --- a/drivers/leds/Makefile
161 +++ b/drivers/leds/Makefile
163 obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o
164 obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
165 obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
166 +obj-$(CONFIG_LEDS_LATCH) += leds-latch.o
167 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
168 obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
169 obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
170 --- a/include/linux/leds.h
171 +++ b/include/linux/leds.h
173 unsigned long *delay_off);
176 +/* For the leds-latch driver */
179 + char *default_trigger;
183 +struct latch_led_platform_data {
186 + struct latch_led *leds;
190 #endif /* __LINUX_LEDS_H_INCLUDED */