From ac67e23bed58a0e34a8cb9ecd1de6c78569f8ef2 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 22 Jan 2009 19:35:48 +0100 Subject: [PATCH] leds: Add rb532 LED driver for the User LED Mikrotik built six LEDs into the Routerboard 532, from which one is destined for custom use, the so called "User LED". This patch adds a driver for it, based on the LEDs class. Signed-off-by: Phil Sutter Acked-by: Florian Fainelli Signed-off-by: Richard Purdie --- drivers/leds/Kconfig | 7 ++++ drivers/leds/Makefile | 1 + drivers/leds/leds-rb532.c | 77 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 drivers/leds/leds-rb532.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 89ea7ef39fe4..db5e6a64c7cf 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -31,6 +31,13 @@ config LEDS_LOCOMO This option enables support for the LEDs on Sharp Locomo. Zaurus models SL-5500 and SL-5600. +config LEDS_MIKROTIK_RB532 + tristate "LED Support for Mikrotik Routerboard 532" + depends on LEDS_CLASS && MIKROTIK_RB532 + help + This option enables support for the so called "User LED" of + Mikrotik's Routerboard 532. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS && ARCH_S3C2410 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 584a3f6c2530..017f69aa2ecd 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o # LED Platform Drivers obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o +obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c new file mode 100644 index 000000000000..c3525f37f73d --- /dev/null +++ b/drivers/leds/leds-rb532.c @@ -0,0 +1,77 @@ +/* + * LEDs driver for the "User LED" on Routerboard532 + * + * Copyright (C) 2009 Phil Sutter + * + * 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 +#include +#include + +#include +#include + +static void rb532_led_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + 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", +}; + +static int __devinit rb532_led_probe(struct platform_device *pdev) +{ + return led_classdev_register(&pdev->dev, &rb532_uled); +} + +static int __devexit rb532_led_remove(struct platform_device *pdev) +{ + led_classdev_unregister(&rb532_uled); + return 0; +} + +static struct platform_driver rb532_led_driver = { + .probe = rb532_led_probe, + .remove = __devexit_p(rb532_led_remove), + .driver = { + .name = "rb532-led", + .owner = THIS_MODULE, + }, +}; + +static int __init rb532_led_init(void) +{ + return platform_driver_register(&rb532_led_driver); +} + +static void __exit rb532_led_exit(void) +{ + platform_driver_unregister(&rb532_led_driver); +} + +module_init(rb532_led_init); +module_exit(rb532_led_exit); + +MODULE_ALIAS("platform:rb532-led"); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("User LED support for Routerboard532"); +MODULE_AUTHOR("Phil Sutter ");