leds-lp5521.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Kernel driver for lp5521
  2. ========================
  3. * National Semiconductor LP5521 led driver chip
  4. * Datasheet: http://www.national.com/pf/LP/LP5521.html
  5. Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
  6. Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
  7. Description
  8. -----------
  9. LP5521 can drive up to 3 channels. Leds can be controlled directly via
  10. the led class control interface. Channels have generic names:
  11. lp5521:channelx, where x is 0 .. 2
  12. All three channels can be also controlled using the engine micro programs.
  13. More details of the instructions can be found from the public data sheet.
  14. Control interface for the engines:
  15. x is 1 .. 3
  16. enginex_mode : disabled, load, run
  17. enginex_load : store program (visible only in engine load mode)
  18. Example (start to blink the channel 2 led):
  19. cd /sys/class/leds/lp5521:channel2/device
  20. echo "load" > engine3_mode
  21. echo "037f4d0003ff6000" > engine3_load
  22. echo "run" > engine3_mode
  23. stop the engine:
  24. echo "disabled" > engine3_mode
  25. sysfs contains a selftest entry.
  26. The test communicates with the chip and checks that
  27. the clock mode is automatically set to the requested one.
  28. Each channel has its own led current settings.
  29. /sys/class/leds/lp5521:channel0/led_current - RW
  30. /sys/class/leds/lp5521:channel0/max_current - RO
  31. Format: 10x mA i.e 10 means 1.0 mA
  32. example platform data:
  33. Note: chan_nr can have values between 0 and 2.
  34. static struct lp5521_led_config lp5521_led_config[] = {
  35. {
  36. .chan_nr = 0,
  37. .led_current = 50,
  38. .max_current = 130,
  39. }, {
  40. .chan_nr = 1,
  41. .led_current = 0,
  42. .max_current = 130,
  43. }, {
  44. .chan_nr = 2,
  45. .led_current = 0,
  46. .max_current = 130,
  47. }
  48. };
  49. static int lp5521_setup(void)
  50. {
  51. /* setup HW resources */
  52. }
  53. static void lp5521_release(void)
  54. {
  55. /* Release HW resources */
  56. }
  57. static void lp5521_enable(bool state)
  58. {
  59. /* Control of chip enable signal */
  60. }
  61. static struct lp5521_platform_data lp5521_platform_data = {
  62. .led_config = lp5521_led_config,
  63. .num_channels = ARRAY_SIZE(lp5521_led_config),
  64. .clock_mode = LP5521_CLOCK_EXT,
  65. .setup_resources = lp5521_setup,
  66. .release_resources = lp5521_release,
  67. .enable = lp5521_enable,
  68. };
  69. If the current is set to 0 in the platform data, that channel is
  70. disabled and it is not visible in the sysfs.