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 <mach/board.h>
17 #include <mach/gpio.h>
20 /* ------------------------------------------------------------------------- */
22 #if defined(CONFIG_NEW_LEDS)
24 #include <linux/platform_device.h>
27 * New cross-platform LED support.
30 static struct gpio_led_platform_data led_data;
32 static struct platform_device at91_leds = {
35 .dev.platform_data = &led_data,
38 void __init at91_gpio_leds(struct gpio_led *leds, int nr)
45 for (i = 0; i < nr; i++)
46 at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
49 led_data.num_leds = nr;
50 platform_device_register(&at91_leds);
54 void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
58 /* ------------------------------------------------------------------------- */
60 #if defined(CONFIG_LEDS)
65 * Old ARM-specific LED framework; not fully functional when generic time is
69 static u8 at91_leds_cpu;
70 static u8 at91_leds_timer;
72 static inline void at91_led_on(unsigned int led)
74 at91_set_gpio_value(led, 0);
77 static inline void at91_led_off(unsigned int led)
79 at91_set_gpio_value(led, 1);
82 static inline void at91_led_toggle(unsigned int led)
84 unsigned long is_off = at91_get_gpio_value(led);
95 static void at91_leds_event(led_event_t evt)
99 local_irq_save(flags);
102 case led_start: /* System startup */
103 at91_led_on(at91_leds_cpu);
106 case led_stop: /* System stop / suspend */
107 at91_led_off(at91_leds_cpu);
110 #ifdef CONFIG_LEDS_TIMER
111 case led_timer: /* Every 50 timer ticks */
112 at91_led_toggle(at91_leds_timer);
116 #ifdef CONFIG_LEDS_CPU
117 case led_idle_start: /* Entering idle state */
118 at91_led_off(at91_leds_cpu);
121 case led_idle_end: /* Exit idle state */
122 at91_led_on(at91_leds_cpu);
130 local_irq_restore(flags);
134 static int __init leds_init(void)
136 if (!at91_leds_timer || !at91_leds_cpu)
139 leds_event = at91_leds_event;
141 leds_event(led_start);
145 __initcall(leds_init);
148 void __init at91_init_leds(u8 cpu_led, u8 timer_led)
150 /* Enable GPIO to access the LEDs */
151 at91_set_gpio_output(cpu_led, 1);
152 at91_set_gpio_output(timer_led, 1);
154 at91_leds_cpu = cpu_led;
155 at91_leds_timer = timer_led;
159 void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}