leds-max77803.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * leds-max77803.h - Flash-led driver for Maxim MAX77803
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * ByungChang Cha <bc.cha@samsung.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. #ifndef __LEDS_MAX77803_H__
  12. #define __LEDS_MAX77803_H__
  13. #define MAX77803_FLASH_IOUT 0x3F
  14. #define MAX77803_TORCH_IOUT 0x0F
  15. /* MAX77803_TORCH_TIMER */
  16. #define MAX77803_TORCH_TMR_DUR 0x0F
  17. #define MAX77803_DIS_TORCH_TMR 0x40
  18. #define MAX77803_TORCH_TMR_MODE 0x80
  19. #define MAX77803_TORCH_TMR_MODE_ONESHOT 0x00
  20. #define MAX77803_TORCH_TMR_MDOE_MAXTIMER 0x01
  21. /* MAX77803_FLASH_TIMER */
  22. #define MAX77803_FLASH_TMR_DUR 0x0F
  23. #define MAX77803_FLASH_TMR_MODE 0x80
  24. /* MAX77803_FLASH_TMR_MODE value */
  25. #define MAX77803_FLASH_TMR_MODE_ONESHOT 0x00
  26. #define MAX77803_FLASH_TMR_MDOE_MAXTIMER 0x01
  27. /* MAX77803_FLASH_EN */
  28. #define MAX77803_TORCH_FLED1_EN 0x0C
  29. #define MAX77803_FLASH_FLED1_EN 0xC0
  30. /* MAX77803_TORCH_FLEDx_EN value */
  31. #define MAX77803_TORCH_OFF 0x00
  32. #define MAX77803_TORCH_BY_FLASHEN 0x01
  33. #define MAX77803_TORCH_BY_TORCHEN 0x02
  34. #define MAX77803_TORCH_BY_I2C 0X03
  35. /* MAX77803_FLASH_FLEDx_EN value */
  36. #define MAX77803_FLASH_OFF 0x00
  37. #define MAX77803_FLASH_BY_FLASHEN 0x01
  38. #define MAX77803_FLASH_BY_TORCHEN 0x02
  39. #define MAX77803_FLASH_BY_I2C 0x03
  40. /* MAX77803_VOUT_CNTL */
  41. #define MAX77803_BOOST_FLASH_MODE 0x07
  42. #define MAX77803_BOOST_FLASH_FLEDNUM 0x80
  43. /* MAX77803_BOOST_FLASH_MODE vaule*/
  44. #define MAX77803_BOOST_FLASH_MODE_OFF 0x00
  45. #define MAX77803_BOOST_FLASH_MODE_FLED1 0x01
  46. #define MAX77803_BOOST_FLASH_MODE_FLED2 0x02
  47. #define MAX77803_BOOST_FLASH_MODE_BOTH 0x03
  48. #define MAX77803_BOOST_FLASH_MODE_FIXED 0x04
  49. /* MAX77803_BOOST_FLASH_FLEDNUM vaule*/
  50. #define MAX77803_BOOST_FLASH_FLEDNUM_1 0x00
  51. #define MAX77803_BOOST_FLASH_FLEDNUM_2 0x80
  52. /* MAX77803_VOUT_FLASH1 */
  53. #define MAX77803_BOOST_VOUT_FLASH 0x7F
  54. #define MAX77803_BOOST_VOUT_FLASH_FROM_VOLT(mV) \
  55. ((mV) <= 3300 ? 0x00 : \
  56. ((mV) <= 5500 ? (((mV) - 3300) / 25 + 0x0C) : 0x7F))
  57. #define MAX_FLASH_CURRENT 1000 /* 1000mA(0x1f) */
  58. #define MAX_TORCH_CURRENT 250 /* 250mA(0x0f) */
  59. #define MAX_FLASH_DRV_LEVEL 63 /* 15.625 + 15.625*63 mA */
  60. #define MAX_TORCH_DRV_LEVEL 15 /* 15.625 + 15.625*15 mA */
  61. enum max77803_led_id {
  62. MAX77803_FLASH_LED_1,
  63. MAX77803_TORCH_LED_1,
  64. MAX77803_LED_MAX,
  65. };
  66. enum max77803_led_time {
  67. MAX77803_FLASH_TIME_62P5MS,
  68. MAX77803_FLASH_TIME_125MS,
  69. MAX77803_FLASH_TIME_187P5MS,
  70. MAX77803_FLASH_TIME_250MS,
  71. MAX77803_FLASH_TIME_312P5MS,
  72. MAX77803_FLASH_TIME_375MS,
  73. MAX77803_FLASH_TIME_437P5MS,
  74. MAX77803_FLASH_TIME_500MS,
  75. MAX77803_FLASH_TIME_562P5MS,
  76. MAX77803_FLASH_TIME_625MS,
  77. MAX77803_FLASH_TIME_687P5MS,
  78. MAX77803_FLASH_TIME_750MS,
  79. MAX77803_FLASH_TIME_812P5MS,
  80. MAX77803_FLASH_TIME_875MS,
  81. MAX77803_FLASH_TIME_937P5MS,
  82. MAX77803_FLASH_TIME_1000MS,
  83. MAX77803_FLASH_TIME_MAX,
  84. };
  85. enum max77803_torch_time {
  86. MAX77803_TORCH_TIME_262MS,
  87. MAX77803_TORCH_TIME_524MS,
  88. MAX77803_TORCH_TIME_786MS,
  89. MAX77803_TORCH_TIME_1048MS,
  90. MAX77803_TORCH_TIME_1572MS,
  91. MAX77803_TORCH_TIME_2096MS,
  92. MAX77803_TORCH_TIME_2620MS,
  93. MAX77803_TORCH_TIME_3114MS,
  94. MAX77803_TORCH_TIME_4193MS,
  95. MAX77803_TORCH_TIME_5242MS,
  96. MAX77803_TORCH_TIME_6291MS,
  97. MAX77803_TORCH_TIME_7340MS,
  98. MAX77803_TORCH_TIME_9437MS,
  99. MAX77803_TORCH_TIME_11534MS,
  100. MAX77803_TORCH_TIME_13631MS,
  101. MAX77803_TORCH_TIME_15728MS,
  102. MAX77803_TORCH_TIME_MAX,
  103. };
  104. enum max77803_timer_mode {
  105. MAX77803_TIMER_MODE_ONE_SHOT,
  106. MAX77803_TIMER_MODE_MAX_TIMER,
  107. };
  108. enum max77803_led_cntrl_mode {
  109. MAX77803_LED_CTRL_BY_FLASHSTB,
  110. MAX77803_LED_CTRL_BY_I2C,
  111. };
  112. struct max77803_led {
  113. const char *name;
  114. const char *default_trigger;
  115. int id;
  116. int timer;
  117. int brightness;
  118. enum max77803_timer_mode timer_mode;
  119. enum max77803_led_cntrl_mode cntrl_mode;
  120. };
  121. struct max77803_led_platform_data {
  122. int num_leds;
  123. struct max77803_led leds[MAX77803_LED_MAX];
  124. };
  125. extern int max77803_led_en(int onoff, int mode);
  126. #endif