leds-s2mpb02.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * leds-S2MPB02.h - Flash-led driver for Samsung S2MPB02
  3. *
  4. * Copyright (C) 2014 Samsung Electronics
  5. * XXX <[email protected]>
  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. * This driver is based on leds-max77804.h
  12. */
  13. #ifndef __LEDS_S2MPB02_H__
  14. #define __LEDS_S2MPB02_H__
  15. #define S2MPB02_FLED_CHANNEL_1 /* GPIOs connected to FLASH_EN1, TORCH_EN1 */
  16. //#define S2MPB02_FLED_CHANNEL_2 /* GPIOs connected to FLASH_EN2, TORCH_EN2 */
  17. //#define S2MPB02_FLED_CONTROLED_BY_GPIO 1
  18. #define S2MPB02_FLASH_TORCH_CURRENT_MAX 0xF
  19. #define S2MPB02_TIMEOUT_MAX 0xF
  20. /* S2MPB02_LV_SEL_VOUT */
  21. #define S2MPB02_LV_SEL_VOUT_MASK 0x07
  22. #define S2MPB02_LV_SEL_VOLT(mV) \
  23. ((mV) <= 2700 ? 0x00 : \
  24. ((mV) <= 3400 ? ((mV) - 2700) / 100 : 0x07))
  25. #define S2MPB02_FLASH_MASK 0xF0
  26. #define S2MPB02_TORCH_MASK 0x0F
  27. #define S2MPB02_FLED_ENABLE 1
  28. #define S2MPB02_FLED_DISABLE 0
  29. #define S2MPB02_FLED_ENABLE_SHIFT 7
  30. #define S2MPB02_FLED_FLASH_MODE 0
  31. #define S2MPB02_FLED_TORCH_MODE 1
  32. #define S2MPB02_FLED_MODE_SHIFT 6
  33. /* S2MPB02_LV_EN */
  34. #define S2MPB02_FLED_CTRL1_LV_EN_MASK 0x08
  35. #define S2MPB02_FLED_CTRL1_LV_ENABLE 1
  36. #define S2MPB02_FLED_CTRL1_LV_DISABLE 0
  37. #define S2MPB02_FLED_ENABLE_MODE_MASK 0xC0
  38. #define S2MPB02_FLED2_MAX_TIME_MASK 0x1F
  39. #define S2MPB02_FLED2_MAX_TIME_CLEAR_MASK 0x04
  40. #define S2MPB02_FLED2_MAX_TIME_EN_MASK 0x01
  41. #define S2MPB02_FLED2_IRON2_MASK 0xC0
  42. #define S2MPB02_FLASH_STEP_MA 100
  43. #define S2MPB02_TORCH_STEP_MA 20
  44. enum s2mpb02_led_id {
  45. S2MPB02_FLASH_LED_1,
  46. S2MPB02_TORCH_LED_1,
  47. S2MPB02_LED_MAX,
  48. };
  49. enum s2mpb02_flash_current {
  50. S2MPB02_FLASH_OUT_I_100MA = 1,
  51. S2MPB02_FLASH_OUT_I_200MA,
  52. S2MPB02_FLASH_OUT_I_300MA,
  53. S2MPB02_FLASH_OUT_I_400MA,
  54. S2MPB02_FLASH_OUT_I_500MA,
  55. S2MPB02_FLASH_OUT_I_600MA,
  56. S2MPB02_FLASH_OUT_I_700MA,
  57. S2MPB02_FLASH_OUT_I_800MA,
  58. S2MPB02_FLASH_OUT_I_900MA,
  59. S2MPB02_FLASH_OUT_I_1000MA,
  60. S2MPB02_FLASH_OUT_I_1100MA,
  61. S2MPB02_FLASH_OUT_I_1200MA,
  62. S2MPB02_FLASH_OUT_I_1300MA,
  63. S2MPB02_FLASH_OUT_I_1400MA,
  64. S2MPB02_FLASH_OUT_I_1500MA,
  65. S2MPB02_FLASH_OUT_I_MAX,
  66. };
  67. enum s2mpb02_torch_current {
  68. S2MPB02_TORCH_OUT_I_20MA = 1,
  69. S2MPB02_TORCH_OUT_I_40MA,
  70. S2MPB02_TORCH_OUT_I_60MA,
  71. S2MPB02_TORCH_OUT_I_80MA,
  72. S2MPB02_TORCH_OUT_I_100MA,
  73. S2MPB02_TORCH_OUT_I_120MA,
  74. S2MPB02_TORCH_OUT_I_140MA,
  75. S2MPB02_TORCH_OUT_I_160MA,
  76. S2MPB02_TORCH_OUT_I_180MA,
  77. S2MPB02_TORCH_OUT_I_200MA,
  78. S2MPB02_TORCH_OUT_I_220MA,
  79. S2MPB02_TORCH_OUT_I_240MA,
  80. S2MPB02_TORCH_OUT_I_260MA,
  81. S2MPB02_TORCH_OUT_I_280MA,
  82. S2MPB02_TORCH_OUT_I_300MA,
  83. S2MPB02_TORCH_OUT_I_MAX,
  84. };
  85. enum s2mpb02_flash_timeout {
  86. S2MPB02_FLASH_TIMEOUT_62P5MS,
  87. S2MPB02_FLASH_TIMEOUT_125MS,
  88. S2MPB02_FLASH_TIMEOUT_187P5MS,
  89. S2MPB02_FLASH_TIMEOUT_250MS,
  90. S2MPB02_FLASH_TIMEOUT_312P5MS,
  91. S2MPB02_FLASH_TIMEOUT_375MS,
  92. S2MPB02_FLASH_TIMEOUT_437P5MS,
  93. S2MPB02_FLASH_TIMEOUT_500MS,
  94. S2MPB02_FLASH_TIMEOUT_562P5MS,
  95. S2MPB02_FLASH_TIMEOUT_625MS,
  96. S2MPB02_FLASH_TIMEOUT_687P5MS,
  97. S2MPB02_FLASH_TIMEOUT_750MS,
  98. S2MPB02_FLASH_TIMEOUT_812P5MS,
  99. S2MPB02_FLASH_TIMEOUT_875MS,
  100. S2MPB02_FLASH_TIMEOUT_937P5MS,
  101. S2MPB02_FLASH_TIMEOUT_1000MS,
  102. S2MPB02_FLASH_TIMEOUT_MAX,
  103. };
  104. enum s2mpb02_torch_timeout {
  105. S2MPB02_TORCH_TIMEOUT_1S,
  106. S2MPB02_TORCH_TIMEOUT_2S,
  107. S2MPB02_TORCH_TIMEOUT_3S,
  108. S2MPB02_TORCH_TIMEOUT_4S,
  109. S2MPB02_TORCH_TIMEOUT_5S,
  110. S2MPB02_TORCH_TIMEOUT_6S,
  111. S2MPB02_TORCH_TIMEOUT_7S,
  112. S2MPB02_TORCH_TIMEOUT_8S,
  113. S2MPB02_TORCH_TIMEOUT_9S,
  114. S2MPB02_TORCH_TIMEOUT_10S,
  115. S2MPB02_TORCH_TIMEOUT_11S,
  116. S2MPB02_TORCH_TIMEOUT_12S,
  117. S2MPB02_TORCH_TIMEOUT_13S,
  118. S2MPB02_TORCH_TIMEOUT_14S,
  119. S2MPB02_TORCH_TIMEOUT_15S,
  120. S2MPB02_TORCH_TIMEOUT_16S,
  121. S2MPB02_TORCH_TIMEOUT_MAX,
  122. };
  123. enum s2mpb02_led_turn_way {
  124. S2MPB02_LED_TURN_WAY_I2C,
  125. S2MPB02_LED_TURN_WAY_GPIO,
  126. S2MPB02_LED_TURN_WAY_MAX,
  127. };
  128. struct s2mpb02_led {
  129. const char *name;
  130. int id;
  131. int brightness;
  132. int timeout;
  133. const char *default_trigger; /* Trigger to use */
  134. uint32_t gpio;
  135. };
  136. struct s2mpb02_led_platform_data {
  137. int num_leds;
  138. struct s2mpb02_led leds[S2MPB02_LED_MAX];
  139. };
  140. extern int s2mpb02_led_en(int mode, int onoff, enum s2mpb02_led_turn_way turn_way);
  141. extern ssize_t s2mpb02_store(const char *buf);
  142. extern ssize_t s2mpb02_show(char *buf);
  143. #if defined(CONFIG_SAMSUNG_SECURE_CAMERA)
  144. extern int s2mpb02_ir_led_init(void);
  145. extern int s2mpb02_ir_led_current(int32_t current_value);
  146. extern int s2mpb02_ir_led_pulse_width(int32_t width);
  147. extern int s2mpb02_ir_led_pulse_delay(int32_t delay);
  148. extern int s2mpb02_ir_led_max_time(int32_t max_time);
  149. #endif
  150. #endif