1 diff -urN kernel-old/drivers/char/avalanche_led/led_drv.c kernel-current/drivers/char/avalanche_led/led_drv.c
2 --- kernel-old/drivers/char/avalanche_led/led_drv.c 1970-01-01 01:00:00.000000000 +0100
3 +++ kernel-current/drivers/char/avalanche_led/led_drv.c 2005-07-10 18:40:23.008730752 +0200
5 +/******************************************************************************
6 + * FILE PURPOSE: - LED driver module Source
7 + ******************************************************************************
8 + * FILE NAME: led_drv.c
10 + * DESCRIPTION: Linux LED character driver implementation
13 + * 27 Aug 2003 Initial Creation Sharath Kumar<krs@ti.com>
15 + * 16 Dec 2003 Updates for 5.7 Sharath Kumar<krs@ti.com>
17 + * 07 Jan 2004 Wrapper for DSL Sharath Kumar<krs@ti.com>
19 + * (C) Copyright 2002, Texas Instruments, Inc
20 + *******************************************************************************/
22 +#include <linux/config.h>
23 +#include <linux/module.h>
24 +#include <linux/init.h>
25 +#include <linux/types.h>
26 +#include <linux/errno.h>
27 +#include <linux/slab.h>
28 +#include <linux/ioport.h>
29 +#include <linux/fcntl.h>
30 +#include <linux/interrupt.h>
31 +#include <linux/sched.h>
32 +#include <linux/mm.h>
34 +#include <asm/uaccess.h>
35 +#include <asm/system.h>
36 +#include <linux/delay.h>
37 +#include <linux/devfs_fs_kernel.h>
38 +#include <linux/wait.h>
39 +#include <linux/proc_fs.h>
40 +#include <linux/timer.h>
41 +#include <asm/ar7/sangam.h>
42 +#include <asm/ar7/avalanche_misc.h>
44 +#include "led_config.h"
46 +#include "led_ioctl.h"
47 +#include "led_platform.h"
49 +//#define tnetd73xx_gpio_ctrl(gpio_pin, pin_mode, pin_direction) avalanche_gpio_ctrl(gpio_pin, pin_mode, pin_direction)
50 +#define tnetd73xx_gpio_out(gpio_pin, value) avalanche_gpio_out_bit(gpio_pin, value)
51 +//#define avalanche_gpio_in_bit(gpio_pin) tnetd73xx_gpio_in(gpio_pin)
53 +#define TI_LED_VERSION "0.1"
54 +#define GPIO_MAP_LEN ((MAX_GPIO_PIN_NUM/32) + 1)
56 +static int gpio_off_state[GPIO_MAP_LEN] = AVALANCHE_GPIO_OFF_MAP;
60 +#define FLICK_TIME (HZ*100/1000)
61 +static unsigned int wan_txrx_state = 0;
62 +static unsigned int wlan_txrx_state = 0;
63 +struct timer_list *pWanTimer = NULL;
65 +static void wan_led_func(unsigned long data)
67 + avalanche_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
68 + avalanche_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
70 + if (wan_txrx_state == 0)
72 + tnetd73xx_gpio_out(2, TRUE);
73 + tnetd73xx_gpio_out(3, FALSE);
78 + tnetd73xx_gpio_out(2, FALSE);
79 + tnetd73xx_gpio_out(3, FALSE);
82 + pWanTimer->expires = jiffies + FLICK_TIME;
83 + add_timer(pWanTimer);
87 +static int led_ioctl( struct inode * inode, struct file * file,
88 + unsigned int cmd, unsigned long arg )
98 + LED_CONFIG_T led_cfg;
99 + if (copy_from_user((char *)&led_cfg, (char *)arg, sizeof(led_cfg)))
101 + printk("in led config error\n");
105 + printk("in led config\n");
106 + ret = avalanche_led_config_set(&led_cfg);
110 + case LED_GET_HANDLE:
112 + LED_MODULE_T led_mod;
115 + if (copy_from_user((char *)&led_mod, (char *)arg, sizeof(led_mod)))
121 + handle = (int)avalanche_led_register(led_mod.name,led_mod.instance);
123 + if (copy_to_user((char *)(&(((LED_MODULE_T *)arg)->handle)), (char *)(&handle), sizeof(int)))
138 + LED_STATE_T led_state;
139 + if (copy_from_user((char *)&led_state, (char *)arg, sizeof(led_state)))
145 + printk("led action : handle = %d, id = %d\n", led_state.handle, led_state.state_id);
147 + if (led_state.handle == 2) //system led
149 + switch (led_state.state_id)
153 + case 2: /*sys led flashing green */
154 + tnetd73xx_gpio_out(4, FALSE);
155 + tnetd73xx_gpio_out(5, TRUE);
156 + tnetd73xx_gpio_out(8, TRUE);
158 + case 3: /*sys led solid green */
159 + tnetd73xx_gpio_out(4, TRUE);
160 + tnetd73xx_gpio_out(5, TRUE);
161 + tnetd73xx_gpio_out(8, TRUE);
164 + case 4: /*sys fail red */
165 + tnetd73xx_gpio_out(4, TRUE);
166 + tnetd73xx_gpio_out(5, FALSE);
167 + tnetd73xx_gpio_out(8, FALSE);
173 + }else if (led_state.handle == 3)
175 + printk("led action : handle = %d, id = %d\n", led_state.handle, led_state.state_id);
176 + avalanche_gpio_ctrl(2, GPIO_PIN, GPIO_OUTPUT_PIN);
177 + avalanche_gpio_ctrl(3, GPIO_PIN, GPIO_OUTPUT_PIN);
179 + switch (led_state.state_id)
181 + case 1: /*no wan interface*/
184 + del_timer(pWanTimer);
188 + tnetd73xx_gpio_out(2, FALSE);
189 + tnetd73xx_gpio_out(3, FALSE);
191 + case 2: /*wan connected */
194 + del_timer(pWanTimer);
198 + tnetd73xx_gpio_out(2, TRUE);
199 + tnetd73xx_gpio_out(3, FALSE);
201 + case 3: /*rx/tx activity */
202 + if (pWanTimer != NULL)
205 + pWanTimer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
206 + init_timer(pWanTimer);
208 + pWanTimer->function = wan_led_func;
209 + pWanTimer->data = 0;
210 + pWanTimer->expires = jiffies + FLICK_TIME;
211 + tnetd73xx_gpio_out(2, FALSE);
212 + tnetd73xx_gpio_out(3, FALSE);
213 + wan_txrx_state = 0;
214 + add_timer(pWanTimer);
217 + case 4: /*no ipaddress */
220 + del_timer(pWanTimer);
224 + tnetd73xx_gpio_out(2, FALSE);
225 + tnetd73xx_gpio_out(3, TRUE);
230 + del_timer(pWanTimer);
236 + }else if (led_state.handle == 4) //test
239 + high = (led_state.state_id & 0xf0) >> 4;
240 + low = (led_state.state_id & 0x0f);
241 + tnetd73xx_gpio_out(high, (low > 0)?1:0);
242 + }else avalanche_led_action((void *)led_state.handle,led_state.state_id);
248 + case LED_RELEASE_HANDLE:
249 + ret = avalanche_led_unregister((void *)arg);
259 +static int led_open( struct inode * inode, struct file * file )
264 +static int led_close( struct inode * inode, struct file * file )
269 +struct file_operations led_fops = {
276 +/* Proc function to display driver version */
278 +led_ver_info(char *buf, char **start, off_t offset, int count, int *eof, void *data)
283 + len += sprintf(buf +len,"\nTI Linux LED Driver Version %s\n",TI_LED_VERSION);
288 +/* proc interface /proc/avalanche/led */
289 +int led_cfg_info(char* buf, char **start, off_t offset, int count,
290 + int *eof, void *data)
294 + int limit = count - 80;
295 + char *msg[5]={"LED OFF", "LED_ON", "LED_ONESHOT_OFF", "LED_ONESHOT_ON","LED_FLASH"};
297 + for(mod_count = 0;mod_count<MAX_MODULE_ENTRIES;mod_count++)
301 + for(instance = 0; instance < MAX_MODULE_INSTANCES; instance++)
306 + for(state_id =0 ;state_id < MAX_STATE_ENTRIES; state_id++)
308 + LED_CONFIG_T led_cfg;
309 + if(avalanche_led_config_get(&led_cfg,mod_count,instance,state_id) == 0)
315 + len+= sprintf(buf+len, "\nModule:%s\n",led_cfg.name);
318 + len+= sprintf(buf+len, "\n Instance:%d\n",instance);
323 + len+= sprintf(buf+len, "\n State: %d\n",state_id);
326 + len+= sprintf(buf+len, "\n mode: %s\n",msg[led_cfg.mode[0]% 5 ]);
329 + len+= sprintf(buf+len, "\n gpio: %d\n",led_cfg.gpio[0]);
332 + len+= sprintf(buf+len, "\n param1: %d\n",led_cfg.param1);
335 + len+= sprintf(buf+len, "\n param2: %d\n",led_cfg.param2);
348 +int __init led_init(void)
351 + /* register LED device */
352 + devfs_register(NULL, "led", DEVFS_FL_AUTO_DEVNUM, 0, 0,
353 + S_IFCHR | S_IRUGO | S_IWUGO, &led_fops,NULL);
356 + avalanche_led_hal_init(gpio_off_state,AVALANCHE_GPIO_PIN_COUNT);
358 + /* create proc entry */
359 + create_proc_read_entry("avalanche/led_cfg", 0, NULL, led_cfg_info, NULL);
360 + create_proc_read_entry("avalanche/led_ver", 0, NULL, led_ver_info, NULL);
367 + avalanche_led_hal_exit();
371 +module_init(led_init);
372 +module_exit(led_exit);
375 +EXPORT_SYMBOL_NOVERS(avalanche_led_register);
376 +EXPORT_SYMBOL_NOVERS(avalanche_led_action);
377 +EXPORT_SYMBOL_NOVERS(avalanche_led_unregister);
378 +EXPORT_SYMBOL_NOVERS(avalanche_led_config_set);
379 +EXPORT_SYMBOL_NOVERS(avalanche_led_config_get);
380 diff -urN kernel-old/drivers/char/avalanche_led/led_hal.c kernel-current/drivers/char/avalanche_led/led_hal.c
381 --- kernel-old/drivers/char/avalanche_led/led_hal.c 1970-01-01 01:00:00.000000000 +0100
382 +++ kernel-current/drivers/char/avalanche_led/led_hal.c 2005-07-10 18:24:22.242038232 +0200
384 +/******************************************************************************
385 + * FILE PURPOSE: - LED HAL module source
386 + ******************************************************************************
387 + * FILE NAME: led_hal.c
389 + * DESCRIPTION: LED HAL API's source.
391 + * REVISION HISTORY:
392 + * 27 Aug 2003 Initial Creation Sharath Kumar<krs@ti.com>
394 + * 16 Dec 2003 Updates for 5.7 Sharath Kumar<krs@ti.com>
396 + * 07 Jan 2004 Wrapper for DSL Sharath Kumar<krs@ti.com>
398 + * (C) Copyright 2002, Texas Instruments, Inc
399 + *******************************************************************************/
401 +#include "led_platform.h"
402 +#include "led_config.h"
403 +#include "led_hal.h"
405 +/* include for gpio APIs */
406 +#include <asm/ar7/avalanche_misc.h>
409 +#define REQUIRES_TIMER(x) ( (x == LED_ONESHOT_ON) || (x == LED_ONESHOT_OFF) || (x == LED_FLASH) )
411 +/*******************TYPEDEFs**************************************************/
414 + unsigned int state;
415 + unsigned int module_map;
416 + unsigned int pos_map[2];
420 +typedef struct state_entry STATE_ENTRY_T;
424 + void (*handler) (STATE_ENTRY_T * state);
425 + unsigned int timer_running;
427 + unsigned int map1[2];
428 + unsigned int map2[2];
430 + unsigned int param1;
431 + unsigned int param2;
432 + unsigned int module_id;
436 +typedef struct module_instance
440 + STATE_ENTRY_T *states[MAX_STATE_ENTRIES];
444 +typedef struct module_entry
446 + unsigned char *name;
447 + MODULE_INSTANCE_T *module_instance[MAX_MODULE_INSTANCES];
453 +/******************variable defn/declns***************************************/
455 +static LED_OBJ_T *leds[MAX_LED_ENTRIES];
456 +static MODULE_ENTRY_T *modules[MAX_MODULE_ENTRIES];
458 +/* Declare Mutex lock */
459 +MUTEX_DECLARE (led_lock);
461 +/* GPIO OFF STATE */
462 +static unsigned int gpio_offstate_map[2];
464 +/* Number of GPIO pins in the system */
465 +static unsigned int num_gpios;
468 +static void (*led_mode_handler[NUM_LED_MODES]) (STATE_ENTRY_T * state);
472 +/******************static functions*****************************************/
474 +static void *led_malloc (int n)
480 + os_memset (p, 0, n);
485 +static void avalanche_gpio_set(int * set_map,int *pos_map)
489 + for(i = 0;i <num_gpios ;i+=32)
492 + avalanche_gpio_out_value(set_map[index],pos_map[index],index);
499 +static MODULE_INSTANCE_T *get_module (char *name, int instance)
502 + MODULE_INSTANCE_T *mod_inst;
505 + if (instance >= MAX_MODULE_INSTANCES)
508 + for (module_id = 0; module_id < MAX_MODULE_ENTRIES; module_id++)
510 + if (modules[module_id]
511 + && !os_strcmp (name, modules[module_id]->name))
515 + if (module_id == MAX_MODULE_ENTRIES)
517 + for (module_id = 0;
518 + (module_id < MAX_MODULE_ENTRIES) && modules[module_id];
521 + if (module_id < MAX_MODULE_ENTRIES)
523 + modules[module_id] = led_malloc (sizeof (MODULE_ENTRY_T));
525 + if (!modules[module_id])
528 + modules[module_id]->name = led_malloc (os_strlen (name) + 1);
530 + if (!modules[module_id]->name)
533 + os_strcpy (modules[module_id]->name, name);
537 + log_msg ("ERROR:Module Count exceeded\n");
542 + if (!modules[module_id]->module_instance[instance])
543 + modules[module_id]->module_instance[instance] =
544 + led_malloc (sizeof (MODULE_INSTANCE_T));
546 + if (!modules[module_id]->module_instance[instance])
549 + mod_inst = modules[module_id]->module_instance[instance];
550 + mod_inst->module_id = module_id;
551 + mod_inst->instance = instance;
557 +static void assign_map(int *to, int *from)
561 + for(i = 0;i <num_gpios ;i+=32)
564 + to[index] = from[index];
571 +static LED_OBJ_T *get_led (int * pos_map)
575 + for (led_id = 0; led_id < MAX_LED_ENTRIES; led_id++)
582 + for(i = 0;i <num_gpios ;i+=32)
585 + if(leds[led_id]->pos_map[index] != pos_map[index])
593 + if (led_id == MAX_LED_ENTRIES)
595 + for (led_id = 0; (led_id < MAX_LED_ENTRIES) && leds[led_id];
598 + if (led_id < MAX_LED_ENTRIES)
600 + leds[led_id] = led_malloc (sizeof (LED_OBJ_T));
605 + assign_map(leds[led_id]->pos_map,pos_map);
609 + log_msg ("ERROR:Module Count exceeded\n");
614 + return leds[led_id];
617 +static void led_oneshot_on_timer_func (int arg)
619 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
620 + LED_OBJ_T *led = state->led;
622 + state->timer_running = 0;
623 + MUTEX_GET (led_lock);
624 + if (led->state == LED_ONESHOT_ON)
626 + led->state = LED_OFF;
627 + avalanche_gpio_set (state->map2,led->pos_map);
629 + MUTEX_RELEASE (led_lock);
633 +static void led_oneshot_off_timer_func (int arg)
635 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
636 + LED_OBJ_T *led = state->led;
638 + state->timer_running = 0;
640 + MUTEX_GET (led_lock);
641 + if (led->state == LED_ONESHOT_OFF)
643 + led->state = LED_ON;
644 + avalanche_gpio_set(state->map2,led->pos_map);
646 + MUTEX_RELEASE (led_lock);
650 +static void led_flash_timer_func (int arg)
652 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
653 + LED_OBJ_T *led = state->led;
656 + if (led->state != LED_FLASH)
659 + MUTEX_GET (led_lock);
661 + if (state->timer_running == 1)
663 + state->timer_running = 2;
664 + avalanche_gpio_set(state->map2,led->pos_map);
665 + os_timer_add (state->os_timer, state->param2, (int)state);
669 + state->timer_running = 1;
670 + avalanche_gpio_set(state->map1,led->pos_map);
671 + os_timer_add (state->os_timer, state->param1, (int)state);
674 + MUTEX_RELEASE (led_lock);
677 +static void led_on(STATE_ENTRY_T * state)
679 + LED_OBJ_T *led = state->led;
681 + led->state = LED_ON;
682 + avalanche_gpio_set(state->map1,led->pos_map);
683 + led->module_map |= (1 << (state->module_id));
687 +static void led_off (STATE_ENTRY_T * state)
689 + LED_OBJ_T *led = state->led;
691 + led->module_map &= ~(1 << (state->module_id));
692 + if (!led->module_map)
694 + led->state = LED_OFF;
695 + avalanche_gpio_set(state->map1,led->pos_map);
700 +static void led_oneshot_on (STATE_ENTRY_T * state)
702 + LED_OBJ_T *led = state->led;
704 + if (state->timer_running)
707 + state->timer_running = 1;
708 + led->state = LED_ONESHOT_ON;
709 + avalanche_gpio_set(state->map1,led->pos_map);
710 + os_timer_add (state->os_timer, state->param1,(int) state);
713 +static void led_oneshot_off (STATE_ENTRY_T * state)
716 + LED_OBJ_T *led = state->led;
718 + if (state->timer_running)
721 + state->timer_running = 1;
722 + led->state = LED_ONESHOT_OFF;
723 + avalanche_gpio_set(state->map1,led->pos_map);
724 + os_timer_add (state->os_timer, state->param1,(int) state);
727 +static void led_flash (STATE_ENTRY_T * state)
729 + LED_OBJ_T *led = state->led;
731 + if (state->timer_running)
734 + state->timer_running = 1;
735 + led->state = LED_FLASH;
736 + avalanche_gpio_set(state->map1,led->pos_map);
737 + os_timer_add (state->os_timer, state->param1,(int) state);
742 +static int led_get_mode(LED_CONFIG_T *led_cfg)
744 + int num_gpio = led_cfg->gpio_num;
746 + int *led_mode = led_cfg->mode;
749 + /* Return Max of available modes */
750 + for(i = 0; i<num_gpio; i++)
752 + max = (max > led_mode[i]) ? max : led_mode[i];
758 +static void led_assign_timer(STATE_ENTRY_T *state_entry)
761 + if (state_entry->os_timer)
763 + os_timer_delete(state_entry->os_timer);
766 + switch(state_entry->mode)
768 + case LED_ONESHOT_ON:
769 + state_entry->os_timer = os_timer_init(led_oneshot_on_timer_func);
772 + case LED_ONESHOT_OFF:
773 + state_entry->os_timer = os_timer_init(led_oneshot_off_timer_func);
777 + state_entry->os_timer = os_timer_init(led_flash_timer_func);
781 + log_msg("invalid mode in function led_assign timer\n");
786 +static int led_get_map(LED_CONFIG_T *led_cfg,int *p_pos_map,int *p_map1,int *p_map2)
789 + int map1[2] = {0,0};
790 + int pos_map[2] = {0,0};
791 + int map2[2] = {0,0};
792 + int requires_timer = REQUIRES_TIMER(led_get_mode(led_cfg));
794 + for (i = 0; i < led_cfg->gpio_num; i++)
797 + int index = led_cfg->gpio[i]/32;
798 + int pos = led_cfg->gpio[i] % 32;
800 + if (led_cfg->gpio[i] >= num_gpios)
802 + log_msg ("Error: gpio number out of range\n");
806 + gpio_map = 1 << pos;
808 + pos_map[index] |= gpio_map;
811 + switch (led_cfg->mode[i])
814 + if(gpio_offstate_map[index] & gpio_map)
815 + map1[index] |= gpio_map;
817 + if (requires_timer && (gpio_offstate_map[index] & gpio_map))
818 + map2[index] |= gpio_map;
823 + if(!(gpio_offstate_map[index] & gpio_map))
824 + map1[index] |= gpio_map;
826 + if (requires_timer && !(gpio_offstate_map[index] & gpio_map))
827 + map2[index] |= gpio_map;
830 + case LED_ONESHOT_OFF:
832 + if ((gpio_offstate_map[index] & gpio_map))
833 + map1[index] |= gpio_map;
835 + map2[index] |= gpio_map;
838 + case LED_ONESHOT_ON:
841 + if (!(gpio_offstate_map[index] & gpio_map))
842 + map1[index] |= gpio_map;
844 + map2[index] |= gpio_map;
848 + log_msg ("Error: Invalid mode\n");
853 + assign_map(p_pos_map,pos_map);
854 + assign_map(p_map1,map1);
855 + assign_map(p_map2,map2);
863 +static int configure_state(STATE_ENTRY_T *state_entry,LED_CONFIG_T *led_cfg)
865 +// int state = led_cfg->state;
871 + if((state_entry->mode = led_get_mode(led_cfg)) >= NUM_LED_MODES)
873 + log_msg ("Error: Invalid mode in func configure_state\n");
877 + state_entry->handler = led_mode_handler[state_entry->mode];
880 + if(led_get_map(led_cfg,pos_map,map1,map2))
882 + log_msg ("Error: gpio number out of range\n");
886 + assign_map(state_entry->map1,map1);
887 + assign_map(state_entry->map2,map2);
888 + state_entry->led = get_led(pos_map);
890 + /* Check if the state requires timer */
891 + if(REQUIRES_TIMER(state_entry->mode))
893 + state_entry->timer_running = 0;
894 + state_entry->param1 = led_cfg->param1;
895 + state_entry->param2 = led_cfg->param2;
896 + led_assign_timer(state_entry);
899 + /* enable gpio pins */
900 + for(i = 0;i<led_cfg->gpio_num;i++)
905 + avalanche_gpio_ctrl (led_cfg->gpio[i],GPIO_PIN,GPIO_OUTPUT_PIN);
907 + /* Turn off the led */
908 + index = led_cfg->gpio[i]/32;
909 + pos = led_cfg->gpio[i] % 32;
910 + value = (gpio_offstate_map[index] & (1 << pos))?1:0;
911 + avalanche_gpio_out_bit(led_cfg->gpio[i],value);
918 +static void free_all_states(void)
922 + for(module_id = 0; module_id < MAX_MODULE_ENTRIES; module_id++)
924 + if(modules[module_id])
927 + for(i = 0; i< MAX_MODULE_INSTANCES; i++)
929 + MODULE_INSTANCE_T *module_instance = modules[module_id]->module_instance[i];
931 + if(module_instance)
935 + for(state_id =0; state_id < MAX_STATE_ENTRIES; state_id++)
937 + STATE_ENTRY_T *state= module_instance->states[state_id];
941 + if(state->os_timer)
942 + os_timer_delete(state->os_timer);
945 + module_instance->states[state_id] = NULL;
952 + os_free(modules[module_id]->name);
953 + os_free(modules[module_id]);
954 + modules[module_id] = NULL;
959 +/***********************************HAL APIS************************************/
961 +/**************************************************************************
962 + * FUNCTION NAME : avalanche_led_hal_init
963 + **************************************************************************
965 + * The function initializes led hal module
969 + * Negative value on Error
970 + ***************************************************************************/
973 +int avalanche_led_hal_init (int *gpio_off_value, int num_gpio_pins)
977 + num_gpios = num_gpio_pins + 4;
978 + assign_map(gpio_offstate_map, gpio_off_value);
980 + MUTEX_INIT (led_lock);
982 + /* initialize led state function handlers */
983 + led_mode_handler[LED_ON] = led_on;
984 + led_mode_handler[LED_OFF] = led_off;
985 + led_mode_handler[LED_ONESHOT_ON] = led_oneshot_on;
986 + led_mode_handler[LED_ONESHOT_OFF] = led_oneshot_off;
987 + led_mode_handler[LED_FLASH] = led_flash;
993 +/**************************************************************************
994 + * FUNCTION NAME : avalanche_led_config_set
995 + **************************************************************************
997 + * The function configures LED state object
1001 + * Negative value on Error
1002 + ***************************************************************************/
1004 +int avalanche_led_config_set(LED_CONFIG_T * led_cfg)
1006 + MODULE_INSTANCE_T *module;
1007 + MUTEX_GET (led_lock);
1008 + module = get_module (led_cfg->name, led_cfg->instance);
1011 + goto config_failed;
1013 + if (led_cfg->state < MAX_STATE_ENTRIES)
1015 + int state = led_cfg->state;
1017 + if (!(module->states[state]))
1019 + module->states[state] = led_malloc (sizeof (STATE_ENTRY_T));
1022 + if (!(module->states[state]))
1023 + goto config_failed;
1025 + module->states[state]->module_id = module->module_id;
1027 + if(configure_state(module->states[state],led_cfg))
1029 + os_free(module->states[state]);
1030 + module->states[state] = NULL;
1031 + goto config_failed;
1037 + log_msg ("ERROR:State Count exceeded\n");
1038 + goto config_failed;
1041 + MUTEX_RELEASE (led_lock);
1046 + MUTEX_RELEASE (led_lock);
1051 +/**************************************************************************
1052 + * FUNCTION NAME : avalanche_led_register
1053 + **************************************************************************
1055 + * The function creates handle to the given module and returns it.
1058 + * Handle to the module instance on success.
1059 + * NULL on failure.
1060 + ***************************************************************************/
1062 +void *avalanche_led_register (const char *mod_name, int instance)
1065 + MUTEX_GET (led_lock);
1066 + p = (void *)get_module ((char *)mod_name, instance);
1067 + MUTEX_RELEASE (led_lock);
1072 +/**************************************************************************
1073 + * FUNCTION NAME : avalanche_led_action
1074 + **************************************************************************
1076 + * The function triggers action on LED
1078 + ***************************************************************************/
1080 +void avalanche_led_action (void *module, int state_id)
1083 + MUTEX_GET (led_lock);
1084 + if (module && (state_id < MAX_STATE_ENTRIES))
1087 + STATE_ENTRY_T *state =
1088 + ((MODULE_INSTANCE_T *) (module))->states[state_id];
1091 + state->handler (state);
1094 + MUTEX_RELEASE (led_lock);
1099 +/**************************************************************************
1100 + * FUNCTION NAME : avalanche_led_unregister
1101 + **************************************************************************
1103 + * The function unregisters the module
1107 + * Negative value on Error
1108 + ***************************************************************************/
1110 +int avalanche_led_unregister (void *mod_inst)
1117 +/**************************************************************************
1118 + * FUNCTION NAME : led_free_all
1119 + **************************************************************************
1121 + * The function frees the memory allocated for holding state
1122 + * configuration data
1124 + ***************************************************************************/
1126 +void avalanche_led_free_all()
1128 + free_all_states();
1131 +/**************************************************************************
1132 + * FUNCTION NAME : avalanche_led_hal_exit
1133 + **************************************************************************
1135 + * The function releases all the allocated memory
1137 + ***************************************************************************/
1139 +void avalanche_led_hal_exit ()
1141 + free_all_states();
1144 +/*****************************************************************************
1145 + * FUNCTION NAME : avalanche_led_config_get
1146 + *****************************************************************************
1148 + * The function returns configuration information corresponding to module
1153 + * Negative value on Error
1154 + ***************************************************************************/
1155 +int avalanche_led_config_get(LED_CONFIG_T *led_cfg,int module_id,int instance, int state_id)
1157 + if(module_id == -1)
1159 + /* The module info is passed through field of led_cfg */
1160 + MODULE_INSTANCE_T *mod = get_module (led_cfg->name, instance);
1162 + module_id = mod->module_id;
1165 + if(module_id >= MAX_MODULE_ENTRIES || module_id < 0)
1168 + if(state_id >= MAX_STATE_ENTRIES || module_id < 0)
1171 + if(instance >= MAX_MODULE_INSTANCES || module_id < 0)
1174 + if(modules[module_id])
1176 + MODULE_INSTANCE_T *module = modules[module_id]->module_instance[instance];
1179 + STATE_ENTRY_T *state = module->states[state_id];
1184 + strcpy(led_cfg->name, modules[module_id]->name);
1185 + led_cfg->state = state_id;
1186 + led_cfg->instance = instance;
1187 + led_cfg->param1 = state->param1;
1188 + led_cfg->param2 = state->param2;
1189 + led_cfg->mode[0] = state->mode;
1192 + /* needs to be modified for multi-pin leds */
1193 + for(i = 0;i < num_gpios && !(led->pos_map[i/32] & (1 << i)); i++);
1195 + led_cfg->gpio[0] = i;
1196 + led_cfg->gpio_num = 1;
1205 diff -urN kernel-old/drivers/char/avalanche_led/led_hal.h kernel-current/drivers/char/avalanche_led/led_hal.h
1206 --- kernel-old/drivers/char/avalanche_led/led_hal.h 1970-01-01 01:00:00.000000000 +0100
1207 +++ kernel-current/drivers/char/avalanche_led/led_hal.h 2005-07-10 18:03:46.120957200 +0200
1209 +/******************************************************************************
1210 + * FILE PURPOSE: - LED HAL module Header
1211 + ******************************************************************************
1212 + * FILE NAME: led_hal.h
1214 + * DESCRIPTION: LED HAL API's.
1216 + * REVISION HISTORY:
1217 + * 11 Oct 03 - PSP TII
1219 + * (C) Copyright 2002, Texas Instruments, Inc
1220 + *******************************************************************************/
1222 +#ifndef __LED_HAL__
1223 +#define __LED_HAL__
1225 +/* Interface prototypes */
1227 +int avalanche_led_hal_init (int *gpio_off_value, int num_gpio_pins);
1228 +int avalanche_led_config_set (LED_CONFIG_T * led_cfg);
1229 +int avalanche_led_config_get (LED_CONFIG_T *led_cfg,int module_id,int instance, int state);
1230 +void *avalanche_led_register (const char *module_name, int instance_num);
1231 +void avalanche_led_action (void *handle, int state_id);
1232 +int avalanche_led_unregister (void *handle);
1233 +void avalanche_led_free_all(void);
1234 +void avalanche_led_hal_exit (void);
1236 +#endif /*__LED_HAL__ */
1237 diff -urN kernel-old/drivers/char/avalanche_led/led_platform.h kernel-current/drivers/char/avalanche_led/led_platform.h
1238 --- kernel-old/drivers/char/avalanche_led/led_platform.h 1970-01-01 01:00:00.000000000 +0100
1239 +++ kernel-current/drivers/char/avalanche_led/led_platform.h 2005-07-10 18:03:46.120957200 +0200
1241 +/******************************************************************************
1242 + * FILE PURPOSE: - LED Platform specific Header file
1243 + ******************************************************************************
1244 + * FILE NAME: led_platform.h
1246 + * DESCRIPTION: Linux specific implementation for OS abstracted function calls
1247 + * made by LED HAL module. This file has functions defined for
1248 + * Memory allocation calls, Mutex calls, String and Timer
1251 + * REVISION HISTORY:
1252 + * 11 Oct 03 - PSP TII
1254 + * (C) Copyright 2002, Texas Instruments, Inc
1255 + *******************************************************************************/
1257 +#ifndef __LED_PLATFORM__
1258 +#define __LED_PLATFORM__
1260 +#include <linux/mm.h>
1261 +#include <linux/slab.h>
1262 +#include <asm/string.h>
1263 +#include <linux/param.h>
1264 +#include <linux/sched.h>
1265 +#include <linux/timer.h>
1266 +#include <linux/spinlock.h>
1269 +#define os_malloc(x) kmalloc(x,GFP_KERNEL)
1270 +#define os_memset memset
1271 +#define os_free(x) kfree(x)
1272 +#define os_strcmp os_strcasecmp
1273 +#define os_strcpy strcpy
1276 +#define log_msg printk
1281 +/* defines for Mutex */
1287 +#define MUTEX_DECLARE(x) static OS_SPINLOCK_T x
1288 +#define MUTEX_INIT(x) x.lock = SPIN_LOCK_UNLOCKED
1289 +#define MUTEX_GET(x) spin_lock_irqsave(&x.lock, x.flags)
1290 +#define MUTEX_RELEASE(x) spin_unlock_irqrestore(&x.lock, x.flags)
1294 +/* String handling functions not defined in asm/string.h */
1295 +static __inline__ int os_strlen(char *str)
1298 + for(i=0;str[i];i++);
1303 +#define LOWER(x) ((x < 'a') ? (x - 'A' + 'a'):(x))
1304 +#define ISALPHA(x) ((( x >= 'a') && (x <= 'z')) || (( x >= 'A') && (x <= 'Z')))
1305 +#define COMP(x,y) ((x == y) || ((ISALPHA(x) && ISALPHA(y)) && (LOWER(x) == LOWER(y))))
1308 +static __inline__ int os_strcasecmp(char *str1, char *str2)
1312 + for(i=0;str1[i] && str2[i];i++)
1323 + return(str1[i] || str2[i]);
1328 +/* Functions for timer related operations */
1329 +static __inline__ void * os_timer_init(void (*func)(int))
1331 + struct timer_list *ptimer;
1332 + ptimer = (struct timer_list *) kmalloc(sizeof(struct timer_list),GFP_KERNEL);
1333 + init_timer( ptimer );
1334 + (void *)ptimer->function = (void *)func;
1335 + return (void *)ptimer;
1338 +static __inline__ int os_timer_add(void *timer_handle,int milisec,int arg)
1340 + struct timer_list *ptimer=timer_handle;
1341 + ptimer->expires = ((HZ * milisec)/1000) + jiffies;
1342 + ptimer->data = arg;
1343 + add_timer(ptimer);
1348 +static __inline__ int os_timer_delete(void *timer_handle)
1350 + struct timer_list *ptimer=timer_handle;
1351 + del_timer(ptimer);
1357 +#endif /* __LED_PLATFORM__ */
1358 diff -urN kernel-old/drivers/char/avalanche_led/led_wrapper.c kernel-current/drivers/char/avalanche_led/led_wrapper.c
1359 --- kernel-old/drivers/char/avalanche_led/led_wrapper.c 1970-01-01 01:00:00.000000000 +0100
1360 +++ kernel-current/drivers/char/avalanche_led/led_wrapper.c 2005-07-10 18:25:14.657069936 +0200
1362 +/******************************************************************************
1363 + * FILE PURPOSE: - LED Wrapper file for DSL module support
1364 + ******************************************************************************
1365 + * FILE NAME: led_wrapper.c
1367 + * DESCRIPTION: LED Wrapper file for DSL module support
1368 + * This is to provide backward compatibility to the ADSL module
1369 + * using OLD LED driver. The numbers mapped for DSL LEDs in the
1370 + * previous implementation is 3,4,5,6. Since these numbers overlap
1371 + * with the existing numbering scheme, the following numbers need to
1372 + * be used in the led configuration file - 32,33,34,35.
1374 + * (C) Copyright 2002, Texas Instruments, Inc
1375 + *******************************************************************************/
1376 +#include <linux/config.h>
1377 +#include <linux/init.h>
1378 +#include <linux/module.h>
1379 +#include <asm/ar7/sangam.h>
1380 +#include "led_platform.h"
1381 +#include "led_config.h"
1383 +#define BITS_PER_INT (8 * sizeof(int))
1384 +#define GPIOS_PER_INT BITS_PER_INT
1385 +#define GPIO_MAP_LEN ((MAX_GPIO_PIN_NUM + GPIOS_PER_INT -1)/GPIOS_PER_INT)
1386 +#define MODULE_MAP_LEN ((MAX_MODULE_ENTRIES + BITS_PER_INT -1)/BITS_PER_INT)
1389 +#define REQUIRES_TIMER(x) (x > 1)
1391 +#define gpio_on(gpio) do \
1393 + if(gpio >= 32 && adsl_led_objs[gpio - 32].onfunc) \
1394 + adsl_led_objs[gpio - 32].onfunc(adsl_led_objs[gpio - 32].param);\
1399 +#define gpio_off(gpio) \
1402 + if(gpio >= 32 && adsl_led_objs[gpio - 32].offfunc) \
1403 + adsl_led_objs[gpio - 32].offfunc(adsl_led_objs[gpio - 32].param);\
1411 +/********************TYPEDEFS***********************************************/
1413 +typedef struct gpio_module
1415 + volatile unsigned int *gpio_write_reg;
1416 + volatile unsigned int *gpio_dir_reg;
1417 + volatile unsigned int *gpio_mode_reg;
1421 + unsigned int gpio_id;
1422 + unsigned int gpio_state;
1423 + int module_map[MODULE_MAP_LEN];
1427 +typedef struct state_entry STATE_ENTRY_T;
1429 +struct state_entry{
1430 + unsigned int timer_running;
1431 + STATE_ENTRY_T *next;
1432 + void (*handler)(STATE_ENTRY_T *state);
1435 + unsigned int param;
1436 + unsigned int module_id;
1437 + unsigned int mode;
1441 +typedef struct module_instance{
1444 + STATE_ENTRY_T *states[MAX_STATE_ENTRIES];
1445 +}MODULE_INSTANCE_T;
1447 +typedef struct module_entry{
1448 + unsigned char *name;
1449 + MODULE_INSTANCE_T *module_instance[MAX_MODULE_INSTANCES];
1454 +typedef struct led_reg{
1455 + unsigned int param;
1456 + void (*init)(unsigned long param);
1457 + void (*onfunc)(unsigned long param);
1458 + void (*offfunc)(unsigned long param);
1463 +/* Interface prototypes */
1464 +static int led_hal_init(GPIO_REGS_T gpio_mod, unsigned int *gpio_off_value,int num_gpio_pins);
1465 +static int avalanche_led_set_config(LED_CONFIG_T *led_cfg);
1466 +static void *avalanche_led_register(const char *module_name, int instance_num);
1467 +static int avalanche_led_action(void *handle,int state_id);
1468 +int avalanche_led_config_get (LED_CONFIG_T *led_cfg,int module_id,int instance, int state);
1470 +led_reg_t adsl_led_objs[4];
1471 +MODULE_INSTANCE_T *dsl_mod = NULL;
1472 +static int gpio_off_state[GPIO_MAP_LEN] = AVALANCHE_GPIO_OFF_MAP;
1476 +static unsigned int num_gpios;
1477 +static GPIO_OBJ_T *gpio_arr;
1478 +GPIO_REGS_T gpio_regs;
1480 +/* GPIO OFF STATE */
1481 +static unsigned int gpio_off_val[GPIO_MAP_LEN];
1484 +MODULE_ENTRY_T *modules[MAX_MODULE_ENTRIES];
1487 +void (*led_mode_handler[NUM_LED_MODES])(STATE_ENTRY_T *state);
1490 +/******************static functions*****************************************/
1491 +static void *led_malloc(int n)
1494 + p=kmalloc(n,GFP_ATOMIC);
1501 +static void free_state(STATE_ENTRY_T *state)
1504 + STATE_ENTRY_T *prev = NULL;
1505 + STATE_ENTRY_T *curr = NULL ;
1506 + while(curr != state)
1511 + while(curr->next != NULL)
1514 + curr = curr->next;
1520 + prev->next = NULL;
1527 +static MODULE_INSTANCE_T* get_module(char * name,int instance)
1530 + MODULE_INSTANCE_T *mod_inst;
1532 + if(instance >= MAX_MODULE_INSTANCES)
1535 + for(module_id=0;module_id <MAX_MODULE_ENTRIES;module_id++)
1537 + if(modules[module_id] && !os_strcmp(name,modules[module_id]->name))
1541 + if(module_id == MAX_MODULE_ENTRIES)
1543 + for(module_id = 0; (module_id < MAX_MODULE_ENTRIES) && modules[module_id] ; module_id++);
1545 + if(module_id < MAX_MODULE_ENTRIES)
1547 + modules[module_id]=led_malloc(sizeof(MODULE_ENTRY_T));
1548 + modules[module_id]->name = led_malloc(os_strlen(name));
1549 + os_strcpy(modules[module_id]->name,name);
1553 + log_msg("ERROR:Module Count exceeded\n");
1558 + if(!modules[module_id]->module_instance[instance])
1559 + modules[module_id]->module_instance[instance] = led_malloc(sizeof(MODULE_INSTANCE_T));
1561 + mod_inst = modules[module_id]->module_instance[instance];
1562 + mod_inst->module_id = module_id;
1563 + mod_inst->instance = instance;
1569 +static void led_timer_func(int arg)
1571 + STATE_ENTRY_T *state = (STATE_ENTRY_T *) arg;
1575 + gpio = state->gpio;
1577 + switch(gpio->gpio_state)
1579 + case LED_ONESHOT_ON:
1580 + gpio->gpio_state = LED_OFF;
1581 + gpio_off(gpio->gpio_id);
1584 + case LED_ONESHOT_OFF:
1585 + gpio->gpio_state = LED_ON;
1586 + gpio_on(gpio->gpio_id);
1592 + if(state->timer_running == 1)
1594 + state->timer_running = 2;
1595 + gpio_off(gpio->gpio_id);
1596 + os_timer_add(state->os_timer,(state->param >> 16),(int)state);
1600 + state->timer_running = 1;
1601 + gpio_on(gpio->gpio_id);
1602 + os_timer_add(state->os_timer, (state->param & 0xffff),(int)state);
1611 + state->timer_running = 0;
1617 +static void led_on(STATE_ENTRY_T *state)
1619 + int mod_index = state->module_id >> 5;
1620 + GPIO_OBJ_T *gpio = state->gpio;
1622 + gpio->gpio_state = LED_ON;
1623 + gpio_on(gpio->gpio_id);
1624 + gpio->module_map[mod_index] |= (1 << (state->module_id % BITS_PER_INT));
1628 +static void led_off(STATE_ENTRY_T *state)
1631 + int mod_index = state->module_id >> 5;
1632 + GPIO_OBJ_T *gpio = state->gpio;
1634 + gpio->module_map[mod_index] &= ~(1 << (state->module_id % BITS_PER_INT) );
1635 + if(!gpio->module_map[mod_index])
1637 + gpio->gpio_state = LED_OFF;
1638 + gpio_off(gpio->gpio_id);
1643 +static void led_oneshot_on(STATE_ENTRY_T *state)
1645 + GPIO_OBJ_T *gpio = state->gpio;
1647 + state->timer_running = 1;
1648 + gpio->gpio_state = LED_ONESHOT_ON;
1649 + gpio_on(gpio->gpio_id);
1650 + os_timer_add(state->os_timer,state->param,(int)state);
1653 +static void led_oneshot_off(STATE_ENTRY_T *state)
1656 + GPIO_OBJ_T *gpio = state->gpio;
1658 + state->timer_running = 1;
1659 + gpio->gpio_state = LED_ONESHOT_OFF;
1660 + gpio_off(gpio->gpio_id);
1661 + os_timer_add(state->os_timer,state->param,(int)state);
1664 +static void led_flash(STATE_ENTRY_T *state)
1667 + GPIO_OBJ_T *gpio = state->gpio;
1669 + state->timer_running = 1;
1670 + gpio->gpio_state = LED_FLASH;
1671 + gpio_on(gpio->gpio_id);
1672 + os_timer_add(state->os_timer,(state->param & 0xffff),(int)state);
1676 +/****************HAL APIS***********************************************/
1677 +int led_hal_init(GPIO_REGS_T gpio_reg,unsigned int *gpio_off_value,int num_gpio_pins)
1680 + unsigned int *p_gpio=gpio_off_val;
1682 + gpio_regs = gpio_reg;
1683 + num_gpios = num_gpio_pins;
1685 + gpio_arr = led_malloc((num_gpio_pins + 4) * sizeof(GPIO_OBJ_T)); /* 4 added for ADSL gpio pins */
1687 + /* get gpios off state */
1688 + for(i=0; i < num_gpio_pins; i+=GPIOS_PER_INT)
1690 + *p_gpio = *gpio_off_value;
1695 + /* initialize gpio objects */
1696 + for(i=0; i<num_gpio_pins + 4;i++) /* 4 added for ADSL gpio pins */
1698 + gpio_arr[i].gpio_id = i;
1703 + /* initialize led state function handlers */
1704 + led_mode_handler[LED_ON] = led_on;
1705 + led_mode_handler[LED_OFF] = led_off;
1706 + led_mode_handler[LED_ONESHOT_ON] = led_oneshot_on;
1707 + led_mode_handler[LED_ONESHOT_OFF] = led_oneshot_off;
1708 + led_mode_handler[LED_FLASH] = led_flash;
1715 + /*********************************************************/
1717 +int avalanche_led_set_config(LED_CONFIG_T *led_cfg)
1719 + MODULE_INSTANCE_T *module;
1720 + module = get_module(led_cfg->name,led_cfg->instance);
1723 + goto config_failed;
1725 + if(led_cfg->state < MAX_STATE_ENTRIES)
1727 + STATE_ENTRY_T *state_entry;
1728 + int state=led_cfg->state;
1731 + if(!(module->states[state]))
1733 + module->states[state] = led_malloc(sizeof(STATE_ENTRY_T));
1736 + state_entry = module->states[state];
1738 + for(i=0;i<led_cfg->gpio_num;i++)
1740 + if(led_cfg->gpio[i] >= (num_gpios + 4) ) /* 4 added for ADSL */
1742 + log_msg("Error: gpio number out of range\n");
1743 + goto config_failed;
1746 + state_entry->gpio = &gpio_arr[led_cfg->gpio[i]];
1747 + state_entry->mode = led_cfg->mode[i];
1748 + state_entry->module_id = module->module_id;
1749 + state_entry->handler = led_mode_handler[state_entry->mode];
1750 + state_entry->timer_running = 0;
1752 + if(REQUIRES_TIMER(led_cfg->mode[i])) /* requires timer */
1755 + state_entry->param = led_cfg->param1;
1757 + if(led_cfg->mode[i] == LED_FLASH)
1758 + state_entry->param |= (led_cfg->param2 << 16);
1760 + if(!(state_entry->os_timer))
1761 + state_entry->os_timer = os_timer_init(led_timer_func);
1764 + if(i == led_cfg->gpio_num - 1)
1766 + free_state(state_entry->next);
1767 + state_entry->next = NULL;
1772 + /* allocate next node */
1773 + else if( !(state_entry->next))
1775 + state_entry->next = led_malloc(sizeof(STATE_ENTRY_T));
1778 + state_entry = state_entry->next;
1786 + log_msg("ERROR:State Count exceeded\n");
1787 + goto config_failed;
1800 + /*********************************************************/
1802 +void *avalanche_led_register(const char * mod_name,int instance)
1805 + p = get_module((void * )mod_name,instance);
1810 +int avalanche_led_action(void *module, int state_id)
1813 + if(module && state_id < MAX_STATE_ENTRIES)
1816 + STATE_ENTRY_T *state =((MODULE_INSTANCE_T *)(module))->states[state_id];
1819 + if(state->timer_running == 0)
1821 + state->handler(state);
1823 + state = state->next;
1832 +int led_get_dsl_config(void)
1836 + LED_CONFIG_T led_cfg;
1837 + int state_count = 0;
1839 + os_strcpy(led_cfg.name,"adsl");
1841 + for(state_id = 0; state_id < MAX_STATE_ENTRIES;state_id++)
1843 + if(avalanche_led_config_get(&led_cfg,-1,0,state_id) == 0)
1845 + /* call configure */
1846 + avalanche_led_set_config(&led_cfg);
1851 + return state_count;
1857 +void register_led_drv(int led_num,led_reg_t *led)
1860 + /* DSL leds are numbered from 3 to 6 */
1861 + int led_index = led_num - 3;
1863 + if(led_index >=0 && led_index <= 2)
1865 + adsl_led_objs[led_index] = *led;
1867 + if(adsl_led_objs[led_index].init)
1868 + adsl_led_objs[led_index].init(adsl_led_objs[led_index].param);
1873 +void deregister_led_drv( int led_num)
1875 + /* DSL leds are numbered from 3 to 6 */
1876 + int led_index = led_num - 3;
1878 + if(led_index >=0 && led_index <= 2)
1880 + adsl_led_objs[led_index].onfunc = NULL;
1881 + adsl_led_objs[led_index].offfunc = NULL;
1886 +void led_operation(int mod,int state_id)
1888 + static int configured = 0;
1890 + if(configured == 0)
1892 + configured = led_get_dsl_config();
1895 + avalanche_led_action(dsl_mod,state_id);
1898 +static int __init led_init(void)
1900 + GPIO_REGS_T gpio_regs;
1902 + gpio_regs.gpio_write_reg = NULL;
1903 + gpio_regs.gpio_dir_reg = NULL;
1904 + gpio_regs.gpio_mode_reg = NULL;
1906 + led_hal_init(gpio_regs,gpio_off_state,AVALANCHE_GPIO_PIN_COUNT);
1908 + /* register instance 0 of adsl module */
1909 + dsl_mod = avalanche_led_register("adsl",0);
1914 +__initcall(led_init);
1918 +EXPORT_SYMBOL_NOVERS(led_init);
1919 +EXPORT_SYMBOL_NOVERS(led_operation);
1920 +EXPORT_SYMBOL_NOVERS(register_led_drv);
1921 +EXPORT_SYMBOL_NOVERS(deregister_led_drv);
1923 diff -urN kernel-old/drivers/char/avalanche_led/Makefile kernel-current/drivers/char/avalanche_led/Makefile
1924 --- kernel-old/drivers/char/avalanche_led/Makefile 1970-01-01 01:00:00.000000000 +0100
1925 +++ kernel-current/drivers/char/avalanche_led/Makefile 2005-07-10 18:25:32.692328160 +0200
1927 +# File: drivers/char/avalanche_led/Makefile
1929 +# Makefile for the Linux LED device driver.
1933 +O_TARGET := avalanche_led.o
1934 +obj-m := avalanche_led.o
1935 +list-multi := avalanche_led.o
1937 +EXTRA_CFLAGS := -I$(TOPDIR)/include/asm/ar7
1939 +export-objs := led_drv.o led_wrapper.o
1941 +avalanche_led-objs := led_hal.o led_drv.o led_wrapper.o
1943 +include $(TOPDIR)/Rules.make
1945 +avalanche_led.o: $(avalanche_led-objs)
1946 + $(LD) -r -o $@ $(avalanche_led-objs)
1949 + rm -f core *.o *.a *.s
1950 diff -urN kernel-old/drivers/char/Config.in kernel-current/drivers/char/Config.in
1951 --- kernel-old/drivers/char/Config.in 2005-07-10 02:55:18.318811000 +0200
1952 +++ kernel-current/drivers/char/Config.in 2005-07-10 18:03:46.121957048 +0200
1953 @@ -133,6 +133,10 @@
1957 +if [ "$CONFIG_AR7" = "y" ]; then
1958 + bool 'Enable LED support' CONFIG_MIPS_AVALANCHE_LED
1961 if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_ZORRO" = "y" ]; then
1962 tristate 'Commodore A2232 serial support (EXPERIMENTAL)' CONFIG_A2232
1964 diff -urN kernel-old/drivers/char/Makefile kernel-current/drivers/char/Makefile
1965 --- kernel-old/drivers/char/Makefile 2005-07-10 02:55:18.319811000 +0200
1966 +++ kernel-current/drivers/char/Makefile 2005-07-10 18:03:46.122956896 +0200
1967 @@ -190,6 +190,19 @@
1968 obj-$(CONFIG_PCI) += keyboard.o $(KEYMAP)
1972 +# Texas Intruments LED driver
1974 +ifeq ($(CONFIG_MIPS_AVALANCHE_LED),y)
1975 +obj-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led/avalanche_led.o
1976 +subdir-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led
1979 +ifeq ($(CONFIG_MIPS_AVALANCHE_LED),m)
1980 +obj-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led/avalanche_led.o
1981 +subdir-$(CONFIG_MIPS_AVALANCHE_LED) += avalanche_led
1984 obj-$(CONFIG_HIL) += hp_keyb.o
1985 obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
1986 obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
1987 diff -urN kernel-old/include/asm-mips/ar7/ledapp.h kernel-current/include/asm-mips/ar7/ledapp.h
1988 --- kernel-old/include/asm-mips/ar7/ledapp.h 1970-01-01 01:00:00.000000000 +0100
1989 +++ kernel-current/include/asm-mips/ar7/ledapp.h 2005-07-10 18:49:37.556426688 +0200
1991 +#ifndef __LED_APP__
1992 +#define __LED_APP__
1994 +#define CONF_FILE "/etc/led.conf"
1995 +#define LED_PROC_FILE "/proc/led_mod/led"
1997 +#define CONFIG_LED_MODULE
1999 +#define MAX_MOD_ID 25
2000 +#define MAX_STATE_ID 25
2001 +#define MAX_LED_ID 25
2004 +#define DEF_ADSL_IDLE 1
2005 +#define DEF_ADSL_TRAINING 2
2006 +#define DEF_ADSL_SYNC 3
2007 +#define DEF_ADSL_ACTIVITY 4
2010 +#define DEF_WAN_IDLE 1
2011 +#define DEF_WAN_NEGOTIATE 2
2012 +#define DEF_WAN_SESSION 3
2015 +#define DEF_LAN_IDLE 1
2016 +#define DEF_LAN_LINK_UP 2
2017 +#define DEF_LAN_ACTIVITY 3
2020 +#define DEF_WLAN_IDLE 1
2021 +#define DEF_WLAN_LINK_UP 2
2022 +#define DEF_WLAN_ACTIVITY 3
2025 +#define DEF_USB_IDLE 1
2026 +#define DEF_USB_LINK_UP 2
2027 +#define DEF_USB_ACTIVITY 3
2030 +#define DEF_ETH_IDLE 1
2031 +#define DEF_ETH_LINK_UP 2
2032 +#define DEF_ETH_ACTIVITY 3
2034 +typedef struct config_elem{
2035 + unsigned char name;
2036 + unsigned char state;
2037 + unsigned char mode;
2038 + unsigned char led;
2042 +typedef struct led_reg{
2043 + unsigned int param;
2044 + void (*init)(unsigned long param);
2045 + void (*onfunc)(unsigned long param);
2046 + void (*offfunc)(unsigned long param);
2050 diff -urN kernel-old/include/asm-mips/ar7/led_config.h kernel-current/include/asm-mips/ar7/led_config.h
2051 --- kernel-old/include/asm-mips/ar7/led_config.h 1970-01-01 01:00:00.000000000 +0100
2052 +++ kernel-current/include/asm-mips/ar7/led_config.h 2005-07-10 18:03:46.122956896 +0200
2054 +/******************************************************************************
2055 + * FILE PURPOSE: - LED config Header
2056 + ******************************************************************************
2057 + * FILE NAME: led_config.h
2059 + * DESCRIPTION: Header file for LED configuration parameters
2060 + * and data structures
2062 + * REVISION HISTORY:
2063 + * 11 Oct 03 - PSP TII
2065 + * (C) Copyright 2002, Texas Instruments, Inc
2066 + *******************************************************************************/
2069 +#ifndef __LED_CONFIG__
2070 +#define __LED_CONFIG__
2072 +/* LED config parameters */
2073 +#define MAX_GPIO_PIN_NUM 64
2074 +#define MAX_GPIOS_PER_STATE 2
2075 +#define MAX_MODULE_ENTRIES 25
2076 +#define MAX_MODULE_INSTANCES 2
2077 +#define MAX_STATE_ENTRIES 25
2078 +#define NUM_LED_MODES 5
2079 +#define MAX_LED_ENTRIES 25
2085 +#define LED_ONESHOT_OFF 2
2086 +#define LED_ONESHOT_ON 3
2087 +#define LED_FLASH 4
2091 +/* Data structure for LED configuration */
2092 +typedef struct led_config{
2093 + unsigned char name[80];
2094 + unsigned int instance;
2095 + unsigned int state;
2096 + unsigned int gpio[MAX_GPIOS_PER_STATE];
2097 + unsigned int mode[MAX_GPIOS_PER_STATE];
2098 + unsigned int gpio_num;
2099 + unsigned int param1;
2100 + unsigned int param2;
2104 +#endif /* __LED_CONFIG__ */
2105 diff -urN kernel-old/include/asm-mips/ar7/led_ioctl.h kernel-current/include/asm-mips/ar7/led_ioctl.h
2106 --- kernel-old/include/asm-mips/ar7/led_ioctl.h 1970-01-01 01:00:00.000000000 +0100
2107 +++ kernel-current/include/asm-mips/ar7/led_ioctl.h 2005-07-10 18:03:46.122956896 +0200
2109 +/******************************************************************************
2110 + * FILE PURPOSE: - LED ioctl Header
2111 + ******************************************************************************
2112 + * FILE NAME: led_ioctl.h
2114 + * DESCRIPTION: Header file defining macros for ioctl commands.
2116 + * REVISION HISTORY:
2117 + * 11 Oct 03 - PSP TII
2119 + * (C) Copyright 2002, Texas Instruments, Inc
2120 + *******************************************************************************/
2121 +#ifndef __LED_IOCTL__
2122 +#define __LED_IOCTL__
2124 +typedef struct led_mod{
2125 +unsigned char *name;
2126 +unsigned int instance;
2127 +unsigned int handle;
2130 +typedef struct led_state{
2131 +unsigned int handle;
2132 +unsigned int state_id;
2135 +#define LED_CONFIG 0
2136 +#define LED_GET_HANDLE 1
2137 +#define LED_ACTION 2
2138 +#define LED_RELEASE_HANDLE 3
2140 +#endif /* __LED_IOCTL__ */