leds-max77828.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * leds-max77828.h - Flash-led driver for Maxim MAX77828
  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_MAX77828_H__
  12. #define __LEDS_MAX77828_H__
  13. /* FLASH & TORCH DATA START */
  14. /* MAX77828_LED_REG_I_FLASH1 */
  15. #define MAX77828_FLASH_FLED1_EN 0x80
  16. #define MAX77828_FLASH_IOUT 0x3F
  17. /* MAX77828_LED_REG_I_TORCH1 */
  18. #define MAX77828_TORCH_FLED1_EN 0x80
  19. #define MAX77828_TORCH_IOUT 0x7E
  20. #define MAX77828_TORCH_DIM_DAC 0x00
  21. #define MAX77828_TORCH_DIM_PWM 0x01
  22. /* MAX77828_LED_REG_MODE_SEL */
  23. #define MAX77828_TORCHEN_PD 0x80
  24. #define MAX77828_FLASHSTB_PD 0x40
  25. #define MAX77828_TORCH_MODE 0x38
  26. #define MAX77828_TORCH_MD_DISABLED 0x00
  27. #define MAX77828_TORCH_MD_TORCHEN 0x08
  28. #define MAX77828_TORCH_MD_FLASHSTB 0x10
  29. #define MAX77828_TORCH_MD_ANY 0x18
  30. #define MAX77828_TORCH_MD_BOTH 0x20
  31. #define MAX77828_TORCH_MD_ENABLED 0x21
  32. #define MAX77828_FLASH_MODE 0x07
  33. #define MAX77828_FLASH_MD_DISABLED 0x00
  34. #define MAX77828_FLASH_MD_TORCHEN 0x01
  35. #define MAX77828_FLASH_MD_FLASHSTB 0x02
  36. #define MAX77828_FLASH_MD_ANY 0x03
  37. #define MAX77828_FLASH_MD_BOTH 0x04
  38. #define MAX77828_FLASH_MD_ENABLED 0x05
  39. /* MAX77828_REG_FLASH_RAMP_SEL */
  40. #define MAX77828_FLASH_RU 0x70
  41. #define MAX77828_FLASH_RD 0x07
  42. /* MAX77828_REG_TORCH_RAMP_SEL */
  43. #define MAX77828_TORCH_RU 0x70
  44. #define MAX77828_TORCH_RD 0x07
  45. /* MAX77828_LED_REG_FLASH_TMR_CNTL */
  46. #define MAX77828_FLASH_TMR_CNTL 0x80
  47. #define MAX77828_FLASH_TMR 0x7F
  48. /* MAX77828_LED_REG_TORCH_TMR_CNTL */
  49. #define MAX77828_TORCH_TMR_CNTL 0x80
  50. #define MAX77828_TORCH_TMR 0x7C
  51. /* MAX77828_REG_MAXFLASH1 */
  52. #define MAX77828_MAXFLASH_HYS 0xE0
  53. #define MAX77828_MAXFLASH_TH 0x1F
  54. /* MAX77828_REG_MAXFLASH2 */
  55. #define MAX77828_LB_TMR_R 0xF0
  56. #define MAX77828_LB_TMR_F 0x0F
  57. /* MAX77828_REG_MAXFLASH3 */
  58. #define MAX77828_MAX_FLASH1_IMIN 0x3F
  59. /* MAX77828_REG_DCDC_CNTL1 */
  60. #define MAX77828_DCDC_MODE_AM 0x00
  61. #define MAX77828_DCDC_MODE_PAM 0x01
  62. #define MAX77828_DCDC_MODE_FAM 0x02
  63. #define MAX77828_DCDC_MODE_DM 0x03
  64. /* MAX77828_REG_DCDC_CNTL2 */
  65. #define MAX77828_DCDC_ADPT_REG 0xC0
  66. #define MAX77828_DCDC_GAIN 0x20
  67. #define MAX77828_DCDC_OPERATION 0x1C
  68. /* MAX77828_REG_DCDC_LIM */
  69. #define MAX77828_DCDC_ILIM 0xC0
  70. #define MAX77828_DCDC_SS 0x3F
  71. /* MAX77828_REG_DCDC_OUT */
  72. #define MAX77828_DCDC_OUT 0xFF
  73. /* MAX77828_REG_DCDC_OUT_MAX */
  74. #define MAX77828_DCDC_OUT_MAX 0xFF
  75. /* FLASH & TORCH DATA END */
  76. /* RGB LED DATA START */
  77. /* MAX77828_LED_REG_LEDEN */
  78. #define MAX77828_LED_EN_MASK 0xFF
  79. #define MAX77828_LED0_EN_MASK 0x01
  80. #define MAX77828_LED1_EN_MASK 0x02
  81. #define MAX77828_LED2_EN_MASK 0x04
  82. #define MAX77828_LED3_EN_MASK 0x08
  83. #define MAX77828_LED_CURRENT 0xFF
  84. /* MAX77828_REG_LEDBLNK */
  85. #define MAX77828_LEDBLINKD 0xF0
  86. #define MAX77828_LEDBLINKP 0x0F
  87. /* MAX77828_REG_LEDRMP */
  88. #define MAX77828_RAMPUP 0xF0
  89. #define MAX77828_RAMPDN 0x0F
  90. /* RGB LED DATA END */
  91. enum max77828_led_id {
  92. MAX77828_FLASH,
  93. MAX77828_TORCH,
  94. MAX77828_RGB_R,
  95. MAX77828_RGB_G,
  96. MAX77828_RGB_B,
  97. MAX77828_LED_MAX,
  98. };
  99. enum max77828_led_mode{
  100. MAX77828_MODE_OFF,
  101. MAX77828_TORCHEN,
  102. MAX77828_FLASHSTB,
  103. MAX77828_TORCHEN_OR_FLASHSTB,
  104. MAX77828_TORCH_AND_FLASHSTB,
  105. MAX77828_MODE_MAX,
  106. };
  107. struct max77828_led
  108. {
  109. const char *name;
  110. const char *default_trigger;
  111. int id;
  112. int timer;
  113. int brightness;
  114. int max_brightness;
  115. };
  116. struct max77828_led_platform_data
  117. {
  118. int num_leds;
  119. struct max77828_led leds[MAX77828_LED_MAX];
  120. };
  121. extern int max77828_led_en(int onoff, int mode);
  122. #endif /*__LEDS_MAX77828_H__ */