leds-sead3.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
  7. * Copyright (C) 2015 Imagination Technologies, Inc.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/leds.h>
  14. #include <linux/err.h>
  15. #include <linux/io.h>
  16. #include <asm/mips-boards/sead3-addr.h>
  17. static void sead3_pled_set(struct led_classdev *led_cdev,
  18. enum led_brightness value)
  19. {
  20. writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
  21. }
  22. static void sead3_fled_set(struct led_classdev *led_cdev,
  23. enum led_brightness value)
  24. {
  25. writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
  26. }
  27. static struct led_classdev sead3_pled = {
  28. .name = "sead3::pled",
  29. .brightness_set = sead3_pled_set,
  30. .flags = LED_CORE_SUSPENDRESUME,
  31. };
  32. static struct led_classdev sead3_fled = {
  33. .name = "sead3::fled",
  34. .brightness_set = sead3_fled_set,
  35. .flags = LED_CORE_SUSPENDRESUME,
  36. };
  37. static int sead3_led_probe(struct platform_device *pdev)
  38. {
  39. int ret;
  40. ret = led_classdev_register(&pdev->dev, &sead3_pled);
  41. if (ret < 0)
  42. return ret;
  43. ret = led_classdev_register(&pdev->dev, &sead3_fled);
  44. if (ret < 0)
  45. led_classdev_unregister(&sead3_pled);
  46. return ret;
  47. }
  48. static int sead3_led_remove(struct platform_device *pdev)
  49. {
  50. led_classdev_unregister(&sead3_pled);
  51. led_classdev_unregister(&sead3_fled);
  52. return 0;
  53. }
  54. static struct platform_driver sead3_led_driver = {
  55. .probe = sead3_led_probe,
  56. .remove = sead3_led_remove,
  57. .driver = {
  58. .name = "sead3-led",
  59. },
  60. };
  61. module_platform_driver(sead3_led_driver);
  62. MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
  63. MODULE_DESCRIPTION("SEAD3 LED driver");
  64. MODULE_LICENSE("GPL");