leds-hp6xx.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * LED Triggers Core
  4. * For the HP Jornada 620/660/680/690 handhelds
  5. *
  6. * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
  7. * this driver is based on leds-spitz.c by Richard Purdie.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/leds.h>
  13. #include <asm/hd64461.h>
  14. #include <mach/hp6xx.h>
  15. static void hp6xxled_green_set(struct led_classdev *led_cdev,
  16. enum led_brightness value)
  17. {
  18. u8 v8;
  19. v8 = inb(PKDR);
  20. if (value)
  21. outb(v8 & (~PKDR_LED_GREEN), PKDR);
  22. else
  23. outb(v8 | PKDR_LED_GREEN, PKDR);
  24. }
  25. static void hp6xxled_red_set(struct led_classdev *led_cdev,
  26. enum led_brightness value)
  27. {
  28. u16 v16;
  29. v16 = inw(HD64461_GPBDR);
  30. if (value)
  31. outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
  32. else
  33. outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
  34. }
  35. static struct led_classdev hp6xx_red_led = {
  36. .name = "hp6xx:red",
  37. .default_trigger = "hp6xx-charge",
  38. .brightness_set = hp6xxled_red_set,
  39. .flags = LED_CORE_SUSPENDRESUME,
  40. };
  41. static struct led_classdev hp6xx_green_led = {
  42. .name = "hp6xx:green",
  43. .default_trigger = "disk-activity",
  44. .brightness_set = hp6xxled_green_set,
  45. .flags = LED_CORE_SUSPENDRESUME,
  46. };
  47. static int hp6xxled_probe(struct platform_device *pdev)
  48. {
  49. int ret;
  50. ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
  51. if (ret < 0)
  52. return ret;
  53. return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
  54. }
  55. static struct platform_driver hp6xxled_driver = {
  56. .probe = hp6xxled_probe,
  57. .driver = {
  58. .name = "hp6xx-led",
  59. },
  60. };
  61. module_platform_driver(hp6xxled_driver);
  62. MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
  63. MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
  64. MODULE_LICENSE("GPL");
  65. MODULE_ALIAS("platform:hp6xx-led");