1 diff -ruN clean/linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c
2 --- clean/linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c 2008-05-20 09:18:21.000000000 -0700
3 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c 2008-05-20 09:31:55.000000000 -0700
5 # include <linux/eeprom.h>
8 +#include <linux/leds.h>
9 #include <linux/i2c-gpio.h>
11 #include <asm/types.h>
13 .dev.platform_data = &avila_npec_data,
16 +static struct gpio_led avila_gpio_leds[] = {
18 + .name = "user", /* green led */
19 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
24 +static struct gpio_led_platform_data avila_gpio_leds_data = {
26 + .leds = avila_gpio_leds,
29 +static struct platform_device avila_gpio_leds_device = {
30 + .name = "leds-gpio",
32 + .dev.platform_data = &avila_gpio_leds_data,
35 +static struct latch_led avila_latch_leds[] = {
37 + .name = "led0", /* green led */
41 + .name = "led1", /* green led */
45 + .name = "led2", /* green led */
49 + .name = "led3", /* green led */
53 + .name = "led4", /* green led */
57 + .name = "led5", /* green led */
61 + .name = "led6", /* green led */
65 + .name = "led7", /* green led */
70 +static struct latch_led_platform_data avila_latch_leds_data = {
72 + .leds = avila_latch_leds,
76 +static struct platform_device avila_latch_leds_device = {
77 + .name = "leds-latch",
79 + .dev.platform_data = &avila_latch_leds_data,
82 static struct platform_device *avila_devices[] __initdata = {
87 platform_device_register(&avila_npeb_device);
88 platform_device_register(&avila_npec_device);
90 + platform_device_register(&avila_gpio_leds_device);
93 #ifdef CONFIG_SENSORS_EEPROM
96 platform_device_register(&avila_npeb_device);
97 platform_device_register(&avila_npec_device);
99 + platform_device_register(&avila_gpio_leds_device);
102 static void __init avila_gw2345_setup(void)
103 @@ -199,22 +270,30 @@
105 avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
106 platform_device_register(&avila_npec_device);
108 + platform_device_register(&avila_gpio_leds_device);
111 static void __init avila_gw2347_setup(void)
113 platform_device_register(&avila_npeb_device);
115 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
116 + platform_device_register(&avila_gpio_leds_device);
119 static void __init avila_gw2348_setup(void)
121 platform_device_register(&avila_npeb_device);
122 platform_device_register(&avila_npec_device);
124 + platform_device_register(&avila_gpio_leds_device);
127 static void __init avila_gw2353_setup(void)
129 platform_device_register(&avila_npeb_device);
130 + platform_device_register(&avila_gpio_leds_device);
133 static void __init avila_gw2355_setup(void)
134 @@ -225,11 +304,29 @@
136 avila_npec_data.phy = 16;
137 platform_device_register(&avila_npec_device);
139 + platform_device_register(&avila_gpio_leds_device);
141 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
142 + avila_latch_leds[0].name = "RXD";
143 + avila_latch_leds[1].name = "TXD";
144 + avila_latch_leds[2].name = "POL";
145 + avila_latch_leds[3].name = "LNK";
146 + avila_latch_leds[4].name = "ERR";
147 + avila_latch_leds_data.num_leds = 5;
148 + avila_latch_leds_data.mem = 0x54000000;
149 + platform_device_register(&avila_latch_leds_device);
152 static void __init avila_gw2357_setup(void)
154 platform_device_register(&avila_npeb_device);
156 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
157 + platform_device_register(&avila_gpio_leds_device);
159 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
160 + platform_device_register(&avila_latch_leds_device);
163 static struct avila_board_info avila_boards[] __initdata = {
164 diff -ruN clean/linux-2.6.25.4/drivers/leds/Kconfig linux-2.6.25.4/drivers/leds/Kconfig
165 --- clean/linux-2.6.25.4/drivers/leds/Kconfig 2008-05-15 08:00:12.000000000 -0700
166 +++ linux-2.6.25.4/drivers/leds/Kconfig 2008-05-20 09:25:15.000000000 -0700
168 outputs. To be useful the particular board must have LEDs
169 and they must be connected to the GPIO lines.
172 + tristate "LED Support for Memory Latched LEDs"
173 + depends on LEDS_CLASS
178 tristate "LED Support for the CM-X270 LEDs"
179 depends on LEDS_CLASS && MACH_ARMCORE
180 diff -ruN clean/linux-2.6.25.4/drivers/leds/leds-latch.c linux-2.6.25.4/drivers/leds/leds-latch.c
181 --- clean/linux-2.6.25.4/drivers/leds/leds-latch.c 1969-12-31 16:00:00.000000000 -0800
182 +++ linux-2.6.25.4/drivers/leds/leds-latch.c 2008-04-30 14:03:21.000000000 -0700
185 + * LEDs driver for Memory Latched Devices
187 + * Copyright (C) 2008 Gateworks Corp.
188 + * Chris Lang <clang@gateworks.com>
190 + * This program is free software; you can redistribute it and/or modify
191 + * it under the terms of the GNU General Public License version 2 as
192 + * published by the Free Software Foundation.
195 +#include <linux/kernel.h>
196 +#include <linux/init.h>
197 +#include <linux/platform_device.h>
198 +#include <linux/leds.h>
199 +#include <linux/workqueue.h>
201 +#include <linux/spinlock.h>
203 +static unsigned int mem_keep = 0xFF;
204 +static spinlock_t mem_lock;
205 +static unsigned char *iobase;
207 +struct latch_led_data {
208 + struct led_classdev cdev;
209 + struct work_struct work;
214 +static void latch_led_set(struct led_classdev *led_cdev,
215 + enum led_brightness value)
217 + struct latch_led_data *led_dat =
218 + container_of(led_cdev, struct latch_led_data, cdev);
220 + spin_lock(mem_lock);
222 + if (value == LED_OFF)
223 + mem_keep |= (0x1 << led_dat->bit);
225 + mem_keep &= ~(0x1 << led_dat->bit);
227 + writeb(mem_keep, iobase);
229 + spin_unlock(mem_lock);
232 +static int latch_led_probe(struct platform_device *pdev)
234 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
235 + struct latch_led *cur_led;
236 + struct latch_led_data *leds_data, *led_dat;
242 + leds_data = kzalloc(sizeof(struct latch_led_data) * pdata->num_leds,
247 + iobase = ioremap_nocache(pdata->mem, 0x1000);
248 + writeb(0xFF, iobase);
250 + for (i = 0; i < pdata->num_leds; i++) {
251 + cur_led = &pdata->leds[i];
252 + led_dat = &leds_data[i];
254 + led_dat->cdev.name = cur_led->name;
255 + led_dat->cdev.default_trigger = cur_led->default_trigger;
256 + led_dat->cdev.brightness_set = latch_led_set;
257 + led_dat->cdev.brightness = LED_OFF;
258 + led_dat->bit = cur_led->bit;
260 + ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
266 + platform_set_drvdata(pdev, leds_data);
272 + for (i = i - 1; i >= 0; i--) {
273 + led_classdev_unregister(&leds_data[i].cdev);
282 +static int __devexit latch_led_remove(struct platform_device *pdev)
285 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
286 + struct latch_led_data *leds_data;
288 + leds_data = platform_get_drvdata(pdev);
290 + for (i = 0; i < pdata->num_leds; i++) {
291 + led_classdev_unregister(&leds_data[i].cdev);
292 + cancel_work_sync(&leds_data[i].work);
300 +static struct platform_driver latch_led_driver = {
301 + .probe = latch_led_probe,
302 + .remove = __devexit_p(latch_led_remove),
304 + .name = "leds-latch",
305 + .owner = THIS_MODULE,
309 +static int __init latch_led_init(void)
311 + return platform_driver_register(&latch_led_driver);
314 +static void __exit latch_led_exit(void)
316 + platform_driver_unregister(&latch_led_driver);
319 +module_init(latch_led_init);
320 +module_exit(latch_led_exit);
322 +MODULE_AUTHOR("Chris Lang <clang@gateworks.com>");
323 +MODULE_DESCRIPTION("Latch LED driver");
324 +MODULE_LICENSE("GPL");
325 diff -ruN clean/linux-2.6.25.4/drivers/leds/Makefile linux-2.6.25.4/drivers/leds/Makefile
326 --- clean/linux-2.6.25.4/drivers/leds/Makefile 2008-05-15 08:00:12.000000000 -0700
327 +++ linux-2.6.25.4/drivers/leds/Makefile 2008-05-20 09:26:14.000000000 -0700
329 obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o
330 obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
331 obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
332 +obj-$(CONFIG_LEDS_LATCH) += leds-latch.o
333 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
334 obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
335 obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
336 diff -ruN clean/linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h
337 --- clean/linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h 2008-05-15 08:00:12.000000000 -0700
338 +++ linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h 2008-05-20 09:22:28.000000000 -0700
340 #define AVILA_PCI_INTC_PIN 9
341 #define AVILA_PCI_INTD_PIN 8
345 +#define AVILA_GW23XX_LED_USER_GPIO 3
346 +#define AVILA_GW23X7_LED_USER_GPIO 4
347 diff -ruN clean/linux-2.6.25.4/include/linux/leds.h linux-2.6.25.4/include/linux/leds.h
348 --- clean/linux-2.6.25.4/include/linux/leds.h 2008-05-15 08:00:12.000000000 -0700
349 +++ linux-2.6.25.4/include/linux/leds.h 2008-05-20 09:32:35.000000000 -0700
351 struct gpio_led *leds;
354 +/* For the leds-latch driver */
357 + char *default_trigger;
361 +struct latch_led_platform_data {
364 + struct latch_led *leds;
368 #endif /* __LINUX_LEDS_H_INCLUDED */