1 /*
2 * linux/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_led.c
3 *
4 * RBTX4927 Status LED toggle
5 *
6 * Copyright (C) 2003 TimeSys Corp.
7 * S. James Hill (James.Hill@timesys.com)
8 * (sjhill@realitydiluted.com)
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
21 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
23 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
24 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30 #include <linux/init.h>
31 #include <asm/io.h>
32 #include <asm/timex.h>
33 #include <asm/tx4927/toshiba_rbtx4927.h>
34
35 static struct led_state {
36 struct timer_list timer;
37 unsigned char val123;
38 unsigned long val45;
39 } led_state;
40
led_toggle(unsigned long v)41 void led_toggle (unsigned long v)
42 {
43 struct led_state *l = (struct led_state *) v;
44
45 writeb(l->val123, RBTX4927_STATUS_LED_123);
46 writel(l->val45, RBTX4927_STATUS_LED_45);
47
48 l->val123 = ~l->val123;
49 l->val45 = ~l->val45;
50
51 l->timer.expires = jiffies + HZ;
52 add_timer(&l->timer);
53 }
54
led_setup(void)55 int __init led_setup (void)
56 {
57 led_state.val123 = 0xfd;
58 #ifdef __MIPSEB__
59 led_state.val45 = 0x5a000000;
60 #else
61 led_state.val45 = 0x0000005a;
62 #endif
63
64 led_state.timer.data = (unsigned long) &led_state;
65 led_state.timer.expires = jiffies + HZ;
66 init_timer(&led_state.timer);
67 led_state.timer.function = led_toggle;
68 add_timer(&led_state.timer);
69
70 return 0;
71 }
72
73 __initcall (led_setup);
74