2 * LED driver for Atmel AT91-based boards.
4 * Copyright (C) SAN People (Pty) Ltd
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
16 #include <asm/mach-types.h>
17 #include <asm/arch/board.h>
18 #include <asm/arch/gpio.h>
21 /* ------------------------------------------------------------------------- */
23 #if defined(CONFIG_NEW_LEDS)
25 #include <linux/platform_device.h>
28 * New cross-platform LED support.
31 static struct gpio_led_platform_data led_data
;
33 static struct platform_device at91_leds
= {
36 .dev
.platform_data
= &led_data
,
39 void __init
at91_gpio_leds(struct gpio_led
*leds
, int nr
)
46 for (i
= 0; i
< nr
; i
++)
47 at91_set_gpio_output(leds
[i
].gpio
, leds
[i
].active_low
);
50 led_data
.num_leds
= nr
;
51 platform_device_register(&at91_leds
);
55 void __init
at91_gpio_leds(struct gpio_led
*leds
, int nr
) {}
59 /* ------------------------------------------------------------------------- */
61 #if defined(CONFIG_LEDS)
66 * Old ARM-specific LED framework; not fully functional when generic time is
70 static u8 at91_leds_cpu
;
71 static u8 at91_leds_timer
;
73 static inline void at91_led_on(unsigned int led
)
75 at91_set_gpio_value(led
, 0);
78 static inline void at91_led_off(unsigned int led
)
80 at91_set_gpio_value(led
, 1);
83 static inline void at91_led_toggle(unsigned int led
)
85 unsigned long is_off
= at91_get_gpio_value(led
);
96 static void at91_leds_event(led_event_t evt
)
100 local_irq_save(flags
);
103 case led_start
: /* System startup */
104 at91_led_on(at91_leds_cpu
);
107 case led_stop
: /* System stop / suspend */
108 at91_led_off(at91_leds_cpu
);
111 #ifdef CONFIG_LEDS_TIMER
112 case led_timer
: /* Every 50 timer ticks */
113 at91_led_toggle(at91_leds_timer
);
117 #ifdef CONFIG_LEDS_CPU
118 case led_idle_start
: /* Entering idle state */
119 at91_led_off(at91_leds_cpu
);
122 case led_idle_end
: /* Exit idle state */
123 at91_led_on(at91_leds_cpu
);
131 local_irq_restore(flags
);
135 static int __init
leds_init(void)
137 if (!at91_leds_timer
|| !at91_leds_cpu
)
140 leds_event
= at91_leds_event
;
142 leds_event(led_start
);
146 __initcall(leds_init
);
149 void __init
at91_init_leds(u8 cpu_led
, u8 timer_led
)
151 /* Enable GPIO to access the LEDs */
152 at91_set_gpio_output(cpu_led
, 1);
153 at91_set_gpio_output(timer_led
, 1);
155 at91_leds_cpu
= cpu_led
;
156 at91_leds_timer
= timer_led
;
160 void __init
at91_init_leds(u8 cpu_led
, u8 timer_led
) {}