1 diff -urN linux.dev/drivers/char/Config.in linux.dev2/drivers/char/Config.in
2 --- linux.dev/drivers/char/Config.in 2005-10-21 17:02:20.199991500 +0200
3 +++ linux.dev2/drivers/char/Config.in 2005-10-21 18:03:44.541778750 +0200
8 +if [ "$CONFIG_AR7" = "y" ]; then
9 + bool 'Enable LED support' CONFIG_AR7_LED
12 if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_ZORRO" = "y" ]; then
13 tristate 'Commodore A2232 serial support (EXPERIMENTAL)' CONFIG_A2232
15 diff -urN linux.dev/drivers/char/Makefile linux.dev2/drivers/char/Makefile
16 --- linux.dev/drivers/char/Makefile 2005-10-21 17:02:20.199991500 +0200
17 +++ linux.dev2/drivers/char/Makefile 2005-10-21 18:03:44.541778750 +0200
19 obj-$(CONFIG_PCI) += keyboard.o $(KEYMAP)
23 +# Texas Intruments LED driver
25 +obj-$(CONFIG_AR7_LED) += avalanche_led/avalanche_led.o
26 +subdir-$(CONFIG_AR7_LED) += avalanche_led
28 obj-$(CONFIG_HIL) += hp_keyb.o
29 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
30 obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
31 diff -urN linux.dev/drivers/char/avalanche_led/Makefile linux.dev2/drivers/char/avalanche_led/Makefile
32 --- linux.dev/drivers/char/avalanche_led/Makefile 1970-01-01 01:00:00.000000000 +0100
33 +++ linux.dev2/drivers/char/avalanche_led/Makefile 2005-10-21 18:03:44.513777000 +0200
35 +# File: drivers/char/avalanche_led/Makefile
37 +# Makefile for the Linux LED device driver.
41 +O_TARGET := avalanche_led.o
42 +obj-m := avalanche_led.o
43 +list-multi := avalanche_led.o
45 +EXTRA_CFLAGS := -I$(TOPDIR)/include/asm/ar7
47 +export-objs := ledmod.o leds.o
49 +avalanche_led-objs := ledmod.o gpio.o uartled.o leds.o
51 +include $(TOPDIR)/Rules.make
53 +avalanche_led.o: $(avalanche_led-objs)
54 + $(LD) -r -o $@ $(avalanche_led-objs)
57 + rm -f core *.o *.a *.s
58 diff -urN linux.dev/drivers/char/avalanche_led/gpio.c linux.dev2/drivers/char/avalanche_led/gpio.c
59 --- linux.dev/drivers/char/avalanche_led/gpio.c 1970-01-01 01:00:00.000000000 +0100
60 +++ linux.dev2/drivers/char/avalanche_led/gpio.c 2005-10-21 18:03:44.513777000 +0200
62 +#include <linux/kernel.h>
63 +#include <asm/uaccess.h>
64 +#include <linux/spinlock.h>
65 +#include <linux/proc_fs.h>
66 +#include <linux/fs.h>
67 +#include <linux/timer.h>
68 +#include <linux/module.h>
70 +#include <asm/ar7/tnetd73xx_err.h>
71 +#include <asm/ar7/tnetd73xx_misc.h>
72 +#include <asm/ar7/ledapp.h>
77 +#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
79 +#define AR7_RESET_FILE "led_mod/ar7reset"
80 +#define AR7_VERSION_FILE "led_mod/hardware_version"
81 +#define AR7_RESET_GPIO 11
82 +#define RESET_POLL_TIME 1
83 +#define RESET_HOLD_TIME 4
86 +static struct proc_dir_entry *reset_file;
87 +static int res_state = 0;
89 +static struct timer_list *pTimer = NULL;
90 +static ssize_t proc_read_reset_fops(struct file *filp,
91 + char *buf,size_t count , loff_t *offp);
93 +static ssize_t proc_read_hwversion_fops(struct file *filp,
94 + char *buf,size_t count , loff_t *offp);
96 +struct file_operations reset_fops = {
97 + read: proc_read_reset_fops
99 +struct file_operations hardware_version_fops = {
100 + read: proc_read_hwversion_fops
104 +static spinlock_t device_lock;
107 +static void gpio_led_on( unsigned long param )
109 + unsigned int flags;
111 + spin_lock_irqsave(&device_lock, flags);
113 + tnetd73xx_gpio_out(param,FALSE);
114 + spin_unlock_irqrestore(&device_lock, flags);
117 +static void gpio_led_off ( unsigned long param )
119 + unsigned int flags = 0x00;
121 + spin_lock_irqsave(&device_lock, flags);
123 + tnetd73xx_gpio_out(param,TRUE);
124 + spin_unlock_irqrestore(&device_lock, flags);
127 +static void gpio_led_init( unsigned long param)
129 + tnetd73xx_gpio_ctrl(param,GPIO_PIN,GPIO_OUTPUT_PIN);
132 +static void board_gpio_reset(void)
134 + /* Initialize the link mask */
135 + device_lock = SPIN_LOCK_UNLOCKED;
139 +#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
141 +static ssize_t proc_read_hwversion_fops(struct file *filp, char *buf,
142 + size_t count, loff_t *offp)
149 + len = sprintf(line, "%d%d.%d%d%d%d\n", tnetd73xx_gpio_in(20),
150 + tnetd73xx_gpio_in(21), tnetd73xx_gpio_in(22),
151 + tnetd73xx_gpio_in(23), tnetd73xx_gpio_in(24),
152 + tnetd73xx_gpio_in(25));
154 + copy_to_user(buf, line, len);
159 +static ssize_t proc_read_reset_fops(struct file *filp,
160 + char *buf,size_t count , loff_t *offp)
162 + char * pdata = NULL;
169 + len = sprintf(line,"%d\n", res_state );
172 + copy_to_user(buf,line,len );
177 +static void reset_timer_func(unsigned long data)
181 + count = (tnetd73xx_gpio_in(AR7_RESET_GPIO) == 0) ? count + 1: 0;
182 + if( count >= RESET_HOLD_TIME/RESET_POLL_TIME )
184 + if (tnetd73xx_gpio_in(AR7_RESET_GPIO) == 0)
188 + pTimer->expires = jiffies + HZ*RESET_POLL_TIME;
189 + add_timer (pTimer);
193 +static void hardware_version_init(void)
195 + static struct proc_dir_entry *hardware_version_file;
196 + hardware_version_file = create_proc_entry(AR7_VERSION_FILE, 0777, NULL);
197 + if(hardware_version_file == NULL)
200 + hardware_version_file->owner = THIS_MODULE;
201 + hardware_version_file->proc_fops = &hardware_version_fops;
203 + tnetd73xx_gpio_ctrl(20,GPIO_PIN,GPIO_INPUT_PIN);
204 + tnetd73xx_gpio_ctrl(21,GPIO_PIN,GPIO_INPUT_PIN);
205 + tnetd73xx_gpio_ctrl(22,GPIO_PIN,GPIO_INPUT_PIN);
206 + tnetd73xx_gpio_ctrl(23,GPIO_PIN,GPIO_INPUT_PIN);
207 + tnetd73xx_gpio_ctrl(24,GPIO_PIN,GPIO_INPUT_PIN);
208 + tnetd73xx_gpio_ctrl(25,GPIO_PIN,GPIO_INPUT_PIN);
213 +static void reset_init(void)
215 + /* Create board reset proc file */
216 + reset_file = create_proc_entry( AR7_RESET_FILE, 0777, NULL);
217 + if( reset_file == NULL)
219 + reset_file->owner = THIS_MODULE;
220 + reset_file->proc_fops = &reset_fops;
222 + /* Initialise GPIO 11 for input */
223 + tnetd73xx_gpio_ctrl(AR7_RESET_GPIO,GPIO_PIN,GPIO_INPUT_PIN);
225 + /* Create a timer which fires every seconds */
226 + pTimer = kmalloc(sizeof(struct timer_list),GFP_KERNEL);
227 + init_timer( pTimer );
228 + pTimer->function = reset_timer_func;
230 + /* Start the timer */
231 + reset_timer_func(0);
235 + remove_proc_entry("AR7_RESET_FILE",NULL);
239 +/*************wwzh****************/
241 +extern unsigned int sys_mod_state;
242 +extern unsigned int wan_mod_state;
243 +extern unsigned int wlan_mod_state;
244 +void sys_led_init(void)
246 + tnetd73xx_gpio_ctrl(4, GPIO_PIN, GPIO_OUTPUT_PIN);
247 + tnetd73xx_gpio_ctrl(5, GPIO_PIN, GPIO_OUTPUT_PIN);
248 + tnetd73xx_gpio_ctrl(8, GPIO_PIN, GPIO_OUTPUT_PIN);
250 + tnetd73xx_gpio_out(4, FALSE);
251 + tnetd73xx_gpio_out(5, TRUE);
252 + tnetd73xx_gpio_out(8, TRUE);
258 +void wan_led_init(void)
261 + tnetd73xx_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
262 + tnetd73xx_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
264 + tnetd73xx_gpio_out(2, FALSE);
265 + tnetd73xx_gpio_out(3, FALSE);
271 +void wlan_led_init(void)
273 + //unsigned long i = 0;
274 + tnetd73xx_gpio_ctrl(12, GPIO_PIN, GPIO_OUTPUT_PIN);
275 + tnetd73xx_gpio_ctrl(13, GPIO_PIN, GPIO_OUTPUT_PIN);
277 + tnetd73xx_gpio_out(12, FALSE);
278 + tnetd73xx_gpio_out(13, TRUE);
279 + //for (i = 0; i < 0x20000000; i++);
280 + wlan_mod_state = 1;
285 +/*************end ****************/
287 +void board_gpio_init(void)
290 + board_gpio_reset();
291 +/**************wwzh*************/
295 + //junzhao 2004.3.15
296 + hardware_version_init();
300 + /* Register Device MAX_LED_ID + 1 for reset to factory default */
302 + temp[0].init = reset_init;
303 + temp[0].onfunc = 0;
304 + temp[0].offfunc = 0;
305 + register_led_drv( MAX_LED_ID + 1 , &temp[0]);
306 +//wwzh for wireless led
308 + /* Register led 12 WiFi 6 */
310 + temp[1].init = gpio_led_init;
311 + temp[1].onfunc = gpio_led_on;
312 + temp[1].offfunc = gpio_led_off;
313 + register_led_drv( 12 , &temp[1]);
318 +/**************end ************/
319 +#if defined(CONFIG_AR5D01)
320 + /* Register led 1 GPIO0 */
321 + temp[0].param = GPIO_0;
322 + temp[0].init = gpio_led_init;
323 + temp[0].onfunc = gpio_led_on;
324 + temp[0].offfunc = gpio_led_off;
325 + register_led_drv( 1 , &temp[0]);
327 + /* Register led 2 EINT1 */
328 + temp[1].param = EINT_1;
329 + temp[1].init = gpio_led_init;
330 + temp[1].onfunc = gpio_led_on;
331 + temp[1].offfunc = gpio_led_off;
332 + register_led_drv( 2 , &temp[1]);
334 + /* Register led 5 EINT1 */
335 + temp[2].param = GPIO_1;
336 + temp[2].init = gpio_led_init;
337 + temp[2].onfunc = gpio_led_on;
338 + temp[2].offfunc = gpio_led_off;
339 + register_led_drv( 5 , &temp[2]);
342 +#if defined(CONFIG_AR5W01)
343 + /* Register led 5 GPIO_1 */
344 + temp[0].param = GPIO_1;
345 + temp[0].init = gpio_led_init;
346 + temp[0].onfunc = gpio_led_on;
347 + temp[0].offfunc = gpio_led_off;
348 + register_led_drv( 5 , &temp[0]);
350 + /* Register led 7 GPIO_0 */
351 + temp[1].param = GPIO_0;
352 + temp[1].init = gpio_led_init;
353 + temp[1].onfunc = gpio_led_on;
354 + temp[1].offfunc = gpio_led_off;
355 + register_led_drv( 7 , &temp[1]);
358 +//wwzh #if defined(CONFIG_AR7RD)
359 +#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
360 + /* Register led 5 Green PPPOE GPIO 13 */
361 + temp[0].param = 13;
362 + temp[0].init = gpio_led_init;
363 + temp[0].onfunc = gpio_led_on;
364 + temp[0].offfunc = gpio_led_off;
365 + register_led_drv( 5 , &temp[0]);
367 + /* Register led 7 Green USB GPIO 12 */
368 + temp[1].param = 12;
369 + temp[1].init = gpio_led_init;
370 + temp[1].onfunc = gpio_led_on;
371 + temp[1].offfunc = gpio_led_off;
372 + register_led_drv( 7 , &temp[1]);
374 + /* Register Device MAX_LED_ID + 1 for reset to factory default */
376 + temp[2].init = reset_init;
377 + temp[2].onfunc = 0;
378 + temp[2].offfunc = 0;
379 + register_led_drv( MAX_LED_ID + 1 , &temp[2]);
381 + /* Register led 8 RED DSL GPIO 10 */
382 + temp[3].param = 10;
383 + temp[3].init = gpio_led_init;
384 + temp[3].onfunc = gpio_led_on;
385 + temp[3].offfunc = gpio_led_off;
386 + register_led_drv( 8 , &temp[3]);
388 + /* Register led 9 RED PPPoE down GPIO 9 */
390 + temp[4].init = gpio_led_init;
391 + temp[4].onfunc = gpio_led_on;
392 + temp[4].offfunc = gpio_led_off;
393 + register_led_drv( 9 , &temp[4]);
395 + /* Register led 10 DSL down GPIO 8 */
397 + temp[5].init = gpio_led_init;
398 + temp[5].onfunc = gpio_led_on;
399 + temp[5].offfunc = gpio_led_off;
400 + register_led_drv( 10 , &temp[5]);
402 + /* Register led 11 Power GPIO 7 */
404 + temp[6].init = gpio_led_init;
405 + temp[6].onfunc = gpio_led_on;
406 + temp[6].offfunc = gpio_led_off;
407 + register_led_drv( 11 , &temp[6]);
409 + /* Register led 12 WiFi 6 */
411 + temp[7].init = gpio_led_init;
412 + temp[7].onfunc = gpio_led_on;
413 + temp[7].offfunc = gpio_led_off;
414 + register_led_drv( 12 , &temp[7]);
416 + /* Register led 13 ELINK(AA1313) GPIO 15 */
417 + temp[8].param = 15;
418 + temp[8].init = gpio_led_init;
419 + temp[8].onfunc = gpio_led_on;
420 + temp[8].offfunc = gpio_led_off;
421 + register_led_drv( 13 , &temp[8]);
423 + /* Register led 14 EACT(Y13) GPIO 16 */
424 + temp[9].param = 16;
425 + temp[9].init = gpio_led_init;
426 + temp[9].onfunc = gpio_led_on;
427 + temp[9].offfunc = gpio_led_off;
428 + register_led_drv( 14 , &temp[9]);
431 +/**************wwzh**************/
433 +/**************end **************/
444 diff -urN linux.dev/drivers/char/avalanche_led/ledmod.c linux.dev2/drivers/char/avalanche_led/ledmod.c
445 --- linux.dev/drivers/char/avalanche_led/ledmod.c 1970-01-01 01:00:00.000000000 +0100
446 +++ linux.dev2/drivers/char/avalanche_led/ledmod.c 2005-10-21 18:03:44.513777000 +0200
448 +#include <linux/config.h>
449 +#include <linux/init.h>
450 +#include <linux/kernel.h>
451 +#include <linux/proc_fs.h>
452 +#include <asm/uaccess.h>
453 +#include <linux/fs.h>
454 +#include <linux/timer.h>
455 +#include <linux/delay.h>
456 +#include <linux/spinlock.h>
457 +#include <asm/ar7/avalanche_regs.h>
458 +#include <asm/ar7/ledapp.h>
459 +#include <linux/module.h>
466 +#define LED_BLINK_UP 5
467 +#define LED_BLINK_DOWN 6
469 +extern void avalanche_leds_init(void);
471 +/***********wwzh**************/
472 +unsigned int sys_mod_state;
473 +unsigned int wan_mod_state;
474 +unsigned int wlan_mod_state;
476 +struct timer_list *pWanTimer = NULL;
477 +struct timer_list *pWlanTimer = NULL;
478 +/***********end **************/
480 +typedef struct state_entry{
481 + unsigned char mode;
483 + void (*handler)(struct state_entry *pState);
484 + unsigned long param;
487 +typedef struct mod_entry{
488 + state_entry_t *states[MAX_STATE_ID];
491 +static mod_entry_t *modArr[MAX_MOD_ID];
492 +static struct proc_dir_entry *led_proc_dir,*led_file;
494 +/* index of the array is the led number HARDWARE SPECIFIC*/
495 +typedef struct led_data{
498 + struct timer_list *pTimer;
499 + unsigned char timer_running;
500 + unsigned long param;
503 +led_data_t led_arr[MAX_LED_ID + 1];
504 +/*!!! The last device is actually being used for ar7 reset to factory default */
507 +static spinlock_t config_lock;
509 +static void board_led_link_up( state_entry_t *pState );
510 +static void board_led_link_down( state_entry_t *pState );
511 +static void board_led_activity_on( state_entry_t *pState );
512 +static void board_led_activity_off( state_entry_t *pState );
513 +static void led_timer_func(unsigned long data);
515 +extern void board_gpio_init(void);
516 +extern void uart_led_init(void);
518 +static ssize_t proc_read_led_fops(struct file *filp,
519 + char *buf,size_t count , loff_t *offp);
520 +static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
521 + size_t count , loff_t *offp);
522 +static int config_led( unsigned long y);
524 +struct file_operations led_fops = {
525 + read: proc_read_led_fops,
526 + write: proc_write_led_fops,
529 +static int led_atoi( char *name)
537 + val = val*10+(*name - '0');
545 +static int free_memory(void)
549 + for( i = 0; i < MAX_MOD_ID ; i++)
551 + if( modArr[i] != NULL )
553 + for( j = 0; j < MAX_STATE_ID ; j++ )
555 + if( modArr[i]->states[j] != NULL )
556 + kfree( modArr[i]->states[j]);
565 +static int led_on( state_entry_t *pState )
567 + if( led_arr[pState->led].led == NULL)
569 + led_arr[pState->led].led->onfunc( led_arr[pState->led].led->param);
573 +static int led_off( state_entry_t *pState )
575 + if( led_arr[pState->led].led == NULL)
577 + led_arr[pState->led].led->offfunc( led_arr[pState->led].led->param);
581 +static void board_led_link_up( state_entry_t *pState )
583 + led_arr[pState->led].state = LED_ON;
584 + if( led_arr[pState->led].timer_running == 0 )
589 +static void board_led_link_down( state_entry_t *pState )
591 + led_arr[pState->led].state = LED_OFF;
592 + if( led_arr[pState->led].timer_running == 0 )
597 +static void add_led_timer(state_entry_t *pState)
599 + led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
600 + led_arr[pState->led].param = pState->param;
601 + led_arr[pState->led].pTimer->data = pState;
602 + add_timer (led_arr[pState->led].pTimer);
605 +static void board_led_activity_on(state_entry_t *pState)
607 + if(led_arr[pState->led].timer_running == 0)
610 + add_led_timer(pState);
611 + led_arr[pState->led].timer_running = 1;
612 + led_arr[pState->led].state = LED_BLINK_UP;
614 + else if( led_arr[pState->led].timer_running > 0xF0)
616 + led_arr[pState->led].state = LED_BLINK_UP;
617 + led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
618 + led_arr[pState->led].param = pState->param;
619 + led_arr[pState->led].pTimer->data = pState;
624 +static void board_led_activity_off(state_entry_t *pState)
626 + if(led_arr[pState->led].timer_running == 0)
629 + add_led_timer(pState);
630 + led_arr[pState->led].timer_running = 1;
631 + led_arr[pState->led].state = LED_BLINK_UP;
633 + else if( led_arr[pState->led].timer_running > 0xF0)
635 + led_arr[pState->led].state = LED_BLINK_UP;
636 + led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
637 + led_arr[pState->led].param = pState->param;
638 + led_arr[pState->led].pTimer->data = pState;
643 +static void board_led_link_flash(state_entry_t *pState)
647 + if(led_arr[pState->led].timer_running == 0)
648 + add_led_timer(pState);
650 + led_arr[pState->led].param = pState->param;
651 + led_arr[pState->led].timer_running = 0xFF;
652 + led_arr[pState->led].state = LED_FLASH;
656 +static void led_timer_func(unsigned long data)
658 + state_entry_t *pState = NULL;
659 + mod_entry_t *pMod = NULL;
660 + unsigned int flags;
662 + spin_lock_irqsave(&config_lock, flags);
664 + pState = (state_entry_t *)data;
666 + if( led_arr[pState->led].state == LED_BLINK_DOWN )
668 + led_arr[pState->led].timer_running = 0;
669 + if( pState->mode == 2 )
670 + led_arr[pState->led].state = LED_OFF;
672 + led_arr[pState->led].state = LED_ON;
674 + else if( led_arr[pState->led].state == LED_BLINK_UP )
676 + led_arr[pState->led].pTimer->expires = jiffies + HZ*(led_arr[pState->led].param)/1000;
677 + led_arr[pState->led].pTimer->data = pState;
678 + add_timer (led_arr[pState->led].pTimer);
679 + if( pState->mode == 2 )
682 + led_arr[pState->led].state = LED_BLINK_DOWN;
687 + led_arr[pState->led].state = LED_BLINK_DOWN;
689 + led_arr[pState->led].timer_running = 1;
691 + else if( led_arr[pState->led].state == LED_FLASH )
693 + led_arr[pState->led].pTimer->expires = jiffies + HZ*(led_arr[pState->led].param)/1000;
694 + led_arr[pState->led].pTimer->data = pState;
695 + add_timer (led_arr[pState->led].pTimer);
697 + if( led_arr[pState->led].timer_running == 0xFF )
700 + led_arr[pState->led].timer_running--;
705 + led_arr[pState->led].timer_running++;
707 + spin_unlock_irqrestore(&config_lock, flags);
710 + else if(led_arr[pState->led].state == LED_OFF)
713 + led_arr[pState->led].timer_running = 0;
715 + else if( led_arr[pState->led].state == LED_ON )
718 + led_arr[pState->led].timer_running = 0;
720 + spin_unlock_irqrestore(&config_lock, flags);
723 +/************wwzh*****************/
725 +/************end *****************/
726 +static ssize_t proc_read_led_fops(struct file *filp,
727 + char *buf,size_t count , loff_t *offp)
729 + char * pdata = NULL;
730 + int i = 0, j = 0, len = 0, totallen = 0;
737 + len += sprintf(line,"LEDS Registered for use are:");
738 + for( i = 0; i< MAX_LED_ID; i++)
739 + if( led_arr[i].led != NULL )
740 + len += sprintf(&line[len]," %d ", i );
741 + line[len++] = '\n';
743 + copy_to_user(pdata, line,len );
747 + len = sprintf(line,"USER MODULE INFORMATION:\n");
748 + copy_to_user(pdata, line,len );
752 + for( i = 0; i< MAX_MOD_ID; i++)
754 + if( modArr[i] != NULL )
756 + len = sprintf(line," Module ID = %d \n" , i);
757 + copy_to_user(pdata, line,len );
761 + for( j = 0; j < MAX_STATE_ID; j++)
763 + if( modArr[i]->states[j] != NULL)
765 + len = sprintf(line ,
766 + " State = %d , Led = %d," , j , modArr[i]->states[j]->led);
767 + copy_to_user(pdata, line,len );
772 + switch( modArr[i]->states[j]->mode )
775 + len = sprintf(line ," Mode = OFF\n");
778 + len = sprintf(line ," Mode = BLINK_ON , On Time(ms) = %d\n" ,
779 + (unsigned int)modArr[i]->states[j]->param);
782 + len = sprintf(line ," Mode = BLINK_OFF , Off Time(ms) = %d\n" ,
783 + (unsigned int)modArr[i]->states[j]->param);
786 + len = sprintf(line ," Mode = ON \n");
789 + len = sprintf(line ," Mode = FLASH , Time Period(ms) = %d\n" ,
790 + (unsigned int)modArr[i]->states[j]->param);
796 + copy_to_user(pdata, line,len );
805 + /* Return with configuration information for LEDs */
809 +static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
810 + size_t count , loff_t *offp)
812 + char *pdata = NULL, *ptemp = NULL;
813 + char line[10],temp[10];
815 + int mod = 0xFFFF , state = 0xFFFF;
818 + /* Check if this write is for configuring stuff */
819 + if( *(int *)(buffer) == 0xFFEEDDCC )
821 + printk("<1>proc write:Calling Configuration\n");
822 + config_led((unsigned long)(buffer + sizeof(int)) );
828 + printk("<1>proc write:Input too long,max length = %d\n",10);
831 + memset( temp, 0x00 , 10);
832 + memset( line, 0x00 , 10);
833 + copy_from_user(line,buffer,count);
834 + line[count] = 0x00;
841 + if( ((*pdata) >= '0' ) && ((*pdata) <= '9') )
846 + else if( (*pdata) == ',' )
855 + mod = led_atoi( temp);
866 + if( ((*pdata) >= '0' ) && ((*pdata) <= '9') )
871 + else if( (*pdata) == 0x00 )
880 + state = led_atoi( temp);
883 + if( (mod == 0xFFFF) || (state == 0xFFFF))
886 + led_operation( mod , state );
890 +/************wwzh*******************/
895 +#define FLICK_TIME (HZ*100/1000)
896 +static unsigned int wan_txrx_state = 0;
897 +static unsigned int wlan_txrx_state = 0;
899 +void led_operation( int mod , int state)
902 + unsigned int flags;
904 + spin_lock_irqsave(&config_lock, flags);
906 + if( (mod >= MAX_MOD_ID) || ( state >= MAX_STATE_ID) )
908 + spin_unlock_irqrestore(&config_lock, flags);
911 + if ( modArr[mod] == NULL )
913 + spin_unlock_irqrestore(&config_lock, flags);
916 + if( modArr[mod]->states[state] == NULL )
918 + spin_unlock_irqrestore(&config_lock, flags);
921 + /* Call the function handler */
922 + modArr[mod]->states[state]->handler(modArr[mod]->states[state]);
924 + spin_unlock_irqrestore(&config_lock, flags);
927 +static void wan_led_func(unsigned long data)
929 + if (wan_txrx_state == 0)
931 + tnetd73xx_gpio_out(2, TRUE);
932 + tnetd73xx_gpio_out(3, FALSE);
933 + wan_txrx_state = 1;
937 + tnetd73xx_gpio_out(2, FALSE);
938 + tnetd73xx_gpio_out(3, FALSE);
939 + wan_txrx_state = 0;
941 + pWanTimer->expires = jiffies + FLICK_TIME;
942 + add_timer(pWanTimer);
946 +static void wlan_led_func(unsigned long data)
948 + if (wlan_txrx_state == 0)
950 + tnetd73xx_gpio_out(12, TRUE);
951 + tnetd73xx_gpio_out(13, FALSE);
952 + wlan_txrx_state = 1;
956 + tnetd73xx_gpio_out(12, FALSE);
957 + tnetd73xx_gpio_out(13, FALSE);
958 + wlan_txrx_state = 0;
961 + pWlanTimer->expires = jiffies + FLICK_TIME;
962 + add_timer(pWlanTimer);
966 +void led_active(int mod, int state)
968 + unsigned int flags = 0;
970 +//printk("mod = %d state = %d\n", mod, state);
971 + spin_lock_irqsave(&config_lock, flags);
972 + if ((mod >= 5) || (state >= 5))
974 + spin_unlock_irqrestore(&config_lock, flags);
980 + case 2: /*system led */
981 + sys_mod_state = state;
986 + case 2: /*sys led flashing green */
987 + tnetd73xx_gpio_out(4, FALSE);
988 + tnetd73xx_gpio_out(5, TRUE);
989 + tnetd73xx_gpio_out(8, TRUE);
991 + case 3: /*sys led solid green */
992 + tnetd73xx_gpio_out(4, TRUE);
993 + tnetd73xx_gpio_out(5, TRUE);
994 + tnetd73xx_gpio_out(8, TRUE);
997 + case 4: /*sys fail red */
998 + tnetd73xx_gpio_out(4, TRUE);
999 + tnetd73xx_gpio_out(5, FALSE);
1000 + tnetd73xx_gpio_out(8, FALSE);
1006 + case 3: /*wan led */
1007 + wan_mod_state = state;
1010 + case 1: /*no wan interface*/
1013 + del_timer(pWanTimer);
1017 + tnetd73xx_gpio_out(2, FALSE);
1018 + tnetd73xx_gpio_out(3, FALSE);
1020 + case 2: /*wan connected */
1023 + del_timer(pWanTimer);
1027 + tnetd73xx_gpio_out(2, TRUE);
1028 + tnetd73xx_gpio_out(3, FALSE);
1030 + case 3: /*rx/tx activity */
1031 + if (pWanTimer != NULL)
1034 + pWanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
1035 + init_timer(pWanTimer);
1037 + pWanTimer->function = wan_led_func;
1038 + pWanTimer->data = 0;
1039 + pWanTimer->expires = jiffies + FLICK_TIME;
1040 + tnetd73xx_gpio_out(2, FALSE);
1041 + tnetd73xx_gpio_out(3, FALSE);
1042 + wan_txrx_state = 0;
1043 + add_timer(pWanTimer);
1046 + case 4: /*no ipaddress */
1049 + del_timer(pWanTimer);
1053 + tnetd73xx_gpio_out(2, FALSE);
1054 + tnetd73xx_gpio_out(3, TRUE);
1059 + del_timer(pWanTimer);
1066 + //wwzh for wireless
1068 + case 4: /*wlan led */
1069 + wlan_mod_state = state;
1072 + case 1: /* wlan off */
1075 + del_timer(pWlanTimer);
1076 + kfree(pWlanTimer);
1077 + pWlanTimer = NULL;
1079 + tnetd73xx_gpio_out(12, FALSE);
1080 + tnetd73xx_gpio_out(13, FALSE);
1082 + case 2: /* wlan ready */
1085 + del_timer(pWlanTimer);
1086 + kfree(pWlanTimer);
1087 + pWlanTimer = NULL;
1089 + tnetd73xx_gpio_out(12, TRUE);
1090 + tnetd73xx_gpio_out(13, FALSE);
1092 + case 3: /* wlan rx/tx activity */
1093 + if (pWlanTimer != NULL)
1096 + pWlanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
1097 + init_timer(pWlanTimer);
1099 + pWlanTimer->function = wlan_led_func;
1100 + pWlanTimer->data = 0;
1101 + pWlanTimer->expires = jiffies + FLICK_TIME;
1102 + tnetd73xx_gpio_out(12, FALSE);
1103 + tnetd73xx_gpio_out(13, FALSE);
1104 + wlan_txrx_state = 0;
1105 + add_timer(pWlanTimer);
1111 + del_timer(pWlanTimer);
1112 + kfree(pWlanTimer);
1113 + pWlanTimer = NULL;
1119 + #endif //for wireless
1123 + spin_unlock_irqrestore(&config_lock, flags);
1125 +static ssize_t proc_read_led_fops(struct file *filp,
1126 + char *buf,size_t count , loff_t *offp)
1128 + char *pdata = NULL;
1129 + int i = 0, j = 0, len = 0, totallen = 0;
1135 + len = sprintf(line, "USER MODULE INFORMATION:\n");
1136 + copy_to_user(pdata, line, len);
1141 + //*******add Module 1 , this Module is ADSL ********/
1142 + for (i = 0; i < MAX_MOD_ID; i++)
1144 + if (modArr[i] != NULL)
1146 + len = sprintf(line, " Module ID = %d\n", i);
1147 + copy_to_user(pdata, line, len);
1151 + for(j = 0; j < MAX_STATE_ID; j++)
1153 + if (modArr[i]->states[j] != NULL)
1155 + len = sprintf(line, "State =%d, Led = %d,", j, modArr[i]->states[j]->led);
1156 + copy_to_user(pdata, line, len);
1160 + switch(modArr[i]->states[j]->mode)
1163 + len = sprintf(line, "Mode = OFF\n");
1166 + len = sprintf(line, "Mode = BLINK_ON, On Time(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);
1169 + len = sprintf(line, "Mode = BLINK_OFF, Off Time(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);
1172 + len = sprintf(line, "Mode = On\n");
1175 + len = sprintf(line, "Mode = FLASH, Time Period(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);
1180 + copy_to_user(pdata, line, len);
1190 + len = sprintf(line, "Module ID = 2(system led)\n");
1191 + copy_to_user(pdata, line, len);
1195 + switch(sys_mod_state)
1198 + len = sprintf(line, "State = OFF\n");
1201 + len = sprintf(line, "State = Booting\n");
1204 + len = sprintf(line, "State = System Ready\n");
1207 + len = sprintf(line, "State = System Failure\n");
1212 + copy_to_user(pdata, line, len);
1217 + len = sprintf(line, "Module ID = 3(WAN led)\n");
1218 + copy_to_user(pdata, line, len);
1222 + switch(wan_mod_state)
1225 + len = sprintf(line, "State = OFF\n");
1228 + len = sprintf(line, "State = Wan Connected\n");
1231 + len = sprintf(line, "State = Wan Tx/Rx Activity\n");
1234 + len = sprintf(line, "State = Wan Connect Failure\n");
1239 + copy_to_user(pdata, line, len);
1244 +//wwzh for wireless
1246 + len = sprintf(line, "Module ID = 4(WLAN led)\n");
1247 + copy_to_user(pdata, line, len);
1251 + switch(wlan_mod_state)
1254 + len = sprintf(line, "State = OFF\n");
1257 + len = sprintf(line, "State = wlan Ready\n");
1260 + len = sprintf(line, "State = wlan rx/tx activity\n");
1265 + copy_to_user(pdata, line, len);
1269 +#endif //for wireless
1274 +static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
1275 + size_t count , loff_t *offp)
1277 + char *pdata = NULL, *ptemp = NULL;
1278 + char line[10], temp[10];
1280 + int mod = 0xffff, state = 0xffff;
1283 + /* Check if this write is for configuring ADSL */
1284 + if( *(int *)(buffer) == 0xFFEEDDCC )
1286 + printk("<1>proc write:Calling Configuration\n");
1287 + config_led((unsigned long)(buffer + sizeof(int)) );
1293 + printk("<1> proc write: Input too long, max length = 10\n");
1296 + memset(temp, 0x00, 10);
1297 + memset(line, 0x00, 10);
1298 + copy_from_user(line, buffer, count);
1299 + line[count] = 0x00;
1307 + if (((*pdata) >= '0') && ((*pdata) <= '9'))
1312 + else if ((*pdata) == ',')
1321 + mod = led_atoi(temp);
1333 + if (((*pdata) >= '0') && ((*pdata) <= '9'))
1338 + else if ((*pdata) == 0x00)
1347 + state = led_atoi(temp);
1350 + if ((mod == 0xFFFF) || (state == 0xFFFF))
1355 + led_active(mod, state);
1357 + led_operation(mod, state);
1362 +/************end *******************/
1363 +static int config_led(unsigned long y)
1365 + config_elem_t *pcfg = NULL;
1366 + char *pdata = NULL;
1368 + int length = 0 , number = 0;
1369 + unsigned int flags;
1371 + spin_lock_irqsave(&config_lock, flags);
1373 + /* ioctl to configure */
1374 + length = *((int*)y);
1375 + pdata = (char *)y + sizeof(int);
1376 + number = (length - sizeof(int))/sizeof(config_elem_t);
1377 + pcfg = (config_elem_t *)(pdata);
1379 + /* Check if an earlier configuration exists IF yes free it up */
1382 + for ( i = 0 ; i < number ; i++ )
1384 + /* If no structure has been allocated for the module do so */
1385 + if ( modArr[pcfg->name] == NULL )
1387 + printk("<1>module = %d\n",pcfg->name);
1388 + if( pcfg->name >= MAX_MOD_ID)
1390 + printk("<1>Exiting Configuration: Module ID too large %d\n",pcfg->name);
1392 + spin_unlock_irqrestore(&config_lock, flags);
1395 + modArr[pcfg->name] = kmalloc(sizeof(mod_entry_t),GFP_KERNEL);
1396 + if(modArr[pcfg->name] == NULL)
1398 + printk("<1>Exiting Configuration: Error in allocating memory\n");
1400 + spin_unlock_irqrestore(&config_lock, flags);
1403 + memset( modArr[pcfg->name], 0x00, sizeof(mod_entry_t));
1406 + /* if no structure is allocated previously for this state
1407 + allocate a structure, if it's already there fill it up */
1408 + if( modArr[pcfg->name]->states[pcfg->state] == NULL)
1410 + printk("<1>STATE = %d\n",pcfg->state);
1411 + if( pcfg->state >= MAX_STATE_ID)
1413 + printk("<1>Exiting Configuration: State ID too large\n");
1415 + spin_unlock_irqrestore(&config_lock, flags);
1418 + modArr[pcfg->name]->states[pcfg->state] =
1419 + kmalloc(sizeof(state_entry_t),GFP_KERNEL);
1420 + if( modArr[pcfg->name]->states[pcfg->state] == NULL)
1423 + spin_unlock_irqrestore(&config_lock, flags);
1426 + memset( modArr[pcfg->name]->states[pcfg->state], 0x00, sizeof(state_entry_t));
1428 + /* Fill up the fields of the state */
1429 + if( pcfg->led >= MAX_LED_ID)
1431 + printk("<1>led = %d\n",pcfg->led);
1433 + spin_unlock_irqrestore(&config_lock, flags);
1436 + modArr[pcfg->name]->states[pcfg->state]->led = pcfg->led;
1437 + modArr[pcfg->name]->states[pcfg->state]->mode = pcfg->mode;
1438 + modArr[pcfg->name]->states[pcfg->state]->param = pcfg->param;
1439 + switch(pcfg->mode)
1442 + modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_down;
1447 + if( pcfg->mode == 2 )
1448 + modArr[pcfg->name]->states[pcfg->state]->handler = board_led_activity_on;
1449 + else if( pcfg->mode == 3)
1450 + modArr[pcfg->name]->states[pcfg->state]->handler = board_led_activity_off;
1452 + modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_flash;
1455 + modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_up;
1458 + printk("<1>Exiting Configuration: Unknown LED Mode\n");
1460 + spin_unlock_irqrestore(&config_lock, flags);
1465 + spin_unlock_irqrestore(&config_lock, flags);
1470 +int __init led_init(void)
1473 + /* Clear our memory */
1474 + memset(modArr,0x00,sizeof(mod_entry_t *)*MAX_MOD_ID);
1475 + memset(led_arr,0x00,sizeof(led_data_t *)*MAX_LED_ID);
1477 + /* Create spin lock for config data structure */
1478 + config_lock=SPIN_LOCK_UNLOCKED;
1480 + /* Create directory */
1481 + led_proc_dir = proc_mkdir("led", NULL);
1482 + if( led_proc_dir == NULL )
1485 + /* Create adsl file */
1486 + led_file = create_proc_entry("led", 0777, led_proc_dir);
1487 + if( led_file == NULL)
1489 + led_file->owner = THIS_MODULE;
1490 + led_file->proc_fops = &led_fops;
1492 + memset( modArr , 0x00 , sizeof(mod_entry_t *) * MAX_MOD_ID);
1493 + /* Reset the GPIO pins */
1494 + board_gpio_init();
1496 + /* Register the UART controlled LEDS */
1498 + /* Create the usb proc file */
1499 + avalanche_leds_init();
1503 + remove_proc_entry("led",led_proc_dir);
1511 + remove_proc_entry("led", led_proc_dir);
1514 +module_init(led_init);
1515 +module_exit(led_exit);
1517 +void register_led_drv( int device , led_reg_t *pInfo)
1519 + unsigned int flags;
1520 + struct timer_list *pTimer = NULL;
1522 + spin_lock_irqsave(&config_lock, flags);
1524 + led_arr[device].led = pInfo;
1525 + if( led_arr[device].led->init != 0x00)
1526 + led_arr[device].led->init(led_arr[device].led->param);
1527 + if( led_arr[device].led->offfunc != 0x00)
1528 + led_arr[device].led->offfunc(led_arr[device].led->param);
1530 + /* Create a timer for blinking */
1531 + pTimer = kmalloc(sizeof(struct timer_list),GFP_KERNEL);
1532 + init_timer( pTimer );
1533 + pTimer->function = led_timer_func;
1535 + led_arr[device].pTimer = pTimer;
1536 + led_arr[device].timer_running = 0;
1538 + spin_unlock_irqrestore(&config_lock, flags);
1543 +void deregister_led_drv( int device)
1545 + unsigned int flags;
1547 + spin_lock_irqsave(&config_lock, flags);
1548 + led_arr[device].led = NULL;
1550 + if( led_arr[device].pTimer != NULL)
1552 + del_timer(led_arr[device].pTimer);
1553 + kfree(led_arr[device].pTimer);
1555 + spin_unlock_irqrestore(&config_lock, flags);
1560 +EXPORT_SYMBOL_NOVERS(led_operation);
1561 +EXPORT_SYMBOL_NOVERS(register_led_drv);
1562 +EXPORT_SYMBOL_NOVERS(deregister_led_drv);
1564 diff -urN linux.dev/drivers/char/avalanche_led/leds.c linux.dev2/drivers/char/avalanche_led/leds.c
1565 --- linux.dev/drivers/char/avalanche_led/leds.c 1970-01-01 01:00:00.000000000 +0100
1566 +++ linux.dev2/drivers/char/avalanche_led/leds.c 2005-10-21 18:03:44.513777000 +0200
1568 +#include <linux/config.h>
1569 +#include <linux/init.h>
1570 +#include <linux/delay.h>
1571 +#include <asm/ar7/avalanche_regs.h>
1572 +#include <linux/spinlock.h>
1573 +#include <linux/timer.h>
1574 +#include <linux/sched.h>
1575 +#include <linux/module.h>
1576 +#include <linux/proc_fs.h>
1577 +#include <asm/uaccess.h>
1578 +#include <linux/fs.h>
1580 +#include <asm/ar7/ledapp.h>
1582 +#if defined(CONFIG_AR5D01) || defined(CONFIG_AR5W01) || defined(CONFIG_AR7)
1584 +#define ETH_MASK 0x01
1585 +#define USB_MASK 0x02
1587 +static struct proc_dir_entry *usb_file;
1588 +static ssize_t proc_read_usb_fops(struct file *filp,
1589 + char *buf,size_t count , loff_t *offp);
1590 +struct file_operations usb_fops = {read: proc_read_usb_fops};
1592 +typedef struct mod_states{
1599 +mod_states_t state_arr[] = {
1600 + { MOD_ETH,DEF_ETH_ACTIVITY,DEF_ETH_LINK_UP,DEF_ETH_IDLE },
1601 + { MOD_USB,DEF_USB_ACTIVITY,DEF_USB_LINK_UP,DEF_USB_IDLE },
1602 + { MOD_LAN,DEF_LAN_ACTIVITY,DEF_LAN_LINK_UP,DEF_LAN_IDLE }
1605 +unsigned char device_links = 0; /* Bitmask with the devices that are up */
1608 +void avalanche_led_activity_pulse(unsigned long device)
1610 + /* If device link is not up return */
1611 + if( !(device_links & (unsigned char)(1 << device)))
1613 +#ifdef MULTIPLEX_LED
1614 + led_operation( state_arr[2].module, state_arr[2].activity);
1616 + led_operation( state_arr[device].module, state_arr[device].activity);
1620 +void avalanche_led_link_up( unsigned long device )
1623 + /* If already UP ignore */
1624 + if( device_links & (unsigned char)(1 << device))
1626 + /* Turn on the bit for the device */
1627 + device_links |= (unsigned char)(1 << device);
1628 +#ifdef MULTIPLEX_LED
1629 + led_operation( state_arr[2].module, state_arr[2].linkup);
1631 + led_operation( state_arr[device].module, state_arr[device].linkup);
1635 +void avalanche_led_link_down ( unsigned long device )
1638 + /* If already DOWN ignore */
1639 + if( !(device_links & (unsigned char)(1 << device)))
1642 + /* Turn off the bit for the device */
1643 + device_links &= ~(unsigned char)(1 << device);
1644 +#ifdef MULTIPLEX_LED
1645 + /* If no links, then shut the LED off */
1647 + led_operation( state_arr[2].module, state_arr[2].idle);
1649 + led_operation( state_arr[device].module, state_arr[device].idle);
1653 +static ssize_t proc_read_usb_fops(struct file *filp,
1654 + char *buf,size_t count , loff_t *offp)
1656 + char * pdata = NULL;
1661 + if( device_links & USB_MASK)
1662 + sprintf(line,"%s\n","1");
1664 + sprintf(line,"%s\n","0");
1665 + copy_to_user(pdata,line,2);
1671 +void avalanche_leds_init(void)
1673 + /* Create usb link proc file */
1674 + usb_file = create_proc_entry("avalanche/usb_link", 0444, NULL);
1675 + if( usb_file == NULL)
1677 + usb_file->owner = THIS_MODULE;
1678 + usb_file->proc_fops = &usb_fops;
1682 +EXPORT_SYMBOL(avalanche_led_activity_pulse);
1683 +EXPORT_SYMBOL(avalanche_led_link_up);
1684 +EXPORT_SYMBOL(avalanche_led_link_down);
1687 +/* We make a dummy init routine for the platforms that do not support this led
1691 +void avalanche_leds_init(void)
1701 diff -urN linux.dev/drivers/char/avalanche_led/uartled.c linux.dev2/drivers/char/avalanche_led/uartled.c
1702 --- linux.dev/drivers/char/avalanche_led/uartled.c 1970-01-01 01:00:00.000000000 +0100
1703 +++ linux.dev2/drivers/char/avalanche_led/uartled.c 2005-10-21 18:03:44.529778000 +0200
1705 +#include <linux/kernel.h>
1706 +#include <asm/uaccess.h>
1707 +#include <linux/spinlock.h>
1708 +#include <asm/ar7/avalanche_regs.h>
1709 +#include <asm/ar7/ledapp.h>
1711 +#define UART_LED_REG (*(volatile unsigned int *)(UARTA_BASE + 0x10))
1713 +static spinlock_t device_lock;
1714 +led_reg_t temp1[2];
1716 +static void uart_led_on(unsigned long param)
1718 + unsigned long flags;
1720 + spin_lock_irqsave(&device_lock,flags);
1721 + UART_LED_REG &= 0xFFFD;
1722 + spin_unlock_irqrestore(&device_lock, flags);
1725 +static void uart_led_off ( unsigned long param )
1727 + unsigned int flags = 0x00;
1728 + spin_lock_irqsave(&device_lock, flags);
1729 + UART_LED_REG |= 0x02;
1730 + spin_unlock_irqrestore(&device_lock, flags);
1733 +void uart_led_init(void)
1736 +#if defined(CONFIG_AR5D01)
1737 + /* Register led 6 UART Pin 1 */
1738 + temp1[0].param = 0;
1739 + temp1[0].init = NULL;
1740 + temp1[0].onfunc = uart_led_on;
1741 + temp1[0].offfunc = uart_led_off;
1742 + register_led_drv( 6 , &temp1[0]);
1745 +#if defined(CONFIG_AR5W01)
1746 + /* Register led 8 UART Pin 1 */
1747 + temp1[0].param = 0;
1748 + temp1[0].init = NULL;
1749 + temp1[0].onfunc = uart_led_on;
1750 + temp1[0].offfunc = uart_led_off;
1751 + register_led_drv( 8 , &temp1[0]);
1754 + /* Initialize the link mask */
1755 + device_lock = SPIN_LOCK_UNLOCKED;
1760 diff -urN linux.dev/include/asm-mips/ar7/led_config.h linux.dev2/include/asm-mips/ar7/led_config.h
1761 --- linux.dev/include/asm-mips/ar7/led_config.h 1970-01-01 01:00:00.000000000 +0100
1762 +++ linux.dev2/include/asm-mips/ar7/led_config.h 2005-10-21 17:02:25.568327000 +0200
1764 +/******************************************************************************
1765 + * FILE PURPOSE: - LED config Header
1766 + ******************************************************************************
1767 + * FILE NAME: led_config.h
1769 + * DESCRIPTION: Header file for LED configuration parameters
1770 + * and data structures
1772 + * REVISION HISTORY:
1773 + * 11 Oct 03 - PSP TII
1775 + * (C) Copyright 2002, Texas Instruments, Inc
1776 + *******************************************************************************/
1779 +#ifndef __LED_CONFIG__
1780 +#define __LED_CONFIG__
1782 +/* LED config parameters */
1783 +#define MAX_GPIO_PIN_NUM 64
1784 +#define MAX_GPIOS_PER_STATE 5
1785 +#define MAX_MODULE_ENTRIES 25
1786 +#define MAX_MODULE_INSTANCES 4
1787 +#define MAX_STATE_ENTRIES 25
1788 +#define MAX_LED_ENTRIES 25
1794 +#define LED_ONESHOT_OFF 2
1795 +#define LED_ONESHOT_ON 3
1796 +#define LED_FLASH 4
1797 +#define LED_BLINK_CODE0 5 /*--- param1: on time, param2: blink nr , (param2 > 100 blink off) ---*/
1798 +#define LED_BLINK_CODE1 6
1799 +#define LED_BLINK_CODE2 7
1801 +#define NUM_LED_MODES 8
1805 +/* Data structure for LED configuration */
1806 +typedef struct led_config{
1807 + unsigned char name[80];
1808 + unsigned int instance;
1809 + unsigned int state;
1810 + unsigned int gpio[MAX_GPIOS_PER_STATE];
1811 + unsigned int mode[MAX_GPIOS_PER_STATE];
1812 + unsigned int gpio_num;
1813 + unsigned int param1;
1814 + unsigned int param2;
1818 +#endif /* __LED_CONFIG__ */
1819 diff -urN linux.dev/include/asm-mips/ar7/led_hal.h linux.dev2/include/asm-mips/ar7/led_hal.h
1820 --- linux.dev/include/asm-mips/ar7/led_hal.h 1970-01-01 01:00:00.000000000 +0100
1821 +++ linux.dev2/include/asm-mips/ar7/led_hal.h 2005-10-21 17:02:25.568327000 +0200
1823 +/******************************************************************************
1824 + * FILE PURPOSE: - LED HAL module Header
1825 + ******************************************************************************
1826 + * FILE NAME: led_hal.h
1828 + * DESCRIPTION: LED HAL API's.
1830 + * REVISION HISTORY:
1831 + * 11 Oct 03 - PSP TII
1833 + * (C) Copyright 2002, Texas Instruments, Inc
1834 + *******************************************************************************/
1836 +#ifndef __LED_HAL__
1837 +#define __LED_HAL__
1839 +/* Interface prototypes */
1840 +#include "led_config.h"
1842 +int avalanche_led_hal_init (int *gpio_off_value, int num_gpio_pins);
1843 +int avalanche_led_config_set (LED_CONFIG_T * led_cfg);
1844 +int avalanche_led_config_get (LED_CONFIG_T *led_cfg,int module_id,int instance, int state);
1845 +void *avalanche_led_register (const char *module_name, int instance_num);
1846 +void avalanche_led_action (void *handle, int state_id);
1847 +void avalanche_led_late_actions(void);
1848 +int avalanche_led_unregister (void *handle);
1849 +void avalanche_led_free_all(void);
1850 +void avalanche_led_hal_exit (void);
1852 +#endif /*__LED_HAL__ */
1853 diff -urN linux.dev/include/asm-mips/ar7/ledapp.h linux.dev2/include/asm-mips/ar7/ledapp.h
1854 --- linux.dev/include/asm-mips/ar7/ledapp.h 1970-01-01 01:00:00.000000000 +0100
1855 +++ linux.dev2/include/asm-mips/ar7/ledapp.h 2005-10-21 18:03:44.573780750 +0200
1857 +#ifndef __LED_APP__
1858 +#define __LED_APP__
1860 +#define CONF_FILE "/etc/led.conf"
1861 +#define LED_PROC_FILE "/proc/led_mod/led"
1863 +#define CONFIG_LED_MODULE
1865 +#define MAX_MOD_ID 25
1866 +#define MAX_STATE_ID 25
1867 +#define MAX_LED_ID 25
1870 +#define DEF_ADSL_IDLE 1
1871 +#define DEF_ADSL_TRAINING 2
1872 +#define DEF_ADSL_SYNC 3
1873 +#define DEF_ADSL_ACTIVITY 4
1876 +#define DEF_WAN_IDLE 1
1877 +#define DEF_WAN_NEGOTIATE 2
1878 +#define DEF_WAN_SESSION 3
1881 +#define DEF_LAN_IDLE 1
1882 +#define DEF_LAN_LINK_UP 2
1883 +#define DEF_LAN_ACTIVITY 3
1886 +#define DEF_WLAN_IDLE 1
1887 +#define DEF_WLAN_LINK_UP 2
1888 +#define DEF_WLAN_ACTIVITY 3
1891 +#define DEF_USB_IDLE 1
1892 +#define DEF_USB_LINK_UP 2
1893 +#define DEF_USB_ACTIVITY 3
1896 +#define DEF_ETH_IDLE 1
1897 +#define DEF_ETH_LINK_UP 2
1898 +#define DEF_ETH_ACTIVITY 3
1900 +typedef struct config_elem{
1901 + unsigned char name;
1902 + unsigned char state;
1903 + unsigned char mode;
1904 + unsigned char led;
1908 +typedef struct led_reg{
1909 + unsigned int param;
1910 + void (*init)(unsigned long param);
1911 + void (*onfunc)(unsigned long param);
1912 + void (*offfunc)(unsigned long param);