2 * Driver for the 8 user LEDs found on the RealViews and Versatiles
3 * Based on DaVinci's DM365 board code
5 * License terms: GNU General Public License (GPL) version 2
6 * Author: Linus Walleij <triad@df.lth.se>
8 #include <linux/kernel.h>
9 #include <linux/init.h>
11 #include <linux/slab.h>
12 #include <linux/leds.h>
14 #include <mach/hardware.h>
15 #include <mach/platform.h>
17 #ifdef VERSATILE_SYS_BASE
18 #define LEDREG (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET)
21 #ifdef REALVIEW_SYS_BASE
22 #define LEDREG (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET)
25 struct versatile_led {
26 struct led_classdev cdev;
31 * The triggers lines up below will only be used if the
32 * LED triggers are compiled in.
37 } versatile_leds[] = {
38 { "versatile:0", "heartbeat", },
39 { "versatile:1", "mmc0", },
48 static void versatile_led_set(struct led_classdev *cdev,
49 enum led_brightness b)
51 struct versatile_led *led = container_of(cdev,
52 struct versatile_led, cdev);
53 u32 reg = readl(LEDREG);
62 static enum led_brightness versatile_led_get(struct led_classdev *cdev)
64 struct versatile_led *led = container_of(cdev,
65 struct versatile_led, cdev);
66 u32 reg = readl(LEDREG);
68 return (reg & led->mask) ? LED_FULL : LED_OFF;
71 static int __init versatile_leds_init(void)
77 for (i = 0; i < ARRAY_SIZE(versatile_leds); i++) {
78 struct versatile_led *led;
80 led = kzalloc(sizeof(*led), GFP_KERNEL);
84 led->cdev.name = versatile_leds[i].name;
85 led->cdev.brightness_set = versatile_led_set;
86 led->cdev.brightness_get = versatile_led_get;
87 led->cdev.default_trigger = versatile_leds[i].trigger;
90 if (led_classdev_register(NULL, &led->cdev) < 0) {
100 * Since we may have triggers on any subsystem, defer registration
101 * until after subsystem_init.
103 fs_initcall(versatile_leds_init);