MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / drivers / char / ledman.c
blob3de22e7df0ba7ff4a7f9f0738306f96ad8456b93
1 /****************************************************************************/
2 /* vi:set tabstop=4 cindent shiftwidth=4:
4 * ledman.c -- An LED manager, primarily, but not limited to SnapGear
5 * devices manages up to 32 seperate LED at once.
6 * Copyright (C) Lineo, 2000-2001.
7 * Copyright (C) SnapGear, 2001-2003.
9 * This driver currently supports 4 types of LED modes:
11 * SET - transient LED's that show activity, cleared at next poll
12 * ON - always ON
13 * OFF - always OFF
14 * FLASHING - a blinking LED with the frequency determined by the poll func
16 * We have two sets of LED's to support non-standard LED usage without
17 * losing previously/during use set of std values.
19 * Hopefully for most cases, adding new HW with new LED patterns will be
20 * as simple as adding two tables, a small function and an entry in
21 * led_modes. The tables being the map and the defaults while the
22 * function is the XXX_set function.
24 * You can, however, add your own functions for XXX_bits, XXX_tick and
25 * take full control over all aspects of the LED's.
27 /****************************************************************************/
29 #include <linux/version.h>
30 #include <linux/module.h>
31 #include <linux/utsname.h>
32 #include <linux/kernel.h>
33 #include <linux/major.h>
34 #include <linux/string.h>
35 #include <linux/fcntl.h>
36 #include <linux/timer.h>
37 #include <linux/delay.h>
38 #include <linux/fs.h>
39 #include <linux/interrupt.h>
40 #include <linux/irq.h>
41 #include <linux/ledman.h>
43 #if LINUX_VERSION_CODE < 0x020300
44 #include <linux/malloc.h>
45 #else
46 #include <linux/slab.h>
47 #endif
49 #if LINUX_VERSION_CODE < 0x020100
50 #define INIT_RET_TYPE int
51 #define Module_init(a)
52 #elif LINUX_VERSION_CODE < 0x020300
53 #include <linux/init.h>
54 #define INIT_RET_TYPE int
55 #define Module_init(a) module_init(a)
56 #else
57 #include <linux/init.h>
58 #define INIT_RET_TYPE static int __init
59 #define Module_init(a) module_init(a)
60 #endif
62 #if LINUX_VERSION_CODE < 0x020100
63 #define Get_user(a,b) a = get_user(b)
64 #else
65 #include <asm/uaccess.h>
66 #define Get_user(a,b) get_user(a,b)
67 #endif
69 #if LINUX_VERSION_CODE < 0x020100
70 static struct symbol_table ledman_syms = {
71 #include <linux/symtab_begin.h>
72 X(ledman_cmd),
73 #include <linux/symtab_end.h>
75 #else
76 EXPORT_SYMBOL(ledman_cmd);
77 #endif
79 /****************************************************************************/
81 static void ledman_poll(unsigned long arg);
82 static int ledman_ioctl(struct inode * inode, struct file * file,
83 unsigned int cmd, unsigned long arg);
84 #if !defined(CONFIG_SH_KEYWEST) && !defined(CONFIG_SH_BIGSUR)
85 static int ledman_bits(unsigned long cmd, unsigned long bits);
86 static void ledman_tick(void);
87 #endif
89 /****************************************************************************/
91 static struct timer_list ledman_timerlist;
93 /****************************************************************************/
95 struct file_operations ledman_fops = {
96 .ioctl = ledman_ioctl,
99 /****************************************************************************/
101 * some types to make adding new LED modes easier
103 * First the elements for def array specifying default LED behaviour
106 #define LEDS_SET 0
107 #define LEDS_ON 1
108 #define LEDS_OFF 2
109 #define LEDS_FLASH 3
110 #define LEDS_MAX 4
112 typedef unsigned long leddef_t[LEDS_MAX];
115 * A LED map is a mapping from numbers in ledman.h to one or more
116 * physical LED bits. Currently the typing limits us to 32 LED's
117 * though this would not be hard to change.
120 typedef unsigned long ledmap_t[LEDMAN_MAX];
123 * A LED mode is a definition of how a set of LED's should behave.
125 * name - a symbolic name for the LED mode, used for changing modes
126 * map - points to a ledmap array, maps ledman.h defines to real LED bits
127 * def - default behaviour for the LED bits (ie, on, flashing ...)
128 * bits - perform command on physical bits, you may use the default or
129 * supply your own for more control.
130 * tick - time based update of LED status, used to clear SET LED's and
131 * also for flashing LED's
132 * set - set the real LED's to match the physical bits
133 * jiffies - how many clock ticks between runs of the tick routine.
137 typedef struct {
138 char name[LEDMAN_MAX_NAME];
139 u_long *map;
140 u_long *def;
141 int (*bits)(unsigned long cmd, unsigned long led);
142 void (*tick)(void);
143 void (*set)(unsigned long led);
144 int jiffies;
145 } ledmode_t;
147 /****************************************************************************/
149 static int current_mode = 0; /* the default LED mode */
150 static int initted = 0;
153 * We have two sets of LED's for transient operations like DHCP and so on
154 * index 0 is the standard LED's and index 1 is the ALTBIT LED's
157 static unsigned long leds_alt, leds_alt_cnt[32];
158 #if !defined(CONFIG_SH_KEYWEST) && !defined(CONFIG_SH_BIGSUR)
159 static unsigned long leds_set[2];
160 #endif
161 static unsigned long leds_on[2], leds_off[2], leds_flash[2];
163 static pid_t ledman_resetpid = -1;
165 /****************************************************************************/
168 * Let the system specific defining begin
171 #if defined(CONFIG_M586)
172 #define CONFIG_X86 1
173 #endif
175 #if defined(CONFIG_X86)
176 #if defined(CONFIG_MTD_SNAPGEODE)
177 #define CONFIG_GEODE 1
178 #else
179 #define CONFIG_AMDSC520 1
180 #endif
181 #if defined(CONFIG_SNAPGEAR)
182 static ledmap_t nettel_old;
183 static leddef_t nettel_def_old;
184 #endif
185 static ledmap_t nettel_std;
186 static leddef_t nettel_def;
187 static void nettel_set(unsigned long bits);
188 static void ledman_initarch(void);
189 #endif /* CONFIG_X86 */
191 #if defined(CONFIG_NETtel) && defined(CONFIG_M5307)
192 #ifdef ENTERASYS
193 static ledmap_t enterasys_std;
194 static leddef_t enterasys_def;
195 #endif
196 static ledmap_t nettel_old;
197 static ledmap_t nettel_new;
198 static leddef_t nettel_def;
199 static void nettel_set(unsigned long bits);
200 #endif
202 #if defined(CONFIG_NETtel) && defined(CONFIG_M5272)
203 static ledmap_t nt5272_std;
204 static leddef_t nt5272_def;
205 static void nt5272_set(unsigned long bits);
206 #endif
208 #if defined(CONFIG_SE1100)
209 static ledmap_t se1100_std;
210 static leddef_t se1100_def;
211 static void se1100_set(unsigned long bits);
212 #endif
214 #if defined(CONFIG_GILBARCONAP) && defined(CONFIG_M5272)
215 static ledmap_t nap5272_std;
216 static leddef_t nap5272_def;
217 static void nap5272_set(unsigned long bits);
218 #endif
220 #if defined(CONFIG_AVNET5282)
221 static ledmap_t ads5282_std;
222 static leddef_t ads5282_def;
223 static void ads5282_set(unsigned long bits);
224 #endif
226 #if defined(CONFIG_SH_SECUREEDGE5410)
227 #include <asm/snapgear.h>
228 static ledmap_t se5410_std;
229 static leddef_t se5410_def;
230 static void se5410_set(unsigned long bits);
231 #endif
233 #if defined(CONFIG_NETtel) && defined(CONFIG_M5206e)
234 static ledmap_t nt1500_std;
235 static leddef_t nt1500_def;
236 static void nt1500_set(unsigned long bits);
237 #endif
239 #ifdef CONFIG_eLIA
240 static ledmap_t elia_std;
241 static leddef_t elia_def;
242 static void elia_set(unsigned long bits);
243 #endif
245 #if defined(CONFIG_SH_KEYWEST) || defined(CONFIG_SH_BIGSUR)
246 static ledmap_t keywest_std;
247 static leddef_t keywest_def;
248 static void keywest_set(unsigned long bits);
249 static void ledman_initkeywest(void);
250 static int keywest_bits(unsigned long cmd, unsigned long bits);
251 static void keywest_tick(void);
252 #endif
254 #if defined(CONFIG_MACH_MONTEJADE) || defined(CONFIG_MACH_IXDPG425) || \
255 defined(CONFIG_MACH_SE5100)
256 static ledmap_t montejade_std;
257 static leddef_t montejade_def;
258 static void ledman_initarch(void);
259 static void montejade_set(unsigned long bits);
260 #endif
262 #if defined(CONFIG_ARCH_SE4000) || defined(CONFIG_MACH_ESS710) || \
263 defined(CONFIG_MACH_SG560) || defined(CONFIG_MACH_SG580) || \
264 defined(CONFIG_MACH_SG565) || defined(CONFIG_MACH_SG640) || \
265 defined(CONFIG_MACH_SG720) || defined(CONFIG_MACH_SG590) || \
266 defined(CONFIG_MACH_SG8100)
267 static ledmap_t snapgear425_std;
268 static leddef_t snapgear425_def;
269 static void ledman_initarch(void);
270 static void snapgear425_set(unsigned long bits);
271 #endif
273 #ifdef CONFIG_MACH_IVPN
274 static ledmap_t ivpn_std;
275 static leddef_t ivpn_def;
276 static void ledman_initarch(void);
277 static void ivpn_set(unsigned long bits);
278 #endif
280 #ifdef CONFIG_ARCH_KS8695
281 static ledmap_t lite3_std;
282 static leddef_t lite3_def;
283 static void ledman_initarch(void);
284 static void lite3_set(unsigned long bits);
285 #endif
287 #ifdef CONFIG_ARCH_EP9312
288 static ledmap_t ipd_std;
289 static leddef_t ipd_def;
290 static void ledman_initarch(void);
291 static void ipd_set(unsigned long bits);
292 #endif
294 /****************************************************************************/
295 /****************************************************************************/
297 #undef LT
298 #define LT (((HZ) + 99) / 100)
300 /****************************************************************************/
302 ledmode_t led_mode[] = {
304 #ifdef ENTERASYS /* first in the list is the default */
305 { "enterasys", enterasys_std, enterasys_def, ledman_bits, ledman_tick, nettel_set, LT },
306 #endif
308 #if defined(CONFIG_X86)
309 { "std", nettel_std, nettel_def, ledman_bits, ledman_tick, nettel_set, LT },
310 #if defined(CONFIG_SNAPGEAR)
311 { "old", nettel_old, nettel_def_old, ledman_bits, ledman_tick, nettel_set, LT },
312 #endif
313 #endif
315 #if defined(CONFIG_NETtel) && defined(CONFIG_M5307)
317 * by default the first entry is used. You can select the old-style
318 * LED patterns for acient boards with the command line parameter:
320 * ledman=old
322 { "new", nettel_new, nettel_def, ledman_bits, ledman_tick, nettel_set, LT },
323 { "old", nettel_old, nettel_def, ledman_bits, ledman_tick, nettel_set, LT },
324 #endif
326 #if defined(CONFIG_NETtel) && defined(CONFIG_M5272)
327 { "std", nt5272_std, nt5272_def, ledman_bits, ledman_tick, nt5272_set, LT },
328 #endif
330 #if defined(CONFIG_NETtel) && defined(CONFIG_M5206e)
331 { "std", nt1500_std, nt1500_def, ledman_bits, ledman_tick, nt1500_set, LT },
332 #endif
334 #if defined(CONFIG_SE1100)
335 { "std", se1100_std, se1100_def, ledman_bits, ledman_tick, se1100_set, LT },
336 #endif
338 #if defined(CONFIG_GILBARCONAP) && defined(CONFIG_M5272)
339 { "std", nap5272_std, nap5272_def, ledman_bits, ledman_tick, nap5272_set, LT },
340 #endif
342 #if defined(CONFIG_SH_SECUREEDGE5410)
343 { "std", se5410_std, se5410_def, ledman_bits, ledman_tick, se5410_set, LT },
344 #endif
346 #ifdef CONFIG_eLIA
347 { "std", elia_std, elia_def, ledman_bits, ledman_tick, elia_set, LT },
348 #endif
350 #if defined(CONFIG_SH_KEYWEST) || defined(CONFIG_SH_BIGSUR)
351 { "std",keywest_std,keywest_def,keywest_bits,keywest_tick,keywest_set,HZ/10},
352 #endif
354 #if defined(CONFIG_MACH_MONTEJADE) || defined(CONFIG_MACH_IXDPG425) || \
355 defined(CONFIG_MACH_SE5100)
356 { "std",montejade_std,montejade_def,ledman_bits,ledman_tick,montejade_set,LT},
357 #endif
359 #if defined(CONFIG_ARCH_SE4000) || defined(CONFIG_MACH_ESS710) || \
360 defined(CONFIG_MACH_SG560) || defined(CONFIG_MACH_SG580) || \
361 defined(CONFIG_MACH_SG565) || defined(CONFIG_MACH_SG640) || \
362 defined(CONFIG_MACH_SG720) || defined(CONFIG_MACH_SG590) || \
363 defined(CONFIG_MACH_SG8100)
364 { "std",snapgear425_std,snapgear425_def,ledman_bits,ledman_tick,snapgear425_set,LT},
365 #endif
367 #ifdef CONFIG_MACH_IVPN
368 { "std",ivpn_std,ivpn_def,ledman_bits,ledman_tick,ivpn_set,LT},
369 #endif
371 #if defined(CONFIG_ARCH_KS8695)
372 { "std",lite3_std,lite3_def,ledman_bits,ledman_tick,lite3_set,LT},
373 #endif
375 #if defined(CONFIG_ARCH_EP9312)
376 { "std", ipd_std, ipd_def, ledman_bits, ledman_tick, ipd_set, LT},
377 #endif
379 #if defined(CONFIG_AVNET5282)
380 { "std", ads5282_std, ads5282_def, ledman_bits, ledman_tick, ads5282_set, LT },
381 #endif
383 { "", NULL, NULL, NULL }
386 /****************************************************************************/
388 * boot arg processing ledman=mode
391 #if LINUX_VERSION_CODE >= 0x020100
392 __setup("ledman=", ledman_setup);
393 #endif
396 ledman_setup(char *arg)
398 ledman_cmd(LEDMAN_CMD_MODE, (unsigned long) arg);
399 return(0);
402 /****************************************************************************/
403 /****************************************************************************/
405 INIT_RET_TYPE ledman_init(void)
407 int expires;
408 printk(KERN_INFO "ledman: Copyright (C) SnapGear, 2000-2003.\n");
410 if (register_chrdev(LEDMAN_MAJOR, "nled", &ledman_fops) < 0) {
411 printk("%s(%d): ledman_init() can't get Major %d\n",
412 __FILE__, __LINE__, LEDMAN_MAJOR);
413 return(-EBUSY);
416 #if defined(CONFIG_SH_KEYWEST) || defined(CONFIG_SH_BIGSUR)
417 ledman_initkeywest();
418 #endif
420 #if defined(CONFIG_X86) || defined(CONFIG_ARM)
421 ledman_initarch();
422 #endif
425 * set the LEDs up correctly at boot
427 ledman_cmd(LEDMAN_CMD_RESET, LEDMAN_ALL);
429 * start the timer
431 init_timer(&ledman_timerlist);
432 if (led_mode[current_mode].tick)
433 expires = jiffies + led_mode[current_mode].jiffies;
434 else
435 expires = jiffies + HZ;
436 ledman_timerlist.function = ledman_poll;
437 ledman_timerlist.data = 0;
438 mod_timer(&ledman_timerlist, expires);
440 #if LINUX_VERSION_CODE < 0x020100
441 register_symtab(&ledman_syms);
442 #endif
444 initted = 1;
445 return 0;
448 Module_init(ledman_init);
450 /****************************************************************************/
452 void
453 ledman_killtimer(void)
456 * stop the timer
458 del_timer(&ledman_timerlist);
461 * set the LEDs up correctly at boot
463 ledman_cmd(LEDMAN_CMD_RESET, LEDMAN_ALL);
466 /****************************************************************************/
468 void
469 ledman_starttimer(void)
472 * start the timer
474 mod_timer(&ledman_timerlist, jiffies + 1);
477 * set the LEDs up correctly at boot
479 ledman_cmd(LEDMAN_CMD_RESET, LEDMAN_ALL);
482 /****************************************************************************/
484 static void
485 ledman_poll(unsigned long arg)
487 int expires;
488 if (led_mode[current_mode].tick) {
489 (*led_mode[current_mode].tick)();
490 expires = jiffies + led_mode[current_mode].jiffies;
491 } else
492 expires = jiffies + HZ;
493 mod_timer(&ledman_timerlist, expires);
496 /****************************************************************************/
498 static int
499 ledman_ioctl(
500 struct inode * inode,
501 struct file * file,
502 unsigned int cmd,
503 unsigned long arg)
505 char mode[LEDMAN_MAX_NAME];
506 int i;
508 if (cmd == LEDMAN_CMD_SIGNAL) {
509 ledman_resetpid = current->pid;
510 return(0);
513 if (cmd == LEDMAN_CMD_MODE) {
514 for (i = 0; i < sizeof(mode) - 1; i++) {
515 Get_user(mode[i], (char __user *) (arg + i));
516 if (!mode[i])
517 break;
519 mode[i] = '\0';
520 arg = (unsigned long) &mode[0];
522 return(ledman_cmd(cmd, arg));
525 /****************************************************************************/
527 * cmd - from ledman.h
528 * led - led code from ledman.h
530 * check parameters and then call
534 ledman_cmd(int cmd, unsigned long led)
536 ledmode_t *lmp;
537 int i;
539 switch (cmd & ~LEDMAN_CMD_ALTBIT) {
540 case LEDMAN_CMD_SET:
541 case LEDMAN_CMD_ON:
542 case LEDMAN_CMD_OFF:
543 case LEDMAN_CMD_FLASH:
544 case LEDMAN_CMD_RESET:
545 case LEDMAN_CMD_ALT_ON:
546 case LEDMAN_CMD_ALT_OFF:
547 break;
548 case LEDMAN_CMD_STARTTIMER:
549 ledman_starttimer();
550 return(0);
551 case LEDMAN_CMD_KILLTIMER:
552 ledman_killtimer();
553 return(0);
554 case LEDMAN_CMD_MODE:
555 for (i = 0; led_mode[i].name[0]; i++)
556 if (strcmp((char *) led, led_mode[i].name) == 0) {
557 current_mode = i;
558 if (initted)
559 ledman_cmd(LEDMAN_CMD_RESET, LEDMAN_ALL);
560 return(0);
562 return(-EINVAL);
563 default:
564 return(-EINVAL);
567 if (led < 0 || led >= LEDMAN_MAX)
568 return(-EINVAL);
570 lmp = &led_mode[current_mode];
571 (*lmp->bits)(cmd, lmp->map[led]);
572 return(0);
575 /****************************************************************************/
577 * Signal the reset pid, if we have one
580 void
581 ledman_signalreset(void)
583 static unsigned long firstjiffies = 0;
584 if (ledman_resetpid == -1)
585 return;
586 if (jiffies > (firstjiffies + (HZ / 4))) {
587 firstjiffies = jiffies;
588 printk("LED: reset switch interrupt! (sending signal to pid=%d)\n",
589 ledman_resetpid);
590 kill_proc(ledman_resetpid, SIGUSR2, 1);
594 /****************************************************************************/
595 #if !defined(CONFIG_SH_KEYWEST) && !defined(CONFIG_SH_BIGSUR)
596 /****************************************************************************/
598 static int
599 ledman_bits(unsigned long cmd, unsigned long bits)
601 ledmode_t *lmp = &led_mode[current_mode];
602 int alt, i;
603 unsigned long new_alt;
605 alt = (cmd & LEDMAN_CMD_ALTBIT) ? 1 : 0;
607 switch (cmd & ~LEDMAN_CMD_ALTBIT) {
608 case LEDMAN_CMD_SET:
609 leds_set[alt] |= bits;
610 break;
611 case LEDMAN_CMD_ON:
612 leds_on[alt] |= bits;
613 leds_off[alt] &= ~bits;
614 leds_flash[alt] &= ~bits;
615 (*lmp->tick)();
616 break;
617 case LEDMAN_CMD_OFF:
618 leds_on[alt] &= ~bits;
619 leds_off[alt] |= bits;
620 leds_flash[alt] &= ~bits;
621 (*lmp->tick)();
622 break;
623 case LEDMAN_CMD_FLASH:
624 leds_on[alt] &= ~bits;
625 leds_off[alt] &= ~bits;
626 leds_flash[alt] |= bits;
627 break;
628 case LEDMAN_CMD_RESET:
629 leds_set[alt] = (leds_set[alt] &~bits) | (bits&lmp->def[LEDS_SET]);
630 leds_on[alt] = (leds_on[alt] &~bits) | (bits&lmp->def[LEDS_ON]);
631 leds_off[alt] = (leds_off[alt] &~bits) | (bits&lmp->def[LEDS_OFF]);
632 leds_flash[alt] = (leds_flash[alt]&~bits) | (bits&lmp->def[LEDS_FLASH]);
633 break;
634 case LEDMAN_CMD_ALT_ON:
635 new_alt = (bits & ~leds_alt);
636 leds_alt |= bits;
638 * put any newly alt'd bits into a default state
640 (*lmp->bits)(LEDMAN_CMD_RESET | LEDMAN_CMD_ALTBIT, new_alt);
641 for (i = 0; i < 32; i++)
642 if (bits & (1 << i))
643 leds_alt_cnt[i]++;
644 break;
645 case LEDMAN_CMD_ALT_OFF:
646 for (i = 0; i < 32; i++)
647 if ((bits & (1 << i)) && leds_alt_cnt[i]) {
648 leds_alt_cnt[i]--;
649 if (leds_alt_cnt[i] == 0)
650 leds_alt &= ~(1 << i);
652 break;
653 default:
654 return(-EINVAL);
656 return(0);
659 /****************************************************************************/
661 static void
662 ledman_tick(void)
664 ledmode_t *lmp = &led_mode[current_mode];
665 int new_value;
666 static int flash_on = 0;
668 * work out which LED's should be on
670 new_value = 0;
671 new_value |= (((leds_set[0] | leds_on[0]) & ~leds_off[0]) & ~leds_alt);
672 new_value |= (((leds_set[1] | leds_on[1]) & ~leds_off[1]) & leds_alt);
674 * flashing LED's run on their own devices, ie, according to the
675 * value fo flash_on
677 if ((flash_on++ % 60) >= 30)
678 new_value |= ((leds_flash[0]&~leds_alt) | (leds_flash[1]&leds_alt));
679 else
680 new_value &= ~((leds_flash[0]&~leds_alt) | (leds_flash[1]&leds_alt));
682 * set the HW
684 (*lmp->set)(new_value);
685 leds_set[0] = leds_set[1] = 0;
688 /****************************************************************************/
689 #endif /* !defined(CONFIG_SH_KEYWEST) && !defined(CONFIG_SH_BIGSUR) */
690 /****************************************************************************/
691 #if defined(CONFIG_NETtel) && defined(CONFIG_M5307)
692 /****************************************************************************/
694 * Here it the definition of the LED's on the NETtel circuit board
695 * as per the labels next to them. The two parallel port LED's steal
696 * some high bits so we can map it more easily onto the HW
698 * LED - D1 D2 D3 D4 D5 D6 D7 D8 D11 D12
699 * HEX - 100 200 004 008 010 020 040 080 002 001
703 #include <asm/coldfire.h>
704 #include <asm/mcfsim.h>
705 #include <asm/nettel.h>
707 static ledmap_t nettel_old = {
708 0x3ff, 0x200, 0x100, 0x008, 0x004, 0x020, 0x010, 0x080, 0x080, 0x080,
709 0x080, 0x040, 0x040, 0x002, 0x002, 0x024, 0x018, 0x001, 0x0ff, 0x0ff,
710 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x100, 0x200, 0x000,
711 0x000, 0x000, 0x000, 0x000
714 #if defined(CONFIG_SNAPGEAR)
717 * all snapgear 5307 based boards have a SW link status on the front
720 static ledmap_t nettel_new = {
721 0x3ff, 0x200, 0x100, 0x040, 0x040, 0x002, 0x002, 0x008, 0x008, 0x020,
722 0x020, 0x000, 0x000, 0x000, 0x000, 0x024, 0x018, 0x001, 0x0ff, 0x080,
723 0x000, 0x000, 0x080, 0x004, 0x010, 0x000, 0x000, 0x100, 0x200, 0x000,
724 0x000, 0x000, 0x000, 0x000
727 #else
729 static ledmap_t nettel_new = {
730 0x3ff, 0x200, 0x100, 0x040, 0x040, 0x002, 0x002, 0x008, 0x004, 0x020,
731 0x010, 0x000, 0x000, 0x000, 0x000, 0x024, 0x018, 0x001, 0x0ff, 0x080,
732 0x000, 0x000, 0x080, 0x000, 0x000, 0x000, 0x000, 0x100, 0x200, 0x000,
733 0x000, 0x000, 0x000, 0x000
736 #endif
738 static leddef_t nettel_def = {
739 0x000, 0x200, 0x000, 0x100,
742 #ifdef ENTERASYS
743 static ledmap_t enterasys_std = {
744 0x3ff, 0x200, 0x100, 0x040, 0x040, 0x002, 0x002, 0x008, 0x004, 0x020,
745 0x010, 0x000, 0x000, 0x000, 0x000, 0x024, 0x018, 0x001, 0x00c, 0x030,
746 0x000, 0x000, 0x080, 0x000, 0x000, 0x000, 0x000, 0x100, 0x200, 0x000,
747 0x000, 0x000, 0x000, 0x000
750 static leddef_t enterasys_def = {
751 0x000, 0x200, 0x000, 0x100,
753 #endif
755 static void
756 nettel_set(unsigned long bits)
758 unsigned long flags;
760 save_flags(flags); cli();
761 * (volatile char *) NETtel_LEDADDR = (~bits & 0xff);
762 mcf_setppleds(0x60, ~(bits >> 3) & 0x60);
763 restore_flags(flags);
766 /****************************************************************************/
767 #endif /* defined(CONFIG_NETtel) && defined(CONFIG_M5307) */
768 /****************************************************************************/
769 #if defined(CONFIG_NETtel) && defined(CONFIG_M5272)
770 /****************************************************************************/
773 * For the SecureEdge Firewall (5272), 5 operational LED's.
775 * LED - POWER HEARTBEAT TX RX VPN
776 * HEX - 001 002 004 008 010
779 #include <asm/coldfire.h>
780 #include <asm/mcfsim.h>
781 #include <asm/nettel.h>
783 static ledmap_t nt5272_std = {
784 0x01f, 0x001, 0x002, 0x008, 0x004, 0x008, 0x004, 0x000, 0x000, 0x008,
785 0x004, 0x000, 0x000, 0x000, 0x000, 0x014, 0x008, 0x010, 0x01c, 0x010,
786 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
787 0x000, 0x000, 0x000, 0x000
790 static leddef_t nt5272_def = {
791 0x000, 0x001, 0x000, 0x002,
794 static void nt5272_set(unsigned long bits)
796 *((volatile unsigned short *) (MCF_MBAR + MCFSIM_PADAT)) = (~bits & 0x1f);
799 /****************************************************************************/
800 #endif /* defined(CONFIG_NETtel) && defined(CONFIG_M5272) */
801 /****************************************************************************/
802 #if defined(CONFIG_SE1100)
803 /****************************************************************************/
806 * For the SecureEdge SE1100 (5272), 3 operational LED's.
808 * LED - RUNNING INTERNAL1 INTERNAL2
809 * HEX - 001 200 002
812 #include <asm/coldfire.h>
813 #include <asm/mcfsim.h>
814 #include <asm/se1100.h>
816 static ledmap_t se1100_std = {
817 0x203, 0x000, 0x001, 0x200, 0x200, 0x200, 0x200, 0x000, 0x000, 0x000,
818 0x000, 0x002, 0x002, 0x002, 0x002, 0x200, 0x002, 0x000, 0x202, 0x000,
819 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
820 0x000, 0x000, 0x000, 0x000
823 static leddef_t se1100_def = {
824 0x000, 0x000, 0x000, 0x001
827 static void se1100_set(unsigned long bits)
829 mcf_setpa(0x203, bits & 0x203);
832 /****************************************************************************/
833 #endif /* defined(CONFIG_SE1100) */
834 /****************************************************************************/
835 #if defined(CONFIG_GILBARCONAP) && defined(CONFIG_M5272)
836 /****************************************************************************/
839 * For the Gilbarco/NAP (5272), 2 operational LED's.
841 * LED - RUNNING DIAG
842 * HEX - 001 002
845 #include <asm/coldfire.h>
846 #include <asm/mcfsim.h>
847 #include <asm/nap.h>
849 static ledmap_t nap5272_std = {
850 0x003, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
851 0x000, 0x000, 0x000, 0x000, 0x000, 0x002, 0x001, 0x000, 0x000, 0x000,
852 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
853 0x000, 0x000, 0x000, 0x000
856 static leddef_t nap5272_def = {
857 0x000, 0x001, 0x000, 0x002,
860 static void nap5272_set(unsigned long bits)
862 mcf_setpa(0x3, ~bits & 0x3);
865 /****************************************************************************/
866 #endif /* defined(CONFIG_SE1100) */
867 /****************************************************************************/
868 #if defined(CONFIG_AVNET5282)
869 /****************************************************************************/
871 #include <asm/coldfire.h>
872 #include <asm/mcfsim.h>
874 #define GPTASYSCR1 (*(volatile unsigned char *)0x401a0006)
875 #define GPTBSYSCR1 (*(volatile unsigned char *)0x401b0006)
876 #define GPTADR (*(volatile unsigned char *)0x401a001d)
877 #define GPTBDR (*(volatile unsigned char *)0x401b001d)
878 #define GPTADDR (*(volatile unsigned char *)0x401a001e)
879 #define GPTBDDR (*(volatile unsigned char *)0x401b001e)
880 #define PORT_TC (*(volatile unsigned char *)0x4010000f)
881 #define PORT_TD (*(volatile unsigned char *)0x40100010)
882 #define DDR_TC (*(volatile unsigned char *)0x40100023)
883 #define DDR_TD (*(volatile unsigned char *)0x40100024)
884 #define DR_TC (*(volatile unsigned char *)0x40100037)
885 #define DR_TD (*(volatile unsigned char *)0x40100038)
888 static ledmap_t ads5282_std = {
889 0x003, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
890 0x000, 0x000, 0x000, 0x000, 0x000, 0x002, 0x001, 0x000, 0x000, 0x000,
891 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
892 0x000, 0x000, 0x000, 0x000
895 static leddef_t ads5282_def = {
896 0x000, 0x001, 0x000, 0x002,
899 static void ads5282_set(unsigned long bits)
901 static int first_call = 1;
903 if (first_call) {
904 GPTASYSCR1 = 0x00;
905 GPTBSYSCR1 = 0x00;
906 GPTADDR = 0x00;
907 GPTBDDR = 0x0f;
908 DDR_TC = 0x05;
909 DDR_TD = 0x05;
910 first_call = 0;
913 if (bits & 0x01) PORT_TC &= ~0x01; else PORT_TC |= 0x01;
914 if (bits & 0x02) PORT_TC &= ~0x04; else PORT_TC |= 0x04;
915 if (bits & 0x04) PORT_TD &= ~0x01; else PORT_TD |= 0x01;
916 if (bits & 0x08) PORT_TD &= ~0x04; else PORT_TD |= 0x04;
917 if (bits & 0x10) GPTBDR &= ~0x01; else GPTBDR |= 0x01;
918 if (bits & 0x20) GPTBDR &= ~0x02; else GPTBDR |= 0x02;
919 if (bits & 0x40) GPTBDR &= ~0x04; else GPTBDR |= 0x04;
920 if (bits & 0x80) GPTBDR &= ~0x08; else GPTBDR |= 0x08;
923 /****************************************************************************/
924 #endif /* defined(CONFIG_AVNET5282) */
925 /****************************************************************************/
926 #if defined(CONFIG_SH_SECUREEDGE5410)
927 /****************************************************************************/
930 * For the SecureEdge5410 7 (or 8 for eth2/DMZ port) operational LED's.
932 * LED - POWR HBEAT LAN1 LAN2 | LAN3 | COM ONLINE VPN
933 * POS - D2 D3 D4 D5 | ?? | D6 D7 D8 DTR
934 * HEX - 01 02 04 08 |0x2000| 10 20 40 80
937 #include <asm/io.h>
938 #if defined(CONFIG_LEDMAP_TAMS_SOHO)
940 * LED - POWR HBEAT LAN1 LAN2 COM ONLINE VPN
941 * POS - D2 D3 D4 D5 ?? D6 D7 DTR
942 * HEX - 01 02 04 08 0x2000 10 20 80
944 static ledmap_t se5410_std = {
945 0x203f,0x0001,0x0002,0x2000,0x2000,0x2000,0x2000,0x0004,0x0004,0x0008,
946 0x0008,0x0000,0x0000,0x0000,0x0000,0x2024,0x0018,0x0020,0x203c,0x0000,
947 0x0000,0x0000,0x0010,0x0000,0x0000,0x0000,0x0000,0x0001,0x0002,0x0000,
948 0x0000,0x0000,0x0000,0x0000
950 #else
951 static ledmap_t se5410_std = {
952 0x207f,0x0001,0x0002,0x0010,0x0010,0x0010,0x0010,0x0004,0x0004,0x0008,
953 0x0008,0x0000,0x0000,0x0000,0x0000,0x2054,0x0028,0x0040,0x207c,0x0000,
954 0x0000,0x0000,0x0020,0x0000,0x0000,0x0000,0x0000,0x0001,0x0002,0x2000,
955 0x2000,0x0000,0x0000,0x0000
957 #endif
959 static leddef_t se5410_def = {
960 0x0000, 0x0001, 0x0000, 0x0002,
963 static void se5410_set(unsigned long bits)
965 unsigned long flags;
967 save_and_cli(flags);
968 SECUREEDGE_WRITE_IOPORT(~bits, 0x207f);
969 restore_flags(flags);
972 /****************************************************************************/
973 #endif /* defined(CONFIG_GILBARCONAP) && defined(CONFIG_M5272) */
974 /****************************************************************************/
975 #if defined(CONFIG_NETtel) && defined(CONFIG_M5206e)
976 /****************************************************************************/
978 * For the WebWhale/NETtel1500, 3 LED's (was 2)
980 * LED - HEARTBEAT DCD DATA
981 * HEX - 001 002 004
984 #include <asm/coldfire.h>
985 #include <asm/mcfsim.h>
986 #include <asm/nettel.h>
988 static ledmap_t nt1500_std = {
989 0x007, 0x000, 0x001, 0x004, 0x004, 0x004, 0x004, 0x000, 0x000, 0x000,
990 0x000, 0x000, 0x000, 0x000, 0x000, 0x004, 0x002, 0x000, 0x007, 0x000,
991 0x002, 0x002, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
992 0x000, 0x000, 0x000, 0x000
995 static leddef_t nt1500_def = {
996 0x000, 0x000, 0x000, 0x001,
999 static void
1000 nt1500_set(unsigned long bits)
1002 * (volatile char *) NETtel_LEDADDR = (~bits & 0x7);
1005 /****************************************************************************/
1006 #endif /* defined(CONFIG_NETtel) && defined(CONFIG_M5206e) */
1007 /****************************************************************************/
1008 #ifdef CONFIG_eLIA
1009 /****************************************************************************/
1011 * For the eLIA, only 2 LED's.
1013 * LED - HEARTBEAT USER
1014 * HEX - 2 1
1017 #ifdef CONFIG_COLDFIRE
1018 #include <asm/coldfire.h>
1019 #include <asm/mcfsim.h>
1020 #endif
1021 #include <asm/elia.h>
1023 static ledmap_t elia_std = {
1024 0x003, 0x000, 0x002, 0x001, 0x001, 0x001, 0x001, 0x000, 0x000, 0x000,
1025 0x000, 0x000, 0x000, 0x000, 0x000, 0x002, 0x001, 0x000, 0x000, 0x000,
1026 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
1027 0x000, 0x000, 0x000, 0x000
1030 static leddef_t elia_def = {
1031 0x000, 0x000, 0x000, 0x002,
1034 static void
1035 elia_set(unsigned long bits)
1037 unsigned long flags;
1039 save_flags(flags); cli();
1040 mcf_setppleds(0x3000, ~(bits << 12) & 0x3000);
1041 restore_flags(flags);
1044 /****************************************************************************/
1045 #endif /* CONFIG_eLIA */
1046 /****************************************************************************/
1047 /****************************************************************************/
1048 #if defined(CONFIG_AMDSC520)
1049 /****************************************************************************/
1051 #include <linux/smp_lock.h>
1052 #include <linux/sched.h>
1053 #include <linux/reboot.h>
1054 #include <linux/delay.h>
1055 #include <asm/io.h>
1057 #if defined(CONFIG_CHINOOK)
1059 * Here is the definition of the LED's on the 6wind Chinook circuit board
1060 * as per the LED order from left to right. These probably don't
1061 * correspond to any known enclosure.
1063 * LED - D1 D2 D3 D4 D5 D6 D7 D8 D9 D10
1064 * HEX - 0001 0400 0008 0010 0800 0020 0040 0080 0100 0200
1066 * Sync LEDs - Activity Link
1067 * HEX - 04000000 08000000
1069 static ledmap_t nettel_std = {
1070 0x0c000ff9, 0x00000001, 0x00000400, 0x00000040, 0x00000040,
1071 0x04000000, 0x04000000, 0x00000010, 0x00000008, 0x00000020,
1072 0x00000800, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1073 0x00000028, 0x00000810, 0x00000200, 0x00000bf8, 0x00000820,
1074 0x00000000, 0x08000000, 0x00000100, 0x00000000, 0x00000000,
1075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1076 0x00000000, 0x00000000, 0x00000000, 0x00000000
1079 static leddef_t nettel_def = {
1080 0x0000, 0x0001, 0x0000, 0x0400,
1083 #elif defined(CONFIG_SNAPGEAR)
1085 * Here is the definition of the LED's on the SnapGear x86 circuit board
1086 * as per the labels next to them.
1088 * LED - D1 D2 D3 D4 D5 D6 D7 D8 D9 D10
1089 * HEX - 001 002 004 008 010 020 040 100 080 200
1091 static ledmap_t nettel_std = {
1092 0x3ff, 0x001, 0x002, 0x080, 0x080, 0x040, 0x040, 0x010, 0x010, 0x020,
1093 0x020, 0x000, 0x000, 0x000, 0x000, 0x048, 0x030, 0x200, 0x3fc, 0x004,
1094 0x000, 0x000, 0x100, 0x008, 0x004, 0x000, 0x000, 0x001, 0x002, 0x000,
1095 0x000, 0x000, 0x000, 0x000
1098 static leddef_t nettel_def = {
1099 0x0000, 0x0001, 0x0000, 0x0002,
1103 * Here is the definition of the LED's on the SnapGear x86 circuit board
1104 * as per the labels next to them. This is for the old enclosure.
1106 * LED - D1 D2 D3 D4 D5 D6 D7 D8 D9 D10
1107 * HEX - 001 002 004 008 010 020 040 100 080 200
1109 static ledmap_t nettel_old = {
1110 0x3ff, 0x002, 0x001, 0x080, 0x080, 0x040, 0x040, 0x010, 0x010, 0x020,
1111 0x020, 0x000, 0x000, 0x000, 0x000, 0x048, 0x030, 0x200, 0x3fc, 0x004,
1112 0x000, 0x000, 0x100, 0x008, 0x004, 0x000, 0x000, 0x001, 0x002, 0x000,
1113 0x000, 0x000, 0x000, 0x000
1116 static leddef_t nettel_def_old = {
1117 0x0000, 0x0002, 0x0000, 0x0001,
1120 #elif defined(CONFIG_SITECTRLER)
1122 * Here it the definition of the LED's on the SiteController circuit board
1123 * as per the labels next to them. (D9 and D10 are not software controlled)
1125 * LED - D1 D2 D3 D4 D5 D6 D7 D8
1126 * HEX - 0001 0002 0004 0008 0010 0020 0040 0080
1128 static ledmap_t nettel_std = {
1129 0x10fd,0x0001,0x1000,0x0004,0x0004,0x0008,0x0008,0x0040,0x0040,0x0080,
1130 0x0080,0x0000,0x0000,0x0000,0x0000,0x00cc,0x0030,0x0000,0x0000,0x0000,
1131 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1000,
1132 0x0000,0x0000,0x0000,0x0000
1135 static leddef_t nettel_def = {
1136 0x0000, 0x0001, 0x0000, 0x1000,
1139 #elif defined(CONFIG_ADTRAN_ADVANTA)
1141 * Here is the definition of the LED's on the Adtran Advanta3110 circuit
1142 * board as per the labels next to them.
1143 * The lower 8 bits are for IO port 0x300.
1144 * The upper 4 bits are for PIO31-28.
1146 * LED - D1 D2 D3 D4 D7 D8 D15green D15red D16green D16red
1147 * HEX - 01 02 04 08 40 80 10000000 40000000 20000000 80000000
1149 static ledmap_t nettel_std = {
1150 0xf00000cf, 0x00000000, 0x20000000, 0x00000000, 0x00000000,
1151 0x00000000, 0x00000000, 0x00000002, 0x00000001, 0x00000008,
1152 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1153 0x00000009, 0x00000006, 0x10000000, 0x100000cf, 0x0000000c,
1154 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1155 0x00000080, 0x00000040, 0x00000001, 0x00000002, 0x00000000,
1156 0x00000000, 0x00000000, 0x00000000, 0x00000000
1159 static leddef_t nettel_def = {
1160 0, 0, 0, 0x20000000,
1163 #else
1165 * Here is the definition of the LED's on the x86 NETtel circuit board
1166 * as per the labels next to them.
1168 * LED - D1 D2 D3 D4 D5 D6 D7 D8 D9 D10
1169 * HEX - 001 002 004 008 010 020 040 100 080 200
1171 static ledmap_t nettel_std = {
1172 0x3ff, 0x002, 0x001, 0x100, 0x100, 0x080, 0x080, 0x010, 0x008, 0x040,
1173 0x020, 0x000, 0x000, 0x000, 0x000, 0x048, 0x030, 0x200, 0x3fc, 0x004,
1174 0x000, 0x000, 0x004, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
1175 0x000, 0x000, 0x000, 0x000
1178 static leddef_t nettel_def = {
1179 0x0000, 0x0002, 0x0000, 0x0001,
1182 #endif
1184 static volatile unsigned long *ledman_ledp;
1186 static void nettel_set(unsigned long bits)
1188 #ifdef CONFIG_ADTRAN_ADVANTA
1189 outb(~bits, 0x300);
1190 *ledman_ledp = (*ledman_ledp & 0x0fffffff) | (~bits & 0xf0000000);
1191 #else
1192 *ledman_ledp = (*ledman_ledp & ~ nettel_std[LEDMAN_ALL])
1193 | (~bits & nettel_std[LEDMAN_ALL]);
1194 #endif
1197 static irqreturn_t ledman_interrupt(int irq, void *dev_id)
1199 ledman_signalreset();
1200 return IRQ_HANDLED;
1203 static void ledman_initarch(void)
1205 volatile unsigned char *mmcrp;
1207 /* Map the CPU MMCR register for access */
1208 mmcrp = (volatile unsigned char *) ioremap(0xfffef000, 4096);
1210 #ifdef CONFIG_ADTRAN_ADVANTA
1211 /* Enable the PIO for the PWR and VPN LEDs */
1212 *(volatile unsigned short *)(mmcrp + 0xc22) &= 0x0fff;
1213 *(volatile unsigned short *)(mmcrp + 0xc2c) |= 0xf000;
1215 /* Enable GPIRQ2, low-to-high transitions, map to IRQ12 */
1216 *(volatile unsigned short *)(mmcrp + 0xc22) |= 0x0020;
1217 *(volatile unsigned long *)(mmcrp + 0xd10) |= 0x0004;
1218 *(mmcrp + 0xd52) = 0x07;
1219 #endif
1221 ledman_ledp = (volatile unsigned long *) (mmcrp + 0xc30);
1223 /* Setup extern "factory default" switch on IRQ12 */
1224 if (request_irq(12, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
1225 printk("LED: failed to register IRQ12 for ERASE witch\n");
1226 else
1227 printk("LED: registered ERASE switch on IRQ12\n");
1230 /****************************************************************************/
1231 #endif /* CONFIG_AMDSC520 */
1232 /****************************************************************************/
1233 /****************************************************************************/
1234 #if defined(CONFIG_GEODE)
1235 /****************************************************************************/
1237 #include <asm/io.h>
1240 * Construct a mapping from virtual LED to gpio bit and bank.
1242 struct gpiomap {
1243 unsigned int bank;
1244 unsigned long bit;
1247 #if defined(CONFIG_REEFEDGE) || defined(CONFIG_SE5000)
1249 * Definition of the LED's on the GEODE SC1100 ReefEdfe circuit board,
1250 * as per the labels next to them.
1252 * LED - D20 D19 D18 D16
1253 * GPIO BIT - 38 18 40 37
1254 * VIRTNUM - 0x8 0x4 0x2 0x1
1256 #define GPIO0_OFF 0x00040000
1257 #define GPIO1_OFF 0x00000160
1259 static ledmap_t nettel_std = {
1260 0x00f, 0x001, 0x002, 0x000, 0x000, 0x000, 0x000, 0x004,
1261 0x004, 0x008, 0x008, 0x000, 0x000, 0x000, 0x000, 0x004,
1262 0x008, 0x000, 0x00e, 0x000, 0x000, 0x000, 0x000, 0x000,
1263 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1264 0x000, 0x000
1267 static struct gpiomap iomap[] = {
1268 /* VIRT 0x1 */ { 1, 0x00000020 },
1269 /* VIRT 0x2 */ { 1, 0x00000100 },
1270 /* VIRT 0x4 */ { 0, 0x00040000 },
1271 /* VIRT 0x8 */ { 1, 0x00000040 },
1274 #elif defined(CONFIG_SE2910)
1276 * Definition of the LED's on the SnapGear SE2910 boards.
1278 * LED - D2 D4 D6 D11 D13 D18 D20 D22 D25 D28
1279 * GPIO BIT - 2 3 17 0 36 47 39 40 18 38
1280 * VIRTNUM - 0x1 0x2 0x4 0x8 0x10 0x20 0x40 0x80 0x100 0x200
1282 #define GPIO0_OFF 0x0006000d
1283 #define GPIO1_OFF 0x000081d0
1285 static ledmap_t nettel_std = {
1286 0x3ff, 0x001, 0x002, 0x080, 0x080, 0x080, 0x080, 0x010,
1287 0x008, 0x040, 0x020, 0x200, 0x200, 0x200, 0x200, 0x30c,
1288 0x0f0, 0x000, 0x3fc, 0x004, 0x000, 0x000, 0x004, 0x000,
1289 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1290 0x000, 0x000
1293 static struct gpiomap iomap[] = {
1294 /* VIRT 0x1 */ { 0, (1 << (02 - 00)) },
1295 /* VIRT 0x2 */ { 0, (1 << (03 - 00)) },
1296 /* VIRT 0x4 */ { 0, (1 << (17 - 00)) },
1297 /* VIRT 0x8 */ { 0, (1 << (00 - 00)) },
1298 /* VIRT 0x10 */ { 1, (1 << (36 - 32)) },
1299 /* VIRT 0x20 */ { 1, (1 << (47 - 32)) },
1300 /* VIRT 0x40 */ { 1, (1 << (39 - 32)) },
1301 /* VIRT 0x80 */ { 1, (1 << (40 - 32)) },
1302 /* VIRT 0x100 */ { 0, (1 << (18 - 00)) },
1303 /* VIRT 0x200 */ { 1, (1 << (38 - 32)) },
1306 #else
1308 * Definition of the LED's on the SnapGear GEODE board.
1310 * LED - D11 D12 D13 D14 D15 D16 D17 D18 D19 D20
1311 * GPIO BIT - 32 33 34 35 36 37 39 40 18 38
1312 * VIRTNUM - 0x1 0x2 0x4 0x8 0x10 0x20 0x40 0x80 0x100 0x200
1314 #define GPIO0_OFF 0x00040000
1315 #define GPIO1_OFF 0x000001ff
1317 static ledmap_t nettel_std = {
1318 0x3ff, 0x001, 0x002, 0x080, 0x080, 0x080, 0x080, 0x010,
1319 0x008, 0x040, 0x020, 0x200, 0x200, 0x200, 0x200, 0x30c,
1320 0x0f0, 0x000, 0x3fc, 0x004, 0x000, 0x000, 0x004, 0x000,
1321 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1322 0x000, 0x000
1325 static struct gpiomap iomap[] = {
1326 /* VIRT 0x1 */ { 1, 0x00000001 },
1327 /* VIRT 0x2 */ { 1, 0x00000002 },
1328 /* VIRT 0x4 */ { 1, 0x00000004 },
1329 /* VIRT 0x8 */ { 1, 0x00000008 },
1330 /* VIRT 0x10 */ { 1, 0x00000010 },
1331 /* VIRT 0x20 */ { 1, 0x00000020 },
1332 /* VIRT 0x40 */ { 1, 0x00000080 },
1333 /* VIRT 0x80 */ { 1, 0x00000100 },
1334 /* VIRT 0x100 */ { 0, 0x00040000 },
1335 /* VIRT 0x200 */ { 1, 0x00000040 },
1338 #endif /* !CONFIG_REEFEDGE && !CONFIG_SE5000 */
1340 #define GPIO_SIZE (sizeof(iomap) / sizeof(*iomap))
1342 static leddef_t nettel_def = {
1343 0x0000, 0x0001, 0x0000, 0x0002,
1347 static void nettel_set(unsigned long bits)
1349 unsigned int gpio[2];
1350 unsigned int i, mask;
1352 gpio[0] = GPIO0_OFF;
1353 gpio[1] = GPIO1_OFF;
1355 for (i = 0, mask = 0x1; (i < GPIO_SIZE); i++, mask <<= 1) {
1356 if (bits & mask)
1357 gpio[iomap[i].bank] &= ~iomap[i].bit;
1360 outl(gpio[0], 0x6400);
1361 outl(gpio[1], 0x6410);
1364 static int ledman_button;
1365 static struct timer_list ledman_timer;
1367 static void ledman_buttonpoll(unsigned long arg)
1369 if (inl(0x6404) & 0x0002) {
1370 if (ledman_button == 0) {
1371 printk("LEDMAN: reset button pushed!\n");
1372 ledman_signalreset();
1374 ledman_button = 1;
1375 } else {
1376 ledman_button = 0;
1379 /* Re-arm timer interrupt. */
1380 mod_timer(&ledman_timer, jiffies + HZ/25);
1383 static void ledman_initarch(void)
1385 init_timer(&ledman_timer);
1386 ledman_timer.function = ledman_buttonpoll;
1387 ledman_timer.data = 0;
1388 mod_timer(&ledman_timer, jiffies + HZ/25);
1391 /****************************************************************************/
1392 #endif /* CONFIG_GEODE */
1393 /****************************************************************************/
1394 /****************************************************************************/
1395 #if defined(CONFIG_SH_KEYWEST) || defined(CONFIG_SH_BIGSUR)
1396 /****************************************************************************/
1398 * Here it the definition of the how we use the 8 segment LED display on
1399 * the Hitachi Keywest
1401 * LED - LD0 LD1 LD2 LD3 LD4 LD5 LD6 LD7
1402 * HEX - 001 002 004 008 010 020 040 080
1403 * HB CNT L1R L1T L2R L2T COM VPN
1407 #include <linux/kernel_stat.h>
1409 #define KEYWEST_NUM_LEDS 8
1411 #if defined(CONFIG_SH_BIGSUR)
1412 #define LED_BASE 0xb1fffe00
1413 #define LED_ADDR(x) (LED_BASE+((x)<<2))
1414 #else
1415 #define LED_BASE 0xb1ffe000
1416 #define LED_ADDR(x) (LED_BASE+(x))
1417 #endif
1419 static ledmap_t keywest_std = {
1420 0x0ff, 0x000, 0x001, 0x040, 0x040, 0x040, 0x040, 0x004, 0x008, 0x010,
1421 0x020, 0x000, 0x000, 0x000, 0x000, 0x054, 0x02a, 0x080, 0x07e, 0x000,
1422 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x001, 0x002, 0x000,
1423 0x000, 0x000, 0x000, 0x000
1426 static leddef_t keywest_def = {
1427 0x000, 0x000, 0x000, 0x001,
1430 static struct keywest_led_value {
1431 int count;
1432 int max;
1433 int prev;
1434 unsigned char disp;
1435 } keywest_led_values[KEYWEST_NUM_LEDS][2];
1438 struct keywest_font_s {
1439 unsigned char row[7];
1440 } keywest_font[] = {
1441 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}, /* bar 0 */
1442 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f }}, /* bar 1 */
1443 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f }}, /* bar 2 */
1444 {{ 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f }}, /* bar 3 */
1445 {{ 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f }}, /* bar 4 */
1446 {{ 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f }}, /* bar 5 */
1447 {{ 0x00, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f }}, /* bar 6 */
1448 {{ 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f }}, /* bar 7 */
1449 {{ 0x00, 0x0a, 0x1f, 0x1f, 0x0e, 0x04, 0x00 }}, /* heart */
1450 {{ 0x08, 0x14, 0x14, 0x1c, 0x1c, 0x1c, 0x1c }}, /* vpn locked */
1451 {{ 0x02, 0x05, 0x05, 0x1c, 0x1c, 0x1c, 0x1c }}, /* vpn unlocked */
1454 static unsigned int keywest_old_cntx = 0;
1457 * program up some display bars
1460 static void ledman_initkeywest()
1462 int i, j;
1464 for (i = 0; i < sizeof(keywest_font) / sizeof(struct keywest_font_s); i++) {
1465 * (unsigned char *)(LED_ADDR(0x20)) = i;
1466 for (j = 0; j < 7; j++)
1467 * (unsigned char *)(LED_ADDR(0x28+j)) = keywest_font[i].row[j];
1469 keywest_old_cntx = kstat.context_swtch;
1473 * We just rip through and write all LED 'disp' chars each tick.
1476 static void keywest_set(unsigned long bits)
1478 int i, alt;
1479 for (i = 0; i < KEYWEST_NUM_LEDS; i++) {
1480 alt = (leds_alt & (1 << i)) ? 1 : 0;
1481 * (unsigned char *)(LED_ADDR(0x38+i)) = keywest_led_values[i][alt].disp;
1485 static int
1486 keywest_bits(unsigned long cmd, unsigned long bits)
1488 ledmode_t *lmp = &led_mode[current_mode];
1489 int alt, i;
1490 unsigned long new_alt;
1492 alt = (cmd & LEDMAN_CMD_ALTBIT) ? 1 : 0;
1494 switch (cmd & ~LEDMAN_CMD_ALTBIT) {
1495 case LEDMAN_CMD_SET:
1496 bits &= ~(leds_flash[alt]|leds_on[alt]|leds_off[alt]);
1497 for (i = 0; i < KEYWEST_NUM_LEDS; i++)
1498 if (bits & (1 << i))
1499 keywest_led_values[i][alt].count++;
1500 break;
1501 case LEDMAN_CMD_ON:
1502 leds_on[alt] |= bits;
1503 leds_off[alt] &= ~bits;
1504 leds_flash[alt] &= ~bits;
1505 (*lmp->tick)();
1506 break;
1507 case LEDMAN_CMD_OFF:
1508 leds_on[alt] &= ~bits;
1509 leds_off[alt] |= bits;
1510 leds_flash[alt] &= ~bits;
1511 (*lmp->tick)();
1512 break;
1513 case LEDMAN_CMD_FLASH:
1514 leds_on[alt] &= ~bits;
1515 leds_off[alt] &= ~bits;
1516 leds_flash[alt] |= bits;
1517 break;
1518 case LEDMAN_CMD_RESET:
1519 leds_on[alt] = (leds_on[alt] &~bits) | (bits&lmp->def[LEDS_ON]);
1520 leds_off[alt] = (leds_off[alt] &~bits) | (bits&lmp->def[LEDS_OFF]);
1521 leds_flash[alt] = (leds_flash[alt]&~bits) | (bits&lmp->def[LEDS_FLASH]);
1522 memset(keywest_led_values, 0, sizeof(keywest_led_values));
1523 break;
1524 case LEDMAN_CMD_ALT_ON:
1525 new_alt = (bits & ~leds_alt);
1526 leds_alt |= bits;
1528 * put any newly alt'd bits into a default state
1530 (*lmp->bits)(LEDMAN_CMD_RESET | LEDMAN_CMD_ALTBIT, new_alt);
1531 for (i = 0; i < 32; i++)
1532 if (bits & (1 << i))
1533 leds_alt_cnt[i]++;
1534 break;
1535 case LEDMAN_CMD_ALT_OFF:
1536 for (i = 0; i < 32; i++)
1537 if ((bits & (1 << i)) && leds_alt_cnt[i]) {
1538 leds_alt_cnt[i]--;
1539 if (leds_alt_cnt[i] == 0)
1540 leds_alt &= ~(1 << i);
1542 break;
1543 default:
1544 return(-EINVAL);
1546 return(0);
1549 static void
1550 keywest_tick(void)
1552 ledmode_t *lmp = &led_mode[current_mode];
1553 int alt, i;
1554 static int flash_on = 0;
1555 struct keywest_led_value *led_value;
1558 * we take over the second LED as a context switch indicator
1560 keywest_led_values[1][0].count = kstat.context_swtch - keywest_old_cntx;
1561 keywest_old_cntx = kstat.context_swtch;
1563 for (i = 0; i < KEYWEST_NUM_LEDS; i++) {
1564 alt = (leds_alt >> i) & 1;
1565 led_value = &keywest_led_values[i][alt];
1566 if (leds_off[alt] & (1 << i)) {
1567 if ((1 << i) == 0x080) /* VPN unlock */
1568 led_value->disp = 0x8a;
1569 else
1570 led_value->disp = 0x20;
1571 } else if (leds_on[alt] & (1 << i)) {
1572 if ((1 << i) == 0x080) /* VPN lock */
1573 led_value->disp = 0x89;
1574 else
1575 led_value->disp = 0x87;
1576 } else if (leds_flash[alt] & (1 << i)) {
1577 if ((flash_on % 6) >= 3) {
1578 if ((1 << i) == 0x001) /* heart beat */
1579 led_value->disp = 0x88;
1580 else
1581 led_value->disp = 0x87;
1582 } else
1583 led_value->disp = 0x20;
1584 } else {
1585 int val;
1587 if (led_value->count > led_value->max)
1588 led_value->max = led_value->count;
1590 val = (led_value->prev + led_value->count) / 2;
1591 led_value->prev = val;
1593 val = (val * 7) / led_value->max;
1594 if (val == 0 && led_value->count)
1595 val = 1;
1596 led_value->disp = 0x80 + (val & 0x7);
1597 led_value->count = 0;
1598 /* degrade the maximum over time (except load) */
1599 if (i != 1)
1600 led_value->max = (led_value->max * 9)/10;
1603 flash_on++;
1604 (*lmp->set)(0);
1607 /****************************************************************************/
1608 #endif /* CONFIG_SH_KEYWEST */
1609 /****************************************************************************/
1610 /****************************************************************************/
1611 #if defined(CONFIG_MACH_MONTEJADE) || defined(CONFIG_MACH_IXDPG425) || \
1612 defined(CONFIG_MACH_SE5100)
1613 /****************************************************************************/
1615 #include <linux/interrupt.h>
1616 #include <asm/hardware.h>
1617 #include <asm/io.h>
1620 * Here is the definition of the LED's on the Intel/MonteJade platform.
1621 * LED D7 is not visible on the front panel, so not much point using it...
1623 * LED - D1 D2 D3 D4 D16 D17 D18 D23
1624 * HEX - 80 40 20 10 08 04 02 01
1626 static ledmap_t montejade_std = {
1627 0xff, 0x00, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
1628 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x10, 0x20, 0xfc, 0x10,
1629 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1630 0x00, 0x00, 0x00, 0x00
1633 static leddef_t montejade_def = {
1634 0x0000, 0x0000, 0x0000, 0x0001,
1638 static volatile unsigned char *ledman_cs2;
1640 static void ledman_interrupt(int irq, void *dev_id)
1642 ledman_signalreset();
1645 static void montejade_set(unsigned long bits)
1647 *ledman_cs2 = ~bits;
1650 static struct timer_list montejade_wdt;
1652 static void montejade_wdtpoll(unsigned long arg)
1654 *IXP4XX_GPIO_GPOUTR ^= 0x400;
1656 /* Re-arm timer interrupt. */
1657 mod_timer(&montejade_wdt, jiffies + HZ/10);
1660 static void montejade_wdtinit(void)
1662 /* Configure GPIO10 as an output to kick watchdog */
1663 gpio_line_config(10, IXP4XX_GPIO_OUT);
1665 /* Setup timer poll, 10 times a second should be good enough */
1666 init_timer(&montejade_wdt);
1667 montejade_wdt.function = montejade_wdtpoll;
1668 montejade_wdt.data = 0;
1669 mod_timer(&montejade_wdt, jiffies + HZ/10);
1672 static void ledman_initarch(void)
1674 /* Configure CS2 for operation, 8bit and writable will do */
1675 *IXP4XX_EXP_CS2 = 0xbfff0003;
1677 /* Map the LED chip select address space */
1678 ledman_cs2 = (volatile unsigned char *) ioremap(IXP4XX_EXP_BUS_CS2_BASE_PHYS, 512);
1679 *ledman_cs2 = 0xffffffff;
1681 /* Configure GPIO9 as interrupt input (ERASE switch) */
1682 gpio_line_config(9, (IXP4XX_GPIO_IN | IXP4XX_GPIO_FALLING_EDGE));
1684 if (request_irq(26, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
1685 printk("LED: failed to register IRQ26 for ERASE witch\n");
1686 else
1687 printk("LED: registered ERASE switch on IRQ26\n");
1689 montejade_wdtinit();
1692 /****************************************************************************/
1693 #endif /* CONFIG_MACH_MONTEJADE || CONFIG_MACH_IXDPG425 || CONFIG_MACH_SE5100 */
1694 /****************************************************************************/
1695 /****************************************************************************/
1696 #if defined(CONFIG_ARCH_SE4000) || defined(CONFIG_MACH_ESS710) || \
1697 defined(CONFIG_MACH_SG560) || defined(CONFIG_MACH_SG580) || \
1698 defined(CONFIG_MACH_SG565) || defined(CONFIG_MACH_SG640) || \
1699 defined(CONFIG_MACH_SG720) || defined(CONFIG_MACH_SG590) || \
1700 defined(CONFIG_MACH_SG8100)
1701 /****************************************************************************/
1703 #include <linux/interrupt.h>
1704 #include <asm/hardware.h>
1705 #include <asm/io.h>
1707 #if defined(CONFIG_MACH_ESS710) || defined(CONFIG_MACH_SG720)
1709 * Here is the definition of the LED's on the SnapGear/ESS710 circuit board
1710 * as per the labels next to them.
1712 * LED - D1 D3 D4 D5
1713 * HEX - 004 008 010 020
1714 * F/OVER H/A ONLINE H/B
1716 static ledmap_t snapgear425_std = {
1717 0x03c, 0x000, 0x020, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1718 0x000, 0x000, 0x000, 0x000, 0x000, 0x024, 0x018, 0x000, 0x03c, 0x000,
1719 0x000, 0x000, 0x010, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1720 0x000, 0x000, 0x000, 0x004, 0x008
1723 static leddef_t snapgear425_def = {
1724 0x0000, 0x0000, 0x0000, 0x0020,
1727 #define LEDMASK 0x3c
1729 #elif defined(CONFIG_MACH_SG640)
1731 * Here is the definition of the LED's on the SnapGear/SG640 circuit board
1732 * as per the labels next to them.
1736 #define LED_D1_UPPER 0x08
1737 #define LED_D1_LOWER 0x10
1738 #define LED_D2_UPPER 0x20
1739 #define LED_D2_LOWER 0x04
1740 #define LEDMASK 0x3c
1742 static ledmap_t snapgear425_std = {
1743 [LEDMAN_ALL] = LEDMASK,
1744 [LEDMAN_POWER] = LED_D1_LOWER,
1745 [LEDMAN_HEARTBEAT] = LED_D1_UPPER,
1746 [LEDMAN_VPN] = LED_D2_LOWER,
1747 [LEDMAN_ONLINE] = LED_D2_UPPER,
1748 [LEDMAN_NVRAM_1] = LED_D1_LOWER | LED_D2_UPPER,
1749 [LEDMAN_NVRAM_2] = LED_D2_LOWER | LED_D1_UPPER,
1750 [LEDMAN_LAN1_DHCP] = LED_D2_LOWER | LED_D2_UPPER,
1751 [LEDMAN_LAN2_DHCP] = LED_D2_LOWER | LED_D2_UPPER,
1754 static leddef_t snapgear425_def = {
1755 [LEDS_ON] = LED_D1_LOWER,
1756 [LEDS_FLASH] = LED_D1_UPPER,
1759 #elif defined(CONFIG_MACH_SG565)
1762 * Here is the definition of the LEDs on the CyberGuard/SG565,
1763 * as per the labels next to them.
1765 * LED - D2 D3 D4 D5 D6 D7 D8
1766 * HEX - 0004 0008 0010 0020 0040 0080 0400
1768 static ledmap_t snapgear425_std = {
1769 [LEDMAN_ALL] = 0x4fc,
1770 [LEDMAN_HEARTBEAT] = 0x004,
1771 [LEDMAN_COM1_RX] = 0x040,
1772 [LEDMAN_COM1_TX] = 0x040,
1773 [LEDMAN_LAN1_RX] = 0x008,
1774 [LEDMAN_LAN1_TX] = 0x008,
1775 [LEDMAN_LAN2_RX] = 0x008,
1776 [LEDMAN_LAN2_TX] = 0x008,
1777 [LEDMAN_USB1_RX] = 0x010,
1778 [LEDMAN_USB1_TX] = 0x010,
1779 [LEDMAN_USB2_RX] = 0x010,
1780 [LEDMAN_USB2_TX] = 0x010,
1781 [LEDMAN_NVRAM_1] = 0x48c,
1782 [LEDMAN_NVRAM_2] = 0x070,
1783 [LEDMAN_VPN] = 0x400,
1784 [LEDMAN_LAN1_DHCP] = 0x4fc,
1785 [LEDMAN_ONLINE] = 0x080,
1786 [LEDMAN_LAN3_RX] = 0x020,
1787 [LEDMAN_LAN3_TX] = 0x020,
1790 static leddef_t snapgear425_def = {
1791 [LEDS_FLASH] = 0x004,
1794 #define LEDMASK 0x04fc
1796 #elif defined(CONFIG_MACH_SG560) || defined(CONFIG_MACH_SG580)
1798 * Here is the definition of the LEDs on the CyberGuard/SG560
1799 * and CyberGuard/SG580, as per the labels next to them.
1801 * LED - D2 D3 D4 D5 D6 D7 D8
1802 * HEX - 0004 0008 0010 0400 0040 0020 0080
1804 static ledmap_t snapgear425_std = {
1805 0x4fc, 0x000, 0x004, 0x040, 0x040, 0x040, 0x040, 0x008, 0x008, 0x010,
1806 0x010, 0x000, 0x000, 0x000, 0x000, 0x0ac, 0x450, 0x080, 0x4fc, 0x000,
1807 0x000, 0x000, 0x020, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1808 0x000, 0x000, 0x000, 0x400
1811 static leddef_t snapgear425_def = {
1812 0x0000, 0x0000, 0x0000, 0x0004,
1815 #define LEDMASK 0x04fc
1817 #elif defined(CONFIG_MACH_SG590)
1819 * Here is the definition of the LEDs on the TAMS/TVR.
1821 #define LED_D2 0x80
1822 #define LED_D3 0x40
1823 #define LED_D4 0x20
1824 #define LED_D5 0x10
1825 #define LED_D6 0x08
1826 #define LED_D7 0x04
1827 #define LEDMASK 0xfc
1829 static ledmap_t snapgear425_std = {
1830 [LEDMAN_ALL] = LEDMASK,
1831 [LEDMAN_HEARTBEAT] = LED_D2,
1832 [LEDMAN_LAN1_RX] = LED_D3,
1833 [LEDMAN_LAN1_TX] = LED_D3,
1834 [LEDMAN_LAN2_RX] = LED_D4,
1835 [LEDMAN_LAN2_TX] = LED_D4,
1836 [LEDMAN_VPN_RX] = LED_D5,
1837 [LEDMAN_VPN_TX] = LED_D5,
1838 [LEDMAN_ONLINE] = LED_D6,
1839 [LEDMAN_VPN] = LED_D7,
1840 [LEDMAN_NVRAM_1] = LED_D4 | LED_D5,
1841 [LEDMAN_NVRAM_2] = LED_D2 | LED_D3 | LED_D6 | LED_D7,
1842 [LEDMAN_LAN1_DHCP] = LEDMASK,
1845 static leddef_t snapgear425_def = {
1846 [LEDS_FLASH] = LED_D2,
1849 #elif defined(CONFIG_MACH_SG8100)
1852 * Here is the definition of the LEDs on the SG8100
1853 * as per the labels next to them.
1855 * LED - D1 D2 D3 D4 D5 D6 D7 D8
1856 * HEX - 0004 0008 0010 0020 0040 0080 0400 0800
1858 static ledmap_t snapgear425_std = {
1859 [LEDMAN_ALL] = 0xcfc,
1860 [LEDMAN_HEARTBEAT] = 0x004,
1861 [LEDMAN_COM1_RX] = 0x040,
1862 [LEDMAN_COM1_TX] = 0x040,
1863 [LEDMAN_LAN1_RX] = 0x008,
1864 [LEDMAN_LAN1_TX] = 0x008,
1865 [LEDMAN_LAN2_RX] = 0x008,
1866 [LEDMAN_LAN2_TX] = 0x008,
1867 [LEDMAN_USB1_RX] = 0x010,
1868 [LEDMAN_USB1_TX] = 0x010,
1869 [LEDMAN_USB2_RX] = 0x010,
1870 [LEDMAN_USB2_TX] = 0x010,
1871 [LEDMAN_NVRAM_1] = 0xc0c,
1872 [LEDMAN_NVRAM_2] = 0x0f0,
1873 [LEDMAN_VPN] = 0x400,
1874 [LEDMAN_LAN1_DHCP] = 0xcfc,
1875 [LEDMAN_ONLINE] = 0x080,
1876 [LEDMAN_LAN3_RX] = 0x020,
1877 [LEDMAN_LAN3_TX] = 0x020,
1880 static leddef_t snapgear425_def = {
1881 [LEDS_FLASH] = 0x004,
1884 #define LEDMASK 0x0cfc
1886 #else
1889 * Here is the definition of the LEDs on the SnapGear/SE4000, as per the
1890 * labels next to them. LED D7 is not visible on the front panel, so not
1891 * much point using it...
1893 * LED - D1 D3 D4 D5 D6 D7
1894 * HEX - 004 008 010 020 040 080
1896 static ledmap_t snapgear425_std = {
1897 0x0fc, 0x000, 0x004, 0x008, 0x008, 0x008, 0x008, 0x000, 0x000, 0x000,
1898 0x000, 0x000, 0x000, 0x000, 0x000, 0x028, 0x010, 0x020, 0x0fc, 0x010,
1899 0x000, 0x000, 0x010, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
1900 0x000, 0x000, 0x000, 0x000
1903 static leddef_t snapgear425_def = {
1904 0x0000, 0x0000, 0x0000, 0x0004,
1907 #define LEDMASK 0xfc
1909 #endif
1911 #if defined(CONFIG_MACH_SG720) || defined(CONFIG_MACH_SG590)
1912 #define ERASEGPIO 10
1913 #define ERASEIRQ IRQ_IXP4XX_GPIO10
1914 #else
1915 #define ERASEGPIO 9
1916 #define ERASEIRQ IRQ_IXP4XX_GPIO9
1917 #endif
1920 static irqreturn_t ledman_interrupt(int irq, void *dev_id)
1922 ledman_signalreset();
1923 return IRQ_HANDLED;
1926 static void snapgear425_set(unsigned long bits)
1928 *IXP4XX_GPIO_GPOUTR = (*IXP4XX_GPIO_GPOUTR & ~LEDMASK) | (~bits & LEDMASK);
1931 static void ledman_initarch(void)
1933 /* Enable LED lines as outputs - do them all in one go */
1934 *IXP4XX_GPIO_GPOER &= ~LEDMASK;
1936 /* Configure GPIO9 as interrupt input (ERASE switch) */
1937 gpio_line_config(ERASEGPIO, IXP4XX_GPIO_IN);
1938 set_irq_type(ERASEIRQ, IRQT_FALLING);
1940 #if !defined(CONFIG_MACH_SG720) && !defined(CONFIG_MACH_SG590)
1941 /* De-assert reset for the hub/switch - just in case... */
1942 gpio_line_config(13, IXP4XX_GPIO_OUT);
1943 gpio_line_set(13, 1);
1944 #endif
1946 if (request_irq(ERASEIRQ, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
1947 printk("LED: failed to register IRQ%d for ERASE witch\n", ERASEIRQ);
1948 else
1949 printk("LED: registered ERASE switch on IRQ%d\n", ERASEIRQ);
1952 /****************************************************************************/
1953 #endif /* CONFIG_ARCH_SE4000 || CONFIG_MACH_ESS710 || CONFIG_MACH_SG560 || CONFIG_MACH_SG565 || CONFIG_MACH_SG580 || CONFIG_MACH_SG640 || CONFIG_MACH_SG720 || CONFIG_MACH_SG590 || CONFIG_MACH_SG8100 */
1954 /****************************************************************************/
1955 /****************************************************************************/
1956 #if defined(CONFIG_MACH_IVPN)
1957 /****************************************************************************/
1959 #include <linux/interrupt.h>
1960 #include <asm/hardware.h>
1961 #include <asm/io.h>
1964 * There is 2 LED banks on the iVPN. But really there is 4 LEDs, 2 green
1965 * and 2 red. They are connected to gpio lines, with the mapping:
1967 * GPIO - 12 13 2 11
1968 * LED - G0 R0 G1 R1
1970 * But...
1972 * I have virtualized the bits in the ledmap, since the iVPN led
1973 * functionality is a little weird, and cannot be displayed by just
1974 * setting the bits.
1977 #define BIT_HEARTBEAT 0x1
1978 #define BIT_LANLINK 0x2
1979 #define BIT_LANACTIVITY 0x4
1980 #define BIT_WANLINK 0x8
1981 #define BIT_WANACTIVITY 0x10
1982 #define BIT_WIFLINK 0x20
1983 #define BIT_WIFACTIVITY 0x40
1984 #define BIT_VPNLINK 0x80
1985 #define BIT_VPNACTIVITY 0x100
1987 static ledmap_t ivpn_std = {
1988 0x1ff, 0x000, 0x001, 0x000, 0x000, 0x000, 0x000, 0x004, 0x004, 0x010,
1989 0x010, 0x000, 0x000, 0x000, 0x000, 0x00a, 0x088, 0x080, 0x000, 0x000,
1990 0x000, 0x000, 0x000, 0x002, 0x008, 0x100, 0x100, 0x000, 0x000, 0x040,
1991 0x040, 0x020, 0x000, 0x000
1994 static leddef_t ivpn_def = {
1995 0x0000, 0x0002, 0x0000, 0x0001,
1999 static irqreturn_t ledman_interrupt(int irq, void *dev_id)
2001 ledman_signalreset();
2002 return IRQ_HANDLED;
2005 static void ivpn_set(unsigned long bits)
2007 unsigned long flags;
2008 unsigned int wanbit, val = 0;
2009 static unsigned int lancnt = 0;
2010 static unsigned int wancnt = 0;
2012 if (bits & BIT_LANLINK) {
2013 if ((bits & BIT_LANACTIVITY) || lancnt) {
2014 if (lancnt++ > 4) {
2015 val |= 0x1;
2016 if (lancnt > 8)
2017 lancnt = 0;
2019 } else {
2020 val |= 0x1;
2022 } else {
2023 val |= 0x2;
2025 if (bits & (BIT_WANLINK | BIT_WIFLINK)) {
2026 wanbit = (bits & BIT_VPNLINK) ? 0x4 : 0x8;
2027 if ((bits & (BIT_WANACTIVITY | BIT_WIFACTIVITY)) || wancnt) {
2028 if (wancnt++ > 4) {
2029 val |= wanbit;
2030 if (wancnt > 8)
2031 wancnt = 0;
2033 } else {
2034 val |= wanbit;
2038 save_flags(flags); cli();
2039 gpio_line_set(2, val & 0x4 ? 0 : 1);
2040 gpio_line_set(11, val & 0x8 ? 0 : 1);
2041 gpio_line_set(12, val & 0x1 ? 0 : 1);
2042 gpio_line_set(13, val & 0x2 ? 0 : 1);
2043 restore_flags(flags);
2046 static void ledman_initarch(void)
2048 #if 0
2049 /* Enabled second ethernet port */
2050 gpio_line_config(3, IXP4XX_GPIO_OUT);
2051 gpio_line_set(3, 0);
2052 #endif
2053 /* Set up GPIO lines to allow access to LEDs. */
2054 gpio_line_set(2, 1);
2055 gpio_line_set(11, 1);
2056 gpio_line_set(12, 1);
2057 gpio_line_set(13, 1);
2058 gpio_line_config(2, IXP4XX_GPIO_OUT);
2059 gpio_line_config(11, IXP4XX_GPIO_OUT);
2060 gpio_line_config(12, IXP4XX_GPIO_OUT);
2061 gpio_line_config(13, IXP4XX_GPIO_OUT);
2062 ivpnss_hwsetup();
2063 ivpnss_memmap();
2065 /* Configure GPIO9 as interrupt input (ERASE switch) */
2066 gpio_line_config(9, (IXP4XX_GPIO_IN | IXP4XX_GPIO_FALLING_EDGE));
2068 if (request_irq(26, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
2069 printk("LED: failed to register IRQ26 for ERASE witch\n");
2070 else
2071 printk("LED: registered ERASE switch on IRQ26\n");
2074 /****************************************************************************/
2075 #endif /* CONFIG_MACH_IVPN */
2076 /****************************************************************************/
2077 /****************************************************************************/
2078 #if defined(CONFIG_ARCH_KS8695)
2079 /****************************************************************************/
2081 #include <linux/interrupt.h>
2082 #include <asm/hardware.h>
2083 #include <asm/io.h>
2086 * Here is the definition of the LED's on the SnapGear/LITE3 circuit board,
2087 * as per the labels next to them. There is only 2 software programmable
2088 * LEDs, so this is pretty easy :-)
2090 * LED - D1 D2
2091 * HEX - 002 004
2093 static ledmap_t lite3_std = {
2094 0x006, 0x004, 0x002, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
2095 0x000, 0x000, 0x000, 0x000, 0x000, 0x002, 0x000, 0x000, 0x000, 0x000,
2096 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
2097 0x000, 0x000, 0x000, 0x000
2100 static leddef_t lite3_def = {
2101 0x0000, 0x0004, 0x0000, 0x0002,
2104 static volatile unsigned int *ledman_gpio;
2106 static irqreturn_t ledman_interrupt(int irq, void *dev_id)
2108 volatile unsigned int *intstatp;
2110 intstatp = (volatile unsigned int __force *) (KS8695_REG(KS8695_INT_STATUS));
2111 *intstatp |= 0x4;
2113 ledman_signalreset();
2114 return IRQ_HANDLED;
2117 static void lite3_set(unsigned long bits)
2119 *ledman_gpio = (*ledman_gpio & ~0x6) | (~bits & 0x6);
2122 static void ledman_initarch(void)
2124 volatile unsigned int *gpiop, *intenp;
2126 /* Enable LED lines as outputs */
2127 gpiop = (volatile unsigned int __force *) (KS8695_REG(KS8695_GPIO_MODE));
2128 *gpiop = (*gpiop | 0x6) & ~0x1;
2130 /* Turn LEDs off */
2131 ledman_gpio = (volatile unsigned int __force *) (KS8695_REG(KS8695_GPIO_DATA));
2132 *ledman_gpio = (*ledman_gpio & ~0x6);
2134 /* Configure GPIO0 as interrupt input (ERASE switch) */
2135 gpiop = (volatile unsigned int __force *) (KS8695_REG(KS8695_GPIO_CTRL));
2136 *gpiop = (*gpiop & ~0x7) | 0xc;
2138 intenp = (volatile unsigned int __force *) (KS8695_REG(KS8695_INT_ENABLE));
2139 *intenp |= 0x4;
2141 if (request_irq(2, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
2142 printk("LED: failed to register IRQ2 for ERASE witch\n");
2143 else
2144 printk("LED: registered ERASE switch on IRQ2\n");
2147 /****************************************************************************/
2148 #endif /* CONFIG_ARCH_KS8695 */
2149 /****************************************************************************/
2150 /****************************************************************************/
2151 #if defined(CONFIG_ARCH_EP9312)
2152 /****************************************************************************/
2154 #include <linux/interrupt.h>
2155 #include <asm/hardware.h>
2156 #include <asm/io.h>
2159 * Here is the definition of the LED's on the Trusonic IPD Board
2161 * It has no visible LED's, though it has provision for deug LED's,
2162 * however, we need flatfsd support ;-)
2164 static ledmap_t ipd_std;
2165 static leddef_t ipd_def;
2167 static void ipd_set(unsigned long bits)
2171 static irqreturn_r ledman_interrupt(int irq, void *dev_id)
2173 while (inl(VIC1RAWINTR) & 0x1)
2175 ledman_signalreset();
2176 return IRQ_HANDLED;
2179 static void ledman_initarch(void)
2181 if (request_irq(32, ledman_interrupt, SA_INTERRUPT, "Erase", NULL))
2182 printk("LED: failed to register IRQ32 for ERASE witch\n");
2183 else
2184 printk("LED: registered ERASE switch on IRQ32\n");
2187 /****************************************************************************/
2188 #endif /* CONFIG_ARCH_EP9312 */
2189 /****************************************************************************/