2007-05-12 00:43:25 +08:00
|
|
|
/*
|
|
|
|
* LED driver for RDC3211 boards
|
|
|
|
*
|
|
|
|
* Copyright 2007 Florian Fainelli <florian@openwrt.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2007-08-06 22:15:57 +08:00
|
|
|
#include <linux/module.h>
|
2007-05-12 00:43:25 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/leds.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
#include <asm/gpio.h>
|
2007-05-12 00:43:25 +08:00
|
|
|
|
2007-08-07 03:25:12 +08:00
|
|
|
/* This is just for testing purpose */
|
2007-08-07 17:12:09 +08:00
|
|
|
int gpio=-1;
|
2007-08-06 22:15:57 +08:00
|
|
|
module_param(gpio, int, 0444);
|
|
|
|
MODULE_PARM_DESC(gpio, " GPIO line");
|
2007-05-12 00:43:25 +08:00
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static void rdc321x_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
|
2007-05-12 00:43:25 +08:00
|
|
|
{
|
2007-08-06 22:15:57 +08:00
|
|
|
gpio_set_value(gpio, brightness ? 1 : 0);
|
2007-05-12 00:43:25 +08:00
|
|
|
}
|
|
|
|
|
2007-08-07 03:25:12 +08:00
|
|
|
/* The DMZ led is at GPIO line 1 */
|
2007-08-06 22:15:57 +08:00
|
|
|
static struct led_classdev rdc321x_dmz_led = {
|
|
|
|
.name = "rdc321x:dmz",
|
|
|
|
.brightness_set = rdc321x_led_set,
|
2007-05-12 00:43:25 +08:00
|
|
|
};
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static int rdc321x_leds_probe(struct platform_device *pdev)
|
2007-05-12 00:43:25 +08:00
|
|
|
{
|
2007-08-06 22:15:57 +08:00
|
|
|
return led_classdev_register(&pdev->dev, &rdc321x_dmz_led);
|
2007-05-12 00:43:25 +08:00
|
|
|
}
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static int rdc321x_leds_remove(struct platform_device *pdev)
|
2007-05-12 00:43:25 +08:00
|
|
|
{
|
2007-08-06 22:15:57 +08:00
|
|
|
led_classdev_unregister(&rdc321x_dmz_led);
|
2007-05-12 00:43:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static struct platform_driver rdc321x_leds_driver = {
|
|
|
|
.probe = rdc321x_leds_probe,
|
|
|
|
.remove = rdc321x_leds_remove,
|
2007-05-12 00:43:25 +08:00
|
|
|
.driver = {
|
2007-08-06 22:15:57 +08:00
|
|
|
.name = "rdc321x-leds",
|
|
|
|
.owner = THIS_MODULE,
|
2007-05-12 00:43:25 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static int __init rdc321x_leds_init(void)
|
2007-05-12 00:43:25 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2007-08-07 17:12:09 +08:00
|
|
|
ret = gpio+1?platform_driver_register(&rdc321x_leds_driver):-EINVAL;
|
2007-05-12 00:43:25 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
static void __exit rdc321x_leds_exit(void)
|
2007-05-12 00:43:25 +08:00
|
|
|
{
|
2007-08-06 22:15:57 +08:00
|
|
|
platform_driver_unregister(&rdc321x_leds_driver);
|
2007-05-12 00:43:25 +08:00
|
|
|
}
|
|
|
|
|
2007-08-06 22:15:57 +08:00
|
|
|
module_init(rdc321x_leds_init);
|
|
|
|
module_exit(rdc321x_leds_exit);
|
2007-05-12 00:43:25 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
|
2007-08-06 22:15:57 +08:00
|
|
|
MODULE_DESCRIPTION("RDC321x LED driver");
|
2007-05-12 00:43:25 +08:00
|
|
|
MODULE_LICENSE("GPL");
|