leds-rb532.c 1.5 KB

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