fix ethernet driver crash when using bridging
[openwrt.git] / target / linux / linux-2.4 / patches / ar7 / 002-led_driver.patch
index eb7d63d..d88fca1 100644 (file)
@@ -1,7 +1,393 @@
+diff -urN linux.old/drivers/char/avalanche_led/gpio.c linux.dev/drivers/char/avalanche_led/gpio.c
+--- linux.old/drivers/char/avalanche_led/gpio.c        1970-01-01 01:00:00.000000000 +0100
++++ linux.dev/drivers/char/avalanche_led/gpio.c        2005-07-12 03:13:02.696541072 +0200
+@@ -0,0 +1,382 @@
++#include <linux/kernel.h>
++#include <asm/uaccess.h>
++#include <linux/spinlock.h>
++#include <linux/proc_fs.h>
++#include <linux/fs.h>
++#include <linux/timer.h>
++#include <linux/module.h>
++
++#include <asm/ar7/tnetd73xx_err.h>
++#include <asm/ar7/tnetd73xx_misc.h>
++#include <asm/ar7/ledapp.h>
++
++#define TRUE 1
++#define FALSE 0
++
++#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
++
++#define AR7_RESET_FILE "led_mod/ar7reset"
++#define AR7_VERSION_FILE "led_mod/hardware_version"
++#define AR7_RESET_GPIO 11
++#define RESET_POLL_TIME 1
++#define RESET_HOLD_TIME 4
++#define NO_OF_LEDS    
++
++static struct proc_dir_entry *reset_file;
++static int res_state = 0;
++static int count;
++static struct timer_list *pTimer = NULL;
++static ssize_t proc_read_reset_fops(struct file *filp,
++                                    char *buf,size_t count , loff_t *offp);
++
++static ssize_t proc_read_hwversion_fops(struct file *filp,
++                                    char *buf,size_t count , loff_t *offp);
++
++struct file_operations reset_fops = {
++                                     read: proc_read_reset_fops
++                                   };
++struct file_operations hardware_version_fops = {
++                                     read: proc_read_hwversion_fops
++                                   };
++#endif
++
++static spinlock_t     device_lock;
++led_reg_t temp[15];
++
++static void gpio_led_on( unsigned long param )
++{
++      unsigned int flags;
++
++      spin_lock_irqsave(&device_lock, flags);
++
++      tnetd73xx_gpio_out(param,FALSE);
++      spin_unlock_irqrestore(&device_lock, flags);
++}
++
++static void gpio_led_off ( unsigned long param )
++{
++      unsigned int flags = 0x00;
++
++      spin_lock_irqsave(&device_lock, flags);
++
++      tnetd73xx_gpio_out(param,TRUE);
++      spin_unlock_irqrestore(&device_lock, flags);
++}
++
++static void gpio_led_init( unsigned long param)
++{
++      tnetd73xx_gpio_ctrl(param,GPIO_PIN,GPIO_OUTPUT_PIN);
++}
++
++static void board_gpio_reset(void)
++{
++      /* Initialize the link mask */
++      device_lock = SPIN_LOCK_UNLOCKED;
++      return;
++}
++
++#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
++
++static ssize_t proc_read_hwversion_fops(struct file *filp, char *buf, 
++                                      size_t count, loff_t *offp)
++{
++      char line[8];
++      int len = 0;
++      if( *offp != 0 )
++              return 0;
++
++      len = sprintf(line,  "%d%d.%d%d%d%d\n", tnetd73xx_gpio_in(20),
++                      tnetd73xx_gpio_in(21), tnetd73xx_gpio_in(22),
++                      tnetd73xx_gpio_in(23), tnetd73xx_gpio_in(24),
++                      tnetd73xx_gpio_in(25));
++      
++      copy_to_user(buf, line, len);
++      *offp = len;
++      return len;
++}     
++
++static ssize_t proc_read_reset_fops(struct file *filp,
++                                 char *buf,size_t count , loff_t *offp)
++{
++  char * pdata = NULL;
++  char line[3];
++  int len = 0;
++  if( *offp != 0 )
++      return 0;
++
++  pdata = buf;
++      len = sprintf(line,"%d\n", res_state );
++//wwzh
++//  res_state = 0;
++  copy_to_user(buf,line,len );
++      *offp = len;
++      return len;
++}
++
++static void reset_timer_func(unsigned long data)
++{
++//wwzh
++#if 0
++      count = (tnetd73xx_gpio_in(AR7_RESET_GPIO) == 0) ? count + 1: 0;
++        if( count >= RESET_HOLD_TIME/RESET_POLL_TIME )
++#endif
++      if (tnetd73xx_gpio_in(AR7_RESET_GPIO) == 0)
++              res_state = 1;
++      else
++              res_state = 0;
++      pTimer->expires = jiffies + HZ*RESET_POLL_TIME;
++      add_timer (pTimer);
++  return;
++}
++
++static void hardware_version_init(void)
++{
++      static struct proc_dir_entry *hardware_version_file;
++      hardware_version_file = create_proc_entry(AR7_VERSION_FILE, 0777, NULL);
++      if(hardware_version_file == NULL)
++               return;
++      
++      hardware_version_file->owner = THIS_MODULE;
++      hardware_version_file->proc_fops = &hardware_version_fops;
++
++      tnetd73xx_gpio_ctrl(20,GPIO_PIN,GPIO_INPUT_PIN);
++      tnetd73xx_gpio_ctrl(21,GPIO_PIN,GPIO_INPUT_PIN);
++      tnetd73xx_gpio_ctrl(22,GPIO_PIN,GPIO_INPUT_PIN);
++      tnetd73xx_gpio_ctrl(23,GPIO_PIN,GPIO_INPUT_PIN);
++      tnetd73xx_gpio_ctrl(24,GPIO_PIN,GPIO_INPUT_PIN);
++      tnetd73xx_gpio_ctrl(25,GPIO_PIN,GPIO_INPUT_PIN);
++      
++      return;
++}
++
++static void reset_init(void)
++{
++  /* Create board reset proc file */
++  reset_file = create_proc_entry( AR7_RESET_FILE, 0777, NULL);
++  if( reset_file == NULL)
++    goto reset_file;
++  reset_file->owner = THIS_MODULE;
++  reset_file->proc_fops = &reset_fops;
++
++  /* Initialise GPIO 11 for input */
++  tnetd73xx_gpio_ctrl(AR7_RESET_GPIO,GPIO_PIN,GPIO_INPUT_PIN);
++
++  /* Create a timer which fires every seconds */
++  pTimer = kmalloc(sizeof(struct timer_list),GFP_KERNEL);
++      init_timer( pTimer );
++      pTimer->function = reset_timer_func;
++      pTimer->data = 0;
++  /* Start the timer */
++  reset_timer_func(0);
++  return ;
++
++  reset_file:
++    remove_proc_entry("AR7_RESET_FILE",NULL);
++      return;
++}
++#endif
++/*************wwzh****************/
++#if 1
++extern unsigned int sys_mod_state;
++extern unsigned int  wan_mod_state;
++extern unsigned int wlan_mod_state;
++void sys_led_init(void)
++{
++      tnetd73xx_gpio_ctrl(4, GPIO_PIN, GPIO_OUTPUT_PIN);
++      tnetd73xx_gpio_ctrl(5, GPIO_PIN, GPIO_OUTPUT_PIN);
++      tnetd73xx_gpio_ctrl(8, GPIO_PIN, GPIO_OUTPUT_PIN);
++
++      tnetd73xx_gpio_out(4, FALSE);
++      tnetd73xx_gpio_out(5, TRUE);
++      tnetd73xx_gpio_out(8, TRUE);
++      
++
++      sys_mod_state = 2;
++
++}
++void wan_led_init(void)
++{
++      
++      tnetd73xx_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
++      tnetd73xx_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
++      
++      tnetd73xx_gpio_out(2, FALSE);
++      tnetd73xx_gpio_out(3, FALSE);
++
++      wan_mod_state = 1;
++}
++//wwzh wireless
++#if 0
++void wlan_led_init(void)
++{
++      //unsigned long i = 0;  
++      tnetd73xx_gpio_ctrl(12, GPIO_PIN, GPIO_OUTPUT_PIN);
++      tnetd73xx_gpio_ctrl(13, GPIO_PIN, GPIO_OUTPUT_PIN);
++      
++      tnetd73xx_gpio_out(12, FALSE);
++      tnetd73xx_gpio_out(13, TRUE);
++      //for (i = 0; i < 0x20000000; i++);
++      wlan_mod_state = 1;
++}
++#endif
++
++#endif
++/*************end ****************/
++
++void board_gpio_init(void)
++{
++
++      board_gpio_reset();
++/**************wwzh*************/
++      sys_led_init();
++      wan_led_init();
++
++      //junzhao 2004.3.15
++      hardware_version_init();
++      
++      //wlan_led_init();
++
++      /* Register Device MAX_LED_ID + 1 for reset to factory default */
++       temp[0].param = 0;
++       temp[0].init = reset_init;
++       temp[0].onfunc = 0;
++       temp[0].offfunc = 0;
++       register_led_drv( MAX_LED_ID + 1 , &temp[0]);
++//wwzh for wireless led  
++#if 1
++  /* Register led 12 WiFi 6 */
++  temp[1].param = 6;
++  temp[1].init = gpio_led_init;
++  temp[1].onfunc = gpio_led_on;
++  temp[1].offfunc = gpio_led_off;
++  register_led_drv( 12 , &temp[1]);
++
++#endif
++
++#if 0
++/**************end ************/
++#if defined(CONFIG_AR5D01)
++  /* Register led 1 GPIO0 */
++  temp[0].param = GPIO_0;
++  temp[0].init = gpio_led_init;
++  temp[0].onfunc = gpio_led_on;
++  temp[0].offfunc = gpio_led_off;
++      register_led_drv( 1 , &temp[0]);
++
++  /* Register led 2 EINT1 */
++  temp[1].param = EINT_1;
++  temp[1].init = gpio_led_init;
++  temp[1].onfunc = gpio_led_on;
++  temp[1].offfunc = gpio_led_off;
++      register_led_drv( 2 , &temp[1]);
++
++  /* Register led 5 EINT1 */
++  temp[2].param = GPIO_1;
++  temp[2].init = gpio_led_init;
++  temp[2].onfunc = gpio_led_on;
++  temp[2].offfunc = gpio_led_off;
++      register_led_drv( 5 , &temp[2]);
++#endif
++
++#if defined(CONFIG_AR5W01)
++  /* Register led 5 GPIO_1 */
++  temp[0].param = GPIO_1;
++  temp[0].init = gpio_led_init;
++  temp[0].onfunc = gpio_led_on;
++  temp[0].offfunc = gpio_led_off;
++      register_led_drv( 5 , &temp[0]);
++
++  /* Register led 7 GPIO_0 */
++  temp[1].param = GPIO_0;
++  temp[1].init = gpio_led_init;
++  temp[1].onfunc = gpio_led_on;
++  temp[1].offfunc = gpio_led_off;
++      register_led_drv( 7 , &temp[1]);
++#endif
++
++//wwzh #if defined(CONFIG_AR7RD)
++#if defined CONFIG_AR7WRD || defined CONFIG_AR7RD
++  /* Register led 5 Green PPPOE GPIO 13 */
++  temp[0].param = 13;
++  temp[0].init = gpio_led_init;
++  temp[0].onfunc = gpio_led_on;
++  temp[0].offfunc = gpio_led_off;
++      register_led_drv( 5 , &temp[0]);
++
++  /* Register led 7 Green USB GPIO 12 */
++  temp[1].param = 12;
++  temp[1].init = gpio_led_init;
++  temp[1].onfunc = gpio_led_on;
++  temp[1].offfunc = gpio_led_off;
++      register_led_drv( 7 , &temp[1]);
++
++  /* Register Device MAX_LED_ID + 1 for reset to factory default */
++  temp[2].param = 0;
++  temp[2].init = reset_init;
++  temp[2].onfunc = 0;
++  temp[2].offfunc = 0;
++      register_led_drv( MAX_LED_ID + 1 , &temp[2]);
++
++  /* Register led 8 RED DSL GPIO 10 */
++  temp[3].param = 10;
++  temp[3].init = gpio_led_init;
++  temp[3].onfunc = gpio_led_on;
++  temp[3].offfunc = gpio_led_off;
++      register_led_drv( 8 , &temp[3]);
++
++  /* Register led 9 RED PPPoE down GPIO 9 */
++  temp[4].param = 9;
++  temp[4].init = gpio_led_init;
++  temp[4].onfunc = gpio_led_on;
++  temp[4].offfunc = gpio_led_off;
++      register_led_drv( 9 , &temp[4]);
++
++  /* Register led 10 DSL down GPIO 8 */
++  temp[5].param = 8;
++  temp[5].init = gpio_led_init;
++  temp[5].onfunc = gpio_led_on;
++  temp[5].offfunc = gpio_led_off;
++      register_led_drv( 10 , &temp[5]);
++
++  /* Register led 11 Power GPIO 7 */
++  temp[6].param = 7;
++  temp[6].init = gpio_led_init;
++  temp[6].onfunc = gpio_led_on;
++  temp[6].offfunc = gpio_led_off;
++      register_led_drv( 11 , &temp[6]);
++
++  /* Register led 12 WiFi 6 */
++  temp[7].param = 6;
++  temp[7].init = gpio_led_init;
++  temp[7].onfunc = gpio_led_on;
++  temp[7].offfunc = gpio_led_off;
++      register_led_drv( 12 , &temp[7]);
++
++  /* Register led 13 ELINK(AA1313) GPIO 15 */
++  temp[8].param = 15;
++  temp[8].init = gpio_led_init;
++  temp[8].onfunc = gpio_led_on;
++  temp[8].offfunc = gpio_led_off;
++      register_led_drv( 13 , &temp[8]);
++
++  /* Register led 14 EACT(Y13) GPIO 16 */
++  temp[9].param = 16;
++  temp[9].init = gpio_led_init;
++  temp[9].onfunc = gpio_led_on;
++  temp[9].offfunc = gpio_led_off;
++      register_led_drv( 14 , &temp[9]);
++
++#endif
++/**************wwzh**************/
++#endif
++/**************end **************/
++  return;
++}
++
++
++
++
++
++
++
++
 diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/avalanche_led/ledmod.c
 --- linux.old/drivers/char/avalanche_led/ledmod.c      1970-01-01 01:00:00.000000000 +0100
-+++ linux.dev/drivers/char/avalanche_led/ledmod.c      2005-07-11 03:16:48.247012224 +0200
-@@ -0,0 +1,719 @@
++++ linux.dev/drivers/char/avalanche_led/ledmod.c      2005-07-12 03:12:40.675888720 +0200
+@@ -0,0 +1,1116 @@
 +#include <linux/config.h>
 +#include <linux/init.h>
 +#include <linux/kernel.h>
@@ -23,224 +409,189 @@ diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/a
 +#define LED_BLINK_UP                  5
 +#define LED_BLINK_DOWN        6
 +
-+typedef struct state_entry {
-+      unsigned char mode;
-+      unsigned char led;
-+      void (*handler) (struct state_entry * pState);
-+      unsigned long param;
-+} state_entry_t;
++extern void avalanche_leds_init(void);
++
++/***********wwzh**************/
++unsigned int sys_mod_state;
++unsigned int wan_mod_state;
++unsigned int wlan_mod_state;
 +
-+typedef struct mod_entry {
-+      state_entry_t *states[MAX_STATE_ID];
-+} mod_entry_t;
++struct timer_list *pWanTimer = NULL;
++struct timer_list *pWlanTimer = NULL;
++/***********end **************/
++
++typedef struct state_entry{
++  unsigned char mode;
++  unsigned char led;
++      void (*handler)(struct state_entry *pState);
++  unsigned long param;
++}state_entry_t;
++
++typedef struct mod_entry{
++  state_entry_t *states[MAX_STATE_ID];
++}mod_entry_t;
 +
 +static mod_entry_t *modArr[MAX_MOD_ID];
-+static struct proc_dir_entry *led_proc_dir, *led_file;
++static struct proc_dir_entry *led_proc_dir,*led_file;
 +
 +/* index of the array is the led number HARDWARE SPECIFIC*/
-+typedef struct led_data {
++typedef struct led_data{
 +      led_reg_t *led;
-+      int state;
++  int                         state;
 +      struct timer_list *pTimer;
 +      unsigned char timer_running;
-+      unsigned long param;
-+} led_data_t;
++  unsigned long param;
++}led_data_t;
 +
 +led_data_t led_arr[MAX_LED_ID + 1];
 +/*!!! The last device is actually being used for ar7 reset to factory default */
-+#if 1
-+/* Ron add for adsl LED blink */
-+#define GPIO_ADSL_ACT  (1<<6)
-+#define GPIO_ADSL_DOWN (1<<8)
-+#define BLINK_FAST     5*HZ/100
-+#define BLINK_SLOW     15*HZ/100
-+static struct timer_list my_led_timer;
-+static int my_blink_count = 0;
-+static int my_mode = 1;
-+void led_operation(int mod, int state);
-+
-+static void my_led_on(unsigned long gpio, int logic)
-+{
-+      if (logic > 0)
-+              GPIO_DATA_OUTPUT |= gpio;
-+      else
-+              GPIO_DATA_OUTPUT &= ~gpio;
-+
-+}
-+static void my_led_off(unsigned long gpio, int logic)
-+{
-+      if (logic > 0)
-+              GPIO_DATA_OUTPUT &= ~gpio;
-+      else
-+              GPIO_DATA_OUTPUT |= gpio;
-+
-+}
 +
-+static void my_led_init(unsigned long gpio, int init, int logic)
-+{
-+      GPIO_DATA_ENABLE |= gpio;
-+      GPIO_DATA_DIR &= ~gpio;
-+      if (init)
-+              my_led_on(gpio, logic);
-+      else
-+              my_led_off(gpio, logic);
-+}
 +
-+static void my_led_blink_timer(unsigned long data)
-+{
-+      unsigned long gpio = GPIO_ADSL_ACT;
-+      unsigned int speed = BLINK_FAST;
-+      if (my_mode == 2) {
-+              gpio = GPIO_ADSL_DOWN;
-+              speed = BLINK_SLOW;
-+      }
-+      if (my_blink_count) {
-+              if (GPIO_DATA_OUTPUT & gpio) {
-+                      GPIO_DATA_OUTPUT &= ~gpio;
-+                      if (my_mode != 2)
-+                              my_blink_count = 0;
-+              } else {
-+                      GPIO_DATA_OUTPUT |= gpio;
-+              }
-+      }
-+      my_led_timer.expires = jiffies + speed;
-+      add_timer(&my_led_timer);
-+}
-+
-+/* Ron add for ADSL led blink */
-+#endif
-+static spinlock_t config_lock;
++static spinlock_t     config_lock;
 +
-+static void board_led_link_up(state_entry_t * pState);
-+static void board_led_link_down(state_entry_t * pState);
-+static void board_led_activity_on(state_entry_t * pState);
-+static void board_led_activity_off(state_entry_t * pState);
++static void board_led_link_up( state_entry_t *pState );
++static void board_led_link_down( state_entry_t *pState );
++static void board_led_activity_on( state_entry_t *pState );
++static void board_led_activity_off( state_entry_t *pState );
 +static void led_timer_func(unsigned long data);
 +
-+static ssize_t proc_read_led_fops(struct file *filp, char *buf, size_t count, loff_t * offp);
-+static ssize_t proc_write_led_fops(struct file *filp, const char *buffer, size_t count, loff_t * offp);
-+static int config_led(unsigned long y);
++extern void board_gpio_init(void);
++extern void uart_led_init(void);
++
++static ssize_t proc_read_led_fops(struct file *filp,
++                                 char *buf,size_t count , loff_t *offp);
++static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
++                                                      size_t count , loff_t *offp);
++static int config_led( unsigned long y);
 +
 +struct file_operations led_fops = {
-+  read:proc_read_led_fops,
-+  write:proc_write_led_fops,
-+};
++                                     read: proc_read_led_fops,
++                                     write: proc_write_led_fops,
++                                   };
 +
-+static int led_atoi(char *name)
++static int led_atoi( char *name)
 +{
 +      int val = 0;
-+      for (;; name++) {
-+              switch (*name) {
-+              case '0'...'9':
-+                      val = val * 10 + (*name - '0');
-+                      break;
-+              default:
-+                      return val;
++  for(;;name++)
++      {
++              switch(*name)
++              {
++                      case '0'...'9':
++                              val = val*10+(*name - '0');
++                              break;
++                      default:
++                              return val;
 +              }
 +      }
 +}
 +
 +static int free_memory(void)
 +{
-+      int i, j;
-+
-+      for (i = 0; i < MAX_MOD_ID; i++) {
-+              if (modArr[i] != NULL) {
-+                      for (j = 0; j < MAX_STATE_ID; j++) {
-+                              if (modArr[i]->states[j] != NULL)
-+                                      kfree(modArr[i]->states[j]);
++  int i, j;
++
++  for( i = 0; i < MAX_MOD_ID ; i++)
++      {
++              if( modArr[i] != NULL )
++              {
++                      for( j = 0; j < MAX_STATE_ID ; j++ )
++                      {
++                              if( modArr[i]->states[j] != NULL )
++                                      kfree( modArr[i]->states[j]);
 +                      }
 +                      kfree(modArr[i]);
-+                      modArr[i] = NULL;
++      modArr[i] = NULL;
 +              }
 +      }
-+      return 0;
++  return 0;
 +}
 +
-+static int led_on(state_entry_t * pState)
++static int led_on( state_entry_t *pState )
 +{
-+      if (led_arr[pState->led].led == NULL)
++      ifled_arr[pState->led].led == NULL)
 +              return -1;
-+      led_arr[pState->led].led->onfunc(led_arr[pState->led].led->param);
-+      return 0;
++  led_arr[pState->led].led->onfunc( led_arr[pState->led].led->param);
++  return 0;
 +}
 +
-+static int led_off(state_entry_t * pState)
++static int led_off( state_entry_t *pState )
 +{
-+      if (led_arr[pState->led].led == NULL)
++      ifled_arr[pState->led].led == NULL)
 +              return -1;
-+      led_arr[pState->led].led->offfunc(led_arr[pState->led].led->param);
-+      return 0;
++  led_arr[pState->led].led->offfunc( led_arr[pState->led].led->param);
++  return 0;
 +}
 +
-+static void board_led_link_up(state_entry_t * pState)
++static void board_led_link_up( state_entry_t *pState )
 +{
-+      led_arr[pState->led].state = LED_ON;
-+      if (led_arr[pState->led].timer_running == 0)
-+              led_on(pState);
-+      return;
++  led_arr[pState->led].state = LED_ON;
++  if( led_arr[pState->led].timer_running == 0 )
++      led_on(pState);
++  return;
 +}
 +
-+static void board_led_link_down(state_entry_t * pState)
++static void board_led_link_down( state_entry_t *pState )
 +{
 +      led_arr[pState->led].state = LED_OFF;
-+      if (led_arr[pState->led].timer_running == 0)
-+              led_off(pState);
-+      return;
++  if( led_arr[pState->led].timer_running == 0 )
++      led_off(pState);
++  return;
 +}
 +
-+static void add_led_timer(state_entry_t * pState)
++static void add_led_timer(state_entry_t *pState)
 +{
-+      led_arr[pState->led].pTimer->expires =
-+              jiffies + HZ * (pState->param) / 1000;
-+      led_arr[pState->led].param = pState->param;
-+      led_arr[pState->led].pTimer->data = pState;
-+      add_timer(led_arr[pState->led].pTimer);
++      led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
++  led_arr[pState->led].param = pState->param;
++  led_arr[pState->led].pTimer->data = pState;
++      add_timer (led_arr[pState->led].pTimer);
 +}
 +
-+static void board_led_activity_on(state_entry_t * pState)
++static void board_led_activity_on(state_entry_t *pState)
 +{
-+      if (led_arr[pState->led].timer_running == 0) {
++  if(led_arr[pState->led].timer_running == 0)
++      {
 +              led_on(pState);
 +              add_led_timer(pState);
-+              led_arr[pState->led].timer_running = 1;
-+              led_arr[pState->led].state = LED_BLINK_UP;
-+      } else if (led_arr[pState->led].timer_running > 0xF0) {
-+              led_arr[pState->led].state = LED_BLINK_UP;
-+              led_arr[pState->led].pTimer->expires =
-+                      jiffies + HZ * (pState->param) / 1000;
-+              led_arr[pState->led].param = pState->param;
-+              led_arr[pState->led].pTimer->data = pState;
++        led_arr[pState->led].timer_running = 1;
++        led_arr[pState->led].state = LED_BLINK_UP;
++      }
++      else if( led_arr[pState->led].timer_running > 0xF0)
++      {
++        led_arr[pState->led].state = LED_BLINK_UP;
++              led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
++      led_arr[pState->led].param = pState->param;
++      led_arr[pState->led].pTimer->data = pState;
 +      }
 +      return;
 +}
 +
-+static void board_led_activity_off(state_entry_t * pState)
++static void board_led_activity_off(state_entry_t *pState)
 +{
-+      if (led_arr[pState->led].timer_running == 0) {
++  if(led_arr[pState->led].timer_running == 0)
++      {
 +              led_off(pState);
 +              add_led_timer(pState);
-+              led_arr[pState->led].timer_running = 1;
-+              led_arr[pState->led].state = LED_BLINK_UP;
-+      } else if (led_arr[pState->led].timer_running > 0xF0) {
-+              led_arr[pState->led].state = LED_BLINK_UP;
-+              led_arr[pState->led].pTimer->expires =
-+                      jiffies + HZ * (pState->param) / 1000;
-+              led_arr[pState->led].param = pState->param;
-+              led_arr[pState->led].pTimer->data = pState;
++        led_arr[pState->led].timer_running = 1;
++        led_arr[pState->led].state = LED_BLINK_UP;
++      }
++      else if( led_arr[pState->led].timer_running > 0xF0)
++      {
++        led_arr[pState->led].state = LED_BLINK_UP;
++              led_arr[pState->led].pTimer->expires = jiffies + HZ*(pState->param)/1000;
++      led_arr[pState->led].param = pState->param;
++      led_arr[pState->led].pTimer->data = pState;
 +      }
 +      return;
 +}
 +
-+static void board_led_link_flash(state_entry_t * pState)
++static void board_led_link_flash(state_entry_t *pState)
 +{
-+      if (led_on(pState))
++  if(led_on(pState))
 +              return;
-+      if (led_arr[pState->led].timer_running == 0)
++  if(led_arr[pState->led].timer_running == 0)
 +              add_led_timer(pState);
 +      else
-+              led_arr[pState->led].param = pState->param;
-+      led_arr[pState->led].timer_running = 0xFF;
++    led_arr[pState->led].param = pState->param;
++  led_arr[pState->led].timer_running = 0xFF;
 +      led_arr[pState->led].state = LED_FLASH;
 +      return;
 +}
@@ -248,157 +599,641 @@ diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/a
 +static void led_timer_func(unsigned long data)
 +{
 +      state_entry_t *pState = NULL;
-+      mod_entry_t *pMod = NULL;
++  mod_entry_t *pMod = NULL;
 +      unsigned int flags;
 +
 +      spin_lock_irqsave(&config_lock, flags);
 +
-+      pState = (state_entry_t *) data;
++  pState = (state_entry_t *)data;
 +
-+      if (led_arr[pState->led].state == LED_BLINK_DOWN) {
++  if( led_arr[pState->led].state == LED_BLINK_DOWN )
++      {
 +              led_arr[pState->led].timer_running = 0;
-+              if (pState->mode == 2)
++              if( pState->mode == 2 )
 +                      led_arr[pState->led].state = LED_OFF;
 +              else
 +                      led_arr[pState->led].state = LED_ON;
-+      } else if (led_arr[pState->led].state == LED_BLINK_UP) {
-+              led_arr[pState->led].pTimer->expires =
-+                      jiffies + HZ * (led_arr[pState->led].param) / 1000;
-+              led_arr[pState->led].pTimer->data = pState;
-+              add_timer(led_arr[pState->led].pTimer);
-+              if (pState->mode == 2) {
-+                      led_off(pState);
++      }
++  else if( led_arr[pState->led].state == LED_BLINK_UP )
++      {
++    led_arr[pState->led].pTimer->expires = jiffies + HZ*(led_arr[pState->led].param)/1000;
++      led_arr[pState->led].pTimer->data = pState;
++              add_timer (led_arr[pState->led].pTimer);
++              if( pState->mode == 2 )
++              {
++              led_off(pState);
 +                      led_arr[pState->led].state = LED_BLINK_DOWN;
-+              } else {
-+                      led_on(pState);
++              }
++              else
++              {
++              led_on(pState);
 +                      led_arr[pState->led].state = LED_BLINK_DOWN;
 +              }
 +              led_arr[pState->led].timer_running = 1;
-+      } else if (led_arr[pState->led].state == LED_FLASH) {
-+              led_arr[pState->led].pTimer->expires =
-+                      jiffies + HZ * (led_arr[pState->led].param) / 1000;
-+              led_arr[pState->led].pTimer->data = pState;
-+              add_timer(led_arr[pState->led].pTimer);
-+
-+              if (led_arr[pState->led].timer_running == 0xFF) {
-+                      led_off(pState);
++      }
++  else if( led_arr[pState->led].state == LED_FLASH )
++      {
++    led_arr[pState->led].pTimer->expires = jiffies + HZ*(led_arr[pState->led].param)/1000;
++      led_arr[pState->led].pTimer->data = pState;
++              add_timer (led_arr[pState->led].pTimer);
++
++              if( led_arr[pState->led].timer_running == 0xFF )
++              {
++              led_off(pState);
 +                      led_arr[pState->led].timer_running--;
-+              } else {
-+                      led_on(pState);
++              }
++              else
++              {
++              led_on(pState);
 +                      led_arr[pState->led].timer_running++;
 +              }
 +              spin_unlock_irqrestore(&config_lock, flags);
++    return;
++      }
++  else if(led_arr[pState->led].state == LED_OFF)
++      {
++      led_off(pState);
++    led_arr[pState->led].timer_running = 0;
++      }
++      else if( led_arr[pState->led].state == LED_ON )
++      {
++      led_on(pState);
++    led_arr[pState->led].timer_running = 0;
++      }
++      spin_unlock_irqrestore(&config_lock, flags);
++  return;
++}
++/************wwzh*****************/
++#if 0
++/************end *****************/
++static ssize_t proc_read_led_fops(struct file *filp,
++                                 char *buf,size_t count , loff_t *offp)
++{
++  char * pdata = NULL;
++  int i = 0, j = 0, len = 0, totallen = 0;
++  char line[255];
++
++  if( *offp != 0 )
++      return 0;
++
++  pdata = buf;
++  len += sprintf(line,"LEDS Registered for use are:");
++  for( i = 0; i< MAX_LED_ID; i++)
++              if( led_arr[i].led != NULL )
++                      len += sprintf(&line[len]," %d ", i );
++  line[len++] = '\n';
++
++  copy_to_user(pdata, line,len );
++  pdata += len;
++  totallen += len;
++  len = 0;
++  len = sprintf(line,"USER MODULE INFORMATION:\n");
++  copy_to_user(pdata, line,len );
++  pdata += len;
++  totallen += len;
++  len = 0;
++  for( i = 0; i< MAX_MOD_ID; i++)
++      {
++              if( modArr[i] != NULL )
++              {
++                      len = sprintf(line,"  Module ID = %d \n" , i);
++              copy_to_user(pdata, line,len );
++      pdata += len;
++              totallen += len;
++              len = 0;
++                      for( j = 0; j < MAX_STATE_ID; j++)
++                      {
++                              if( modArr[i]->states[j] != NULL)
++                              {
++                                      len = sprintf(line ,
++                              "    State = %d , Led = %d," , j , modArr[i]->states[j]->led);
++                              copy_to_user(pdata, line,len );
++          pdata += len;
++                              totallen += len;
++
++                              len = 0;
++          switch( modArr[i]->states[j]->mode )
++                                      {
++                                              case 1:
++                                                                      len = sprintf(line ," Mode = OFF\n");
++                                                                      break;
++                                              case 2:
++                                                                      len = sprintf(line ," Mode = BLINK_ON , On Time(ms) = %d\n" ,
++                                       (unsigned int)modArr[i]->states[j]->param);
++                                                                      break;
++                                              case 3:
++                                                                      len = sprintf(line ," Mode = BLINK_OFF , Off Time(ms) = %d\n" ,
++                                       (unsigned int)modArr[i]->states[j]->param);
++                                                                      break;
++                                              case 4:
++                                                                      len = sprintf(line ," Mode = ON \n");
++                                                                      break;
++                                              case 5:
++                                                                      len = sprintf(line ," Mode = FLASH , Time Period(ms) = %d\n" ,
++                                       (unsigned int)modArr[i]->states[j]->param);
++                                                                      break;
++                                              default:
++                                                      break;
++
++                                      }
++                              copy_to_user(pdata, line,len );
++          pdata += len;
++                              totallen += len;
++
++                              len = 0;
++                              }
++                      }
++              }
++      }
++  /* Return with configuration information for LEDs */
++      *offp = totallen;
++      return totallen;
++}
++static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
++                                                      size_t count , loff_t *offp)
++{
++  char *pdata = NULL, *ptemp = NULL;
++  char line[10],temp[10];
++  int i = 0;
++  int mod = 0xFFFF , state = 0xFFFF;
++  int flag = 0;
++
++  /* Check if this write is for configuring stuff */
++  if( *(int *)(buffer) == 0xFFEEDDCC )
++      {
++    printk("<1>proc write:Calling Configuration\n");
++              config_led((unsigned long)(buffer + sizeof(int)) );
++              return count;
++      }
++
++  if( count >= 10)
++      {
++    printk("<1>proc write:Input too long,max length = %d\n",10);
++    return count;
++      }
++  memset( temp, 0x00 , 10);
++  memset( line, 0x00 , 10);
++  copy_from_user(line,buffer,count);
++  line[count] = 0x00;
++  pdata = line;
++  ptemp = temp;
++  while( flag == 0)
++  {
++              if( i > 10 )
++                      break;
++              if( ((*pdata) >= '0' ) && ((*pdata) <= '9') )
++              {       
++                      *ptemp = *pdata ;
++                      ptemp++;
++              }       
++              else if( (*pdata) == ',' )
++              {
++      *ptemp = 0x00;
++                      flag = 1;
++              }       
++              pdata++;
++              i++;
++  };
++      if( flag == 1)
++      mod = led_atoi( temp);
++      else
++              return count;
++              
++  ptemp = temp;
++  *ptemp = 0x00;
++  flag = 0;
++  while( flag == 0)
++  {
++              if( i > 10 )
++                      break;
++              if( ((*pdata) >= '0' ) && ((*pdata) <= '9') )
++              {       
++                      *ptemp = *pdata ;
++                      ptemp++;
++              }       
++              else if( (*pdata) == 0x00 )
++              {
++      *ptemp = 0x00;
++                      flag = 1;
++              }       
++              pdata++;
++    i++;
++  };
++      if( flag == 1)
++      state = led_atoi( temp);
++      else
++              return count;
++  if( (mod == 0xFFFF) || (state == 0xFFFF))
++              return count;
++  else
++    led_operation( mod , state );
++  return count;
++}
++
++/************wwzh*******************/
++#else
++
++#define TRUE 1
++#define FALSE 0
++#define FLICK_TIME (HZ*100/1000)
++static unsigned int wan_txrx_state = 0;
++static unsigned int wlan_txrx_state = 0;
++
++void led_operation( int mod , int state)
++{
++
++      unsigned int flags;
++
++      spin_lock_irqsave(&config_lock, flags);
++
++      if( (mod >= MAX_MOD_ID) || ( state >= MAX_STATE_ID) )
++      {
++        spin_unlock_irqrestore(&config_lock, flags);
++              return;
++      }
++      if ( modArr[mod] == NULL )
++      {
++        spin_unlock_irqrestore(&config_lock, flags);
++              return;
++      }
++      if( modArr[mod]->states[state] == NULL )
++      {
++        spin_unlock_irqrestore(&config_lock, flags);
 +              return;
-+      } else if (led_arr[pState->led].state == LED_OFF) {
-+              led_off(pState);
-+              led_arr[pState->led].timer_running = 0;
-+      } else if (led_arr[pState->led].state == LED_ON) {
-+              led_on(pState);
-+              led_arr[pState->led].timer_running = 0;
 +      }
++  /* Call the function handler  */
++  modArr[mod]->states[state]->handler(modArr[mod]->states[state]);
++
 +      spin_unlock_irqrestore(&config_lock, flags);
-+      return;
 +}
 +
++static void wan_led_func(unsigned long data)
++{
++      if (wan_txrx_state == 0)
++      {
++              tnetd73xx_gpio_out(2, TRUE);
++              tnetd73xx_gpio_out(3, FALSE);
++              wan_txrx_state = 1;
++      }
++      else
++      {
++              tnetd73xx_gpio_out(2, FALSE);
++              tnetd73xx_gpio_out(3, FALSE);
++              wan_txrx_state = 0;
++      }
++      pWanTimer->expires = jiffies + FLICK_TIME;
++      add_timer(pWanTimer);
++}
++//wwzh for wireless
++#if 0
++static void wlan_led_func(unsigned long data)
++{
++      if (wlan_txrx_state == 0)
++      {
++              tnetd73xx_gpio_out(12, TRUE);
++              tnetd73xx_gpio_out(13, FALSE);
++              wlan_txrx_state = 1;
++      }
++      else
++      {
++              tnetd73xx_gpio_out(12, FALSE);
++              tnetd73xx_gpio_out(13, FALSE);
++              wlan_txrx_state = 0;
++              
++      }
++      pWlanTimer->expires = jiffies + FLICK_TIME;
++      add_timer(pWlanTimer);
++}
++#endif
++
++void led_active(int mod, int state)
++{
++      unsigned int flags = 0;
++
++//printk("mod = %d state = %d\n", mod, state);
++      spin_lock_irqsave(&config_lock, flags);
++      if ((mod >= 5) || (state >= 5))
++      {
++              spin_unlock_irqrestore(&config_lock, flags);
++              return;
++      }
++      
++      switch (mod)
++      {
++              case 2: /*system led */
++                      sys_mod_state = state;
++                      switch (state)
++                      {
++                              case 1: 
++                                      break;
++                              case 2:  /*sys led flashing green */
++                                      tnetd73xx_gpio_out(4, FALSE);
++                                      tnetd73xx_gpio_out(5, TRUE);
++                                      tnetd73xx_gpio_out(8, TRUE);
++                                      break;
++                              case 3: /*sys led solid green */
++                                      tnetd73xx_gpio_out(4, TRUE);
++                                      tnetd73xx_gpio_out(5, TRUE);
++                                      tnetd73xx_gpio_out(8, TRUE);
++                                      
++                                      break;
++                              case 4: /*sys fail red */
++                                      tnetd73xx_gpio_out(4, TRUE);
++                                      tnetd73xx_gpio_out(5, FALSE);
++                                      tnetd73xx_gpio_out(8, FALSE);
++                                      break;
++                              default:
++                                      break;
++                      }
++                      break;
++              case 3: /*wan led */
++                      wan_mod_state = state;
++                      switch (state)
++                      {
++                              case 1: /*no wan interface*/
++                                      if (pWanTimer)
++                                      {
++                                              del_timer(pWanTimer);
++                                              kfree(pWanTimer);
++                                              pWanTimer = NULL;
++                                      }
++                                      tnetd73xx_gpio_out(2, FALSE);
++                                      tnetd73xx_gpio_out(3, FALSE);
++                                      break;
++                              case 2: /*wan connected */
++                                      if (pWanTimer)
++                                      {
++                                              del_timer(pWanTimer);
++                                              kfree(pWanTimer);
++                                              pWanTimer = NULL;
++                                      }
++                                      tnetd73xx_gpio_out(2, TRUE);
++                                      tnetd73xx_gpio_out(3, FALSE);
++                                      break;
++                              case 3: /*rx/tx activity */
++                                      if (pWanTimer != NULL)
++                                              break;  
++                              
++                                      pWanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
++                                      init_timer(pWanTimer);
++                                      
++                                      pWanTimer->function = wan_led_func;
++                                      pWanTimer->data = 0;
++                                      pWanTimer->expires = jiffies + FLICK_TIME;
++                                      tnetd73xx_gpio_out(2, FALSE);
++                                      tnetd73xx_gpio_out(3, FALSE);
++                                      wan_txrx_state = 0;
++                                      add_timer(pWanTimer);
++
++                                      break;
++                              case 4: /*no ipaddress */
++                                      if (pWanTimer)
++                                      {
++                                              del_timer(pWanTimer);
++                                              kfree(pWanTimer);
++                                              pWanTimer = NULL;
++                                      }
++                                      tnetd73xx_gpio_out(2, FALSE);
++                                      tnetd73xx_gpio_out(3, TRUE);
++                                      break;
++                              default:
++                                      if (pWanTimer)
++                                      {       
++                                              del_timer(pWanTimer);
++                                              kfree(pWanTimer);
++                                              pWanTimer = NULL;
++                                      }
++                                      break;
++                      }
++                      break;
++      //wwzh for wireless 
++      #if 0
++              case 4: /*wlan led */
++                      wlan_mod_state = state;
++                      switch (state)
++                      {
++                              case 1: /* wlan off */
++                                      if (pWlanTimer)
++                                      {
++                                              del_timer(pWlanTimer);
++                                              kfree(pWlanTimer);
++                                              pWlanTimer = NULL;
++                                      }
++                                      tnetd73xx_gpio_out(12, FALSE);
++                                      tnetd73xx_gpio_out(13, FALSE);
++                                      break;
++                              case 2: /* wlan ready */
++                                      if (pWlanTimer)
++                                      {
++                                              del_timer(pWlanTimer);
++                                              kfree(pWlanTimer);
++                                              pWlanTimer = NULL;
++                                      }
++                                      tnetd73xx_gpio_out(12, TRUE);
++                                      tnetd73xx_gpio_out(13, FALSE);
++                                      break;
++                              case 3: /* wlan rx/tx activity */
++                                      if (pWlanTimer != NULL)
++                                              break;
++                                      
++                                      pWlanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
++                                      init_timer(pWlanTimer);
++                                      
++                                      pWlanTimer->function = wlan_led_func;
++                                      pWlanTimer->data = 0;
++                                      pWlanTimer->expires = jiffies + FLICK_TIME;
++                                      tnetd73xx_gpio_out(12, FALSE);
++                                      tnetd73xx_gpio_out(13, FALSE);
++                                      wlan_txrx_state = 0;
++                                      add_timer(pWlanTimer);
++                                      
++                                      break;
++                              default:
++                                      if (pWlanTimer)
++                                      {
++                                              del_timer(pWlanTimer);
++                                              kfree(pWlanTimer);
++                                              pWlanTimer = NULL;
++                                      }
++                                      
++                                      break;
++                      }
++                      break;
++      #endif //for wireless
++              default:
++                      break;
++      }
++      spin_unlock_irqrestore(&config_lock, flags);
++}
 +static ssize_t proc_read_led_fops(struct file *filp,
-+                                                                char *buf, size_t count, loff_t * offp)
++                                 char *buf,size_t count , loff_t *offp)
 +{
 +      char *pdata = NULL;
 +      int i = 0, j = 0, len = 0, totallen = 0;
 +      char line[255];
-+
++      
 +      if (*offp != 0)
 +              return 0;
-+
 +      pdata = buf;
-+      len += sprintf(line, "LEDS Registered for use are:");
-+      for (i = 0; i < MAX_LED_ID; i++)
-+              if (led_arr[i].led != NULL)
-+                      len += sprintf(&line[len], " %d ", i);
-+      line[len++] = '\n';
-+
-+      copy_to_user(pdata, line, len);
-+      pdata += len;
-+      totallen += len;
-+      len = 0;
 +      len = sprintf(line, "USER MODULE INFORMATION:\n");
 +      copy_to_user(pdata, line, len);
 +      pdata += len;
 +      totallen += len;
 +      len = 0;
-+      for (i = 0; i < MAX_MOD_ID; i++) {
-+              if (modArr[i] != NULL) {
-+                      len = sprintf(line, "  Module ID = %d \n", i);
++      
++      //*******add Module 1 , this Module is ADSL ********/
++      for (i = 0; i < MAX_MOD_ID; i++)
++      {
++              if (modArr[i] != NULL)
++              {
++                      len = sprintf(line, " Module ID = %d\n", i);
 +                      copy_to_user(pdata, line, len);
 +                      pdata += len;
 +                      totallen += len;
 +                      len = 0;
-+                      for (j = 0; j < MAX_STATE_ID; j++) {
-+                              if (modArr[i]->states[j] != NULL) {
-+                                      len = sprintf(line,       "    State = %d , Led = %d,", j,
-+                                                                modArr[i]->states[j]->led);
++                      for(j = 0; j < MAX_STATE_ID; j++)
++                      {
++                              if (modArr[i]->states[j] != NULL)
++                              {
++                                      len = sprintf(line, "State =%d, Led = %d,", j, modArr[i]->states[j]->led);
 +                                      copy_to_user(pdata, line, len);
 +                                      pdata += len;
 +                                      totallen += len;
-+
 +                                      len = 0;
-+                                      switch (modArr[i]->states[j]->mode) {
-+                                      case 1:
-+                                              len = sprintf(line,     " Mode = OFF\n");
-+                                              break;
-+                                      case 2:
-+                                              len = sprintf(line,     " Mode = BLINK_ON , On Time(ms) = %d\n",
-+                                                                      (unsigned int) modArr[i]->states[j]->
-+                                                                      param);
-+                                              break;
-+                                      case 3:
-+                                              len = sprintf(line,     " Mode = BLINK_OFF , Off Time(ms) = %d\n",
-+                                                                      (unsigned int) modArr[i]->states[j]->
-+                                                                      param);
-+                                              break;
-+                                      case 4:
-+                                              len = sprintf(line,     " Mode = ON \n");
-+                                              break;
-+                                      case 5:
-+                                              len = sprintf(line,     " Mode = FLASH , Time Period(ms) = %d\n",
-+                                                                      (unsigned int) modArr[i]->states[j]->
-+                                                                      param);
-+                                              break;
-+                                      default:
-+                                              break;
-+
++                                      switch(modArr[i]->states[j]->mode)
++                                      {
++                                        case 1:
++                                          len = sprintf(line, "Mode = OFF\n");
++                                          break;
++                                        case 2:
++                                          len = sprintf(line, "Mode = BLINK_ON, On Time(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);      
++                                          break;
++                                        case 3:
++                                          len = sprintf(line, "Mode = BLINK_OFF, Off Time(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);
++                                          break;
++                                        case 4:
++                                          len = sprintf(line, "Mode = On\n");
++                                          break;
++                                        case 5:
++                                          len = sprintf(line, "Mode = FLASH, Time Period(ms) = %d\n", (unsigned int)modArr[i]->states[j]->param);
++                                          break;
++                                        default:
++                                          break;              
 +                                      }
 +                                      copy_to_user(pdata, line, len);
 +                                      pdata += len;
 +                                      totallen += len;
-+
 +                                      len = 0;
 +                              }
-+                      }
++                      } 
 +              }
++
 +      }
-+      /* Return with configuration information for LEDs */
++
++      len = sprintf(line, "Module ID = 2(system led)\n");
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++      switch(sys_mod_state)
++      {
++              case 1:
++                      len = sprintf(line, "State = OFF\n");
++                      break;
++              case 2: 
++                      len = sprintf(line, "State = Booting\n");
++                      break;
++              case 3:
++                      len = sprintf(line, "State = System Ready\n");
++                      break;
++              case 4:
++                      len = sprintf(line, "State = System Failure\n");
++                      break;
++              default:
++                      break;
++      }
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++      
++      len = sprintf(line, "Module ID = 3(WAN led)\n");
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++      switch(wan_mod_state)
++      {
++              case 1:
++                      len = sprintf(line, "State = OFF\n");
++                      break;
++              case 2:
++                      len = sprintf(line, "State = Wan Connected\n");
++                      break;
++              case 3:
++                      len = sprintf(line, "State = Wan Tx/Rx Activity\n");
++                      break;
++              case 4:
++                      len = sprintf(line, "State = Wan Connect Failure\n");
++                      break;
++              default:
++                      break;
++      }
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++
++//wwzh for wireless
++#if 0
++      len = sprintf(line, "Module ID = 4(WLAN led)\n");
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++      switch(wlan_mod_state)
++      {
++              case 1:
++                      len = sprintf(line, "State = OFF\n");
++                      break;
++              case 2:
++                      len = sprintf(line, "State = wlan Ready\n");
++                      break;
++              case 3:
++                      len = sprintf(line, "State = wlan rx/tx activity\n");
++                      break;
++              default:
++                      break; 
++      }
++      copy_to_user(pdata, line, len);
++      pdata += len;
++      totallen += len;
++      len = 0;
++#endif //for wireless
++      
 +      *offp = totallen;
 +      return totallen;
 +}
-+
-+static ssize_t proc_write_led_fops(struct file *filp, const char *buffer, size_t count, loff_t * offp)
++static ssize_t proc_write_led_fops(struct file *filp,const char *buffer,
++                                               size_t count , loff_t *offp)
 +{
 +      char *pdata = NULL, *ptemp = NULL;
 +      char line[10], temp[10];
 +      int i = 0;
-+      int mod = 0xFFFF, state = 0xFFFF;
++      int mod = 0xffff, state = 0xffff;
 +      int flag = 0;
 +
-+      /* Check if this write is for configuring stuff */
-+      if (*(int *) (buffer) == 0xFFEEDDCC) {
-+              printk("<1>proc write:Calling Configuration\n");
-+              config_led((unsigned long) (buffer + sizeof(int)));
-+              return count;
++       /* Check if this write is for configuring ADSL */
++      if( *(int *)(buffer) == 0xFFEEDDCC )
++      {
++               printk("<1>proc write:Calling Configuration\n");
++               config_led((unsigned long)(buffer + sizeof(int)) );
++               return count;
 +      }
 +
-+      if (count >= 10) {
-+              printk("<1>proc write:Input too long,max length = %d\n", 10);
++      if (count > 10)
++      {
++              printk("<1> proc write: Input too long, max length = 10\n");
 +              return count;
 +      }
 +      memset(temp, 0x00, 10);
@@ -406,41 +1241,51 @@ diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/a
 +      copy_from_user(line, buffer, count);
 +      line[count] = 0x00;
 +      pdata = line;
-+      ptemp = temp;
-+      while (flag == 0) {
++      ptemp = temp;   
++      
++      while (flag == 0)
++      {
 +              if (i > 10)
 +                      break;
-+              if (((*pdata) >= '0') && ((*pdata) <= '9')) {
++              if (((*pdata) >= '0') && ((*pdata) <= '9'))
++              {
 +                      *ptemp = *pdata;
 +                      ptemp++;
-+              } else if ((*pdata) == ',') {
++              }
++              else if ((*pdata) == ',')
++              {
 +                      *ptemp = 0x00;
 +                      flag = 1;
 +              }
 +              pdata++;
 +              i++;
-+      };
++      }
 +      if (flag == 1)
 +              mod = led_atoi(temp);
 +      else
 +              return count;
-+
++      
 +      ptemp = temp;
 +      *ptemp = 0x00;
 +      flag = 0;
-+      while (flag == 0) {
++      
++      while(flag == 0)
++      {
 +              if (i > 10)
 +                      break;
-+              if (((*pdata) >= '0') && ((*pdata) <= '9')) {
++              if (((*pdata) >= '0') && ((*pdata) <= '9'))
++              {
 +                      *ptemp = *pdata;
 +                      ptemp++;
-+              } else if ((*pdata) == 0x00) {
++              }
++              else if ((*pdata) == 0x00)
++              {
 +                      *ptemp = 0x00;
 +                      flag = 1;
 +              }
 +              pdata++;
 +              i++;
-+      };
++      }
 +      if (flag == 1)
 +              state = led_atoi(temp);
 +      else
@@ -448,230 +1293,171 @@ diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/a
 +      if ((mod == 0xFFFF) || (state == 0xFFFF))
 +              return count;
 +      else
-+              led_operation(mod, state);
-+      return count;
++      {
++              if (mod != 4)
++                      led_active(mod, state); 
++              else 
++                      led_operation(mod, state);
++      } 
++      return 1;
 +}
-+
++#endif
++/************end *******************/
 +static int config_led(unsigned long y)
 +{
-+      config_elem_t *pcfg = NULL;
-+      char *pdata = NULL;
-+      int i;
-+      int length = 0, number = 0;
++  config_elem_t *pcfg = NULL;
++  char *pdata = NULL;
++  int i;
++  int length = 0 , number = 0;
 +      unsigned int flags;
 +
 +      spin_lock_irqsave(&config_lock, flags);
 +
-+      /* ioctl to configure */
-+      length = *((int *) y);
-+      pdata = (char *) y + sizeof(int);
-+      number = (length - sizeof(int)) / sizeof(config_elem_t);
-+      pcfg = (config_elem_t *) (pdata);
-+
-+      /* Check if an earlier configuration exists IF yes free it up */
-+      free_memory();
-+
-+      for (i = 0; i < number; i++) {
-+              /* If no structure has been allocated for the module do so */
-+              if (modArr[pcfg->name] == NULL) {
-+                      printk("<1>module =  %d\n", pcfg->name);
-+                      if (pcfg->name >= MAX_MOD_ID) {
-+                              printk
-+                                      ("<1>Exiting Configuration: Module ID too large %d\n",
-+                                       pcfg->name);
-+                              free_memory();
-+                              spin_unlock_irqrestore(&config_lock, flags);
-+                              return -1;
-+                      }
-+                      modArr[pcfg->name] = kmalloc(sizeof(mod_entry_t), GFP_KERNEL);
-+                      if (modArr[pcfg->name] == NULL) {
-+                              printk
-+                                      ("<1>Exiting Configuration: Error in allocating memory\n");
-+                              free_memory();
-+                              spin_unlock_irqrestore(&config_lock, flags);
-+                              return -1;
++    /* ioctl to configure */
++    length =  *((int*)y);
++    pdata = (char *)y + sizeof(int);
++    number =  (length - sizeof(int))/sizeof(config_elem_t);
++    pcfg = (config_elem_t *)(pdata);
++
++    /* Check if an earlier configuration exists IF yes free it up */
++    free_memory();
++
++    for ( i = 0 ; i < number ; i++ )
++    {
++                      /* If no structure has been allocated for the module do so */
++      if ( modArr[pcfg->name] == NULL )
++                      {
++                                      printk("<1>module =  %d\n",pcfg->name);
++        if( pcfg->name >= MAX_MOD_ID)
++                              {
++                                      printk("<1>Exiting Configuration: Module ID too large %d\n",pcfg->name);
++                                      free_memory();
++                                      spin_unlock_irqrestore(&config_lock, flags);
++                                      return -1;
++                              }
++        modArr[pcfg->name] = kmalloc(sizeof(mod_entry_t),GFP_KERNEL);
++        if(modArr[pcfg->name] == NULL)
++                              {
++                                      printk("<1>Exiting Configuration: Error in allocating memory\n");
++                                      free_memory();
++                                      spin_unlock_irqrestore(&config_lock, flags);
++                                      return -1;
++                              }
++                              memset( modArr[pcfg->name], 0x00, sizeof(mod_entry_t));
 +                      }
-+                      memset(modArr[pcfg->name], 0x00, sizeof(mod_entry_t));
-+              }
 +
-+              /* if no structure is allocated previously for this state
-+                 allocate a structure, if it's already there fill it up */
-+              if (modArr[pcfg->name]->states[pcfg->state] == NULL) {
-+                      printk("<1>STATE =  %d\n", pcfg->state);
-+                      if (pcfg->state >= MAX_STATE_ID) {
-+                              printk("<1>Exiting Configuration: State ID too large\n");
-+                              free_memory();
-+                              spin_unlock_irqrestore(&config_lock, flags);
-+                              return -1;
++      /* if no structure is allocated previously for this state
++         allocate a structure, if it's already there fill it up */
++                      if( modArr[pcfg->name]->states[pcfg->state] == NULL)
++                      {
++                                      printk("<1>STATE =  %d\n",pcfg->state);
++                              if( pcfg->state >= MAX_STATE_ID)
++                              {
++                                      printk("<1>Exiting Configuration: State ID too large\n");
++                                      free_memory();
++                                      spin_unlock_irqrestore(&config_lock, flags);
++                                      return -1;
++                              }
++                              modArr[pcfg->name]->states[pcfg->state] =
++                        kmalloc(sizeof(state_entry_t),GFP_KERNEL);
++                              if( modArr[pcfg->name]->states[pcfg->state] == NULL)
++                              {
++                                      free_memory();
++                                      spin_unlock_irqrestore(&config_lock, flags);
++                                      return -1;
++                              }
++                              memset( modArr[pcfg->name]->states[pcfg->state], 0x00, sizeof(state_entry_t));
 +                      }
-+                      modArr[pcfg->name]->states[pcfg->state] =
-+                              kmalloc(sizeof(state_entry_t), GFP_KERNEL);
-+                      if (modArr[pcfg->name]->states[pcfg->state] == NULL) {
++                      /* Fill up the fields of the state */
++      if( pcfg->led >= MAX_LED_ID)
++                      {
++                              printk("<1>led =  %d\n",pcfg->led);
 +                              free_memory();
 +                              spin_unlock_irqrestore(&config_lock, flags);
 +                              return -1;
 +                      }
-+                      memset(modArr[pcfg->name]->states[pcfg->state], 0x00,
-+                                 sizeof(state_entry_t));
-+              }
-+              /* Fill up the fields of the state */
-+              if (pcfg->led >= MAX_LED_ID) {
-+                      printk("<1>led =  %d\n", pcfg->led);
-+                      free_memory();
-+                      spin_unlock_irqrestore(&config_lock, flags);
-+                      return -1;
-+              }
-+              modArr[pcfg->name]->states[pcfg->state]->led = pcfg->led;
-+              modArr[pcfg->name]->states[pcfg->state]->mode = pcfg->mode;
-+              modArr[pcfg->name]->states[pcfg->state]->param = pcfg->param;
-+              switch (pcfg->mode) {
-+              case 1:
-+                      modArr[pcfg->name]->states[pcfg->state]->handler =
-+                              board_led_link_down;
-+                      break;
-+              case 2:
-+              case 3:
-+              case 5:
-+                      if (pcfg->mode == 2)
-+                              modArr[pcfg->name]->states[pcfg->state]->handler =
-+                                      board_led_activity_on;
-+                      else if (pcfg->mode == 3)
-+                              modArr[pcfg->name]->states[pcfg->state]->handler =
-+                                      board_led_activity_off;
-+                      else
-+                              modArr[pcfg->name]->states[pcfg->state]->handler =
-+                                      board_led_link_flash;
-+                      break;
-+              case 4:
-+                      modArr[pcfg->name]->states[pcfg->state]->handler =
-+                              board_led_link_up;
-+                      break;
-+              default:
-+                      printk("<1>Exiting Configuration: Unknown LED Mode\n");
-+                      free_memory();
-+                      spin_unlock_irqrestore(&config_lock, flags);
-+                      return -1;
-+              }
-+              pcfg++;
-+      }
++      modArr[pcfg->name]->states[pcfg->state]->led = pcfg->led;
++      modArr[pcfg->name]->states[pcfg->state]->mode = pcfg->mode;
++      modArr[pcfg->name]->states[pcfg->state]->param = pcfg->param;
++                      switch(pcfg->mode)
++                      {
++                              case 1:
++                      modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_down;
++                                      break;
++                              case 2:
++                              case 3:
++                              case 5:
++                                      if( pcfg->mode == 2 )
++                                              modArr[pcfg->name]->states[pcfg->state]->handler = board_led_activity_on;
++                                      else if( pcfg->mode == 3)
++                              modArr[pcfg->name]->states[pcfg->state]->handler = board_led_activity_off;
++                                      else
++                      modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_flash;
++                                      break;
++                              case 4:
++                      modArr[pcfg->name]->states[pcfg->state]->handler = board_led_link_up;
++                                      break;
++                              default:
++                                printk("<1>Exiting Configuration: Unknown LED Mode\n");
++                                      free_memory();
++                                      spin_unlock_irqrestore(&config_lock, flags);
++                                      return -1;
++                      }
++                      pcfg++;                 
++    }
 +      spin_unlock_irqrestore(&config_lock, flags);
-+      return 0;
++  return 0;
 +}
 +
 +
 +int __init led_init(void)
 +{
 +
-+      /* Clear our memory */
-+      memset(modArr, 0x00, sizeof(mod_entry_t *) * MAX_MOD_ID);
-+      memset(led_arr, 0x00, sizeof(led_data_t *) * MAX_LED_ID);
++  /* Clear our memory */
++  memset(modArr,0x00,sizeof(mod_entry_t *)*MAX_MOD_ID);
++  memset(led_arr,0x00,sizeof(led_data_t *)*MAX_LED_ID);
 +
 +      /* Create spin lock for config data structure */
-+      config_lock = SPIN_LOCK_UNLOCKED;
-+
-+#if 0
-+      /* Create directory */
-+      led_proc_dir = proc_mkdir("led_mod", NULL);
-+      if (led_proc_dir == NULL)
-+              goto out;
-+#endif
-+      
-+      /* Create adsl file */
-+      led_file = create_proc_entry("led", 0777, NULL);
-+      if (led_file == NULL)
-+              goto led_file;
-+
-+      led_file->owner = THIS_MODULE;
-+      led_file->proc_fops = &led_fops;
-+
-+      memset(modArr, 0x00, sizeof(mod_entry_t *) * MAX_MOD_ID);
-+
-+      /* Ron add for ADSL LED blink */
-+      my_mode = 1;
-+      my_led_init(GPIO_ADSL_ACT, 0, -1);
-+      my_led_init(GPIO_ADSL_DOWN, 0, -1);
-+      init_timer(&my_led_timer);
-+      my_led_timer.function = my_led_blink_timer;
-+      my_led_timer.data = 0;
-+      my_led_timer.expires = jiffies + BLINK_SLOW;
-+      add_timer(&my_led_timer);
-+      /* Ron add for ADSL LED blink */
-+      return 0;
++      config_lock=SPIN_LOCK_UNLOCKED;
++
++  /* Create directory */
++  led_proc_dir = proc_mkdir("led", NULL);
++  if( led_proc_dir == NULL )
++    goto out;
++
++  /* Create adsl file */
++  led_file = create_proc_entry("led", 0777, led_proc_dir);
++  if( led_file == NULL)
++    goto led_file;
++  led_file->owner = THIS_MODULE;
++  led_file->proc_fops = &led_fops;
++
++  memset( modArr , 0x00 , sizeof(mod_entry_t *) * MAX_MOD_ID);
++      /* Reset the GPIO pins  */
++  board_gpio_init();
++
++      /* Register the UART controlled LEDS  */
++  uart_led_init();
++  /* Create the usb proc file */
++      avalanche_leds_init();
++  return 0;
 +
 +  led_file:
-+      remove_proc_entry("led", NULL);
++    remove_proc_entry("led",led_proc_dir);
 +  out:
-+      return 0;
++    return 0;
 +
 +}
 +
-+void led_exit(void)
++void led_exit()
 +{
-+      remove_proc_entry("led", NULL);
++      remove_proc_entry("led", led_proc_dir);
 +}
 +
-+void led_operation(int mod, int state)
-+{
-+
-+      unsigned int flags;
-+
-+      spin_lock_irqsave(&config_lock, flags);
-+#if 1
-+      /* Ron Add for ADSL LED blink */
-+      //printk("mod==%d state==%d\n",mod,state);
-+
-+      if (mod == 1) {
-+              switch (state) {
-+                      /* off */
-+              case 1:
-+                      my_mode = 1;
-+                      my_blink_count = 0;
-+                      my_led_off(GPIO_ADSL_ACT, -1);
-+                      my_led_off(GPIO_ADSL_DOWN, -1);
-+                      break;
-+                      /* sync */
-+              case 2:
-+                      if (my_mode == 1) {
-+                              my_mode = 2;
-+                              my_led_off(GPIO_ADSL_ACT, -1);
-+                              my_blink_count++;
-+                      }
-+                      break;
-+                      /* on */
-+              case 3:
-+                      my_mode = 3;
-+                      my_blink_count = 0;
-+                      my_led_off(GPIO_ADSL_DOWN, -1);
-+                      my_led_on(GPIO_ADSL_ACT, -1);
-+                      break;
-+                      /* off */
-+              case 4:
-+                      my_mode = 4;
-+                      my_led_off(GPIO_ADSL_DOWN, -1);
-+                      my_blink_count++;
-+                      break;
-+              }
-+      }                                                       /* Ron add for ADSL LED Blink */
-+#endif
-+      if ((mod >= MAX_MOD_ID) || (state >= MAX_STATE_ID)) {
-+              spin_unlock_irqrestore(&config_lock, flags);
-+              return;
-+      }
-+      if (modArr[mod] == NULL) {
-+              spin_unlock_irqrestore(&config_lock, flags);
-+              return;
-+      }
-+      if (modArr[mod]->states[state] == NULL) {
-+              spin_unlock_irqrestore(&config_lock, flags);
-+              return;
-+      }
-+      /* Call the function handler  */
-+      modArr[mod]->states[state]->handler(modArr[mod]->states[state]);
-+
-+      spin_unlock_irqrestore(&config_lock, flags);
-+}
++module_init(led_init);
++module_exit(led_exit);
 +
-+void register_led_drv(int device, led_reg_t * pInfo)
++void register_led_drv( int device , led_reg_t *pInfo)
 +{
 +      unsigned int flags;
 +      struct timer_list *pTimer = NULL;
@@ -679,51 +1465,185 @@ diff -urN linux.old/drivers/char/avalanche_led/ledmod.c linux.dev/drivers/char/a
 +      spin_lock_irqsave(&config_lock, flags);
 +
 +      led_arr[device].led = pInfo;
-+      if (led_arr[device].led->init != 0x00)
-+              led_arr[device].led->init(led_arr[device].led->param);
-+      if (led_arr[device].led->offfunc != 0x00)
-+              led_arr[device].led->offfunc(led_arr[device].led->param);
++      ifled_arr[device].led->init != 0x00)
++      led_arr[device].led->init(led_arr[device].led->param);
++      ifled_arr[device].led->offfunc != 0x00)
++      led_arr[device].led->offfunc(led_arr[device].led->param);
 +
 +      /* Create a timer for blinking   */
-+      pTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
-+      init_timer(pTimer);
++  pTimer = kmalloc(sizeof(struct timer_list),GFP_KERNEL);
++      init_timer( pTimer );
 +      pTimer->function = led_timer_func;
 +      pTimer->data = 0;
-+      led_arr[device].pTimer = pTimer;
-+      led_arr[device].timer_running = 0;
++  led_arr[device].pTimer = pTimer;
++  led_arr[device].timer_running = 0;
 +
 +      spin_unlock_irqrestore(&config_lock, flags);
 +
-+      return;
++  return;
 +}
 +
-+void deregister_led_drv(int device)
++void deregister_led_drv( int device)
 +{
 +      unsigned int flags;
 +
 +      spin_lock_irqsave(&config_lock, flags);
 +      led_arr[device].led = NULL;
 +
-+      if (led_arr[device].pTimer != NULL) {
++      if( led_arr[device].pTimer != NULL)
++      {
 +              del_timer(led_arr[device].pTimer);
 +              kfree(led_arr[device].pTimer);
 +      }
 +      spin_unlock_irqrestore(&config_lock, flags);
 +
-+      return;
++  return;
 +}
 +
-+module_init(led_init);
-+module_exit(led_exit);
-+
-+
-+EXPORT_SYMBOL_NOVERS(led_init);
 +EXPORT_SYMBOL_NOVERS(led_operation);
 +EXPORT_SYMBOL_NOVERS(register_led_drv);
 +EXPORT_SYMBOL_NOVERS(deregister_led_drv);
++
+diff -urN linux.old/drivers/char/avalanche_led/leds.c linux.dev/drivers/char/avalanche_led/leds.c
+--- linux.old/drivers/char/avalanche_led/leds.c        1970-01-01 01:00:00.000000000 +0100
++++ linux.dev/drivers/char/avalanche_led/leds.c        2005-07-12 03:08:48.265220512 +0200
+@@ -0,0 +1,133 @@
++#include <linux/config.h>
++#include <linux/init.h>
++#include <linux/delay.h>
++#include <asm/ar7/avalanche_regs.h>
++#include <linux/spinlock.h>
++#include <linux/timer.h>
++#include <linux/sched.h>
++#include <linux/module.h>
++#include <linux/proc_fs.h>
++#include <asm/uaccess.h>
++#include <linux/fs.h>
++
++#include <asm/ar7/ledapp.h>
++
++#if defined(CONFIG_AR5D01) || defined(CONFIG_AR5W01) || defined(CONFIG_AR7)
++
++#define ETH_MASK 0x01
++#define USB_MASK 0x02
++
++static struct proc_dir_entry *usb_file;
++static ssize_t proc_read_usb_fops(struct file *filp,
++                                 char *buf,size_t count , loff_t *offp);
++struct file_operations usb_fops = {read: proc_read_usb_fops};
++
++typedef struct mod_states{
++  int module;
++  int activity;
++  int linkup;
++  int idle;
++}mod_states_t;
++
++mod_states_t state_arr[] = {
++                              { MOD_ETH,DEF_ETH_ACTIVITY,DEF_ETH_LINK_UP,DEF_ETH_IDLE },
++                              { MOD_USB,DEF_USB_ACTIVITY,DEF_USB_LINK_UP,DEF_USB_IDLE },
++                              { MOD_LAN,DEF_LAN_ACTIVITY,DEF_LAN_LINK_UP,DEF_LAN_IDLE }
++                              };
++
++unsigned char device_links = 0;       /* Bitmask with the devices that are up */
++
++
++void avalanche_led_activity_pulse(unsigned long device)
++{
++      /* If device link is not up return */
++  if( !(device_links & (unsigned char)(1 << device)))
++              return;
++#ifdef MULTIPLEX_LED
++      led_operation( state_arr[2].module, state_arr[2].activity);
++#else
++      led_operation( state_arr[device].module, state_arr[device].activity);
++#endif
++}
++
++void avalanche_led_link_up( unsigned long device )
++{
++      
++  /* If already UP ignore */
++  if( device_links & (unsigned char)(1 << device))
++              return;
++  /* Turn on the bit for the device */
++      device_links |= (unsigned char)(1 << device);
++#ifdef MULTIPLEX_LED
++      led_operation( state_arr[2].module, state_arr[2].linkup);
++#else
++      led_operation( state_arr[device].module, state_arr[device].linkup);
++#endif
++}
++
++void avalanche_led_link_down ( unsigned long device )
++{
++
++  /* If already DOWN ignore */
++  if( !(device_links & (unsigned char)(1 << device)))
++              return;
++
++      /* Turn off the bit for the device */
++      device_links &= ~(unsigned char)(1 << device);
++#ifdef MULTIPLEX_LED
++      /* If no links, then shut the LED off  */
++      if(!device_links)
++              led_operation( state_arr[2].module, state_arr[2].idle);
++#else
++      led_operation( state_arr[device].module, state_arr[device].idle);
++#endif
++}
++
++static ssize_t proc_read_usb_fops(struct file *filp,
++                                 char *buf,size_t count , loff_t *offp)
++{
++  char * pdata = NULL;
++  char line[3];
++  if( *offp != 0 )
++      return 0;
++  pdata = buf;
++  if( device_links & USB_MASK)
++      sprintf(line,"%s\n","1");
++  else
++      sprintf(line,"%s\n","0");
++  copy_to_user(pdata,line,2);
++      *offp = 2;
++      return 2;
++}
++
++
++void avalanche_leds_init(void)
++{
++  /* Create usb link proc file */
++  usb_file = create_proc_entry("avalanche/usb_link", 0444, NULL);
++  if( usb_file == NULL)
++    return;
++  usb_file->owner = THIS_MODULE;
++  usb_file->proc_fops = &usb_fops;
++      return;
++}
++
++EXPORT_SYMBOL(avalanche_led_activity_pulse);
++EXPORT_SYMBOL(avalanche_led_link_up);
++EXPORT_SYMBOL(avalanche_led_link_down);
++
++#else
++/* We make a dummy init routine for the platforms that do not support this led
++   API
++*/
++
++void avalanche_leds_init(void)
++{
++}
++
++#endif
++
++
++
++
++
 diff -urN linux.old/drivers/char/avalanche_led/Makefile linux.dev/drivers/char/avalanche_led/Makefile
 --- linux.old/drivers/char/avalanche_led/Makefile      1970-01-01 01:00:00.000000000 +0100
-+++ linux.dev/drivers/char/avalanche_led/Makefile      2005-07-11 02:42:24.191796312 +0200
++++ linux.dev/drivers/char/avalanche_led/Makefile      2005-07-12 03:08:48.265220512 +0200
 @@ -0,0 +1,23 @@
 +# File: drivers/char/avalanche_led/Makefile
 +#
@@ -737,9 +1657,9 @@ diff -urN linux.old/drivers/char/avalanche_led/Makefile linux.dev/drivers/char/a
 +
 +EXTRA_CFLAGS := -I$(TOPDIR)/include/asm/ar7
 +
-+export-objs := ledmod.o
++export-objs := ledmod.o leds.o
 +
-+avalanche_led-objs := ledmod.o
++avalanche_led-objs := ledmod.o gpio.o uartled.o leds.o
 +
 +include $(TOPDIR)/Rules.make
 +
@@ -748,9 +1668,68 @@ diff -urN linux.old/drivers/char/avalanche_led/Makefile linux.dev/drivers/char/a
 +
 +clean:
 +      rm -f core *.o *.a *.s
+diff -urN linux.old/drivers/char/avalanche_led/uartled.c linux.dev/drivers/char/avalanche_led/uartled.c
+--- linux.old/drivers/char/avalanche_led/uartled.c     1970-01-01 01:00:00.000000000 +0100
++++ linux.dev/drivers/char/avalanche_led/uartled.c     2005-07-12 03:08:48.266220360 +0200
+@@ -0,0 +1,55 @@
++#include <linux/kernel.h>
++#include <asm/uaccess.h>
++#include <linux/spinlock.h>
++#include <asm/ar7/avalanche_regs.h>
++#include <asm/ar7/ledapp.h>
++
++#define UART_LED_REG  (*(volatile unsigned int *)(UARTA_BASE + 0x10))
++
++static spinlock_t     device_lock;
++led_reg_t temp1[2];
++
++static void uart_led_on(unsigned long param)
++{
++  unsigned long flags;
++
++  spin_lock_irqsave(&device_lock,flags);
++  UART_LED_REG &= 0xFFFD;
++  spin_unlock_irqrestore(&device_lock, flags);
++}
++
++static void uart_led_off ( unsigned long param )
++{
++   unsigned int flags = 0x00;
++   spin_lock_irqsave(&device_lock, flags);
++   UART_LED_REG |= 0x02;
++      spin_unlock_irqrestore(&device_lock, flags);
++}
++
++void uart_led_init(void)
++{
++
++#if defined(CONFIG_AR5D01)
++  /* Register led 6 UART Pin 1 */
++  temp1[0].param = 0;
++  temp1[0].init = NULL;
++  temp1[0].onfunc = uart_led_on;
++  temp1[0].offfunc = uart_led_off;
++      register_led_drv( 6 , &temp1[0]);
++#endif
++
++#if defined(CONFIG_AR5W01)
++  /* Register led 8 UART Pin 1 */
++  temp1[0].param = 0;
++  temp1[0].init = NULL;
++  temp1[0].onfunc = uart_led_on;
++  temp1[0].offfunc = uart_led_off;
++      register_led_drv( 8 , &temp1[0]);
++#endif
++
++      /* Initialize the link mask */
++      device_lock = SPIN_LOCK_UNLOCKED;
++
++  return;
++}
++
 diff -urN linux.old/drivers/char/Config.in linux.dev/drivers/char/Config.in
 --- linux.old/drivers/char/Config.in   2005-07-10 20:53:55.650624032 +0200
-+++ linux.dev/drivers/char/Config.in   2005-07-10 20:50:43.556826000 +0200
++++ linux.dev/drivers/char/Config.in   2005-07-12 03:07:20.861507896 +0200
 @@ -133,6 +133,10 @@
        fi
     fi
@@ -764,7 +1743,7 @@ diff -urN linux.old/drivers/char/Config.in linux.dev/drivers/char/Config.in
  fi
 diff -urN linux.old/drivers/char/Makefile linux.dev/drivers/char/Makefile
 --- linux.old/drivers/char/Makefile    2005-07-10 20:53:55.651623880 +0200
-+++ linux.dev/drivers/char/Makefile    2005-07-10 20:50:43.556826000 +0200
++++ linux.dev/drivers/char/Makefile    2005-07-12 03:07:20.861507896 +0200
 @@ -190,6 +190,19 @@
    obj-$(CONFIG_PCI) += keyboard.o $(KEYMAP)
  endif
@@ -787,7 +1766,7 @@ diff -urN linux.old/drivers/char/Makefile linux.dev/drivers/char/Makefile
  obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
 diff -urN linux.old/include/asm-mips/ar7/ledapp.h linux.dev/include/asm-mips/ar7/ledapp.h
 --- linux.old/include/asm-mips/ar7/ledapp.h    1970-01-01 01:00:00.000000000 +0100
-+++ linux.dev/include/asm-mips/ar7/ledapp.h    2005-07-10 20:50:43.557826000 +0200
++++ linux.dev/include/asm-mips/ar7/ledapp.h    2005-07-12 03:08:48.266220360 +0200
 @@ -0,0 +1,59 @@
 +#ifndef __LED_APP__
 +#define __LED_APP__
This page took 0.090985 seconds and 4 git commands to generate.