leds-hp6xx.c 1.9 KB

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