leds-lp55xx.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. LP5521/LP5523/LP55231 Common Driver
  2. ===================================
  3. Authors: Milo(Woogyom) Kim <milo.kim@ti.com>
  4. Description
  5. -----------
  6. LP5521, LP5523/55231 have common features as below.
  7. Register access via the I2C
  8. Device initialization/deinitialization
  9. Create LED class devices for multiple output channels
  10. Device attributes for user-space interface
  11. Program memory for running LED patterns
  12. The LP55xx common driver provides these features using exported functions.
  13. lp55xx_init_device() / lp55xx_deinit_device()
  14. lp55xx_register_leds() / lp55xx_unregister_leds()
  15. lp55xx_regsister_sysfs() / lp55xx_unregister_sysfs()
  16. ( Driver Structure Data )
  17. In lp55xx common driver, two different data structure is used.
  18. o lp55xx_led
  19. control multi output LED channels such as led current, channel index.
  20. o lp55xx_chip
  21. general chip control such like the I2C and platform data.
  22. For example, LP5521 has maximum 3 LED channels.
  23. LP5523/55231 has 9 output channels.
  24. lp55xx_chip for LP5521 ... lp55xx_led #1
  25. lp55xx_led #2
  26. lp55xx_led #3
  27. lp55xx_chip for LP5523 ... lp55xx_led #1
  28. lp55xx_led #2
  29. .
  30. .
  31. lp55xx_led #9
  32. ( Chip Dependent Code )
  33. To support device specific configurations, special structure
  34. 'lpxx_device_config' is used.
  35. Maximum number of channels
  36. Reset command, chip enable command
  37. Chip specific initialization
  38. Brightness control register access
  39. Setting LED output current
  40. Program memory address access for running patterns
  41. Additional device specific attributes
  42. ( Firmware Interface )
  43. LP55xx family devices have the internal program memory for running
  44. various LED patterns.
  45. This pattern data is saved as a file in the user-land or
  46. hex byte string is written into the memory through the I2C.
  47. LP55xx common driver supports the firmware interface.
  48. LP55xx chips have three program engines.
  49. To load and run the pattern, the programming sequence is following.
  50. (1) Select an engine number (1/2/3)
  51. (2) Mode change to load
  52. (3) Write pattern data into selected area
  53. (4) Mode change to run
  54. The LP55xx common driver provides simple interfaces as below.
  55. select_engine : Select which engine is used for running program
  56. run_engine : Start program which is loaded via the firmware interface
  57. firmware : Load program data
  58. For example, run blinking pattern in engine #1 of LP5521
  59. echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
  60. echo 1 > /sys/class/firmware/lp5521/loading
  61. echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
  62. echo 0 > /sys/class/firmware/lp5521/loading
  63. echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
  64. For example, run blinking pattern in engine #3 of LP55231
  65. echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
  66. echo 1 > /sys/class/firmware/lp55231/loading
  67. echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
  68. echo 0 > /sys/class/firmware/lp55231/loading
  69. echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
  70. To start blinking patterns in engine #2 and #3 simultaneously,
  71. for idx in 2 3
  72. do
  73. echo $idx > /sys/class/leds/red/device/select_engine
  74. sleep 0.1
  75. echo 1 > /sys/class/firmware/lp5521/loading
  76. echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
  77. echo 0 > /sys/class/firmware/lp5521/loading
  78. done
  79. echo 1 > /sys/class/leds/red/device/run_engine
  80. Here is another example for LP5523.
  81. echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
  82. echo 1 > /sys/class/firmware/lp5523/loading
  83. echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
  84. echo 0 > /sys/class/firmware/lp5523/loading
  85. echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
  86. As soon as 'loading' is set to 0, registered callback is called.
  87. Inside the callback, the selected engine is loaded and memory is updated.
  88. To run programmed pattern, 'run_engine' attribute should be enabled.
  89. ( 'run_engine' and 'firmware_cb' )
  90. The sequence of running the program data is common.
  91. But each device has own specific register addresses for commands.
  92. To support this, 'run_engine' and 'firmware_cb' are configurable in each driver.
  93. run_engine : Control the selected engine
  94. firmware_cb : The callback function after loading the firmware is done.
  95. Chip specific commands for loading and updating program memory.