2009-01-22 18:35:48 +00:00
|
|
|
/*
|
|
|
|
* LEDs driver for the "User LED" on Routerboard532
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org>
|
|
|
|
*
|
|
|
|
* Based on leds-cobalt-qube.c by Florian Fainelly and
|
|
|
|
* rb-diag.c (my own standalone driver for both LED and
|
|
|
|
* button of Routerboard532).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/leds.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
#include <asm/mach-rc32434/gpio.h>
|
|
|
|
#include <asm/mach-rc32434/rb.h>
|
|
|
|
|
|
|
|
static void rb532_led_set(struct led_classdev *cdev,
|
2012-11-28 04:38:09 +00:00
|
|
|
enum led_brightness brightness)
|
2009-01-22 18:35:48 +00:00
|
|
|
{
|
|
|
|
if (brightness)
|
|
|
|
set_latch_u5(LO_ULED, 0);
|
|
|
|
|
|
|
|
else
|
|
|
|
set_latch_u5(0, LO_ULED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum led_brightness rb532_led_get(struct led_classdev *cdev)
|
|
|
|
{
|
|
|
|
return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct led_classdev rb532_uled = {
|
|
|
|
.name = "uled",
|
|
|
|
.brightness_set = rb532_led_set,
|
|
|
|
.brightness_get = rb532_led_get,
|
|
|
|
.default_trigger = "nand-disk",
|
|
|
|
};
|
|
|
|
|
2012-11-19 18:23:02 +00:00
|
|
|
static int rb532_led_probe(struct platform_device *pdev)
|
2009-01-22 18:35:48 +00:00
|
|
|
{
|
|
|
|
return led_classdev_register(&pdev->dev, &rb532_uled);
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:26:00 +00:00
|
|
|
static int rb532_led_remove(struct platform_device *pdev)
|
2009-01-22 18:35:48 +00:00
|
|
|
{
|
|
|
|
led_classdev_unregister(&rb532_uled);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver rb532_led_driver = {
|
|
|
|
.probe = rb532_led_probe,
|
2012-11-19 18:20:20 +00:00
|
|
|
.remove = rb532_led_remove,
|
2009-01-22 18:35:48 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "rb532-led",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-10 23:09:24 +00:00
|
|
|
module_platform_driver(rb532_led_driver);
|
2009-01-22 18:35:48 +00:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("User LED support for Routerboard532");
|
|
|
|
MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");
|
2012-01-10 23:09:24 +00:00
|
|
|
MODULE_ALIAS("platform:rb532-led");
|