leds-lp5562.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Kernel driver for LP5562
  2. ========================
  3. * TI LP5562 LED Driver
  4. Author: Milo(Woogyom) Kim <milo.kim@ti.com>
  5. Description
  6. LP5562 can drive up to 4 channels. R/G/B and White.
  7. LEDs can be controlled directly via the led class control interface.
  8. All four channels can be also controlled using the engine micro programs.
  9. LP5562 has the internal program memory for running various LED patterns.
  10. For the details, please refer to 'firmware' section in leds-lp55xx.txt
  11. Device attribute: engine_mux
  12. 3 Engines are allocated in LP5562, but the number of channel is 4.
  13. Therefore each channel should be mapped to the engine number.
  14. Value : RGB or W
  15. This attribute is used for programming LED data with the firmware interface.
  16. Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
  17. so additional sysfs is required.
  18. LED Map
  19. Red ... Engine 1 (fixed)
  20. Green ... Engine 2 (fixed)
  21. Blue ... Engine 3 (fixed)
  22. White ... Engine 1 or 2 or 3 (selective)
  23. How to load the program data using engine_mux
  24. Before loading the LP5562 program data, engine_mux should be written between
  25. the engine selection and loading the firmware.
  26. Engine mux has two different mode, RGB and W.
  27. RGB is used for loading RGB program data, W is used for W program data.
  28. For example, run blinking green channel pattern,
  29. echo 2 > /sys/bus/i2c/devices/xxxx/select_engine # 2 is for green channel
  30. echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux # engine mux for RGB
  31. echo 1 > /sys/class/firmware/lp5562/loading
  32. echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
  33. echo 0 > /sys/class/firmware/lp5562/loading
  34. echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
  35. To run a blinking white pattern,
  36. echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
  37. echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
  38. echo 1 > /sys/class/firmware/lp5562/loading
  39. echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
  40. echo 0 > /sys/class/firmware/lp5562/loading
  41. echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
  42. How to load the predefined patterns
  43. Please refer to 'leds-lp55xx.txt"
  44. Setting Current of Each Channel
  45. Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
  46. The 'led_current' and 'max_current' are used.
  47. (Example of Platform data)
  48. To configure the platform specific data, lp55xx_platform_data structure is used.
  49. static struct lp55xx_led_config lp5562_led_config[] = {
  50. {
  51. .name = "R",
  52. .chan_nr = 0,
  53. .led_current = 20,
  54. .max_current = 40,
  55. },
  56. {
  57. .name = "G",
  58. .chan_nr = 1,
  59. .led_current = 20,
  60. .max_current = 40,
  61. },
  62. {
  63. .name = "B",
  64. .chan_nr = 2,
  65. .led_current = 20,
  66. .max_current = 40,
  67. },
  68. {
  69. .name = "W",
  70. .chan_nr = 3,
  71. .led_current = 20,
  72. .max_current = 40,
  73. },
  74. };
  75. static int lp5562_setup(void)
  76. {
  77. /* setup HW resources */
  78. }
  79. static void lp5562_release(void)
  80. {
  81. /* Release HW resources */
  82. }
  83. static void lp5562_enable(bool state)
  84. {
  85. /* Control of chip enable signal */
  86. }
  87. static struct lp55xx_platform_data lp5562_platform_data = {
  88. .led_config = lp5562_led_config,
  89. .num_channels = ARRAY_SIZE(lp5562_led_config),
  90. .setup_resources = lp5562_setup,
  91. .release_resources = lp5562_release,
  92. .enable = lp5562_enable,
  93. };
  94. If the current is set to 0 in the platform data, that channel is
  95. disabled and it is not visible in the sysfs.