diff options
| -rw-r--r-- | arch/arm/mach-at91rm9200/Makefile | 9 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/board-csb337.c | 3 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/board-csb637.c | 3 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/board-dk.c | 3 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/board-ek.c | 3 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/devices.c | 19 | ||||
| -rw-r--r-- | arch/arm/mach-at91rm9200/leds.c | 100 | ||||
| -rw-r--r-- | include/asm-arm/arch-at91rm9200/board.h | 5 |
8 files changed, 141 insertions, 4 deletions
diff --git a/arch/arm/mach-at91rm9200/Makefile b/arch/arm/mach-at91rm9200/Makefile index 75e6ee318ded..ef88c4128edc 100644 --- a/arch/arm/mach-at91rm9200/Makefile +++ b/arch/arm/mach-at91rm9200/Makefile | |||
| @@ -16,11 +16,12 @@ obj-$(CONFIG_MACH_CSB637) += board-csb637.o | |||
| 16 | #obj-$(CONFIG_MACH_KB9200) += board-kb9202.o | 16 | #obj-$(CONFIG_MACH_KB9200) += board-kb9202.o |
| 17 | 17 | ||
| 18 | # LEDs support | 18 | # LEDs support |
| 19 | #led-$(CONFIG_ARCH_AT91RM9200DK) += leds.o | 19 | led-$(CONFIG_ARCH_AT91RM9200DK) += leds.o |
| 20 | #led-$(CONFIG_MACH_AT91RM9200EK) += leds.o | 20 | led-$(CONFIG_MACH_AT91RM9200EK) += leds.o |
| 21 | #led-$(CONFIG_MACH_CSB337) += leds.o | 21 | led-$(CONFIG_MACH_CSB337) += leds.o |
| 22 | #led-$(CONFIG_MACH_CSB637) += leds.o | 22 | led-$(CONFIG_MACH_CSB637) += leds.o |
| 23 | #led-$(CONFIG_MACH_KB9200) += leds.o | 23 | #led-$(CONFIG_MACH_KB9200) += leds.o |
| 24 | #led-$(CONFIG_MACH_KAFA) += leds.o | ||
| 24 | obj-$(CONFIG_LEDS) += $(led-y) | 25 | obj-$(CONFIG_LEDS) += $(led-y) |
| 25 | 26 | ||
| 26 | # VGA support | 27 | # VGA support |
diff --git a/arch/arm/mach-at91rm9200/board-csb337.c b/arch/arm/mach-at91rm9200/board-csb337.c index 54022e58d50d..f45104ceea8f 100644 --- a/arch/arm/mach-at91rm9200/board-csb337.c +++ b/arch/arm/mach-at91rm9200/board-csb337.c | |||
| @@ -67,6 +67,9 @@ static void __init csb337_map_io(void) | |||
| 67 | /* Initialize clocks: 3.6864 MHz crystal */ | 67 | /* Initialize clocks: 3.6864 MHz crystal */ |
| 68 | at91_clock_init(3686400); | 68 | at91_clock_init(3686400); |
| 69 | 69 | ||
| 70 | /* Setup the LEDs */ | ||
| 71 | at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); | ||
| 72 | |||
| 70 | #ifdef CONFIG_SERIAL_AT91 | 73 | #ifdef CONFIG_SERIAL_AT91 |
| 71 | at91_console_port = CSB337_SERIAL_CONSOLE; | 74 | at91_console_port = CSB337_SERIAL_CONSOLE; |
| 72 | memcpy(at91_serial_map, serial, sizeof(serial)); | 75 | memcpy(at91_serial_map, serial, sizeof(serial)); |
diff --git a/arch/arm/mach-at91rm9200/board-csb637.c b/arch/arm/mach-at91rm9200/board-csb637.c index 8195f9d919ea..f2c2d6e79bc6 100644 --- a/arch/arm/mach-at91rm9200/board-csb637.c +++ b/arch/arm/mach-at91rm9200/board-csb637.c | |||
| @@ -67,6 +67,9 @@ static void __init csb637_map_io(void) | |||
| 67 | /* Initialize clocks: 3.6864 MHz crystal */ | 67 | /* Initialize clocks: 3.6864 MHz crystal */ |
| 68 | at91_clock_init(3686400); | 68 | at91_clock_init(3686400); |
| 69 | 69 | ||
| 70 | /* Setup the LEDs */ | ||
| 71 | at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); | ||
| 72 | |||
| 70 | #ifdef CONFIG_SERIAL_AT91 | 73 | #ifdef CONFIG_SERIAL_AT91 |
| 71 | at91_console_port = CSB637_SERIAL_CONSOLE; | 74 | at91_console_port = CSB637_SERIAL_CONSOLE; |
| 72 | memcpy(at91_serial_map, serial, sizeof(serial)); | 75 | memcpy(at91_serial_map, serial, sizeof(serial)); |
diff --git a/arch/arm/mach-at91rm9200/board-dk.c b/arch/arm/mach-at91rm9200/board-dk.c index 8a783368366e..fefbea882aab 100644 --- a/arch/arm/mach-at91rm9200/board-dk.c +++ b/arch/arm/mach-at91rm9200/board-dk.c | |||
| @@ -70,6 +70,9 @@ static void __init dk_map_io(void) | |||
| 70 | /* Initialize clocks: 18.432 MHz crystal */ | 70 | /* Initialize clocks: 18.432 MHz crystal */ |
| 71 | at91_clock_init(18432000); | 71 | at91_clock_init(18432000); |
| 72 | 72 | ||
| 73 | /* Setup the LEDs */ | ||
| 74 | at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); | ||
| 75 | |||
| 73 | #ifdef CONFIG_SERIAL_AT91 | 76 | #ifdef CONFIG_SERIAL_AT91 |
| 74 | at91_console_port = DK_SERIAL_CONSOLE; | 77 | at91_console_port = DK_SERIAL_CONSOLE; |
| 75 | memcpy(at91_serial_map, serial, sizeof(serial)); | 78 | memcpy(at91_serial_map, serial, sizeof(serial)); |
diff --git a/arch/arm/mach-at91rm9200/board-ek.c b/arch/arm/mach-at91rm9200/board-ek.c index fd0752eba897..1f8e450060be 100644 --- a/arch/arm/mach-at91rm9200/board-ek.c +++ b/arch/arm/mach-at91rm9200/board-ek.c | |||
| @@ -70,6 +70,9 @@ static void __init ek_map_io(void) | |||
| 70 | /* Initialize clocks: 18.432 MHz crystal */ | 70 | /* Initialize clocks: 18.432 MHz crystal */ |
| 71 | at91_clock_init(18432000); | 71 | at91_clock_init(18432000); |
| 72 | 72 | ||
| 73 | /* Setup the LEDs */ | ||
| 74 | at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2); | ||
| 75 | |||
| 73 | #ifdef CONFIG_SERIAL_AT91 | 76 | #ifdef CONFIG_SERIAL_AT91 |
| 74 | at91_console_port = EK_SERIAL_CONSOLE; | 77 | at91_console_port = EK_SERIAL_CONSOLE; |
| 75 | memcpy(at91_serial_map, serial, sizeof(serial)); | 78 | memcpy(at91_serial_map, serial, sizeof(serial)); |
diff --git a/arch/arm/mach-at91rm9200/devices.c b/arch/arm/mach-at91rm9200/devices.c index 57eedd5beaf6..aa36760efbc3 100644 --- a/arch/arm/mach-at91rm9200/devices.c +++ b/arch/arm/mach-at91rm9200/devices.c | |||
| @@ -290,4 +290,23 @@ void __init at91_add_device_mmc(struct at91_mmc_data *data) | |||
| 290 | void __init at91_add_device_mmc(struct at91_mmc_data *data) {} | 290 | void __init at91_add_device_mmc(struct at91_mmc_data *data) {} |
| 291 | #endif | 291 | #endif |
| 292 | 292 | ||
| 293 | /* -------------------------------------------------------------------- | ||
| 294 | * LEDs | ||
| 295 | * -------------------------------------------------------------------- */ | ||
| 296 | |||
| 297 | #if defined(CONFIG_LEDS) | ||
| 298 | u8 at91_leds_cpu; | ||
| 299 | u8 at91_leds_timer; | ||
| 300 | |||
| 301 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | ||
| 302 | { | ||
| 303 | at91_leds_cpu = cpu_led; | ||
| 304 | at91_leds_timer = timer_led; | ||
| 305 | } | ||
| 306 | |||
| 307 | #else | ||
| 308 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | ||
| 309 | #endif | ||
| 310 | |||
| 311 | |||
| 293 | /* -------------------------------------------------------------------- */ | 312 | /* -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91rm9200/leds.c b/arch/arm/mach-at91rm9200/leds.c new file mode 100644 index 000000000000..28150e8905ba --- /dev/null +++ b/arch/arm/mach-at91rm9200/leds.c | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | /* | ||
| 2 | * LED driver for Atmel AT91-based boards. | ||
| 3 | * | ||
| 4 | * Copyright (C) SAN People (Pty) Ltd | ||
| 5 | * | ||
| 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. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/config.h> | ||
| 13 | #include <linux/kernel.h> | ||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/init.h> | ||
| 16 | |||
| 17 | #include <asm/mach-types.h> | ||
| 18 | #include <asm/leds.h> | ||
| 19 | #include <asm/arch/board.h> | ||
| 20 | #include <asm/arch/gpio.h> | ||
| 21 | |||
| 22 | |||
| 23 | static inline void at91_led_on(unsigned int led) | ||
| 24 | { | ||
| 25 | at91_set_gpio_value(led, 0); | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline void at91_led_off(unsigned int led) | ||
| 29 | { | ||
| 30 | at91_set_gpio_value(led, 1); | ||
| 31 | } | ||
| 32 | |||
| 33 | static inline void at91_led_toggle(unsigned int led) | ||
| 34 | { | ||
| 35 | unsigned long is_off = at91_get_gpio_value(led); | ||
| 36 | if (is_off) | ||
| 37 | at91_led_on(led); | ||
| 38 | else | ||
| 39 | at91_led_off(led); | ||
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | /* | ||
| 44 | * Handle LED events. | ||
| 45 | */ | ||
| 46 | static void at91_leds_event(led_event_t evt) | ||
| 47 | { | ||
| 48 | unsigned long flags; | ||
| 49 | |||
| 50 | local_irq_save(flags); | ||
| 51 | |||
| 52 | switch(evt) { | ||
| 53 | case led_start: /* System startup */ | ||
| 54 | at91_led_on(at91_leds_cpu); | ||
| 55 | break; | ||
| 56 | |||
| 57 | case led_stop: /* System stop / suspend */ | ||
| 58 | at91_led_off(at91_leds_cpu); | ||
| 59 | break; | ||
| 60 | |||
| 61 | #ifdef CONFIG_LEDS_TIMER | ||
| 62 | case led_timer: /* Every 50 timer ticks */ | ||
| 63 | at91_led_toggle(at91_leds_timer); | ||
| 64 | break; | ||
| 65 | #endif | ||
| 66 | |||
| 67 | #ifdef CONFIG_LEDS_CPU | ||
| 68 | case led_idle_start: /* Entering idle state */ | ||
| 69 | at91_led_off(at91_leds_cpu); | ||
| 70 | break; | ||
| 71 | |||
| 72 | case led_idle_end: /* Exit idle state */ | ||
| 73 | at91_led_on(at91_leds_cpu); | ||
| 74 | break; | ||
| 75 | #endif | ||
| 76 | |||
| 77 | default: | ||
| 78 | break; | ||
| 79 | } | ||
| 80 | |||
| 81 | local_irq_restore(flags); | ||
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | static int __init leds_init(void) | ||
| 86 | { | ||
| 87 | if (!at91_leds_timer || !at91_leds_cpu) | ||
| 88 | return -ENODEV; | ||
| 89 | |||
| 90 | /* Enable PIO to access the LEDs */ | ||
| 91 | at91_set_gpio_output(at91_leds_timer, 1); | ||
| 92 | at91_set_gpio_output(at91_leds_cpu, 1); | ||
| 93 | |||
| 94 | leds_event = at91_leds_event; | ||
| 95 | |||
| 96 | leds_event(led_start); | ||
| 97 | return 0; | ||
| 98 | } | ||
| 99 | |||
| 100 | __initcall(leds_init); | ||
diff --git a/include/asm-arm/arch-at91rm9200/board.h b/include/asm-arm/arch-at91rm9200/board.h index 2e7d1139a799..834d0ab991ae 100644 --- a/include/asm-arm/arch-at91rm9200/board.h +++ b/include/asm-arm/arch-at91rm9200/board.h | |||
| @@ -77,4 +77,9 @@ struct at91_usbh_data { | |||
| 77 | }; | 77 | }; |
| 78 | extern void __init at91_add_device_usbh(struct at91_usbh_data *data); | 78 | extern void __init at91_add_device_usbh(struct at91_usbh_data *data); |
| 79 | 79 | ||
| 80 | /* LEDs */ | ||
| 81 | extern u8 at91_leds_cpu; | ||
| 82 | extern u8 at91_leds_timer; | ||
| 83 | extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); | ||
| 84 | |||
| 80 | #endif | 85 | #endif |
