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>
10 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/leds.h>
14 #include <linux/platform_device.h>
16 struct versatile_led
{
18 struct led_classdev cdev
;
23 * The triggers lines up below will only be used if the
24 * LED triggers are compiled in.
29 } versatile_leds
[] = {
30 { "versatile:0", "heartbeat", },
31 { "versatile:1", "mmc0", },
32 { "versatile:2", "cpu0" },
33 { "versatile:3", "cpu1" },
34 { "versatile:4", "cpu2" },
35 { "versatile:5", "cpu3" },
40 static void versatile_led_set(struct led_classdev
*cdev
,
41 enum led_brightness b
)
43 struct versatile_led
*led
= container_of(cdev
,
44 struct versatile_led
, cdev
);
45 u32 reg
= readl(led
->base
);
51 writel(reg
, led
->base
);
54 static enum led_brightness
versatile_led_get(struct led_classdev
*cdev
)
56 struct versatile_led
*led
= container_of(cdev
,
57 struct versatile_led
, cdev
);
58 u32 reg
= readl(led
->base
);
60 return (reg
& led
->mask
) ? LED_FULL
: LED_OFF
;
63 static int versatile_leds_probe(struct platform_device
*dev
)
69 res
= platform_get_resource(dev
, IORESOURCE_MEM
, 0);
70 base
= devm_ioremap_resource(&dev
->dev
, res
);
76 for (i
= 0; i
< ARRAY_SIZE(versatile_leds
); i
++) {
77 struct versatile_led
*led
;
79 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) {
99 static struct platform_driver versatile_leds_driver
= {
101 .name
= "versatile-leds",
103 .probe
= versatile_leds_probe
,
106 module_platform_driver(versatile_leds_driver
);
108 MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
109 MODULE_DESCRIPTION("ARM Versatile LED driver");
110 MODULE_LICENSE("GPL v2");