leds-lp3952.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * LED driver for TI lp3952 controller
  3. *
  4. * Copyright (C) 2016, DAQRI, LLC.
  5. * Author: Tony Makkiel <tony.makkiel@daqri.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #ifndef LEDS_LP3952_H_
  13. #define LEDS_LP3952_H_
  14. #define LP3952_NAME "lp3952"
  15. #define LP3952_CMD_REG_COUNT 8
  16. #define LP3952_BRIGHT_MAX 4
  17. #define LP3952_LABEL_MAX_LEN 15
  18. #define LP3952_REG_LED_CTRL 0x00
  19. #define LP3952_REG_R1_BLNK_TIME_CTRL 0x01
  20. #define LP3952_REG_R1_BLNK_CYCLE_CTRL 0x02
  21. #define LP3952_REG_G1_BLNK_TIME_CTRL 0x03
  22. #define LP3952_REG_G1_BLNK_CYCLE_CTRL 0x04
  23. #define LP3952_REG_B1_BLNK_TIME_CTRL 0x05
  24. #define LP3952_REG_B1_BLNK_CYCLE_CTRL 0x06
  25. #define LP3952_REG_ENABLES 0x0B
  26. #define LP3952_REG_PAT_GEN_CTRL 0x11
  27. #define LP3952_REG_RGB1_MAX_I_CTRL 0x12
  28. #define LP3952_REG_RGB2_MAX_I_CTRL 0x13
  29. #define LP3952_REG_CMD_0 0x50
  30. #define LP3952_REG_RESET 0x60
  31. #define REG_MAX LP3952_REG_RESET
  32. #define LP3952_PATRN_LOOP BIT(1)
  33. #define LP3952_PATRN_GEN_EN BIT(2)
  34. #define LP3952_INT_B00ST_LDR BIT(2)
  35. #define LP3952_ACTIVE_MODE BIT(6)
  36. #define LP3952_LED_MASK_ALL 0x3f
  37. /* Transition Time in ms */
  38. enum lp3952_tt {
  39. TT0,
  40. TT55,
  41. TT110,
  42. TT221,
  43. TT422,
  44. TT885,
  45. TT1770,
  46. TT3539
  47. };
  48. /* Command Execution Time in ms */
  49. enum lp3952_cet {
  50. CET197,
  51. CET393,
  52. CET590,
  53. CET786,
  54. CET1180,
  55. CET1376,
  56. CET1573,
  57. CET1769,
  58. CET1966,
  59. CET2163,
  60. CET2359,
  61. CET2556,
  62. CET2763,
  63. CET2949,
  64. CET3146
  65. };
  66. /* Max Current in % */
  67. enum lp3952_colour_I_log_0 {
  68. I0,
  69. I7,
  70. I14,
  71. I21,
  72. I32,
  73. I46,
  74. I71,
  75. I100
  76. };
  77. enum lp3952_leds {
  78. LP3952_BLUE_2,
  79. LP3952_GREEN_2,
  80. LP3952_RED_2,
  81. LP3952_BLUE_1,
  82. LP3952_GREEN_1,
  83. LP3952_RED_1,
  84. LP3952_LED_ALL
  85. };
  86. struct lp3952_ctrl_hdl {
  87. struct led_classdev cdev;
  88. char name[LP3952_LABEL_MAX_LEN];
  89. enum lp3952_leds channel;
  90. void *priv;
  91. };
  92. struct ptrn_gen_cmd {
  93. union {
  94. struct {
  95. u16 tt:3;
  96. u16 b:3;
  97. u16 cet:4;
  98. u16 g:3;
  99. u16 r:3;
  100. };
  101. struct {
  102. u8 lsb;
  103. u8 msb;
  104. } bytes;
  105. };
  106. } __packed;
  107. struct lp3952_led_array {
  108. struct regmap *regmap;
  109. struct i2c_client *client;
  110. struct gpio_desc *enable_gpio;
  111. struct lp3952_ctrl_hdl leds[LP3952_LED_ALL];
  112. };
  113. #endif /* LEDS_LP3952_H_ */