f29047340e412e49f23388504c8ea4251b4f9a1f
[openwrt/svn-archive/archive.git] / target / linux / rdc-2.6 / files / drivers / leds / leds-rdc3211.c
1 /*
2 * LED driver for RDC3211 boards
3 *
4 * Copyright 2007 Florian Fainelli <florian@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/err.h>
18
19 #include <asm/gpio.h>
20
21 /* This is just for testing purpose */
22 int gpio=-1;
23 module_param(gpio, int, 0444);
24 MODULE_PARM_DESC(gpio, " GPIO line");
25
26 static void rdc321x_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
27 {
28 gpio_set_value(gpio, brightness ? 1 : 0);
29 }
30
31 /* The DMZ led is at GPIO line 1 */
32 static struct led_classdev rdc321x_dmz_led = {
33 .name = "rdc321x:dmz",
34 .brightness_set = rdc321x_led_set,
35 };
36
37 static int rdc321x_leds_probe(struct platform_device *pdev)
38 {
39 return led_classdev_register(&pdev->dev, &rdc321x_dmz_led);
40 }
41
42 static int rdc321x_leds_remove(struct platform_device *pdev)
43 {
44 led_classdev_unregister(&rdc321x_dmz_led);
45 return 0;
46 }
47
48 static struct platform_driver rdc321x_leds_driver = {
49 .probe = rdc321x_leds_probe,
50 .remove = rdc321x_leds_remove,
51 .driver = {
52 .name = "rdc321x-leds",
53 .owner = THIS_MODULE,
54 }
55 };
56
57 static int __init rdc321x_leds_init(void)
58 {
59 int ret;
60
61 ret = gpio+1?platform_driver_register(&rdc321x_leds_driver):-EINVAL;
62
63 return ret;
64 }
65
66 static void __exit rdc321x_leds_exit(void)
67 {
68 platform_driver_unregister(&rdc321x_leds_driver);
69 }
70
71 module_init(rdc321x_leds_init);
72 module_exit(rdc321x_leds_exit);
73
74 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
75 MODULE_DESCRIPTION("RDC321x LED driver");
76 MODULE_LICENSE("GPL");