led-lm3530.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (C) 2011 ST-Ericsson SA.
  3. * Copyright (C) 2009 Motorola, Inc.
  4. *
  5. * License Terms: GNU General Public License v2
  6. *
  7. * Simple driver for National Semiconductor LM35330 Backlight driver chip
  8. *
  9. * Author: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com>
  10. * based on leds-lm3530.c by Dan Murphy <D.Murphy@motorola.com>
  11. */
  12. #ifndef _LINUX_LED_LM3530_H__
  13. #define _LINUX_LED_LM3530_H__
  14. #define LM3530_FS_CURR_5mA (0) /* Full Scale Current */
  15. #define LM3530_FS_CURR_8mA (1)
  16. #define LM3530_FS_CURR_12mA (2)
  17. #define LM3530_FS_CURR_15mA (3)
  18. #define LM3530_FS_CURR_19mA (4)
  19. #define LM3530_FS_CURR_22mA (5)
  20. #define LM3530_FS_CURR_26mA (6)
  21. #define LM3530_FS_CURR_29mA (7)
  22. #define LM3530_ALS_AVRG_TIME_32ms (0) /* ALS Averaging Time */
  23. #define LM3530_ALS_AVRG_TIME_64ms (1)
  24. #define LM3530_ALS_AVRG_TIME_128ms (2)
  25. #define LM3530_ALS_AVRG_TIME_256ms (3)
  26. #define LM3530_ALS_AVRG_TIME_512ms (4)
  27. #define LM3530_ALS_AVRG_TIME_1024ms (5)
  28. #define LM3530_ALS_AVRG_TIME_2048ms (6)
  29. #define LM3530_ALS_AVRG_TIME_4096ms (7)
  30. #define LM3530_RAMP_TIME_1ms (0) /* Brigtness Ramp Time */
  31. #define LM3530_RAMP_TIME_130ms (1) /* Max to 0 and vice versa */
  32. #define LM3530_RAMP_TIME_260ms (2)
  33. #define LM3530_RAMP_TIME_520ms (3)
  34. #define LM3530_RAMP_TIME_1s (4)
  35. #define LM3530_RAMP_TIME_2s (5)
  36. #define LM3530_RAMP_TIME_4s (6)
  37. #define LM3530_RAMP_TIME_8s (7)
  38. /* ALS Resistor Select */
  39. #define LM3530_ALS_IMPD_Z (0x00) /* ALS Impedance */
  40. #define LM3530_ALS_IMPD_13_53kOhm (0x01)
  41. #define LM3530_ALS_IMPD_9_01kOhm (0x02)
  42. #define LM3530_ALS_IMPD_5_41kOhm (0x03)
  43. #define LM3530_ALS_IMPD_2_27kOhm (0x04)
  44. #define LM3530_ALS_IMPD_1_94kOhm (0x05)
  45. #define LM3530_ALS_IMPD_1_81kOhm (0x06)
  46. #define LM3530_ALS_IMPD_1_6kOhm (0x07)
  47. #define LM3530_ALS_IMPD_1_138kOhm (0x08)
  48. #define LM3530_ALS_IMPD_1_05kOhm (0x09)
  49. #define LM3530_ALS_IMPD_1_011kOhm (0x0A)
  50. #define LM3530_ALS_IMPD_941Ohm (0x0B)
  51. #define LM3530_ALS_IMPD_759Ohm (0x0C)
  52. #define LM3530_ALS_IMPD_719Ohm (0x0D)
  53. #define LM3530_ALS_IMPD_700Ohm (0x0E)
  54. #define LM3530_ALS_IMPD_667Ohm (0x0F)
  55. enum lm3530_mode {
  56. LM3530_BL_MODE_MANUAL = 0, /* "man" */
  57. LM3530_BL_MODE_ALS, /* "als" */
  58. LM3530_BL_MODE_PWM, /* "pwm" */
  59. };
  60. /* ALS input select */
  61. enum lm3530_als_mode {
  62. LM3530_INPUT_AVRG = 0, /* ALS1 and ALS2 input average */
  63. LM3530_INPUT_ALS1, /* ALS1 Input */
  64. LM3530_INPUT_ALS2, /* ALS2 Input */
  65. LM3530_INPUT_CEIL, /* Max of ALS1 and ALS2 */
  66. };
  67. /* PWM Platform Specific Data */
  68. struct lm3530_pwm_data {
  69. void (*pwm_set_intensity) (int brightness, int max_brightness);
  70. int (*pwm_get_intensity) (int max_brightness);
  71. };
  72. /**
  73. * struct lm3530_platform_data
  74. * @mode: mode of operation i.e. Manual, ALS or PWM
  75. * @als_input_mode: select source of ALS input - ALS1/2 or average
  76. * @max_current: full scale LED current
  77. * @pwm_pol_hi: PWM input polarity - active high/active low
  78. * @als_avrg_time: ALS input averaging time
  79. * @brt_ramp_law: brightness mapping mode - exponential/linear
  80. * @brt_ramp_fall: rate of fall of led current
  81. * @brt_ramp_rise: rate of rise of led current
  82. * @als1_resistor_sel: internal resistance from ALS1 input to ground
  83. * @als2_resistor_sel: internal resistance from ALS2 input to ground
  84. * @als_vmin: als input voltage calibrated for max brightness in mV
  85. * @als_vmax: als input voltage calibrated for min brightness in mV
  86. * @brt_val: brightness value (0-127)
  87. * @pwm_data: PWM control functions (only valid when the mode is PWM)
  88. */
  89. struct lm3530_platform_data {
  90. enum lm3530_mode mode;
  91. enum lm3530_als_mode als_input_mode;
  92. u8 max_current;
  93. bool pwm_pol_hi;
  94. u8 als_avrg_time;
  95. bool brt_ramp_law;
  96. u8 brt_ramp_fall;
  97. u8 brt_ramp_rise;
  98. u8 als1_resistor_sel;
  99. u8 als2_resistor_sel;
  100. u32 als_vmin;
  101. u32 als_vmax;
  102. u8 brt_val;
  103. struct lm3530_pwm_data pwm_data;
  104. };
  105. #endif /* _LINUX_LED_LM3530_H__ */