clean up patches, add atm driver proc support, add real led driver
[openwrt/svn-archive/archive.git] / openwrt / target / linux / linux-2.4 / patches / ar7 / 002-led_driver.patch
1 diff -urN kernel-old/drivers/char/avalanche_led/led_drv.c kernel-current/drivers/char/avalanche_led/led_drv.c
2 --- kernel-old/drivers/char/avalanche_led/led_drv.c 1970-01-01 01:00:00.000000000 +0100
3 +++ kernel-current/drivers/char/avalanche_led/led_drv.c 2005-07-10 18:40:23.008730752 +0200
4 @@ -0,0 +1,375 @@
5 +/******************************************************************************
6 + * FILE PURPOSE: - LED driver module Source
7 + ******************************************************************************
8 + * FILE NAME: led_drv.c
9 + *
10 + * DESCRIPTION: Linux LED character driver implementation
11 + *
12 + * REVISION HISTORY:
13 + * 27 Aug 2003 Initial Creation Sharath Kumar<krs@ti.com>
14 + *
15 + * 16 Dec 2003 Updates for 5.7 Sharath Kumar<krs@ti.com>
16 + *
17 + * 07 Jan 2004 Wrapper for DSL Sharath Kumar<krs@ti.com>
18 + *
19 + * (C) Copyright 2002, Texas Instruments, Inc
20 + *******************************************************************************/
21 +
22 +#include <linux/config.h>
23 +#include <linux/module.h>
24 +#include <linux/init.h>
25 +#include <linux/types.h>
26 +#include <linux/errno.h>
27 +#include <linux/slab.h>
28 +#include <linux/ioport.h>
29 +#include <linux/fcntl.h>
30 +#include <linux/interrupt.h>
31 +#include <linux/sched.h>
32 +#include <linux/mm.h>
33 +#include <asm/io.h>
34 +#include <asm/uaccess.h>
35 +#include <asm/system.h>
36 +#include <linux/delay.h>
37 +#include <linux/devfs_fs_kernel.h>
38 +#include <linux/wait.h>
39 +#include <linux/proc_fs.h>
40 +#include <linux/timer.h>
41 +#include <asm/ar7/sangam.h>
42 +#include <asm/ar7/avalanche_misc.h>
43 +
44 +#include "led_config.h"
45 +#include "led_hal.h"
46 +#include "led_ioctl.h"
47 +#include "led_platform.h"
48 +
49 +//#define tnetd73xx_gpio_ctrl(gpio_pin, pin_mode, pin_direction) avalanche_gpio_ctrl(gpio_pin, pin_mode, pin_direction)
50 +#define tnetd73xx_gpio_out(gpio_pin, value) avalanche_gpio_out_bit(gpio_pin, value)
51 +//#define avalanche_gpio_in_bit(gpio_pin) tnetd73xx_gpio_in(gpio_pin)
52 +
53 +#define TI_LED_VERSION "0.1"
54 +#define GPIO_MAP_LEN ((MAX_GPIO_PIN_NUM/32) + 1)
55 +
56 +static int gpio_off_state[GPIO_MAP_LEN] = AVALANCHE_GPIO_OFF_MAP;
57 +
58 +#define TRUE 1
59 +#define FALSE 0
60 +#define FLICK_TIME (HZ*100/1000)
61 +static unsigned int wan_txrx_state = 0;
62 +static unsigned int wlan_txrx_state = 0;
63 +struct timer_list *pWanTimer = NULL;
64 +
65 +static void wan_led_func(unsigned long data)
66 +{
67 + avalanche_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
68 + avalanche_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
69 +
70 + if (wan_txrx_state == 0)
71 + {
72 + tnetd73xx_gpio_out(2, TRUE);
73 + tnetd73xx_gpio_out(3, FALSE);
74 + wan_txrx_state = 1;
75 + }
76 + else
77 + {
78 + tnetd73xx_gpio_out(2, FALSE);
79 + tnetd73xx_gpio_out(3, FALSE);
80 + wan_txrx_state = 0;
81 + }
82 + pWanTimer->expires = jiffies + FLICK_TIME;
83 + add_timer(pWanTimer);
84 +
85 +}
86 +
87 +static int led_ioctl( struct inode * inode, struct file * file,
88 + unsigned int cmd, unsigned long arg )
89 +{
90 +
91 + int ret = 0;
92 +// char name[80];
93 +
94 + switch ( cmd )
95 + {
96 + case LED_CONFIG:
97 + {
98 + LED_CONFIG_T led_cfg;
99 + if (copy_from_user((char *)&led_cfg, (char *)arg, sizeof(led_cfg)))
100 + {
101 + printk("in led config error\n");
102 + ret = -EFAULT;
103 + break;
104 + }
105 + printk("in led config\n");
106 + ret = avalanche_led_config_set(&led_cfg);
107 + }
108 + break;
109 +
110 + case LED_GET_HANDLE:
111 + {
112 + LED_MODULE_T led_mod;
113 + int handle;
114 +
115 + if (copy_from_user((char *)&led_mod, (char *)arg, sizeof(led_mod)))
116 + {
117 + ret = -EFAULT;
118 + break;
119 + }
120 +
121 + handle = (int)avalanche_led_register(led_mod.name,led_mod.instance);
122 +
123 + if (copy_to_user((char *)(&(((LED_MODULE_T *)arg)->handle)), (char *)(&handle), sizeof(int)))
124 + {
125 + ret = -EFAULT;
126 + break;
127 + }
128 +
129 + if(handle)
130 + ret = 0;
131 + else
132 + ret = -1;
133 + }
134 + break;
135 +
136 + case LED_ACTION:
137 + {
138 + LED_STATE_T led_state;
139 + if (copy_from_user((char *)&led_state, (char *)arg, sizeof(led_state)))
140 + {
141 + ret = -EFAULT;
142 + break;
143 + }
144 + else {
145 + printk("led action : handle = %d, id = %d\n", led_state.handle, led_state.state_id);
146 + //add by leijun
147 + if (led_state.handle == 2) //system led
148 + {
149 + switch (led_state.state_id)
150 + {
151 + case 1:
152 + break;
153 + case 2: /*sys led flashing green */
154 + tnetd73xx_gpio_out(4, FALSE);
155 + tnetd73xx_gpio_out(5, TRUE);
156 + tnetd73xx_gpio_out(8, TRUE);
157 + break;
158 + case 3: /*sys led solid green */
159 + tnetd73xx_gpio_out(4, TRUE);
160 + tnetd73xx_gpio_out(5, TRUE);
161 + tnetd73xx_gpio_out(8, TRUE);
162 +
163 + break;
164 + case 4: /*sys fail red */
165 + tnetd73xx_gpio_out(4, TRUE);
166 + tnetd73xx_gpio_out(5, FALSE);
167 + tnetd73xx_gpio_out(8, FALSE);
168 + break;
169 + default:
170 + break;
171 +
172 + }
173 + }else if (led_state.handle == 3)
174 + {
175 + printk("led action : handle = %d, id = %d\n", led_state.handle, led_state.state_id);
176 + avalanche_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
177 + avalanche_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
178 +
179 + switch (led_state.state_id)
180 + {
181 + case 1: /*no wan interface*/
182 + if (pWanTimer)
183 + {
184 + del_timer(pWanTimer);
185 + kfree(pWanTimer);
186 + pWanTimer = NULL;
187 + }
188 + tnetd73xx_gpio_out(2, FALSE);
189 + tnetd73xx_gpio_out(3, FALSE);
190 + break;
191 + case 2: /*wan connected */
192 + if (pWanTimer)
193 + {
194 + del_timer(pWanTimer);
195 + kfree(pWanTimer);
196 + pWanTimer = NULL;
197 + }
198 + tnetd73xx_gpio_out(2, TRUE);
199 + tnetd73xx_gpio_out(3, FALSE);
200 + break;
201 + case 3: /*rx/tx activity */
202 + if (pWanTimer != NULL)
203 + break;
204 +
205 + pWanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
206 + init_timer(pWanTimer);
207 +
208 + pWanTimer->function = wan_led_func;
209 + pWanTimer->data = 0;
210 + pWanTimer->expires = jiffies + FLICK_TIME;
211 + tnetd73xx_gpio_out(2, FALSE);
212 + tnetd73xx_gpio_out(3, FALSE);
213 + wan_txrx_state = 0;
214 + add_timer(pWanTimer);
215 +
216 + break;
217 + case 4: /*no ipaddress */
218 + if (pWanTimer)
219 + {
220 + del_timer(pWanTimer);
221 + kfree(pWanTimer);
222 + pWanTimer = NULL;
223 + }
224 + tnetd73xx_gpio_out(2, FALSE);
225 + tnetd73xx_gpio_out(3, TRUE);
226 + break;
227 + default:
228 + if (pWanTimer)
229 + {
230 + del_timer(pWanTimer);
231 + kfree(pWanTimer);
232 + pWanTimer = NULL;
233 + }
234 + break;
235 + }
236 + }else if (led_state.handle == 4) //test
237 + {
238 + int high, low;
239 + high = (led_state.state_id & 0xf0) >> 4;
240 + low = (led_state.state_id & 0x0f);
241 + tnetd73xx_gpio_out(high, (low > 0)?1:0);
242 + }else avalanche_led_action((void *)led_state.handle,led_state.state_id);
243 + }
244 +
245 + }
246 + break;
247 +
248 + case LED_RELEASE_HANDLE:
249 + ret = avalanche_led_unregister((void *)arg);
250 + break;
251 +
252 + default:
253 + ret = -EINVAL;
254 + }
255 + return ret;
256 +
257 +}
258 +
259 +static int led_open( struct inode * inode, struct file * file )
260 +{
261 + return 0;
262 +}
263 +
264 +static int led_close( struct inode * inode, struct file * file )
265 +{
266 + return 0;
267 +}
268 +
269 +struct file_operations led_fops = {
270 + ioctl: led_ioctl,
271 + open: led_open,
272 + release: led_close
273 +};
274 +
275 +
276 +/* Proc function to display driver version */
277 +static int
278 +led_ver_info(char *buf, char **start, off_t offset, int count, int *eof, void *data)
279 +{
280 +// int instance;
281 + int len=0;
282 +
283 + len += sprintf(buf +len,"\nTI Linux LED Driver Version %s\n",TI_LED_VERSION);
284 + return len;
285 +}
286 +
287 +
288 +/* proc interface /proc/avalanche/led */
289 +int led_cfg_info(char* buf, char **start, off_t offset, int count,
290 + int *eof, void *data)
291 +{
292 + int mod_count = 0;
293 + int len=0;
294 + int limit = count - 80;
295 + char *msg[5]={"LED OFF", "LED_ON", "LED_ONESHOT_OFF", "LED_ONESHOT_ON","LED_FLASH"};
296 +
297 + for(mod_count = 0;mod_count<MAX_MODULE_ENTRIES;mod_count++)
298 + {
299 + int instance;
300 +
301 + for(instance = 0; instance < MAX_MODULE_INSTANCES; instance++)
302 + {
303 + int state_id;
304 + int flag = 0;
305 +
306 + for(state_id =0 ;state_id < MAX_STATE_ENTRIES; state_id++)
307 + {
308 + LED_CONFIG_T led_cfg;
309 + if(avalanche_led_config_get(&led_cfg,mod_count,instance,state_id) == 0)
310 + {
311 + if(flag == 0)
312 + {
313 + flag = 1;
314 + if(len <= limit)
315 + len+= sprintf(buf+len, "\nModule:%s\n",led_cfg.name);
316 +
317 + if(len <= limit)
318 + len+= sprintf(buf+len, "\n Instance:%d\n",instance);
319 +
320 + }
321 +
322 + if(len <= limit)
323 + len+= sprintf(buf+len, "\n State: %d\n",state_id);
324 +
325 + if(len <= limit)
326 + len+= sprintf(buf+len, "\n mode: %s\n",msg[led_cfg.mode[0]% 5 ]);
327 +
328 + if(len <= limit)
329 + len+= sprintf(buf+len, "\n gpio: %d\n",led_cfg.gpio[0]);
330 +
331 + if(len <= limit)
332 + len+= sprintf(buf+len, "\n param1: %d\n",led_cfg.param1);
333 +
334 + if(len <= limit)
335 + len+= sprintf(buf+len, "\n param2: %d\n",led_cfg.param2);
336 + }
337 + }
338 + }
339 + }
340 +
341 +
342 +
343 + return len;
344 +}
345 +
346 +
347 +
348 +int __init led_init(void)
349 +{
350 +
351 + /* register LED device */
352 + devfs_register(NULL, "led", DEVFS_FL_AUTO_DEVNUM, 0, 0,
353 + S_IFCHR | S_IRUGO | S_IWUGO, &led_fops,NULL);
354 +
355 +
356 + avalanche_led_hal_init(gpio_off_state,AVALANCHE_GPIO_PIN_COUNT);
357 +
358 + /* create proc entry */
359 + create_proc_read_entry("avalanche/led_cfg", 0, NULL, led_cfg_info, NULL);
360 + create_proc_read_entry("avalanche/led_ver", 0, NULL, led_ver_info, NULL);
361 +
362 + return 0;
363 +}
364 +
365 +void led_exit(void)
366 +{
367 + avalanche_led_hal_exit();
368 + return;
369 +}
370 +
371 +module_init(led_init);
372 +module_exit(led_exit);
373 +
374 +
375 +EXPORT_SYMBOL_NOVERS(avalanche_led_register);
376 +EXPORT_SYMBOL_NOVERS(avalanche_led_action);
377 +EXPORT_SYMBOL_NOVERS(avalanche_led_unregister);
378 +EXPORT_SYMBOL_NOVERS(avalanche_led_config_set);
379 +EXPORT_SYMBOL_NOVERS(avalanche_led_config_get);
380 diff -urN kernel-old/drivers/char/avalanche_led/led_hal.c kernel-current/drivers/char/avalanche_led/led_hal.c
381 --- kernel-old/drivers/char/avalanche_led/led_hal.c 1970-01-01 01:00:00.000000000 +0100
382 +++ kernel-current/drivers/char/avalanche_led/led_hal.c 2005-07-10 18:24:22.242038232 +0200
383 @@ -0,0 +1,821 @@
384 +/******************************************************************************
385 + * FILE PURPOSE: - LED HAL module source
386 + ******************************************************************************
387 + * FILE NAME: led_hal.c
388 + *
389 + * DESCRIPTION: LED HAL API's source.
390 + *
391 + * REVISION HISTORY:
392 + * 27 Aug 2003 Initial Creation Sharath Kumar<krs@ti.com>
393 + *
394 + * 16 Dec 2003 Updates for 5.7 Sharath Kumar<krs@ti.com>
395 + *
396 + * 07 Jan 2004 Wrapper for DSL Sharath Kumar<krs@ti.com>
397 + *
398 + * (C) Copyright 2002, Texas Instruments, Inc
399 + *******************************************************************************/
400 +
401 +#include "led_platform.h"
402 +#include "led_config.h"
403 +#include "led_hal.h"
404 +
405 +/* include for gpio APIs */
406 +#include <asm/ar7/avalanche_misc.h>
407 +
408 +
409 +#define REQUIRES_TIMER(x) ( (x == LED_ONESHOT_ON) || (x == LED_ONESHOT_OFF) || (x == LED_FLASH) )
410 +
411 +/*******************TYPEDEFs**************************************************/
412 +typedef struct
413 +{
414 + unsigned int state;
415 + unsigned int module_map;
416 + unsigned int pos_map[2];
417 +}
418 +LED_OBJ_T;
419 +
420 +typedef struct state_entry STATE_ENTRY_T;
421 +
422 +struct state_entry
423 +{
424 + void (*handler) (STATE_ENTRY_T * state);
425 + unsigned int timer_running;
426 + LED_OBJ_T *led;
427 + unsigned int map1[2];
428 + unsigned int map2[2];
429 + void *os_timer;
430 + unsigned int param1;
431 + unsigned int param2;
432 + unsigned int module_id;
433 + unsigned int mode;
434 +};
435 +
436 +typedef struct module_instance
437 +{
438 + int module_id;
439 + int instance;
440 + STATE_ENTRY_T *states[MAX_STATE_ENTRIES];
441 +}
442 +MODULE_INSTANCE_T;
443 +
444 +typedef struct module_entry
445 +{
446 + unsigned char *name;
447 + MODULE_INSTANCE_T *module_instance[MAX_MODULE_INSTANCES];
448 +}
449 +MODULE_ENTRY_T;
450 +
451 +
452 +
453 +/******************variable defn/declns***************************************/
454 +
455 +static LED_OBJ_T *leds[MAX_LED_ENTRIES];
456 +static MODULE_ENTRY_T *modules[MAX_MODULE_ENTRIES];
457 +
458 +/* Declare Mutex lock */
459 +MUTEX_DECLARE (led_lock);
460 +
461 +/* GPIO OFF STATE */
462 +static unsigned int gpio_offstate_map[2];
463 +
464 +/* Number of GPIO pins in the system */
465 +static unsigned int num_gpios;
466 +
467 +/* LED handlers */
468 +static void (*led_mode_handler[NUM_LED_MODES]) (STATE_ENTRY_T * state);
469 +
470 +
471 +
472 +/******************static functions*****************************************/
473 +
474 +static void *led_malloc (int n)
475 +{
476 + void *p;
477 + p = os_malloc (n);
478 +
479 + if (p)
480 + os_memset (p, 0, n);
481 +
482 + return p;
483 +}
484 +
485 +static void avalanche_gpio_set(int * set_map,int *pos_map)
486 +{
487 + int i;
488 +
489 + for(i = 0;i <num_gpios ;i+=32)
490 + {
491 + int index = i/32;
492 + avalanche_gpio_out_value(set_map[index],pos_map[index],index);
493 +
494 + }
495 +
496 +}
497 +
498 +
499 +static MODULE_INSTANCE_T *get_module (char *name, int instance)
500 +{
501 + int module_id;
502 + MODULE_INSTANCE_T *mod_inst;
503 +
504 +
505 + if (instance >= MAX_MODULE_INSTANCES)
506 + return NULL;
507 +
508 + for (module_id = 0; module_id < MAX_MODULE_ENTRIES; module_id++)
509 + {
510 + if (modules[module_id]
511 + && !os_strcmp (name, modules[module_id]->name))
512 + break;
513 + }
514 +
515 + if (module_id == MAX_MODULE_ENTRIES)
516 + {
517 + for (module_id = 0;
518 + (module_id < MAX_MODULE_ENTRIES) && modules[module_id];
519 + module_id++);
520 +
521 + if (module_id < MAX_MODULE_ENTRIES)
522 + {
523 + modules[module_id] = led_malloc (sizeof (MODULE_ENTRY_T));
524 +
525 + if (!modules[module_id])
526 + return NULL;
527 +
528 + modules[module_id]->name = led_malloc (os_strlen (name) + 1);
529 +
530 + if (!modules[module_id]->name)
531 + return NULL;
532 +
533 + os_strcpy (modules[module_id]->name, name);
534 + }
535 + else
536 + {
537 + log_msg ("ERROR:Module Count exceeded\n");
538 + return NULL;
539 + }
540 + }
541 +
542 + if (!modules[module_id]->module_instance[instance])
543 + modules[module_id]->module_instance[instance] =
544 + led_malloc (sizeof (MODULE_INSTANCE_T));
545 +
546 + if (!modules[module_id]->module_instance[instance])
547 + return NULL;
548 +
549 + mod_inst = modules[module_id]->module_instance[instance];
550 + mod_inst->module_id = module_id;
551 + mod_inst->instance = instance;
552 +
553 + return mod_inst;
554 +}
555 +
556 +
557 +static void assign_map(int *to, int *from)
558 +{
559 + int i;
560 +
561 + for(i = 0;i <num_gpios ;i+=32)
562 + {
563 + int index = i/32;
564 + to[index] = from[index];
565 + }
566 +}
567 +
568 +
569 +
570 +
571 +static LED_OBJ_T *get_led (int * pos_map)
572 +{
573 + int led_id;
574 +
575 + for (led_id = 0; led_id < MAX_LED_ENTRIES; led_id++)
576 + {
577 + if (leds[led_id])
578 + {
579 + int i;
580 + int flag=0;
581 +
582 + for(i = 0;i <num_gpios ;i+=32)
583 + {
584 + int index = i/32;
585 + if(leds[led_id]->pos_map[index] != pos_map[index])
586 + flag =1;
587 + }
588 + if(flag == 0)
589 + break;
590 + }
591 + }
592 +
593 + if (led_id == MAX_LED_ENTRIES)
594 + {
595 + for (led_id = 0; (led_id < MAX_LED_ENTRIES) && leds[led_id];
596 + led_id++);
597 +
598 + if (led_id < MAX_LED_ENTRIES)
599 + {
600 + leds[led_id] = led_malloc (sizeof (LED_OBJ_T));
601 +
602 + if (!leds[led_id])
603 + return NULL;
604 +
605 + assign_map(leds[led_id]->pos_map,pos_map);
606 + }
607 + else
608 + {
609 + log_msg ("ERROR:Module Count exceeded\n");
610 + return NULL;
611 + }
612 + }
613 +
614 + return leds[led_id];
615 +}
616 +
617 +static void led_oneshot_on_timer_func (int arg)
618 +{
619 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
620 + LED_OBJ_T *led = state->led;
621 +
622 + state->timer_running = 0;
623 + MUTEX_GET (led_lock);
624 + if (led->state == LED_ONESHOT_ON)
625 + {
626 + led->state = LED_OFF;
627 + avalanche_gpio_set (state->map2,led->pos_map);
628 + }
629 + MUTEX_RELEASE (led_lock);
630 +
631 +}
632 +
633 +static void led_oneshot_off_timer_func (int arg)
634 +{
635 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
636 + LED_OBJ_T *led = state->led;
637 +
638 + state->timer_running = 0;
639 +
640 + MUTEX_GET (led_lock);
641 + if (led->state == LED_ONESHOT_OFF)
642 + {
643 + led->state = LED_ON;
644 + avalanche_gpio_set(state->map2,led->pos_map);
645 + }
646 + MUTEX_RELEASE (led_lock);
647 +
648 +}
649 +
650 +static void led_flash_timer_func (int arg)
651 +{
652 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
653 + LED_OBJ_T *led = state->led;
654 +
655 +
656 + if (led->state != LED_FLASH)
657 + return;
658 +
659 + MUTEX_GET (led_lock);
660 +
661 + if (state->timer_running == 1)
662 + {
663 + state->timer_running = 2;
664 + avalanche_gpio_set(state->map2,led->pos_map);
665 + os_timer_add (state->os_timer, state->param2, (int)state);
666 + }
667 + else
668 + {
669 + state->timer_running = 1;
670 + avalanche_gpio_set(state->map1,led->pos_map);
671 + os_timer_add (state->os_timer, state->param1, (int)state);
672 + }
673 +
674 + MUTEX_RELEASE (led_lock);
675 +}
676 +
677 +static void led_on(STATE_ENTRY_T * state)
678 +{
679 + LED_OBJ_T *led = state->led;
680 +
681 + led->state = LED_ON;
682 + avalanche_gpio_set(state->map1,led->pos_map);
683 + led->module_map |= (1 << (state->module_id));
684 +
685 +}
686 +
687 +static void led_off (STATE_ENTRY_T * state)
688 +{
689 + LED_OBJ_T *led = state->led;
690 +
691 + led->module_map &= ~(1 << (state->module_id));
692 + if (!led->module_map)
693 + {
694 + led->state = LED_OFF;
695 + avalanche_gpio_set(state->map1,led->pos_map);
696 + }
697 +
698 +}
699 +
700 +static void led_oneshot_on (STATE_ENTRY_T * state)
701 +{
702 + LED_OBJ_T *led = state->led;
703 +
704 + if (state->timer_running)
705 + return;
706 +
707 + state->timer_running = 1;
708 + led->state = LED_ONESHOT_ON;
709 + avalanche_gpio_set(state->map1,led->pos_map);
710 + os_timer_add (state->os_timer, state->param1,(int) state);
711 +}
712 +
713 +static void led_oneshot_off (STATE_ENTRY_T * state)
714 +{
715 +
716 + LED_OBJ_T *led = state->led;
717 +
718 + if (state->timer_running)
719 + return;
720 +
721 + state->timer_running = 1;
722 + led->state = LED_ONESHOT_OFF;
723 + avalanche_gpio_set(state->map1,led->pos_map);
724 + os_timer_add (state->os_timer, state->param1,(int) state);
725 +}
726 +
727 +static void led_flash (STATE_ENTRY_T * state)
728 +{
729 + LED_OBJ_T *led = state->led;
730 +
731 + if (state->timer_running)
732 + return;
733 +
734 + state->timer_running = 1;
735 + led->state = LED_FLASH;
736 + avalanche_gpio_set(state->map1,led->pos_map);
737 + os_timer_add (state->os_timer, state->param1,(int) state);
738 +}
739 +
740 +
741 +
742 +static int led_get_mode(LED_CONFIG_T *led_cfg)
743 +{
744 + int num_gpio = led_cfg->gpio_num;
745 + int i;
746 + int *led_mode = led_cfg->mode;
747 + int max = -1;
748 +
749 + /* Return Max of available modes */
750 + for(i = 0; i<num_gpio; i++)
751 + {
752 + max = (max > led_mode[i]) ? max : led_mode[i];
753 + }
754 +
755 + return max;
756 +}
757 +
758 +static void led_assign_timer(STATE_ENTRY_T *state_entry)
759 +{
760 +
761 + if (state_entry->os_timer)
762 + {
763 + os_timer_delete(state_entry->os_timer);
764 + }
765 +
766 + switch(state_entry->mode)
767 + {
768 + case LED_ONESHOT_ON:
769 + state_entry->os_timer = os_timer_init(led_oneshot_on_timer_func);
770 + break;
771 +
772 + case LED_ONESHOT_OFF:
773 + state_entry->os_timer = os_timer_init(led_oneshot_off_timer_func);
774 + break;
775 +
776 + case LED_FLASH:
777 + state_entry->os_timer = os_timer_init(led_flash_timer_func);
778 + break;
779 +
780 + default:
781 + log_msg("invalid mode in function led_assign timer\n");
782 + }
783 +
784 +}
785 +
786 +static int led_get_map(LED_CONFIG_T *led_cfg,int *p_pos_map,int *p_map1,int *p_map2)
787 +{
788 + int i;
789 + int map1[2] = {0,0};
790 + int pos_map[2] = {0,0};
791 + int map2[2] = {0,0};
792 + int requires_timer = REQUIRES_TIMER(led_get_mode(led_cfg));
793 +
794 + for (i = 0; i < led_cfg->gpio_num; i++)
795 + {
796 + int gpio_map;
797 + int index = led_cfg->gpio[i]/32;
798 + int pos = led_cfg->gpio[i] % 32;
799 +
800 + if (led_cfg->gpio[i] >= num_gpios)
801 + {
802 + log_msg ("Error: gpio number out of range\n");
803 + return -1;
804 + }
805 +
806 + gpio_map = 1 << pos;
807 +
808 + pos_map[index] |= gpio_map;
809 +
810 +
811 + switch (led_cfg->mode[i])
812 + {
813 + case LED_OFF:
814 + if(gpio_offstate_map[index] & gpio_map)
815 + map1[index] |= gpio_map;
816 +
817 + if (requires_timer && (gpio_offstate_map[index] & gpio_map))
818 + map2[index] |= gpio_map;
819 + break;
820 +
821 + case LED_ON:
822 +
823 + if(!(gpio_offstate_map[index] & gpio_map))
824 + map1[index] |= gpio_map;
825 +
826 + if (requires_timer && !(gpio_offstate_map[index] & gpio_map))
827 + map2[index] |= gpio_map;
828 + break;
829 +
830 + case LED_ONESHOT_OFF:
831 +
832 + if ((gpio_offstate_map[index] & gpio_map))
833 + map1[index] |= gpio_map;
834 + else
835 + map2[index] |= gpio_map;
836 + break;
837 +
838 + case LED_ONESHOT_ON:
839 + case LED_FLASH:
840 +
841 + if (!(gpio_offstate_map[index] & gpio_map))
842 + map1[index] |= gpio_map;
843 + else
844 + map2[index] |= gpio_map;
845 + break;
846 +
847 + default:
848 + log_msg ("Error: Invalid mode\n");
849 + return -1;
850 + }
851 + }
852 +
853 + assign_map(p_pos_map,pos_map);
854 + assign_map(p_map1,map1);
855 + assign_map(p_map2,map2);
856 +
857 + return 0;
858 +}
859 +
860 +
861 +
862 +
863 +static int configure_state(STATE_ENTRY_T *state_entry,LED_CONFIG_T *led_cfg)
864 +{
865 +// int state = led_cfg->state;
866 + int i;
867 + int map1[2] ;
868 + int pos_map[2];
869 + int map2[2];
870 +
871 + if((state_entry->mode = led_get_mode(led_cfg)) >= NUM_LED_MODES)
872 + {
873 + log_msg ("Error: Invalid mode in func configure_state\n");
874 + return -1;
875 + }
876 +
877 + state_entry->handler = led_mode_handler[state_entry->mode];
878 +
879 +
880 + if(led_get_map(led_cfg,pos_map,map1,map2))
881 + {
882 + log_msg ("Error: gpio number out of range\n");
883 + return -1;
884 + }
885 +
886 + assign_map(state_entry->map1,map1);
887 + assign_map(state_entry->map2,map2);
888 + state_entry->led = get_led(pos_map);
889 +
890 + /* Check if the state requires timer */
891 + if(REQUIRES_TIMER(state_entry->mode))
892 + {
893 + state_entry->timer_running = 0;
894 + state_entry->param1 = led_cfg->param1;
895 + state_entry->param2 = led_cfg->param2;
896 + led_assign_timer(state_entry);
897 + }
898 +
899 + /* enable gpio pins */
900 + for(i = 0;i<led_cfg->gpio_num;i++)
901 + {
902 + int value;
903 + int index;
904 + int pos;
905 + avalanche_gpio_ctrl (led_cfg->gpio[i],GPIO_PIN,GPIO_OUTPUT_PIN);
906 +
907 + /* Turn off the led */
908 + index = led_cfg->gpio[i]/32;
909 + pos = led_cfg->gpio[i] % 32;
910 + value = (gpio_offstate_map[index] & (1 << pos))?1:0;
911 + avalanche_gpio_out_bit(led_cfg->gpio[i],value);
912 + }
913 +
914 + return 0;
915 +}
916 +
917 +
918 +static void free_all_states(void)
919 +{
920 + int module_id;
921 +
922 + for(module_id = 0; module_id < MAX_MODULE_ENTRIES; module_id++)
923 + {
924 + if(modules[module_id])
925 + {
926 + int i;
927 + for(i = 0; i< MAX_MODULE_INSTANCES; i++)
928 + {
929 + MODULE_INSTANCE_T *module_instance = modules[module_id]->module_instance[i];
930 +
931 + if(module_instance)
932 + {
933 + int state_id;
934 +
935 + for(state_id =0; state_id < MAX_STATE_ENTRIES; state_id++)
936 + {
937 + STATE_ENTRY_T *state= module_instance->states[state_id];
938 +
939 + if(state)
940 + {
941 + if(state->os_timer)
942 + os_timer_delete(state->os_timer);
943 +
944 + os_free(state);
945 + module_instance->states[state_id] = NULL;
946 + }
947 +
948 + }
949 + }
950 +
951 + }
952 + os_free(modules[module_id]->name);
953 + os_free(modules[module_id]);
954 + modules[module_id] = NULL;
955 + }
956 + }
957 +}
958 +
959 +/***********************************HAL APIS************************************/
960 +
961 +/**************************************************************************
962 + * FUNCTION NAME : avalanche_led_hal_init
963 + **************************************************************************
964 + * DESCRIPTION :
965 + * The function initializes led hal module
966 + *
967 + * RETURNS :
968 + * 0 on Success
969 + * Negative value on Error
970 + ***************************************************************************/
971 +
972 +
973 +int avalanche_led_hal_init (int *gpio_off_value, int num_gpio_pins)
974 +{
975 + //int i;
976 +
977 + num_gpios = num_gpio_pins + 4;
978 + assign_map(gpio_offstate_map, gpio_off_value);
979 +
980 + MUTEX_INIT (led_lock);
981 +
982 + /* initialize led state function handlers */
983 + led_mode_handler[LED_ON] = led_on;
984 + led_mode_handler[LED_OFF] = led_off;
985 + led_mode_handler[LED_ONESHOT_ON] = led_oneshot_on;
986 + led_mode_handler[LED_ONESHOT_OFF] = led_oneshot_off;
987 + led_mode_handler[LED_FLASH] = led_flash;
988 +
989 + return 0;
990 +}
991 +
992 +
993 +/**************************************************************************
994 + * FUNCTION NAME : avalanche_led_config_set
995 + **************************************************************************
996 + * DESCRIPTION :
997 + * The function configures LED state object
998 + *
999 + * RETURNS :
1000 + * 0 on Success
1001 + * Negative value on Error
1002 + ***************************************************************************/
1003 +
1004 +int avalanche_led_config_set(LED_CONFIG_T * led_cfg)
1005 +{
1006 + MODULE_INSTANCE_T *module;
1007 + MUTEX_GET (led_lock);
1008 + module = get_module (led_cfg->name, led_cfg->instance);
1009 +
1010 + if (!module)
1011 + goto config_failed;
1012 +
1013 + if (led_cfg->state < MAX_STATE_ENTRIES)
1014 + {
1015 + int state = led_cfg->state;
1016 +
1017 + if (!(module->states[state]))
1018 + {
1019 + module->states[state] = led_malloc (sizeof (STATE_ENTRY_T));
1020 + }
1021 +
1022 + if (!(module->states[state]))
1023 + goto config_failed;
1024 +
1025 + module->states[state]->module_id = module->module_id;
1026 +
1027 + if(configure_state(module->states[state],led_cfg))
1028 + {
1029 + os_free(module->states[state]);
1030 + module->states[state] = NULL;
1031 + goto config_failed;
1032 + }
1033 +
1034 + }
1035 + else
1036 + {
1037 + log_msg ("ERROR:State Count exceeded\n");
1038 + goto config_failed;
1039 + }
1040 +
1041 + MUTEX_RELEASE (led_lock);
1042 + return 0;
1043 +
1044 + config_failed:
1045 +
1046 + MUTEX_RELEASE (led_lock);
1047 + return -1;
1048 +
1049 +}
1050 +
1051 +/**************************************************************************
1052 + * FUNCTION NAME : avalanche_led_register
1053 + **************************************************************************
1054 + * DESCRIPTION :
1055 + * The function creates handle to the given module and returns it.
1056 + *
1057 + * RETURNS :
1058 + * Handle to the module instance on success.
1059 + * NULL on failure.
1060 + ***************************************************************************/
1061 +
1062 +void *avalanche_led_register (const char *mod_name, int instance)
1063 +{
1064 + void *p;
1065 + MUTEX_GET (led_lock);
1066 + p = (void *)get_module ((char *)mod_name, instance);
1067 + MUTEX_RELEASE (led_lock);
1068 + return p;
1069 +}
1070 +
1071 +
1072 +/**************************************************************************
1073 + * FUNCTION NAME : avalanche_led_action
1074 + **************************************************************************
1075 + * DESCRIPTION :
1076 + * The function triggers action on LED
1077 + *
1078 + ***************************************************************************/
1079 +
1080 +void avalanche_led_action (void *module, int state_id)
1081 +{
1082 +
1083 + MUTEX_GET (led_lock);
1084 + if (module && (state_id < MAX_STATE_ENTRIES))
1085 + {
1086 +
1087 + STATE_ENTRY_T *state =
1088 + ((MODULE_INSTANCE_T *) (module))->states[state_id];
1089 + if (state)
1090 + {
1091 + state->handler (state);
1092 + }
1093 + }
1094 + MUTEX_RELEASE (led_lock);
1095 + return;
1096 +}
1097 +
1098 +
1099 +/**************************************************************************
1100 + * FUNCTION NAME : avalanche_led_unregister
1101 + **************************************************************************
1102 + * DESCRIPTION :
1103 + * The function unregisters the module
1104 + *
1105 + * RETURNS :
1106 + * 0 on Success
1107 + * Negative value on Error
1108 + ***************************************************************************/
1109 +
1110 +int avalanche_led_unregister (void *mod_inst)
1111 +{
1112 +
1113 + return 0;
1114 +}
1115 +
1116 +
1117 +/**************************************************************************
1118 + * FUNCTION NAME : led_free_all
1119 + **************************************************************************
1120 + * DESCRIPTION :
1121 + * The function frees the memory allocated for holding state
1122 + * configuration data
1123 + *
1124 + ***************************************************************************/
1125 +
1126 +void avalanche_led_free_all()
1127 +{
1128 + free_all_states();
1129 +}
1130 +
1131 +/**************************************************************************
1132 + * FUNCTION NAME : avalanche_led_hal_exit
1133 + **************************************************************************
1134 + * DESCRIPTION :
1135 + * The function releases all the allocated memory
1136 + *
1137 + ***************************************************************************/
1138 +
1139 +void avalanche_led_hal_exit ()
1140 +{
1141 + free_all_states();
1142 +}
1143 +
1144 +/*****************************************************************************
1145 + * FUNCTION NAME : avalanche_led_config_get
1146 + *****************************************************************************
1147 + * DESCRIPTION :
1148 + * The function returns configuration information corresponding to module
1149 + * state.
1150 + *
1151 + * RETURNS :
1152 + * 0 on Success
1153 + * Negative value on Error
1154 + ***************************************************************************/
1155 +int avalanche_led_config_get(LED_CONFIG_T *led_cfg,int module_id,int instance, int state_id)
1156 +{
1157 + if(module_id == -1)
1158 + {
1159 + /* The module info is passed through field of led_cfg */
1160 + MODULE_INSTANCE_T *mod = get_module (led_cfg->name, instance);
1161 + if(mod)
1162 + module_id = mod->module_id;
1163 +
1164 + }
1165 + if(module_id >= MAX_MODULE_ENTRIES || module_id < 0)
1166 + return -1;
1167 +
1168 + if(state_id >= MAX_STATE_ENTRIES || module_id < 0)
1169 + return -1;
1170 +
1171 + if(instance >= MAX_MODULE_INSTANCES || module_id < 0)
1172 + return -1;
1173 +
1174 + if(modules[module_id])
1175 + {
1176 + MODULE_INSTANCE_T *module = modules[module_id]->module_instance[instance];
1177 + if(module)
1178 + {
1179 + STATE_ENTRY_T *state = module->states[state_id];
1180 + if(state)
1181 + {
1182 + int i;
1183 + LED_OBJ_T *led;
1184 + strcpy(led_cfg->name, modules[module_id]->name);
1185 + led_cfg->state = state_id;
1186 + led_cfg->instance = instance;
1187 + led_cfg->param1 = state->param1;
1188 + led_cfg->param2 = state->param2;
1189 + led_cfg->mode[0] = state->mode;
1190 + led = state->led;
1191 +
1192 + /* needs to be modified for multi-pin leds */
1193 + for(i = 0;i < num_gpios && !(led->pos_map[i/32] & (1 << i)); i++);
1194 +
1195 + led_cfg->gpio[0] = i;
1196 + led_cfg->gpio_num = 1;
1197 +
1198 + return 0;
1199 + }
1200 + }
1201 + }
1202 +
1203 + return -1;
1204 +}
1205 diff -urN kernel-old/drivers/char/avalanche_led/led_hal.h kernel-current/drivers/char/avalanche_led/led_hal.h
1206 --- kernel-old/drivers/char/avalanche_led/led_hal.h 1970-01-01 01:00:00.000000000 +0100
1207 +++ kernel-current/drivers/char/avalanche_led/led_hal.h 2005-07-10 18:03:46.120957200 +0200
1208 @@ -0,0 +1,28 @@
1209 +/******************************************************************************
1210 + * FILE PURPOSE: - LED HAL module Header
1211 + ******************************************************************************
1212 + * FILE NAME: led_hal.h
1213 + *
1214 + * DESCRIPTION: LED HAL API's.
1215 + *
1216 + * REVISION HISTORY:
1217 + * 11 Oct 03 - PSP TII
1218 + *
1219 + * (C) Copyright 2002, Texas Instruments, Inc
1220 + *******************************************************************************/
1221 +
1222 +#ifndef __LED_HAL__
1223 +#define __LED_HAL__
1224 +
1225 +/* Interface prototypes */
1226 +
1227 +int avalanche_led_hal_init (int *gpio_off_value, int num_gpio_pins);
1228 +int avalanche_led_config_set (LED_CONFIG_T * led_cfg);
1229 +int avalanche_led_config_get (LED_CONFIG_T *led_cfg,int module_id,int instance, int state);
1230 +void *avalanche_led_register (const char *module_name, int instance_num);
1231 +void avalanche_led_action (void *handle, int state_id);
1232 +int avalanche_led_unregister (void *handle);
1233 +void avalanche_led_free_all(void);
1234 +void avalanche_led_hal_exit (void);
1235 +
1236 +#endif /*__LED_HAL__ */
1237 diff -urN kernel-old/drivers/char/avalanche_led/led_platform.h kernel-current/drivers/char/avalanche_led/led_platform.h
1238 --- kernel-old/drivers/char/avalanche_led/led_platform.h 1970-01-01 01:00:00.000000000 +0100
1239 +++ kernel-current/drivers/char/avalanche_led/led_platform.h 2005-07-10 18:03:46.120957200 +0200
1240 @@ -0,0 +1,117 @@
1241 +/******************************************************************************
1242 + * FILE PURPOSE: - LED Platform specific Header file
1243 + ******************************************************************************
1244 + * FILE NAME: led_platform.h
1245 + *
1246 + * DESCRIPTION: Linux specific implementation for OS abstracted function calls
1247 + * made by LED HAL module. This file has functions defined for
1248 + * Memory allocation calls, Mutex calls, String and Timer
1249 + * operations.
1250 + *
1251 + * REVISION HISTORY:
1252 + * 11 Oct 03 - PSP TII
1253 + *
1254 + * (C) Copyright 2002, Texas Instruments, Inc
1255 + *******************************************************************************/
1256 +
1257 +#ifndef __LED_PLATFORM__
1258 +#define __LED_PLATFORM__
1259 +
1260 +#include <linux/mm.h>
1261 +#include <linux/slab.h>
1262 +#include <asm/string.h>
1263 +#include <linux/param.h>
1264 +#include <linux/sched.h>
1265 +#include <linux/timer.h>
1266 +#include <linux/spinlock.h>
1267 +
1268 +
1269 +#define os_malloc(x) kmalloc(x,GFP_KERNEL)
1270 +#define os_memset memset
1271 +#define os_free(x) kfree(x)
1272 +#define os_strcmp os_strcasecmp
1273 +#define os_strcpy strcpy
1274 +
1275 +#if defined(DEBUG)
1276 +#define log_msg printk
1277 +#else
1278 +#define log_msg(x)
1279 +#endif
1280 +
1281 +/* defines for Mutex */
1282 +typedef struct {
1283 + spinlock_t lock;
1284 + int flags;
1285 +}OS_SPINLOCK_T;
1286 +
1287 +#define MUTEX_DECLARE(x) static OS_SPINLOCK_T x
1288 +#define MUTEX_INIT(x) x.lock = SPIN_LOCK_UNLOCKED
1289 +#define MUTEX_GET(x) spin_lock_irqsave(&x.lock, x.flags)
1290 +#define MUTEX_RELEASE(x) spin_unlock_irqrestore(&x.lock, x.flags)
1291 +
1292 +
1293 +
1294 +/* String handling functions not defined in asm/string.h */
1295 +static __inline__ int os_strlen(char *str)
1296 +{
1297 + int i;
1298 + for(i=0;str[i];i++);
1299 + return i;
1300 +}
1301 +
1302 +
1303 +#define LOWER(x) ((x < 'a') ? (x - 'A' + 'a'):(x))
1304 +#define ISALPHA(x) ((( x >= 'a') && (x <= 'z')) || (( x >= 'A') && (x <= 'Z')))
1305 +#define COMP(x,y) ((x == y) || ((ISALPHA(x) && ISALPHA(y)) && (LOWER(x) == LOWER(y))))
1306 +
1307 +
1308 +static __inline__ int os_strcasecmp(char *str1, char *str2)
1309 +{
1310 + int i;
1311 +
1312 + for(i=0;str1[i] && str2[i];i++)
1313 + {
1314 + char x,y;
1315 +
1316 + x = str1[i];
1317 + y = str2[i];
1318 +
1319 + if(!COMP(x,y))
1320 + break;
1321 + }
1322 +
1323 + return(str1[i] || str2[i]);
1324 +}
1325 +
1326 +
1327 +
1328 +/* Functions for timer related operations */
1329 +static __inline__ void * os_timer_init(void (*func)(int))
1330 +{
1331 + struct timer_list *ptimer;
1332 + ptimer = (struct timer_list *) kmalloc(sizeof(struct timer_list),GFP_KERNEL);
1333 + init_timer( ptimer );
1334 + (void *)ptimer->function = (void *)func;
1335 + return (void *)ptimer;
1336 +}
1337 +
1338 +static __inline__ int os_timer_add(void *timer_handle,int milisec,int arg)
1339 +{
1340 + struct timer_list *ptimer=timer_handle;
1341 + ptimer->expires = ((HZ * milisec)/1000) + jiffies;
1342 + ptimer->data = arg;
1343 + add_timer(ptimer);
1344 + return 0;
1345 +
1346 +}
1347 +
1348 +static __inline__ int os_timer_delete(void *timer_handle)
1349 +{
1350 + struct timer_list *ptimer=timer_handle;
1351 + del_timer(ptimer);
1352 + kfree(ptimer);
1353 + return 0;
1354 +}
1355 +
1356 +
1357 +#endif /* __LED_PLATFORM__ */
1358 diff -urN kernel-old/drivers/char/avalanche_led/led_wrapper.c kernel-current/drivers/char/avalanche_led/led_wrapper.c
1359 --- kernel-old/drivers/char/avalanche_led/led_wrapper.c 1970-01-01 01:00:00.000000000 +0100
1360 +++ kernel-current/drivers/char/avalanche_led/led_wrapper.c 2005-07-10 18:25:14.657069936 +0200
1361 @@ -0,0 +1,561 @@
1362 +/******************************************************************************
1363 + * FILE PURPOSE: - LED Wrapper file for DSL module support
1364 + ******************************************************************************
1365 + * FILE NAME: led_wrapper.c
1366 + *
1367 + * DESCRIPTION: LED Wrapper file for DSL module support
1368 + * This is to provide backward compatibility to the ADSL module
1369 + * using OLD LED driver. The numbers mapped for DSL LEDs in the
1370 + * previous implementation is 3,4,5,6. Since these numbers overlap
1371 + * with the existing numbering scheme, the following numbers need to
1372 + * be used in the led configuration file - 32,33,34,35.
1373 + *
1374 + * (C) Copyright 2002, Texas Instruments, Inc
1375 + *******************************************************************************/
1376 +#include <linux/config.h>
1377 +#include <linux/init.h>
1378 +#include <linux/module.h>
1379 +#include <asm/ar7/sangam.h>
1380 +#include "led_platform.h"
1381 +#include "led_config.h"
1382 +
1383 +#define BITS_PER_INT (8 * sizeof(int))
1384 +#define GPIOS_PER_INT BITS_PER_INT
1385 +#define GPIO_MAP_LEN ((MAX_GPIO_PIN_NUM + GPIOS_PER_INT -1)/GPIOS_PER_INT)
1386 +#define MODULE_MAP_LEN ((MAX_MODULE_ENTRIES + BITS_PER_INT -1)/BITS_PER_INT)
1387 +
1388 +
1389 +#define REQUIRES_TIMER(x) (x > 1)
1390 +
1391 +#define gpio_on(gpio) do \
1392 + { \
1393 + if(gpio >= 32 && adsl_led_objs[gpio - 32].onfunc) \
1394 + adsl_led_objs[gpio - 32].onfunc(adsl_led_objs[gpio - 32].param);\
1395 + } while(0)
1396 +
1397 +
1398 +
1399 +#define gpio_off(gpio) \
1400 + do \
1401 + { \
1402 + if(gpio >= 32 && adsl_led_objs[gpio - 32].offfunc) \
1403 + adsl_led_objs[gpio - 32].offfunc(adsl_led_objs[gpio - 32].param);\
1404 + } while(0)
1405 +
1406 +
1407 +
1408 +
1409 +
1410 +
1411 +/********************TYPEDEFS***********************************************/
1412 +
1413 +typedef struct gpio_module
1414 +{
1415 + volatile unsigned int *gpio_write_reg;
1416 + volatile unsigned int *gpio_dir_reg;
1417 + volatile unsigned int *gpio_mode_reg;
1418 +}GPIO_REGS_T;
1419 +
1420 +typedef struct {
1421 + unsigned int gpio_id;
1422 + unsigned int gpio_state;
1423 + int module_map[MODULE_MAP_LEN];
1424 +}GPIO_OBJ_T;
1425 +
1426 +
1427 +typedef struct state_entry STATE_ENTRY_T;
1428 +
1429 +struct state_entry{
1430 + unsigned int timer_running;
1431 + STATE_ENTRY_T *next;
1432 + void (*handler)(STATE_ENTRY_T *state);
1433 + GPIO_OBJ_T *gpio;
1434 + void *os_timer;
1435 + unsigned int param;
1436 + unsigned int module_id;
1437 + unsigned int mode;
1438 +};
1439 +
1440 +
1441 +typedef struct module_instance{
1442 + int module_id;
1443 + int instance;
1444 + STATE_ENTRY_T *states[MAX_STATE_ENTRIES];
1445 +}MODULE_INSTANCE_T;
1446 +
1447 +typedef struct module_entry{
1448 + unsigned char *name;
1449 + MODULE_INSTANCE_T *module_instance[MAX_MODULE_INSTANCES];
1450 +}MODULE_ENTRY_T;
1451 +
1452 +
1453 +
1454 +typedef struct led_reg{
1455 + unsigned int param;
1456 + void (*init)(unsigned long param);
1457 + void (*onfunc)(unsigned long param);
1458 + void (*offfunc)(unsigned long param);
1459 +}led_reg_t;
1460 +
1461 +
1462 +
1463 +/* Interface prototypes */
1464 +static int led_hal_init(GPIO_REGS_T gpio_mod, unsigned int *gpio_off_value,int num_gpio_pins);
1465 +static int avalanche_led_set_config(LED_CONFIG_T *led_cfg);
1466 +static void *avalanche_led_register(const char *module_name, int instance_num);
1467 +static int avalanche_led_action(void *handle,int state_id);
1468 +int avalanche_led_config_get (LED_CONFIG_T *led_cfg,int module_id,int instance, int state);
1469 +
1470 +led_reg_t adsl_led_objs[4];
1471 +MODULE_INSTANCE_T *dsl_mod = NULL;
1472 +static int gpio_off_state[GPIO_MAP_LEN] = AVALANCHE_GPIO_OFF_MAP;
1473 +
1474 +
1475 +
1476 +static unsigned int num_gpios;
1477 +static GPIO_OBJ_T *gpio_arr;
1478 +GPIO_REGS_T gpio_regs;
1479 +
1480 +/* GPIO OFF STATE */
1481 +static unsigned int gpio_off_val[GPIO_MAP_LEN];
1482 +
1483 +
1484 +MODULE_ENTRY_T *modules[MAX_MODULE_ENTRIES];
1485 +
1486 +/* LED handlers */
1487 +void (*led_mode_handler[NUM_LED_MODES])(STATE_ENTRY_T *state);
1488 +
1489 +
1490 +/******************static functions*****************************************/
1491 +static void *led_malloc(int n)
1492 +{
1493 + void *p;
1494 + p=kmalloc(n,GFP_ATOMIC);
1495 +
1496 + if(p)
1497 + os_memset(p,0,n);
1498 + return p;
1499 +}
1500 +
1501 +static void free_state(STATE_ENTRY_T *state)
1502 +{
1503 +
1504 + STATE_ENTRY_T *prev = NULL;
1505 + STATE_ENTRY_T *curr = NULL ;
1506 + while(curr != state)
1507 + {
1508 + curr = state;
1509 + prev = NULL;
1510 +
1511 + while(curr->next != NULL)
1512 + {
1513 + prev = curr;
1514 + curr = curr->next;
1515 + }
1516 +
1517 + os_free(curr);
1518 + if(prev)
1519 + {
1520 + prev->next = NULL;
1521 + }
1522 +
1523 + }
1524 +
1525 +}
1526 +
1527 +static MODULE_INSTANCE_T* get_module(char * name,int instance)
1528 +{
1529 + int module_id;
1530 + MODULE_INSTANCE_T *mod_inst;
1531 +
1532 + if(instance >= MAX_MODULE_INSTANCES)
1533 + return NULL;
1534 +
1535 + for(module_id=0;module_id <MAX_MODULE_ENTRIES;module_id++)
1536 + {
1537 + if(modules[module_id] && !os_strcmp(name,modules[module_id]->name))
1538 + break;
1539 + }
1540 +
1541 + if(module_id == MAX_MODULE_ENTRIES)
1542 + {
1543 + for(module_id = 0; (module_id < MAX_MODULE_ENTRIES) && modules[module_id] ; module_id++);
1544 +
1545 + if(module_id < MAX_MODULE_ENTRIES)
1546 + {
1547 + modules[module_id]=led_malloc(sizeof(MODULE_ENTRY_T));
1548 + modules[module_id]->name = led_malloc(os_strlen(name));
1549 + os_strcpy(modules[module_id]->name,name);
1550 + }
1551 + else
1552 + {
1553 + log_msg("ERROR:Module Count exceeded\n");
1554 + return NULL;
1555 + }
1556 + }
1557 +
1558 + if(!modules[module_id]->module_instance[instance])
1559 + modules[module_id]->module_instance[instance] = led_malloc(sizeof(MODULE_INSTANCE_T));
1560 +
1561 + mod_inst = modules[module_id]->module_instance[instance];
1562 + mod_inst->module_id = module_id;
1563 + mod_inst->instance = instance;
1564 +
1565 + return mod_inst;
1566 +}
1567 +
1568 +
1569 +static void led_timer_func(int arg)
1570 +{
1571 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
1572 + GPIO_OBJ_T *gpio;
1573 +
1574 +
1575 + gpio = state->gpio;
1576 +
1577 + switch(gpio->gpio_state)
1578 + {
1579 + case LED_ONESHOT_ON:
1580 + gpio->gpio_state = LED_OFF;
1581 + gpio_off(gpio->gpio_id);
1582 + break;
1583 +
1584 + case LED_ONESHOT_OFF:
1585 + gpio->gpio_state = LED_ON;
1586 + gpio_on(gpio->gpio_id);
1587 + break;
1588 +
1589 + case LED_FLASH:
1590 + {
1591 +
1592 + if(state->timer_running == 1)
1593 + {
1594 + state->timer_running = 2;
1595 + gpio_off(gpio->gpio_id);
1596 + os_timer_add(state->os_timer,(state->param >> 16),(int)state);
1597 + }
1598 + else
1599 + {
1600 + state->timer_running = 1;
1601 + gpio_on(gpio->gpio_id);
1602 + os_timer_add(state->os_timer, (state->param & 0xffff),(int)state);
1603 + }
1604 + return;
1605 + }
1606 + default:
1607 + break;
1608 +
1609 + }
1610 +
1611 + state->timer_running = 0;
1612 +
1613 +
1614 +}
1615 +
1616 +
1617 +static void led_on(STATE_ENTRY_T *state)
1618 +{
1619 + int mod_index = state->module_id >> 5;
1620 + GPIO_OBJ_T *gpio = state->gpio;
1621 +
1622 + gpio->gpio_state = LED_ON;
1623 + gpio_on(gpio->gpio_id);
1624 + gpio->module_map[mod_index] |= (1 << (state->module_id % BITS_PER_INT));
1625 +
1626 +}
1627 +
1628 +static void led_off(STATE_ENTRY_T *state)
1629 +{
1630 +
1631 + int mod_index = state->module_id >> 5;
1632 + GPIO_OBJ_T *gpio = state->gpio;
1633 +
1634 + gpio->module_map[mod_index] &= ~(1 << (state->module_id % BITS_PER_INT) );
1635 + if(!gpio->module_map[mod_index])
1636 + {
1637 + gpio->gpio_state = LED_OFF;
1638 + gpio_off(gpio->gpio_id);
1639 + }
1640 +
1641 +}
1642 +
1643 +static void led_oneshot_on(STATE_ENTRY_T *state)
1644 +{
1645 + GPIO_OBJ_T *gpio = state->gpio;
1646 +
1647 + state->timer_running = 1;
1648 + gpio->gpio_state = LED_ONESHOT_ON;
1649 + gpio_on(gpio->gpio_id);
1650 + os_timer_add(state->os_timer,state->param,(int)state);
1651 +}
1652 +
1653 +static void led_oneshot_off(STATE_ENTRY_T *state)
1654 +{
1655 +
1656 + GPIO_OBJ_T *gpio = state->gpio;
1657 +
1658 + state->timer_running = 1;
1659 + gpio->gpio_state = LED_ONESHOT_OFF;
1660 + gpio_off(gpio->gpio_id);
1661 + os_timer_add(state->os_timer,state->param,(int)state);
1662 +}
1663 +
1664 +static void led_flash(STATE_ENTRY_T *state)
1665 +{
1666 +
1667 + GPIO_OBJ_T *gpio = state->gpio;
1668 +
1669 + state->timer_running = 1;
1670 + gpio->gpio_state = LED_FLASH;
1671 + gpio_on(gpio->gpio_id);
1672 + os_timer_add(state->os_timer,(state->param & 0xffff),(int)state);
1673 +}
1674 +
1675 +
1676 +/****************HAL APIS***********************************************/
1677 +int led_hal_init(GPIO_REGS_T gpio_reg,unsigned int *gpio_off_value,int num_gpio_pins)
1678 +{
1679 + int i;
1680 + unsigned int *p_gpio=gpio_off_val;
1681 +
1682 + gpio_regs = gpio_reg;
1683 + num_gpios = num_gpio_pins;
1684 +
1685 + gpio_arr = led_malloc((num_gpio_pins + 4) * sizeof(GPIO_OBJ_T)); /* 4 added for ADSL gpio pins */
1686 +
1687 + /* get gpios off state */
1688 + for(i=0; i < num_gpio_pins; i+=GPIOS_PER_INT)
1689 + {
1690 + *p_gpio = *gpio_off_value;
1691 + gpio_off_value++;
1692 + p_gpio++;
1693 + }
1694 +
1695 + /* initialize gpio objects */
1696 + for(i=0; i<num_gpio_pins + 4;i++) /* 4 added for ADSL gpio pins */
1697 + {
1698 + gpio_arr[i].gpio_id = i;
1699 + }
1700 +
1701 +
1702 +
1703 + /* initialize led state function handlers */
1704 + led_mode_handler[LED_ON] = led_on;
1705 + led_mode_handler[LED_OFF] = led_off;
1706 + led_mode_handler[LED_ONESHOT_ON] = led_oneshot_on;
1707 + led_mode_handler[LED_ONESHOT_OFF] = led_oneshot_off;
1708 + led_mode_handler[LED_FLASH] = led_flash;
1709 +
1710 +
1711 + return 0;
1712 +}
1713 +
1714 +
1715 + /*********************************************************/
1716 +
1717 +int avalanche_led_set_config(LED_CONFIG_T *led_cfg)
1718 +{
1719 + MODULE_INSTANCE_T *module;
1720 + module = get_module(led_cfg->name,led_cfg->instance);
1721 +
1722 + if(!module )
1723 + goto config_failed;
1724 +
1725 + if(led_cfg->state < MAX_STATE_ENTRIES)
1726 + {
1727 + STATE_ENTRY_T *state_entry;
1728 + int state=led_cfg->state;
1729 + int i;
1730 +
1731 + if(!(module->states[state]))
1732 + {
1733 + module->states[state] = led_malloc(sizeof(STATE_ENTRY_T));
1734 + }
1735 +
1736 + state_entry = module->states[state];
1737 +
1738 + for(i=0;i<led_cfg->gpio_num;i++)
1739 + {
1740 + if(led_cfg->gpio[i] >= (num_gpios + 4) ) /* 4 added for ADSL */
1741 + {
1742 + log_msg("Error: gpio number out of range\n");
1743 + goto config_failed;
1744 + }
1745 +
1746 + state_entry->gpio = &gpio_arr[led_cfg->gpio[i]];
1747 + state_entry->mode = led_cfg->mode[i];
1748 + state_entry->module_id = module->module_id;
1749 + state_entry->handler = led_mode_handler[state_entry->mode];
1750 + state_entry->timer_running = 0;
1751 +
1752 + if(REQUIRES_TIMER(led_cfg->mode[i])) /* requires timer */
1753 + {
1754 +
1755 + state_entry->param = led_cfg->param1;
1756 +
1757 + if(led_cfg->mode[i] == LED_FLASH)
1758 + state_entry->param |= (led_cfg->param2 << 16);
1759 +
1760 + if(!(state_entry->os_timer))
1761 + state_entry->os_timer = os_timer_init(led_timer_func);
1762 + }
1763 +
1764 + if(i == led_cfg->gpio_num - 1)
1765 + {
1766 + free_state(state_entry->next);
1767 + state_entry->next = NULL;
1768 + break;
1769 + }
1770 +
1771 +
1772 + /* allocate next node */
1773 + else if( !(state_entry->next))
1774 + {
1775 + state_entry->next = led_malloc(sizeof(STATE_ENTRY_T));
1776 + }
1777 +
1778 + state_entry = state_entry->next;
1779 +
1780 +
1781 + }
1782 +
1783 + }
1784 + else
1785 + {
1786 + log_msg("ERROR:State Count exceeded\n");
1787 + goto config_failed;
1788 + }
1789 +
1790 + return 0;
1791 +
1792 + config_failed:
1793 +
1794 + return -1;
1795 +
1796 +
1797 +
1798 +}
1799 +
1800 + /*********************************************************/
1801 +
1802 +void *avalanche_led_register(const char * mod_name,int instance)
1803 +{
1804 + void *p;
1805 + p = get_module((void * )mod_name,instance);
1806 + return p;
1807 + }
1808 +
1809 +
1810 +int avalanche_led_action(void *module, int state_id)
1811 +{
1812 +
1813 + if(module && state_id < MAX_STATE_ENTRIES)
1814 + {
1815 +
1816 + STATE_ENTRY_T *state =((MODULE_INSTANCE_T *)(module))->states[state_id];
1817 + while(state)
1818 + {
1819 + if(state->timer_running == 0)
1820 + {
1821 + state->handler(state);
1822 + }
1823 + state = state->next;
1824 +
1825 + }
1826 + }
1827 + return 0;
1828 +}
1829 +
1830 +
1831 +
1832 +int led_get_dsl_config(void)
1833 +{
1834 +
1835 + int state_id = 0;
1836 + LED_CONFIG_T led_cfg;
1837 + int state_count = 0;
1838 +
1839 + os_strcpy(led_cfg.name,"adsl");
1840 +
1841 + for(state_id = 0; state_id < MAX_STATE_ENTRIES;state_id++)
1842 + {
1843 + if(avalanche_led_config_get(&led_cfg,-1,0,state_id) == 0)
1844 + {
1845 + /* call configure */
1846 + avalanche_led_set_config(&led_cfg);
1847 + state_count++;
1848 + }
1849 +
1850 + }
1851 + return state_count;
1852 +
1853 +
1854 +}
1855 +
1856 +
1857 +void register_led_drv(int led_num,led_reg_t *led)
1858 +{
1859 +
1860 + /* DSL leds are numbered from 3 to 6 */
1861 + int led_index = led_num - 3;
1862 +
1863 + if(led_index >=0 && led_index <= 2)
1864 + {
1865 + adsl_led_objs[led_index] = *led;
1866 +
1867 + if(adsl_led_objs[led_index].init)
1868 + adsl_led_objs[led_index].init(adsl_led_objs[led_index].param);
1869 + }
1870 +
1871 +}
1872 +
1873 +void deregister_led_drv( int led_num)
1874 +{
1875 + /* DSL leds are numbered from 3 to 6 */
1876 + int led_index = led_num - 3;
1877 +
1878 + if(led_index >=0 && led_index <= 2)
1879 + {
1880 + adsl_led_objs[led_index].onfunc = NULL;
1881 + adsl_led_objs[led_index].offfunc = NULL;
1882 + }
1883 + return;
1884 +}
1885 +
1886 +void led_operation(int mod,int state_id)
1887 +{
1888 + static int configured = 0;
1889 +
1890 + if(configured == 0)
1891 + {
1892 + configured = led_get_dsl_config();
1893 + }
1894 +
1895 + avalanche_led_action(dsl_mod,state_id);
1896 +}
1897 +
1898 +static int __init led_init(void)
1899 +{
1900 + GPIO_REGS_T gpio_regs;
1901 +
1902 + gpio_regs.gpio_write_reg = NULL;
1903 + gpio_regs.gpio_dir_reg = NULL;
1904 + gpio_regs.gpio_mode_reg = NULL;
1905 +
1906 + led_hal_init(gpio_regs,gpio_off_state,AVALANCHE_GPIO_PIN_COUNT);
1907 +
1908 + /* register instance 0 of adsl module */
1909 + dsl_mod = avalanche_led_register("adsl",0);
1910 + return 0;
1911 +
1912 +}
1913 +
1914 +__initcall(led_init);
1915 +
1916 +
1917 +
1918 +EXPORT_SYMBOL_NOVERS(led_init);
1919 +EXPORT_SYMBOL_NOVERS(led_operation);
1920 +EXPORT_SYMBOL_NOVERS(register_led_drv);
1921 +EXPORT_SYMBOL_NOVERS(deregister_led_drv);
1922 +
1923 diff -urN kernel-old/drivers/char/avalanche_led/Makefile kernel-current/drivers/char/avalanche_led/Makefile
1924 --- kernel-old/drivers/char/avalanche_led/Makefile 1970-01-01 01:00:00.000000000 +0100
1925 +++ kernel-current/drivers/char/avalanche_led/Makefile 2005-07-10 18:25:32.692328160 +0200
1926 @@ -0,0 +1,23 @@
1927 +# File: drivers/char/avalanche_led/Makefile
1928 +#
1929 +# Makefile for the Linux LED device driver.
1930 +#
1931 +
1932 +
1933 +O_TARGET := avalanche_led.o
1934 +obj-m := avalanche_led.o
1935 +list-multi := avalanche_led.o
1936 +
1937 +EXTRA_CFLAGS := -I$(TOPDIR)/include/asm/ar7
1938 +
1939 +export-objs := led_drv.o led_wrapper.o
1940 +
1941 +avalanche_led-objs := led_hal.o led_drv.o led_wrapper.o
1942 +
1943 +include $(TOPDIR)/Rules.make
1944 +
1945 +avalanche_led.o: $(avalanche_led-objs)
1946 + $(LD) -r -o $@ $(avalanche_led-objs)
1947 +
1948 +clean:
1949 + rm -f core *.o *.a *.s
1950 diff -urN kernel-old/drivers/char/Config.in kernel-current/drivers/char/Config.in
1951 --- kernel-old/drivers/char/Config.in 2005-07-10 02:55:18.318811000 +0200
1952 +++ kernel-current/drivers/char/Config.in 2005-07-10 18:03:46.121957048 +0200
1953 @@ -133,6 +133,10 @@
1954 fi
1955 fi
1956 fi
1957 +if [ "$CONFIG_AR7" = "y" ]; then
1958 + bool 'Enable LED support' CONFIG_MIPS_AVALANCHE_LED
1959 +fi
1960 +
1961 if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_ZORRO" = "y" ]; then
1962 tristate 'Commodore A2232 serial support (EXPERIMENTAL)' CONFIG_A2232
1963 fi
1964 diff -urN kernel-old/drivers/char/Makefile kernel-current/drivers/char/Makefile
1965 --- kernel-old/drivers/char/Makefile 2005-07-10 02:55:18.319811000 +0200
1966 +++ kernel-current/drivers/char/Makefile 2005-07-10 18:03:46.122956896 +0200
1967 @@ -190,6 +190,19 @@
1968 obj-$(CONFIG_PCI) += keyboard.o $(KEYMAP)
1969 endif
1970
1971 +#
1972 +# Texas Intruments LED driver
1973 +#
1974 +ifeq ($(CONFIG_MIPS_AVALANCHE_LED),y)
1975 +obj-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led/avalanche_led.o
1976 +subdir-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led
1977 +endif
1978 +
1979 +ifeq ($(CONFIG_MIPS_AVALANCHE_LED),m)
1980 +obj-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led/avalanche_led.o
1981 +subdir-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led
1982 +endif
1983 +
1984 obj-$(CONFIG_HIL) += hp_keyb.o
1985 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
1986 obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
1987 diff -urN kernel-old/include/asm-mips/ar7/ledapp.h kernel-current/include/asm-mips/ar7/ledapp.h
1988 --- kernel-old/include/asm-mips/ar7/ledapp.h 1970-01-01 01:00:00.000000000 +0100
1989 +++ kernel-current/include/asm-mips/ar7/ledapp.h 2005-07-10 18:49:37.556426688 +0200
1990 @@ -0,0 +1,59 @@
1991 +#ifndef __LED_APP__
1992 +#define __LED_APP__
1993 +
1994 +#define CONF_FILE "/etc/led.conf"
1995 +#define LED_PROC_FILE "/proc/led_mod/led"
1996 +
1997 +#define CONFIG_LED_MODULE
1998 +
1999 +#define MAX_MOD_ID 25
2000 +#define MAX_STATE_ID 25
2001 +#define MAX_LED_ID 25
2002 +
2003 +#define MOD_ADSL 1
2004 +#define DEF_ADSL_IDLE 1
2005 +#define DEF_ADSL_TRAINING 2
2006 +#define DEF_ADSL_SYNC 3
2007 +#define DEF_ADSL_ACTIVITY 4
2008 +
2009 +#define MOD_WAN 2
2010 +#define DEF_WAN_IDLE 1
2011 +#define DEF_WAN_NEGOTIATE 2
2012 +#define DEF_WAN_SESSION 3
2013 +
2014 +#define MOD_LAN 3
2015 +#define DEF_LAN_IDLE 1
2016 +#define DEF_LAN_LINK_UP 2
2017 +#define DEF_LAN_ACTIVITY 3
2018 +
2019 +#define MOD_WLAN 4
2020 +#define DEF_WLAN_IDLE 1
2021 +#define DEF_WLAN_LINK_UP 2
2022 +#define DEF_WLAN_ACTIVITY 3
2023 +
2024 +#define MOD_USB 5
2025 +#define DEF_USB_IDLE 1
2026 +#define DEF_USB_LINK_UP 2
2027 +#define DEF_USB_ACTIVITY 3
2028 +
2029 +#define MOD_ETH 6
2030 +#define DEF_ETH_IDLE 1
2031 +#define DEF_ETH_LINK_UP 2
2032 +#define DEF_ETH_ACTIVITY 3
2033 +
2034 +typedef struct config_elem{
2035 + unsigned char name;
2036 + unsigned char state;
2037 + unsigned char mode;
2038 + unsigned char led;
2039 + int param;
2040 +}config_elem_t;
2041 +
2042 +typedef struct led_reg{
2043 + unsigned int param;
2044 + void (*init)(unsigned long param);
2045 + void (*onfunc)(unsigned long param);
2046 + void (*offfunc)(unsigned long param);
2047 +}led_reg_t;
2048 +
2049 +#endif
2050 diff -urN kernel-old/include/asm-mips/ar7/led_config.h kernel-current/include/asm-mips/ar7/led_config.h
2051 --- kernel-old/include/asm-mips/ar7/led_config.h 1970-01-01 01:00:00.000000000 +0100
2052 +++ kernel-current/include/asm-mips/ar7/led_config.h 2005-07-10 18:03:46.122956896 +0200
2053 @@ -0,0 +1,51 @@
2054 +/******************************************************************************
2055 + * FILE PURPOSE: - LED config Header
2056 + ******************************************************************************
2057 + * FILE NAME: led_config.h
2058 + *
2059 + * DESCRIPTION: Header file for LED configuration parameters
2060 + * and data structures
2061 + *
2062 + * REVISION HISTORY:
2063 + * 11 Oct 03 - PSP TII
2064 + *
2065 + * (C) Copyright 2002, Texas Instruments, Inc
2066 + *******************************************************************************/
2067 +
2068 +
2069 +#ifndef __LED_CONFIG__
2070 +#define __LED_CONFIG__
2071 +
2072 +/* LED config parameters */
2073 +#define MAX_GPIO_PIN_NUM 64
2074 +#define MAX_GPIOS_PER_STATE 2
2075 +#define MAX_MODULE_ENTRIES 25
2076 +#define MAX_MODULE_INSTANCES 2
2077 +#define MAX_STATE_ENTRIES 25
2078 +#define NUM_LED_MODES 5
2079 +#define MAX_LED_ENTRIES 25
2080 +
2081 +
2082 +/* LED modes */
2083 +#define LED_OFF 0
2084 +#define LED_ON 1
2085 +#define LED_ONESHOT_OFF 2
2086 +#define LED_ONESHOT_ON 3
2087 +#define LED_FLASH 4
2088 +
2089 +
2090 +
2091 +/* Data structure for LED configuration */
2092 +typedef struct led_config{
2093 + unsigned char name[80];
2094 + unsigned int instance;
2095 + unsigned int state;
2096 + unsigned int gpio[MAX_GPIOS_PER_STATE];
2097 + unsigned int mode[MAX_GPIOS_PER_STATE];
2098 + unsigned int gpio_num;
2099 + unsigned int param1;
2100 + unsigned int param2;
2101 +}LED_CONFIG_T;
2102 +
2103 +
2104 +#endif /* __LED_CONFIG__ */
2105 diff -urN kernel-old/include/asm-mips/ar7/led_ioctl.h kernel-current/include/asm-mips/ar7/led_ioctl.h
2106 --- kernel-old/include/asm-mips/ar7/led_ioctl.h 1970-01-01 01:00:00.000000000 +0100
2107 +++ kernel-current/include/asm-mips/ar7/led_ioctl.h 2005-07-10 18:03:46.122956896 +0200
2108 @@ -0,0 +1,32 @@
2109 +/******************************************************************************
2110 + * FILE PURPOSE: - LED ioctl Header
2111 + ******************************************************************************
2112 + * FILE NAME: led_ioctl.h
2113 + *
2114 + * DESCRIPTION: Header file defining macros for ioctl commands.
2115 + *
2116 + * REVISION HISTORY:
2117 + * 11 Oct 03 - PSP TII
2118 + *
2119 + * (C) Copyright 2002, Texas Instruments, Inc
2120 + *******************************************************************************/
2121 +#ifndef __LED_IOCTL__
2122 +#define __LED_IOCTL__
2123 +
2124 +typedef struct led_mod{
2125 +unsigned char *name;
2126 +unsigned int instance;
2127 +unsigned int handle;
2128 +}LED_MODULE_T;
2129 +
2130 +typedef struct led_state{
2131 +unsigned int handle;
2132 +unsigned int state_id;
2133 +}LED_STATE_T;
2134 +
2135 +#define LED_CONFIG 0
2136 +#define LED_GET_HANDLE 1
2137 +#define LED_ACTION 2
2138 +#define LED_RELEASE_HANDLE 3
2139 +
2140 +#endif /* __LED_IOCTL__ */