[avr32] generate LZMA compressed uImage as well
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 304-gateworks_led_latch.patch
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
4 @@ -120,6 +120,12 @@
5 outputs. To be useful the particular board must have LEDs
6 and they must be connected to the GPIO lines.
7
8 +config LEDS_LATCH
9 + tristate "LED Support for Memory Latched LEDs"
10 + depends on LEDS_CLASS
11 + help
12 + -- To Do --
13 +
14 config LEDS_CM_X270
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
20 @@ -0,0 +1,141 @@
21 +/*
22 + * LEDs driver for Memory Latched Devices
23 + *
24 + * Copyright (C) 2008 Gateworks Corp.
25 + * Chris Lang <clang@gateworks.com>
26 + *
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.
30 + *
31 + */
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>
37 +#include <asm/io.h>
38 +#include <linux/spinlock.h>
39 +
40 +static unsigned int mem_keep = 0xFF;
41 +static spinlock_t mem_lock;
42 +static unsigned char *iobase;
43 +
44 +struct latch_led_data {
45 + struct led_classdev cdev;
46 + struct work_struct work;
47 + u8 new_level;
48 + u8 bit;
49 +};
50 +
51 +static void latch_led_set(struct led_classdev *led_cdev,
52 + enum led_brightness value)
53 +{
54 + struct latch_led_data *led_dat =
55 + container_of(led_cdev, struct latch_led_data, cdev);
56 +
57 + spin_lock(mem_lock);
58 +
59 + if (value == LED_OFF)
60 + mem_keep |= (0x1 << led_dat->bit);
61 + else
62 + mem_keep &= ~(0x1 << led_dat->bit);
63 +
64 + writeb(mem_keep, iobase);
65 +
66 + spin_unlock(mem_lock);
67 +}
68 +
69 +static int latch_led_probe(struct platform_device *pdev)
70 +{
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;
74 + int i, ret = 0;
75 +
76 + if (!pdata)
77 + return -EBUSY;
78 +
79 + leds_data = kzalloc(sizeof(struct latch_led_data) * pdata->num_leds,
80 + GFP_KERNEL);
81 + if (!leds_data)
82 + return -ENOMEM;
83 +
84 + iobase = ioremap_nocache(pdata->mem, 0x1000);
85 + writeb(0xFF, iobase);
86 +
87 + for (i = 0; i < pdata->num_leds; i++) {
88 + cur_led = &pdata->leds[i];
89 + led_dat = &leds_data[i];
90 +
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;
96 +
97 + ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
98 + if (ret < 0) {
99 + goto err;
100 + }
101 + }
102 +
103 + platform_set_drvdata(pdev, leds_data);
104 +
105 + return 0;
106 +
107 +err:
108 + if (i > 0) {
109 + for (i = i - 1; i >= 0; i--) {
110 + led_classdev_unregister(&leds_data[i].cdev);
111 + }
112 + }
113 +
114 + kfree(leds_data);
115 +
116 + return ret;
117 +}
118 +
119 +static int __devexit latch_led_remove(struct platform_device *pdev)
120 +{
121 + int i;
122 + struct latch_led_platform_data *pdata = pdev->dev.platform_data;
123 + struct latch_led_data *leds_data;
124 +
125 + leds_data = platform_get_drvdata(pdev);
126 +
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);
130 + }
131 +
132 + kfree(leds_data);
133 +
134 + return 0;
135 +}
136 +
137 +static struct platform_driver latch_led_driver = {
138 + .probe = latch_led_probe,
139 + .remove = __devexit_p(latch_led_remove),
140 + .driver = {
141 + .name = "leds-latch",
142 + .owner = THIS_MODULE,
143 + },
144 +};
145 +
146 +static int __init latch_led_init(void)
147 +{
148 + return platform_driver_register(&latch_led_driver);
149 +}
150 +
151 +static void __exit latch_led_exit(void)
152 +{
153 + platform_driver_unregister(&latch_led_driver);
154 +}
155 +
156 +module_init(latch_led_init);
157 +module_exit(latch_led_exit);
158 +
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
165 @@ -21,6 +21,7 @@
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
170
171 # LED Triggers
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
176 @@ -173,7 +173,7 @@
177 .dev.platform_data = &avila_npec_data,
178 };
179
180 -static struct gpio_led avila_leds[] = {
181 +static struct gpio_led avila_gpio_leds[] = {
182 {
183 .name = "user", /* green led */
184 .gpio = AVILA_GW23XX_LED_USER_GPIO,
185 @@ -181,17 +181,65 @@
186 }
187 };
188
189 -static struct gpio_led_platform_data avila_leds_data = {
190 +static struct gpio_led_platform_data avila_gpio_leds_data = {
191 .num_leds = 1,
192 - .leds = avila_leds,
193 + .leds = avila_gpio_leds,
194 };
195
196 -static struct platform_device avila_leds_device = {
197 +static struct platform_device avila_gpio_leds_device = {
198 .name = "leds-gpio",
199 .id = -1,
200 - .dev.platform_data = &avila_leds_data,
201 + .dev.platform_data = &avila_gpio_leds_data,
202 };
203
204 +static struct latch_led avila_latch_leds[] = {
205 + {
206 + .name = "led0", /* green led */
207 + .bit = 0,
208 + },
209 + {
210 + .name = "led1", /* green led */
211 + .bit = 1,
212 + },
213 + {
214 + .name = "led2", /* green led */
215 + .bit = 2,
216 + },
217 + {
218 + .name = "led3", /* green led */
219 + .bit = 3,
220 + },
221 + {
222 + .name = "led4", /* green led */
223 + .bit = 4,
224 + },
225 + {
226 + .name = "led5", /* green led */
227 + .bit = 5,
228 + },
229 + {
230 + .name = "led6", /* green led */
231 + .bit = 6,
232 + },
233 + {
234 + .name = "led7", /* green led */
235 + .bit = 7,
236 + }
237 +};
238 +
239 +static struct latch_led_platform_data avila_latch_leds_data = {
240 + .num_leds = 8,
241 + .leds = avila_latch_leds,
242 + .mem = 0x51000000,
243 +};
244 +
245 +static struct platform_device avila_latch_leds_device = {
246 + .name = "leds-latch",
247 + .id = -1,
248 + .dev.platform_data = &avila_latch_leds_data,
249 +};
250 +
251 +
252 static struct resource avila_gpio_resources[] = {
253 {
254 .name = "gpio",
255 @@ -221,7 +269,7 @@
256 platform_device_register(&avila_npeb_device);
257 platform_device_register(&avila_npec_device);
258
259 - platform_device_register(&avila_leds_device);
260 + platform_device_register(&avila_gpio_leds_device);
261 }
262
263 #ifdef CONFIG_SENSORS_EEPROM
264 @@ -230,7 +278,7 @@
265 platform_device_register(&avila_npeb_device);
266 platform_device_register(&avila_npec_device);
267
268 - platform_device_register(&avila_leds_device);
269 + platform_device_register(&avila_gpio_leds_device);
270 }
271
272 static void __init avila_gw2345_setup(void)
273 @@ -242,7 +290,7 @@
274 avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
275 platform_device_register(&avila_npec_device);
276
277 - platform_device_register(&avila_leds_device);
278 + platform_device_register(&avila_gpio_leds_device);
279 }
280
281 static void __init avila_gw2347_setup(void)
282 @@ -250,8 +298,8 @@
283 avila_npeb_data.quirks |= IXP4XX_ETH_QUIRK_GW23X7;
284 platform_device_register(&avila_npeb_device);
285
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);
290 }
291
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);
296
297 - platform_device_register(&avila_leds_device);
298 + platform_device_register(&avila_gpio_leds_device);
299 }
300
301 static void __init avila_gw2353_setup(void)
302 {
303 platform_device_register(&avila_npeb_device);
304 - platform_device_register(&avila_leds_device);
305 + platform_device_register(&avila_gpio_leds_device);
306 }
307
308 static void __init avila_gw2355_setup(void)
309 @@ -277,7 +325,17 @@
310 avila_npec_data.phy = 16;
311 platform_device_register(&avila_npec_device);
312
313 - platform_device_register(&avila_leds_device);
314 + platform_device_register(&avila_gpio_leds_device);
315 +
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);
325 }
326
327 static void __init avila_gw2357_setup(void)
328 @@ -285,8 +343,11 @@
329 avila_npeb_data.quirks |= IXP4XX_ETH_QUIRK_GW23X7;
330 platform_device_register(&avila_npeb_device);
331
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);
336 +
337 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
338 + platform_device_register(&avila_latch_leds_device);
339 }
340
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
345 @@ -25,6 +25,8 @@
346 # include <linux/i2c.h>
347 # include <linux/eeprom.h>
348 #endif
349 +
350 +#include <linux/leds.h>
351
352 #include <linux/i2c-gpio.h>
353 #include <asm/types.h>
354 @@ -149,19 +151,52 @@
355 }
356 };
357
358 -#ifdef CONFIG_LEDS_IXP4XX
359 -static struct platform_device cambria_leds_pld = {
360 - .name = "IXP4XX-PLD-LED",
361 - .id = -1,
362 - .num_resources = 0,
363 -};
364 -
365 -static struct platform_device cambria_leds_mem = {
366 - .name = "IXP4XX-MEM-LED",
367 - .id = -1,
368 - .num_resources = 0,
369 +static struct latch_led cambria_leds[] = {
370 + {
371 + .name = "ledA", /* green led */
372 + .bit = 0,
373 + },
374 + {
375 + .name = "ledB", /* green led */
376 + .bit = 1,
377 + },
378 + {
379 + .name = "ledC", /* green led */
380 + .bit = 2,
381 + },
382 + {
383 + .name = "ledD", /* green led */
384 + .bit = 3,
385 + },
386 + {
387 + .name = "ledE", /* green led */
388 + .bit = 4,
389 + },
390 + {
391 + .name = "ledF", /* green led */
392 + .bit = 5,
393 + },
394 + {
395 + .name = "ledG", /* green led */
396 + .bit = 6,
397 + },
398 + {
399 + .name = "ledH", /* green led */
400 + .bit = 7,
401 + }
402 +};
403 +
404 +static struct latch_led_platform_data cambria_leds_data = {
405 + .num_leds = 8,
406 + .leds = cambria_leds,
407 + .mem = 0x53F40000,
408 +};
409 +
410 +static struct platform_device cambria_leds_device = {
411 + .name = "leds-latch",
412 + .id = -1,
413 + .dev.platform_data = &cambria_leds_data,
414 };
415 -#endif
416
417 static struct platform_device *cambria_devices[] __initdata = {
418 &cambria_i2c_gpio,
419 @@ -234,6 +269,9 @@
420 cambria_pata_data.cs1_cfg = IXP4XX_EXP_CS3;
421
422 platform_device_register(&cambria_pata);
423 +
424 + *IXP4XX_EXP_CS3 |= 0xbfff3c03;
425 + platform_device_register(&cambria_leds_device);
426 }
427
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
431 @@ -123,5 +123,18 @@
432 struct gpio_led *leds;
433 };
434
435 +/* For the leds-latch driver */
436 +struct latch_led {
437 + const char *name;
438 + char *default_trigger;
439 + unsigned bit;
440 +};
441 +
442 +struct latch_led_platform_data {
443 + int num_leds;
444 + u32 mem;
445 + struct latch_led *leds;
446 +};
447 +
448
449 #endif /* __LINUX_LEDS_H_INCLUDED */
This page took 0.058288 seconds and 5 git commands to generate.