diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:49:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:49:45 +0000 |
commit | 2c3c1048746a4622d8c89a29670120dc8fab93c4 (patch) | |
tree | 848558de17fb3008cdf4d861b01ac7781903ce39 /drivers/leds/leds-rb532.c | |
parent | Initial commit. (diff) | |
download | linux-2c3c1048746a4622d8c89a29670120dc8fab93c4.tar.xz linux-2c3c1048746a4622d8c89a29670120dc8fab93c4.zip |
Adding upstream version 6.1.76.upstream/6.1.76upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | drivers/leds/leds-rb532.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/leds/leds-rb532.c b/drivers/leds/leds-rb532.c new file mode 100644 index 000000000..b6447c172 --- /dev/null +++ b/drivers/leds/leds-rb532.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * 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, + 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 rb532_led_probe(struct platform_device *pdev) +{ + return led_classdev_register(&pdev->dev, &rb532_uled); +} + +static int 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 = rb532_led_remove, + .driver = { + .name = "rb532-led", + }, +}; + +module_platform_driver(rb532_led_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("User LED support for Routerboard532"); +MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>"); +MODULE_ALIAS("platform:rb532-led"); |