1
0

leds-wndr3700-usb.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include <linux/leds.h>
  11. #include <linux/module.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include <asm/mach-ath79/ath79.h>
  15. #define DRIVER_NAME "wndr3700-led-usb"
  16. static void wndr3700_usb_led_set(struct led_classdev *cdev,
  17. enum led_brightness brightness)
  18. {
  19. if (brightness)
  20. ath79_device_reset_clear(AR71XX_RESET_GE1_PHY);
  21. else
  22. ath79_device_reset_set(AR71XX_RESET_GE1_PHY);
  23. }
  24. static enum led_brightness wndr3700_usb_led_get(struct led_classdev *cdev)
  25. {
  26. return ath79_device_reset_get(AR71XX_RESET_GE1_PHY) ? LED_OFF : LED_FULL;
  27. }
  28. static struct led_classdev wndr3700_usb_led = {
  29. .name = "netgear:green:usb",
  30. .brightness_set = wndr3700_usb_led_set,
  31. .brightness_get = wndr3700_usb_led_get,
  32. };
  33. static int wndr3700_usb_led_probe(struct platform_device *pdev)
  34. {
  35. return led_classdev_register(&pdev->dev, &wndr3700_usb_led);
  36. }
  37. static int wndr3700_usb_led_remove(struct platform_device *pdev)
  38. {
  39. led_classdev_unregister(&wndr3700_usb_led);
  40. return 0;
  41. }
  42. static struct platform_driver wndr3700_usb_led_driver = {
  43. .probe = wndr3700_usb_led_probe,
  44. .remove = wndr3700_usb_led_remove,
  45. .driver = {
  46. .name = DRIVER_NAME,
  47. .owner = THIS_MODULE,
  48. },
  49. };
  50. static int __init wndr3700_usb_led_init(void)
  51. {
  52. return platform_driver_register(&wndr3700_usb_led_driver);
  53. }
  54. static void __exit wndr3700_usb_led_exit(void)
  55. {
  56. platform_driver_unregister(&wndr3700_usb_led_driver);
  57. }
  58. module_init(wndr3700_usb_led_init);
  59. module_exit(wndr3700_usb_led_exit);
  60. MODULE_DESCRIPTION("USB LED driver for the NETGEAR WNDR3700");
  61. MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
  62. MODULE_LICENSE("GPL v2");
  63. MODULE_ALIAS("platform:" DRIVER_NAME);