2 * LED driver for MTX-1 boards
4 * Copyright 2007 Florian Fainelli <florian@openwrt.org>
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.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/leds.h>
16 #include <linux/err.h>
19 static struct platform_device
*pdev
;
21 static void mtx1_led_set(struct led_classdev
*led_cdev
, enum led_brightness brightness
)
23 if (!strcmp("mtx1:green", led_cdev
->name
))
24 gpio_set_value(211, brightness
? 1 : 0);
26 gpio_set_value(212, brightness
? 1 : 0);
29 static struct led_classdev mtx1_green_led
= {
31 .brightness_set
= mtx1_led_set
,
34 static struct led_classdev mtx1_red_led
= {
36 .brightness_set
= mtx1_led_set
,
39 static int mtx1_leds_probe(struct platform_device
*pdev
)
43 ret
= led_classdev_register(&pdev
->dev
, &mtx1_green_led
);
47 ret
= led_classdev_register(&pdev
->dev
, &mtx1_red_led
);
49 led_classdev_unregister(&mtx1_green_led
);
55 static int mtx1_leds_remove(struct platform_device
*pdev
)
57 led_classdev_unregister(&mtx1_green_led
);
58 led_classdev_unregister(&mtx1_red_led
);
62 static struct platform_driver mtx1_leds_driver
= {
63 .probe
= mtx1_leds_probe
,
64 .remove
= mtx1_leds_remove
,
70 static int __init
mtx1_leds_init(void)
74 ret
= platform_driver_register(&mtx1_leds_driver
);
78 pdev
= platform_device_register_simple("mtx1-leds", -1, NULL
, 0);
81 platform_driver_unregister(&mtx1_leds_driver
);
90 static void __exit
mtx1_leds_exit(void)
92 platform_device_unregister(pdev
);
93 platform_driver_unregister(&mtx1_leds_driver
);
96 module_init(mtx1_leds_init
);
97 module_exit(mtx1_leds_exit
);
99 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
100 MODULE_DESCRIPTION("MTX-1 LED driver");
101 MODULE_LICENSE("GPL");