leds-rb532.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 rb532_led_probe(struct platform_device *pdev)
  34. {
  35. return led_classdev_register(&pdev->dev, &rb532_uled);
  36. }
  37. static int 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 = rb532_led_remove,
  45. .driver = {
  46. .name = "rb532-led",
  47. },
  48. };
  49. module_platform_driver(rb532_led_driver);
  50. MODULE_LICENSE("GPL");
  51. MODULE_DESCRIPTION("User LED support for Routerboard532");
  52. MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>");
  53. MODULE_ALIAS("platform:rb532-led");