+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-22 06:52:42.973338640 +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;
++}
++
++
++
++
++
++
++
++