Root/target/linux/ar71xx/files/drivers/leds/leds-wndr3700-usb.c

1/*
2 * USB LED driver for the NETGEAR WNDR3700
3 *
4 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#include <linux/leds.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14
15#include <asm/mach-ath79/ar71xx_regs.h>
16#include <asm/mach-ath79/ath79.h>
17
18#define DRIVER_NAME "wndr3700-led-usb"
19
20static void wndr3700_usb_led_set(struct led_classdev *cdev,
21                 enum led_brightness brightness)
22{
23    if (brightness)
24        ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
25    else
26        ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
27}
28
29static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
30{
31    return ath79_device_reset_get(AR71XX_RESET_GE1_PHY) ? LED_OFF : LED_FULL;
32}
33
34static struct led_classdev wndr3700_usb_led = {
35    .name = "wndr3700:green:usb",
36    .brightness_set = wndr3700_usb_led_set,
37    .brightness_get = wndr3700_usb_led_get,
38};
39
40static int __devinit wndr3700_usb_led_probe(struct platform_device *pdev)
41{
42    return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
43}
44
45static int __devexit wndr3700_usb_led_remove(struct platform_device *pdev)
46{
47    led_classdev_unregister(&wndr3700_usb_led);
48    return 0;
49}
50
51static struct platform_driver wndr3700_usb_led_driver = {
52    .probe = wndr3700_usb_led_probe,
53    .remove = __devexit_p(wndr3700_usb_led_remove),
54    .driver = {
55        .name = DRIVER_NAME,
56        .owner = THIS_MODULE,
57    },
58};
59
60static int __init wndr3700_usb_led_init(void)
61{
62    return platform_driver_register(&wndr3700_usb_led_driver);
63}
64
65static void __exit wndr3700_usb_led_exit(void)
66{
67    platform_driver_unregister(&wndr3700_usb_led_driver);
68}
69
70module_init(wndr3700_usb_led_init);
71module_exit(wndr3700_usb_led_exit);
72
73MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
74MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
75MODULE_LICENSE("GPL v2");
76MODULE_ALIAS("platform:" DRIVER_NAME);
77

Archive Download this file



interactive