-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ARM] 4981/1: [KS8695] Simple LED driver
Simple gpio-connected LED driver for KS8695 platforms. (Based on old AT91 LED driver) Signed-off-by: Andrew Victor <linux@maxim.org.za> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
- Loading branch information
Andrew Victor
authored and
Russell King
committed
Apr 17, 2008
1 parent
05dda97
commit fdb72fd
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* LED driver for KS8695-based boards. | ||
* | ||
* Copyright (C) Andrew Victor | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/init.h> | ||
|
||
#include <asm/mach-types.h> | ||
#include <asm/leds.h> | ||
#include <asm/arch/devices.h> | ||
#include <asm/arch/gpio.h> | ||
|
||
|
||
static inline void ks8695_led_on(unsigned int led) | ||
{ | ||
gpio_set_value(led, 0); | ||
} | ||
|
||
static inline void ks8695_led_off(unsigned int led) | ||
{ | ||
gpio_set_value(led, 1); | ||
} | ||
|
||
static inline void ks8695_led_toggle(unsigned int led) | ||
{ | ||
unsigned long is_off = gpio_get_value(led); | ||
if (is_off) | ||
ks8695_led_on(led); | ||
else | ||
ks8695_led_off(led); | ||
} | ||
|
||
|
||
/* | ||
* Handle LED events. | ||
*/ | ||
static void ks8695_leds_event(led_event_t evt) | ||
{ | ||
unsigned long flags; | ||
|
||
local_irq_save(flags); | ||
|
||
switch(evt) { | ||
case led_start: /* System startup */ | ||
ks8695_led_on(ks8695_leds_cpu); | ||
break; | ||
|
||
case led_stop: /* System stop / suspend */ | ||
ks8695_led_off(ks8695_leds_cpu); | ||
break; | ||
|
||
#ifdef CONFIG_LEDS_TIMER | ||
case led_timer: /* Every 50 timer ticks */ | ||
ks8695_led_toggle(ks8695_leds_timer); | ||
break; | ||
#endif | ||
|
||
#ifdef CONFIG_LEDS_CPU | ||
case led_idle_start: /* Entering idle state */ | ||
ks8695_led_off(ks8695_leds_cpu); | ||
break; | ||
|
||
case led_idle_end: /* Exit idle state */ | ||
ks8695_led_on(ks8695_leds_cpu); | ||
break; | ||
#endif | ||
|
||
default: | ||
break; | ||
} | ||
|
||
local_irq_restore(flags); | ||
} | ||
|
||
|
||
static int __init leds_init(void) | ||
{ | ||
if ((ks8695_leds_timer == -1) || (ks8695_leds_cpu == -1)) | ||
return -ENODEV; | ||
|
||
leds_event = ks8695_leds_event; | ||
|
||
leds_event(led_start); | ||
return 0; | ||
} | ||
|
||
__initcall(leds_init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters