leds-pm8xxx.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __LEDS_PM8XXX_H__
  13. #define __LEDS_PM8XXX_H__
  14. #include <linux/kernel.h>
  15. #include <linux/mfd/pm8xxx/pwm.h>
  16. #define PM8XXX_LEDS_DEV_NAME "pm8xxx-led"
  17. #define WLED_FIRST_STRING (1 << 2)
  18. #define WLED_SECOND_STRING (1 << 1)
  19. #define WLED_THIRD_STRING (1 << 0)
  20. /**
  21. * enum pm8xxx_leds - PMIC8XXX supported led ids
  22. * @PM8XXX_ID_LED_KB_LIGHT - keyboard backlight led
  23. * @PM8XXX_ID_LED_0 - First low current led
  24. * @PM8XXX_ID_LED_1 - Second low current led
  25. * @PM8XXX_ID_LED_2 - Third low current led
  26. * @PM8XXX_ID_FLASH_LED_0 - First flash led
  27. * @PM8XXX_ID_FLASH_LED_0 - Second flash led
  28. */
  29. enum pm8xxx_leds {
  30. PM8XXX_ID_LED_KB_LIGHT = 1,
  31. PM8XXX_ID_LED_0,
  32. PM8XXX_ID_LED_1,
  33. PM8XXX_ID_LED_2,
  34. PM8XXX_ID_FLASH_LED_0,
  35. PM8XXX_ID_FLASH_LED_1,
  36. PM8XXX_ID_WLED,
  37. PM8XXX_ID_RGB_LED_RED,
  38. PM8XXX_ID_RGB_LED_GREEN,
  39. PM8XXX_ID_RGB_LED_BLUE,
  40. PM8XXX_ID_MAX,
  41. };
  42. /**
  43. * pm8xxx_led_modes - Operating modes of LEDs
  44. */
  45. enum pm8xxx_led_modes {
  46. PM8XXX_LED_MODE_MANUAL,
  47. PM8XXX_LED_MODE_PWM1,
  48. PM8XXX_LED_MODE_PWM2,
  49. PM8XXX_LED_MODE_PWM3,
  50. PM8XXX_LED_MODE_DTEST1,
  51. PM8XXX_LED_MODE_DTEST2,
  52. PM8XXX_LED_MODE_DTEST3,
  53. PM8XXX_LED_MODE_DTEST4
  54. };
  55. /* current boost limit */
  56. enum wled_current_bost_limit {
  57. WLED_CURR_LIMIT_105mA,
  58. WLED_CURR_LIMIT_385mA,
  59. WLED_CURR_LIMIT_525mA,
  60. WLED_CURR_LIMIT_805mA,
  61. WLED_CURR_LIMIT_980mA,
  62. WLED_CURR_LIMIT_1260mA,
  63. WLED_CURR_LIMIT_1400mA,
  64. WLED_CURR_LIMIT_1680mA,
  65. };
  66. /* over voltage protection threshold */
  67. enum wled_ovp_threshold {
  68. WLED_OVP_35V,
  69. WLED_OVP_32V,
  70. WLED_OVP_29V,
  71. WLED_OVP_37V,
  72. };
  73. /**
  74. * wled_config_data - wled configuration data
  75. * @strings - strings supported
  76. * @ovp_val - over voltage protection threshold
  77. * @boost_curr_lim - boot current limit
  78. * @cp_select - high pole capacitance
  79. * @ctrl_delay_us - delay in activation of led
  80. * @dig_mod_gen_en - digital module generator
  81. * @cs_out_en - current sink output enable
  82. * @op_fdbck - selection of output as feedback for the boost
  83. * @cabc_en - enable cabc for backlight pwm control
  84. *
  85. */
  86. struct wled_config_data {
  87. u8 strings;
  88. u8 ovp_val;
  89. u8 boost_curr_lim;
  90. u8 cp_select;
  91. u8 ctrl_delay_us;
  92. bool dig_mod_gen_en;
  93. bool cs_out_en;
  94. bool op_fdbck;
  95. bool cabc_en;
  96. bool sstart_en;
  97. bool max_current_ind;
  98. u8 max_three;
  99. u8 max_two;
  100. u8 max_one;
  101. };
  102. /**
  103. * pm8xxx_led_config - led configuration parameters
  104. * @id - LED id
  105. * @mode - LED mode
  106. * @max_current - maximum current that LED can sustain
  107. * @pwm_channel - PWM channel ID the LED is driven to
  108. * @pwm_period_us - PWM period value in micro seconds
  109. * @default_state - default state of the led
  110. * @pwm_duty_cycles - PWM duty cycle information
  111. */
  112. struct pm8xxx_led_config {
  113. u8 id;
  114. u8 mode;
  115. u16 max_current;
  116. int pwm_channel;
  117. u32 pwm_period_us;
  118. bool default_state;
  119. struct pm8xxx_pwm_duty_cycles *pwm_duty_cycles;
  120. struct wled_config_data *wled_cfg;
  121. };
  122. /**
  123. * pm8xxx_led_platform_data - platform data for LED
  124. * @led_core - array of LEDs. Each datum in array contains
  125. * core data for the LED
  126. * @configs - array of platform configuration parameters
  127. * for each LED. It maps one-to-one with
  128. * array of LEDs
  129. * @num_configs - count of members of configs array
  130. */
  131. struct pm8xxx_led_platform_data {
  132. struct led_platform_data *led_core;
  133. struct pm8xxx_led_config *configs;
  134. u32 num_configs;
  135. };
  136. #endif /* __LEDS_PM8XXX_H__ */