1 diff -ruN trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/Kconfig linux-2.6.24.5/drivers/leds/Kconfig
2 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/Kconfig 2008-04-29 11:29:49.000000000 -0700
3 +++ linux-2.6.24.5/drivers/leds/Kconfig 2008-04-29 17:18:47.000000000 -0700
5 outputs. To be useful the particular board must have LEDs
6 and they must be connected to the GPIO lines.
9 + tristate "LED Support for Memory Latched LEDs"
10 + depends on LEDS_CLASS
15 tristate "LED Support for the CM-X270 LEDs"
16 depends on LEDS_CLASS && MACH_ARMCORE
17 diff -ruN trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/leds-latch.c linux-2.6.24.5/drivers/leds/leds-latch.c
18 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/leds-latch.c 1969-12-31 16:00:00.000000000 -0800
19 +++ linux-2.6.24.5/drivers/leds/leds-latch.c 2008-04-30 14:03:21.000000000 -0700
22 + * LEDs driver for Memory Latched Devices
24 + * Copyright (C) 2008 Gateworks Corp.
25 + * Chris Lang <clang@gateworks.com>
27 + * This program is free software; you can redistribute it and/or modify
28 + * it under the terms of the GNU General Public License version 2 as
29 + * published by the Free Software Foundation.
32 +#include <linux/kernel.h>
33 +#include <linux/init.h>
34 +#include <linux/platform_device.h>
35 +#include <linux/leds.h>
36 +#include <linux/workqueue.h>
38 +#include <linux/spinlock.h>
40 +static unsigned int mem_keep = 0xFF;
41 +static spinlock_t mem_lock;
42 +static unsigned char *iobase;
44 +struct latch_led_data {
45 + struct led_classdev cdev;
46 + struct work_struct work;
51 +static void latch_led_set(struct led_classdev *led_cdev,
52 + enum led_brightness value)
54 + struct latch_led_data *led_dat =
55 + container_of(led_cdev, struct latch_led_data, cdev);
57 + spin_lock(mem_lock);
59 + if (value == LED_OFF)
60 + mem_keep |= (0x1 << led_dat->bit);
62 + mem_keep &= ~(0x1 << led_dat->bit);
64 + writeb(mem_keep, iobase);
66 + spin_unlock(mem_lock);
69 +static int latch_led_probe(struct platform_device *pdev)
71 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
72 + struct latch_led *cur_led;
73 + struct latch_led_data *leds_data, *led_dat;
79 + leds_data = kzalloc(sizeof(struct latch_led_data) * pdata->num_leds,
84 + iobase = ioremap_nocache(pdata->mem, 0x1000);
85 + writeb(0xFF, iobase);
87 + for (i = 0; i < pdata->num_leds; i++) {
88 + cur_led = &pdata->leds[i];
89 + led_dat = &leds_data[i];
91 + led_dat->cdev.name = cur_led->name;
92 + led_dat->cdev.default_trigger = cur_led->default_trigger;
93 + led_dat->cdev.brightness_set = latch_led_set;
94 + led_dat->cdev.brightness = LED_OFF;
95 + led_dat->bit = cur_led->bit;
97 + ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
103 + platform_set_drvdata(pdev, leds_data);
109 + for (i = i - 1; i >= 0; i--) {
110 + led_classdev_unregister(&leds_data[i].cdev);
119 +static int __devexit latch_led_remove(struct platform_device *pdev)
122 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
123 + struct latch_led_data *leds_data;
125 + leds_data = platform_get_drvdata(pdev);
127 + for (i = 0; i < pdata->num_leds; i++) {
128 + led_classdev_unregister(&leds_data[i].cdev);
129 + cancel_work_sync(&leds_data[i].work);
137 +static struct platform_driver latch_led_driver = {
138 + .probe = latch_led_probe,
139 + .remove = __devexit_p(latch_led_remove),
141 + .name = "leds-latch",
142 + .owner = THIS_MODULE,
146 +static int __init latch_led_init(void)
148 + return platform_driver_register(&latch_led_driver);
151 +static void __exit latch_led_exit(void)
153 + platform_driver_unregister(&latch_led_driver);
156 +module_init(latch_led_init);
157 +module_exit(latch_led_exit);
159 +MODULE_AUTHOR("Chris Lang <clang@gateworks.com>");
160 +MODULE_DESCRIPTION("Latch LED driver");
161 +MODULE_LICENSE("GPL");
162 diff -ruN trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/Makefile linux-2.6.24.5/drivers/leds/Makefile
163 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/drivers/leds/Makefile 2008-04-29 11:29:49.000000000 -0700
164 +++ linux-2.6.24.5/drivers/leds/Makefile 2008-04-29 17:19:02.000000000 -0700
166 obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
167 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
168 obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
169 +obj-$(CONFIG_LEDS_LATCH) += leds-latch.o
172 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
173 diff -ruN trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/arch/arm/mach-ixp4xx/avila-setup.c linux-2.6.24.5/arch/arm/mach-ixp4xx/avila-setup.c
174 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/arch/arm/mach-ixp4xx/avila-setup.c 2008-04-29 11:29:50.000000000 -0700
175 +++ linux-2.6.24.5/arch/arm/mach-ixp4xx/avila-setup.c 2008-04-30 15:43:40.000000000 -0700
177 .dev.platform_data = &avila_npec_data,
180 -static struct gpio_led avila_leds[] = {
181 +static struct gpio_led avila_gpio_leds[] = {
183 .name = "user", /* green led */
184 .gpio = AVILA_GW23XX_LED_USER_GPIO,
185 @@ -181,17 +181,65 @@
189 -static struct gpio_led_platform_data avila_leds_data = {
190 +static struct gpio_led_platform_data avila_gpio_leds_data = {
192 - .leds = avila_leds,
193 + .leds = avila_gpio_leds,
196 -static struct platform_device avila_leds_device = {
197 +static struct platform_device avila_gpio_leds_device = {
200 - .dev.platform_data = &avila_leds_data,
201 + .dev.platform_data = &avila_gpio_leds_data,
204 +static struct latch_led avila_latch_leds[] = {
206 + .name = "led0", /* green led */
210 + .name = "led1", /* green led */
214 + .name = "led2", /* green led */
218 + .name = "led3", /* green led */
222 + .name = "led4", /* green led */
226 + .name = "led5", /* green led */
230 + .name = "led6", /* green led */
234 + .name = "led7", /* green led */
239 +static struct latch_led_platform_data avila_latch_leds_data = {
241 + .leds = avila_latch_leds,
245 +static struct platform_device avila_latch_leds_device = {
246 + .name = "leds-latch",
248 + .dev.platform_data = &avila_latch_leds_data,
252 static struct resource avila_gpio_resources[] = {
256 platform_device_register(&avila_npeb_device);
257 platform_device_register(&avila_npec_device);
259 - platform_device_register(&avila_leds_device);
260 + platform_device_register(&avila_gpio_leds_device);
263 #ifdef CONFIG_SENSORS_EEPROM
265 platform_device_register(&avila_npeb_device);
266 platform_device_register(&avila_npec_device);
268 - platform_device_register(&avila_leds_device);
269 + platform_device_register(&avila_gpio_leds_device);
272 static void __init avila_gw2345_setup(void)
274 avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
275 platform_device_register(&avila_npec_device);
277 - platform_device_register(&avila_leds_device);
278 + platform_device_register(&avila_gpio_leds_device);
281 static void __init avila_gw2347_setup(void)
283 avila_npeb_data.quirks |= IXP4XX_ETH_QUIRK_GW23X7;
284 platform_device_register(&avila_npeb_device);
286 - avila_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
287 - platform_device_register(&avila_leds_device);
288 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
289 + platform_device_register(&avila_gpio_leds_device);
292 static void __init avila_gw2348_setup(void)
293 @@ -259,13 +307,13 @@
294 platform_device_register(&avila_npeb_device);
295 platform_device_register(&avila_npec_device);
297 - platform_device_register(&avila_leds_device);
298 + platform_device_register(&avila_gpio_leds_device);
301 static void __init avila_gw2353_setup(void)
303 platform_device_register(&avila_npeb_device);
304 - platform_device_register(&avila_leds_device);
305 + platform_device_register(&avila_gpio_leds_device);
308 static void __init avila_gw2355_setup(void)
310 avila_npec_data.phy = 16;
311 platform_device_register(&avila_npec_device);
313 - platform_device_register(&avila_leds_device);
314 + platform_device_register(&avila_gpio_leds_device);
316 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
317 + avila_latch_leds[0].name = "RXD";
318 + avila_latch_leds[1].name = "TXD";
319 + avila_latch_leds[2].name = "POL";
320 + avila_latch_leds[3].name = "LNK";
321 + avila_latch_leds[4].name = "ERR";
322 + avila_latch_leds_data.num_leds = 5;
323 + avila_latch_leds_data.mem = 0x54000000;
324 + platform_device_register(&avila_latch_leds_device);
327 static void __init avila_gw2357_setup(void)
329 avila_npeb_data.quirks |= IXP4XX_ETH_QUIRK_GW23X7;
330 platform_device_register(&avila_npeb_device);
332 - avila_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
333 - platform_device_register(&avila_leds_device);
334 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
335 + platform_device_register(&avila_gpio_leds_device);
337 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
338 + platform_device_register(&avila_latch_leds_device);
341 static struct avila_board_info avila_boards[] __initdata = {
342 diff -ruN trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/arch/arm/mach-ixp4xx/cambria-setup.c linux-2.6.24.5/arch/arm/mach-ixp4xx/cambria-setup.c
343 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/arch/arm/mach-ixp4xx/cambria-setup.c 2008-04-29 11:29:49.000000000 -0700
344 +++ linux-2.6.24.5/arch/arm/mach-ixp4xx/cambria-setup.c 2008-04-30 14:43:57.000000000 -0700
346 # include <linux/i2c.h>
347 # include <linux/eeprom.h>
350 +#include <linux/leds.h>
352 #include <linux/i2c-gpio.h>
353 #include <asm/types.h>
354 @@ -149,19 +151,52 @@
358 -#ifdef CONFIG_LEDS_IXP4XX
359 -static struct platform_device cambria_leds_pld = {
360 - .name = "IXP4XX-PLD-LED",
362 - .num_resources = 0,
365 -static struct platform_device cambria_leds_mem = {
366 - .name = "IXP4XX-MEM-LED",
368 - .num_resources = 0,
369 +static struct latch_led cambria_leds[] = {
371 + .name = "ledA", /* green led */
375 + .name = "ledB", /* green led */
379 + .name = "ledC", /* green led */
383 + .name = "ledD", /* green led */
387 + .name = "ledE", /* green led */
391 + .name = "ledF", /* green led */
395 + .name = "ledG", /* green led */
399 + .name = "ledH", /* green led */
404 +static struct latch_led_platform_data cambria_leds_data = {
406 + .leds = cambria_leds,
410 +static struct platform_device cambria_leds_device = {
411 + .name = "leds-latch",
413 + .dev.platform_data = &cambria_leds_data,
417 static struct platform_device *cambria_devices[] __initdata = {
420 cambria_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
422 platform_device_register(&cambria_pata);
424 + *IXP4XX_EXP_CS3 |= 0xbfff3c03;
425 + platform_device_register(&cambria_leds_device);
428 #ifdef CONFIG_MACH_CAMBRIA
429 --- trunk/build_dir/linux-ixp4xx_generic/linux-2.6.24.5/include/linux/leds.h 2008-04-18 18:53:39.000000000 -0700
430 +++ linux-2.6.24.5/include/linux/leds.h 2008-04-29 17:48:56.000000000 -0700
432 struct gpio_led *leds;
435 +/* For the leds-latch driver */
438 + char *default_trigger;
442 +struct latch_led_platform_data {
445 + struct latch_led *leds;
449 #endif /* __LINUX_LEDS_H_INCLUDED */