leds-rb532.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * LEDs driver for the "User LED" on Routerboard532
  3. *
  4. * Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org>
  5. *
  6. * Based on leds-cobalt-qube.c by Florian Fainelly and
  7. * rb-diag.c (my own standalone driver for both LED and
  8. * button of Routerboard532).
  9. */
  10. #include <linux/leds.h>
  11. #include <linux/module.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/mach-rc32434/gpio.h>
  14. #include <asm/mach-rc32434/rb.h>
  15. static void rb532_led_set(struct led_classdev *cdev,
  16. enum led_brightness brightness)
  17. {
  18. if (brightness)
  19. set_latch_u5(LO_ULED, 0);
  20. else
  21. set_latch_u5(0, LO_ULED);
  22. }
  23. static enum led_brightness rb532_led_get(struct led_classdev *cdev)
  24. {
  25. return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF;
  26. }
  27. static struct led_classdev rb532_uled = {
  28. .name = "uled",
  29. .brightness_set = rb532_led_set,
  30. .brightness_get = rb532_led_get,
  31. .default_trigger = "nand-disk",
  32. };
  33. static int __devinit rb532_led_probe(struct platform_device *pdev)
  34. {
  35. return led_classdev_register(&pdev->dev, &rb532_uled);
  36. }
  37. static int __devexit rb532_led_remove(struct platform_device *pdev)
  38. {
  39. led_classdev_unregister(&rb532_uled);
  40. return 0;
  41. }
  42. static struct platform_driver rb532_led_driver = {
  43. .probe = rb532_led_probe,
  44. .remove = __devexit_p(rb532_led_remove),
  45. .driver = {
  46. .name = "rb532-led",
  47. .owner = THIS_MODULE,
  48. },
  49. };
  50. static int __init rb532_led_init(void)
  51. {
  52. return platform_driver_register(&rb532_led_driver);
  53. }
  54. static void __exit rb532_led_exit(void)
  55. {
  56. platform_driver_unregister(&rb532_led_driver);
  57. }
  58. module_init(rb532_led_init);
  59. module_exit(rb532_led_exit);
  60. MODULE_ALIAS("platform:rb532-led");
  61. MODULE_LICENSE("GPL");
  62. MODULE_DESCRIPTION("User LED support for Routerboard532");
  63. MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");