aat2870.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * linux/include/linux/mfd/aat2870.h
  3. *
  4. * Copyright (c) 2011, NVIDIA Corporation.
  5. * Author: Jin Park <jinyoungp@nvidia.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #ifndef __LINUX_MFD_AAT2870_H
  22. #define __LINUX_MFD_AAT2870_H
  23. #include <linux/debugfs.h>
  24. #include <linux/i2c.h>
  25. /* Register offsets */
  26. #define AAT2870_BL_CH_EN 0x00
  27. #define AAT2870_BLM 0x01
  28. #define AAT2870_BLS 0x02
  29. #define AAT2870_BL1 0x03
  30. #define AAT2870_BL2 0x04
  31. #define AAT2870_BL3 0x05
  32. #define AAT2870_BL4 0x06
  33. #define AAT2870_BL5 0x07
  34. #define AAT2870_BL6 0x08
  35. #define AAT2870_BL7 0x09
  36. #define AAT2870_BL8 0x0A
  37. #define AAT2870_FLR 0x0B
  38. #define AAT2870_FM 0x0C
  39. #define AAT2870_FS 0x0D
  40. #define AAT2870_ALS_CFG0 0x0E
  41. #define AAT2870_ALS_CFG1 0x0F
  42. #define AAT2870_ALS_CFG2 0x10
  43. #define AAT2870_AMB 0x11
  44. #define AAT2870_ALS0 0x12
  45. #define AAT2870_ALS1 0x13
  46. #define AAT2870_ALS2 0x14
  47. #define AAT2870_ALS3 0x15
  48. #define AAT2870_ALS4 0x16
  49. #define AAT2870_ALS5 0x17
  50. #define AAT2870_ALS6 0x18
  51. #define AAT2870_ALS7 0x19
  52. #define AAT2870_ALS8 0x1A
  53. #define AAT2870_ALS9 0x1B
  54. #define AAT2870_ALSA 0x1C
  55. #define AAT2870_ALSB 0x1D
  56. #define AAT2870_ALSC 0x1E
  57. #define AAT2870_ALSD 0x1F
  58. #define AAT2870_ALSE 0x20
  59. #define AAT2870_ALSF 0x21
  60. #define AAT2870_SUB_SET 0x22
  61. #define AAT2870_SUB_CTRL 0x23
  62. #define AAT2870_LDO_AB 0x24
  63. #define AAT2870_LDO_CD 0x25
  64. #define AAT2870_LDO_EN 0x26
  65. #define AAT2870_REG_NUM 0x27
  66. /* Device IDs */
  67. enum aat2870_id {
  68. AAT2870_ID_BL,
  69. AAT2870_ID_LDOA,
  70. AAT2870_ID_LDOB,
  71. AAT2870_ID_LDOC,
  72. AAT2870_ID_LDOD
  73. };
  74. /* Backlight channels */
  75. #define AAT2870_BL_CH1 0x01
  76. #define AAT2870_BL_CH2 0x02
  77. #define AAT2870_BL_CH3 0x04
  78. #define AAT2870_BL_CH4 0x08
  79. #define AAT2870_BL_CH5 0x10
  80. #define AAT2870_BL_CH6 0x20
  81. #define AAT2870_BL_CH7 0x40
  82. #define AAT2870_BL_CH8 0x80
  83. #define AAT2870_BL_CH_ALL 0xFF
  84. /* Backlight current magnitude (mA) */
  85. enum aat2870_current {
  86. AAT2870_CURRENT_0_45 = 1,
  87. AAT2870_CURRENT_0_90,
  88. AAT2870_CURRENT_1_80,
  89. AAT2870_CURRENT_2_70,
  90. AAT2870_CURRENT_3_60,
  91. AAT2870_CURRENT_4_50,
  92. AAT2870_CURRENT_5_40,
  93. AAT2870_CURRENT_6_30,
  94. AAT2870_CURRENT_7_20,
  95. AAT2870_CURRENT_8_10,
  96. AAT2870_CURRENT_9_00,
  97. AAT2870_CURRENT_9_90,
  98. AAT2870_CURRENT_10_8,
  99. AAT2870_CURRENT_11_7,
  100. AAT2870_CURRENT_12_6,
  101. AAT2870_CURRENT_13_5,
  102. AAT2870_CURRENT_14_4,
  103. AAT2870_CURRENT_15_3,
  104. AAT2870_CURRENT_16_2,
  105. AAT2870_CURRENT_17_1,
  106. AAT2870_CURRENT_18_0,
  107. AAT2870_CURRENT_18_9,
  108. AAT2870_CURRENT_19_8,
  109. AAT2870_CURRENT_20_7,
  110. AAT2870_CURRENT_21_6,
  111. AAT2870_CURRENT_22_5,
  112. AAT2870_CURRENT_23_4,
  113. AAT2870_CURRENT_24_3,
  114. AAT2870_CURRENT_25_2,
  115. AAT2870_CURRENT_26_1,
  116. AAT2870_CURRENT_27_0,
  117. AAT2870_CURRENT_27_9
  118. };
  119. struct aat2870_register {
  120. bool readable;
  121. bool writeable;
  122. u8 value;
  123. };
  124. struct aat2870_data {
  125. struct device *dev;
  126. struct i2c_client *client;
  127. struct mutex io_lock;
  128. struct aat2870_register *reg_cache; /* register cache */
  129. int en_pin; /* enable GPIO pin (if < 0, ignore this value) */
  130. bool is_enable;
  131. /* init and uninit for platform specified */
  132. int (*init)(struct aat2870_data *aat2870);
  133. void (*uninit)(struct aat2870_data *aat2870);
  134. /* i2c io funcntions */
  135. int (*read)(struct aat2870_data *aat2870, u8 addr, u8 *val);
  136. int (*write)(struct aat2870_data *aat2870, u8 addr, u8 val);
  137. int (*update)(struct aat2870_data *aat2870, u8 addr, u8 mask, u8 val);
  138. /* for debugfs */
  139. struct dentry *dentry_root;
  140. struct dentry *dentry_reg;
  141. };
  142. struct aat2870_subdev_info {
  143. int id;
  144. const char *name;
  145. void *platform_data;
  146. };
  147. struct aat2870_platform_data {
  148. int en_pin; /* enable GPIO pin (if < 0, ignore this value) */
  149. struct aat2870_subdev_info *subdevs;
  150. int num_subdevs;
  151. /* init and uninit for platform specified */
  152. int (*init)(struct aat2870_data *aat2870);
  153. void (*uninit)(struct aat2870_data *aat2870);
  154. };
  155. struct aat2870_bl_platform_data {
  156. /* backlight channels, default is AAT2870_BL_CH_ALL */
  157. int channels;
  158. /* backlight current magnitude, default is AAT2870_CURRENT_27_9 */
  159. int max_current;
  160. /* maximum brightness, default is 255 */
  161. int max_brightness;
  162. };
  163. #endif /* __LINUX_MFD_AAT2870_H */