leds-hp6xx.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/leds.h>
  17. #include <asm/hd64461.h>
  18. #include <mach/hp6xx.h>
  19. static void hp6xxled_green_set(struct led_classdev *led_cdev,
  20. enum led_brightness value)
  21. {
  22. u8 v8;
  23. v8 = inb(PKDR);
  24. if (value)
  25. outb(v8 & (~PKDR_LED_GREEN), PKDR);
  26. else
  27. outb(v8 | PKDR_LED_GREEN, PKDR);
  28. }
  29. static void hp6xxled_red_set(struct led_classdev *led_cdev,
  30. enum led_brightness value)
  31. {
  32. u16 v16;
  33. v16 = inw(HD64461_GPBDR);
  34. if (value)
  35. outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
  36. else
  37. outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
  38. }
  39. static struct led_classdev hp6xx_red_led = {
  40. .name = "hp6xx:red",
  41. .default_trigger = "hp6xx-charge",
  42. .brightness_set = hp6xxled_red_set,
  43. .flags = LED_CORE_SUSPENDRESUME,
  44. };
  45. static struct led_classdev hp6xx_green_led = {
  46. .name = "hp6xx:green",
  47. .default_trigger = "ide-disk",
  48. .brightness_set = hp6xxled_green_set,
  49. .flags = LED_CORE_SUSPENDRESUME,
  50. };
  51. static int hp6xxled_probe(struct platform_device *pdev)
  52. {
  53. int ret;
  54. ret = led_classdev_register(&pdev->dev, &hp6xx_red_led);
  55. if (ret < 0)
  56. return ret;
  57. ret = led_classdev_register(&pdev->dev, &hp6xx_green_led);
  58. if (ret < 0)
  59. led_classdev_unregister(&hp6xx_red_led);
  60. return ret;
  61. }
  62. static int hp6xxled_remove(struct platform_device *pdev)
  63. {
  64. led_classdev_unregister(&hp6xx_red_led);
  65. led_classdev_unregister(&hp6xx_green_led);
  66. return 0;
  67. }
  68. static struct platform_driver hp6xxled_driver = {
  69. .probe = hp6xxled_probe,
  70. .remove = hp6xxled_remove,
  71. .driver = {
  72. .name = "hp6xx-led",
  73. .owner = THIS_MODULE,
  74. },
  75. };
  76. module_platform_driver(hp6xxled_driver);
  77. MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
  78. MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
  79. MODULE_LICENSE("GPL");
  80. MODULE_ALIAS("platform:hp6xx-led");