import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / mach-omaha / leds.c
1 /*
2  *  linux/arch/arm/mach-omaha/leds.c
3  *
4  *  Omaha LED control routines
5  *
6  *  Copyright (C) 1999-2002 ARM Limited
7  *  Copyright (C) 2000 Deep Blue Solutions Ltd
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25
26 #include <asm/hardware.h>
27 #include <asm/io.h>
28 #include <asm/leds.h>
29 #include <asm/system.h>
30 #include <asm/mach-types.h>
31
32 static int saved_leds;
33
34 static void omaha_leds_event(led_event_t ledevt)
35 {
36         unsigned long flags;                          
37         unsigned int ctrl = IO_ADDRESS(PLAT_DBG_LEDS);
38         unsigned int leds;
39         
40         // yup, change the LEDs
41         local_irq_save(flags);
42
43         switch(ledevt) {
44         case led_idle_start:
45                 leds = __raw_readl(ctrl);
46                 leds |= GREEN_LED;
47                 __raw_writel(leds,ctrl);
48                 break;
49
50         case led_idle_end:
51                 leds = __raw_readl(ctrl);
52                 leds &= ~GREEN_LED;
53                 __raw_writel(leds,ctrl);
54                 break;
55
56         case led_timer:
57                 leds = __raw_readl(ctrl);
58                 leds ^= YELLOW_LED;
59                 __raw_writel(leds,ctrl);
60                 break;
61
62         case led_red_on:
63                 leds = __raw_readl(ctrl);
64                 leds |= RED_LED;
65                 __raw_writel(leds,ctrl);
66                 break;
67
68         case led_red_off:
69                 leds = __raw_readl(ctrl);
70                 leds &= ~RED_LED;
71                 __raw_writel(leds,ctrl);
72                 break;
73
74         default:
75                 break;
76         }
77
78         local_irq_restore(flags);
79 }
80
81 static int __init leds_init(void)
82 {
83         if (machine_is_omaha())
84                 leds_event = omaha_leds_event;
85
86         return 0;
87 }
88
89 __initcall(leds_init);