leds-lp5521.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. LP5521 has the internal program memory for running various LED patterns.
  15. There are two ways to run LED patterns.
  16. 1) Legacy interface - enginex_mode and enginex_load
  17. Control interface for the engines:
  18. x is 1 .. 3
  19. enginex_mode : disabled, load, run
  20. enginex_load : store program (visible only in engine load mode)
  21. Example (start to blink the channel 2 led):
  22. cd /sys/class/leds/lp5521:channel2/device
  23. echo "load" > engine3_mode
  24. echo "037f4d0003ff6000" > engine3_load
  25. echo "run" > engine3_mode
  26. To stop the engine:
  27. echo "disabled" > engine3_mode
  28. 2) Firmware interface - LP55xx common interface
  29. For the details, please refer to 'firmware' section in leds-lp55xx.txt
  30. sysfs contains a selftest entry.
  31. The test communicates with the chip and checks that
  32. the clock mode is automatically set to the requested one.
  33. Each channel has its own led current settings.
  34. /sys/class/leds/lp5521:channel0/led_current - RW
  35. /sys/class/leds/lp5521:channel0/max_current - RO
  36. Format: 10x mA i.e 10 means 1.0 mA
  37. example platform data:
  38. Note: chan_nr can have values between 0 and 2.
  39. The name of each channel can be configurable.
  40. If the name field is not defined, the default name will be set to 'xxxx:channelN'
  41. (XXXX : pdata->label or i2c client name, N : channel number)
  42. static struct lp55xx_led_config lp5521_led_config[] = {
  43. {
  44. .name = "red",
  45. .chan_nr = 0,
  46. .led_current = 50,
  47. .max_current = 130,
  48. }, {
  49. .name = "green",
  50. .chan_nr = 1,
  51. .led_current = 0,
  52. .max_current = 130,
  53. }, {
  54. .name = "blue",
  55. .chan_nr = 2,
  56. .led_current = 0,
  57. .max_current = 130,
  58. }
  59. };
  60. static int lp5521_setup(void)
  61. {
  62. /* setup HW resources */
  63. }
  64. static void lp5521_release(void)
  65. {
  66. /* Release HW resources */
  67. }
  68. static void lp5521_enable(bool state)
  69. {
  70. /* Control of chip enable signal */
  71. }
  72. static struct lp55xx_platform_data lp5521_platform_data = {
  73. .led_config = lp5521_led_config,
  74. .num_channels = ARRAY_SIZE(lp5521_led_config),
  75. .clock_mode = LP55XX_CLOCK_EXT,
  76. .setup_resources = lp5521_setup,
  77. .release_resources = lp5521_release,
  78. .enable = lp5521_enable,
  79. };
  80. If the current is set to 0 in the platform data, that channel is
  81. disabled and it is not visible in the sysfs.