090c53a25aa38164fb315c5aae9e6f87b2c4ff54
[openwrt.git] / target / linux / adm5120-2.6 / files / drivers / char / adm5120_gpio.c
1 /*
2 * ADM5120 LED (GPIO) driver
3 *
4 * Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005
5 * Copyright (C) OpenWrt.org, Florian Fainelli <florian@openwrt.org>, 2007
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/leds.h>
16
17 #define GPIO_IO ((unsigned long *)0xb20000b8)
18
19 static void adm5120_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
20 {
21 if (brightness)
22 *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (brightness << 24);
23 else
24 *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (0 << 24);
25 }
26
27 static struct led_classdev adm5120_gpio_led = {
28 .name = "adm5120:led",
29 .brightness_set = adm5120_led_set,
30 };
31
32 static int __init adm5120_led_init(void)
33 {
34 int ret = led_classdev_register(NULL, &adm5120_gpio_led);
35
36 if (ret < 0)
37 printk(KERN_WARNING "adm5120: unable to register LED device\n");
38
39 return ret;
40 }
41
42 static void __exit adm5120_led_exit(void)
43 {
44 led_classdev_unregister(&adm5120_gpio_led);
45 }
46
47 module_init(adm5120_led_init);
48 module_exit(adm5120_led_exit);
49
50 MODULE_DESCRIPTION("ADM5120 LED driver");
51 MODULE_AUTHOR("Jeroen Vreeken, OpenWrt.org");
52 MODULE_LICENSE("GPL");
This page took 0.045445 seconds and 3 git commands to generate.