blob: db5af83f0ceccba97c0030f7a7b9ada92bf00126 [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Phil Sutterac67e232009-01-22 19:35:48 +01002/*
3 * LEDs driver for the "User LED" on Routerboard532
4 *
5 * Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org>
6 *
7 * Based on leds-cobalt-qube.c by Florian Fainelly and
8 * rb-diag.c (my own standalone driver for both LED and
9 * button of Routerboard532).
10 */
11
12#include <linux/leds.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15
16#include <asm/mach-rc32434/gpio.h>
17#include <asm/mach-rc32434/rb.h>
18
19static void rb532_led_set(struct led_classdev *cdev,
Sachin Kamat7a0eff42012-11-27 20:38:09 -080020 enum led_brightness brightness)
Phil Sutterac67e232009-01-22 19:35:48 +010021{
22 if (brightness)
23 set_latch_u5(LO_ULED, 0);
24
25 else
26 set_latch_u5(0, LO_ULED);
27}
28
29static enum led_brightness rb532_led_get(struct led_classdev *cdev)
30{
31 return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF;
32}
33
34static struct led_classdev rb532_uled = {
35 .name = "uled",
36 .brightness_set = rb532_led_set,
37 .brightness_get = rb532_led_get,
38 .default_trigger = "nand-disk",
39};
40
Bill Pemberton98ea1ea2012-11-19 13:23:02 -050041static int rb532_led_probe(struct platform_device *pdev)
Phil Sutterac67e232009-01-22 19:35:48 +010042{
43 return led_classdev_register(&pdev->dev, &rb532_uled);
44}
45
Bill Pemberton678e8a62012-11-19 13:26:00 -050046static int rb532_led_remove(struct platform_device *pdev)
Phil Sutterac67e232009-01-22 19:35:48 +010047{
48 led_classdev_unregister(&rb532_uled);
49 return 0;
50}
51
52static struct platform_driver rb532_led_driver = {
53 .probe = rb532_led_probe,
Bill Pembertondf07cf82012-11-19 13:20:20 -050054 .remove = rb532_led_remove,
Phil Sutterac67e232009-01-22 19:35:48 +010055 .driver = {
56 .name = "rb532-led",
Phil Sutterac67e232009-01-22 19:35:48 +010057 },
58};
59
Axel Lin892a8842012-01-10 15:09:24 -080060module_platform_driver(rb532_led_driver);
Phil Sutterac67e232009-01-22 19:35:48 +010061
62MODULE_LICENSE("GPL");
63MODULE_DESCRIPTION("User LED support for Routerboard532");
64MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");
Axel Lin892a8842012-01-10 15:09:24 -080065MODULE_ALIAS("platform:rb532-led");