1
2
3
4
5
6
7
8
9
10 #ifndef __MFD_LP8788_H__
11 #define __MFD_LP8788_H__
12
13 #include <linux/gpio.h>
14 #include <linux/irqdomain.h>
15 #include <linux/pwm.h>
16 #include <linux/regmap.h>
17
18 #define LP8788_DEV_BUCK "lp8788-buck"
19 #define LP8788_DEV_DLDO "lp8788-dldo"
20 #define LP8788_DEV_ALDO "lp8788-aldo"
21 #define LP8788_DEV_CHARGER "lp8788-charger"
22 #define LP8788_DEV_RTC "lp8788-rtc"
23 #define LP8788_DEV_BACKLIGHT "lp8788-backlight"
24 #define LP8788_DEV_VIBRATOR "lp8788-vibrator"
25 #define LP8788_DEV_KEYLED "lp8788-keyled"
26 #define LP8788_DEV_ADC "lp8788-adc"
27
28 #define LP8788_NUM_BUCKS 4
29 #define LP8788_NUM_DLDOS 12
30 #define LP8788_NUM_ALDOS 10
31 #define LP8788_NUM_BUCK2_DVS 2
32
33 #define LP8788_CHG_IRQ "CHG_IRQ"
34 #define LP8788_PRSW_IRQ "PRSW_IRQ"
35 #define LP8788_BATT_IRQ "BATT_IRQ"
36 #define LP8788_ALM_IRQ "ALARM_IRQ"
37
38 enum lp8788_int_id {
39
40 LP8788_INT_TSDL,
41 LP8788_INT_TSDH,
42 LP8788_INT_UVLO,
43 LP8788_INT_FLAGMON,
44 LP8788_INT_PWRON_TIME,
45 LP8788_INT_PWRON,
46 LP8788_INT_COMP1,
47 LP8788_INT_COMP2,
48
49
50 LP8788_INT_CHG_INPUT_STATE,
51 LP8788_INT_CHG_STATE,
52 LP8788_INT_EOC,
53 LP8788_INT_CHG_RESTART,
54 LP8788_INT_RESTART_TIMEOUT,
55 LP8788_INT_FULLCHG_TIMEOUT,
56 LP8788_INT_PRECHG_TIMEOUT,
57
58
59 LP8788_INT_RTC_ALARM1 = 17,
60 LP8788_INT_RTC_ALARM2,
61 LP8788_INT_ENTER_SYS_SUPPORT,
62 LP8788_INT_EXIT_SYS_SUPPORT,
63 LP8788_INT_BATT_LOW,
64 LP8788_INT_NO_BATT,
65
66 LP8788_INT_MAX = 24,
67 };
68
69 enum lp8788_dvs_sel {
70 DVS_SEL_V0,
71 DVS_SEL_V1,
72 DVS_SEL_V2,
73 DVS_SEL_V3,
74 };
75
76 enum lp8788_ext_ldo_en_id {
77 EN_ALDO1,
78 EN_ALDO234,
79 EN_ALDO5,
80 EN_ALDO7,
81 EN_DLDO7,
82 EN_DLDO911,
83 EN_LDOS_MAX,
84 };
85
86 enum lp8788_charger_event {
87 NO_CHARGER,
88 CHARGER_DETECTED,
89 };
90
91 enum lp8788_bl_ctrl_mode {
92 LP8788_BL_REGISTER_ONLY,
93 LP8788_BL_COMB_PWM_BASED,
94 LP8788_BL_COMB_REGISTER_BASED,
95 };
96
97 enum lp8788_bl_dim_mode {
98 LP8788_DIM_EXPONENTIAL,
99 LP8788_DIM_LINEAR,
100 };
101
102 enum lp8788_bl_full_scale_current {
103 LP8788_FULLSCALE_5000uA,
104 LP8788_FULLSCALE_8500uA,
105 LP8788_FULLSCALE_1200uA,
106 LP8788_FULLSCALE_1550uA,
107 LP8788_FULLSCALE_1900uA,
108 LP8788_FULLSCALE_2250uA,
109 LP8788_FULLSCALE_2600uA,
110 LP8788_FULLSCALE_2950uA,
111 };
112
113 enum lp8788_bl_ramp_step {
114 LP8788_RAMP_8us,
115 LP8788_RAMP_1024us,
116 LP8788_RAMP_2048us,
117 LP8788_RAMP_4096us,
118 LP8788_RAMP_8192us,
119 LP8788_RAMP_16384us,
120 LP8788_RAMP_32768us,
121 LP8788_RAMP_65538us,
122 };
123
124 enum lp8788_isink_scale {
125 LP8788_ISINK_SCALE_100mA,
126 LP8788_ISINK_SCALE_120mA,
127 };
128
129 enum lp8788_isink_number {
130 LP8788_ISINK_1,
131 LP8788_ISINK_2,
132 LP8788_ISINK_3,
133 };
134
135 enum lp8788_alarm_sel {
136 LP8788_ALARM_1,
137 LP8788_ALARM_2,
138 LP8788_ALARM_MAX,
139 };
140
141 enum lp8788_adc_id {
142 LPADC_VBATT_5P5,
143 LPADC_VIN_CHG,
144 LPADC_IBATT,
145 LPADC_IC_TEMP,
146 LPADC_VBATT_6P0,
147 LPADC_VBATT_5P0,
148 LPADC_ADC1,
149 LPADC_ADC2,
150 LPADC_VDD,
151 LPADC_VCOIN,
152 LPADC_VDD_LDO,
153 LPADC_ADC3,
154 LPADC_ADC4,
155 LPADC_MAX,
156 };
157
158 struct lp8788;
159
160
161
162
163
164
165 struct lp8788_buck1_dvs {
166 int gpio;
167 enum lp8788_dvs_sel vsel;
168 };
169
170
171
172
173
174
175 struct lp8788_buck2_dvs {
176 int gpio[LP8788_NUM_BUCK2_DVS];
177 enum lp8788_dvs_sel vsel;
178 };
179
180
181
182
183
184
185 struct lp8788_chg_param {
186 u8 addr;
187 u8 val;
188 };
189
190
191
192
193
194
195
196
197
198
199 struct lp8788_charger_platform_data {
200 const char *adc_vbatt;
201 const char *adc_batt_temp;
202 unsigned int max_vbatt_mv;
203 struct lp8788_chg_param *chg_params;
204 int num_chg_params;
205 void (*charger_event) (struct lp8788 *lp,
206 enum lp8788_charger_event event);
207 };
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 struct lp8788_backlight_platform_data {
223 char *name;
224 int initial_brightness;
225 enum lp8788_bl_ctrl_mode bl_mode;
226 enum lp8788_bl_dim_mode dim_mode;
227 enum lp8788_bl_full_scale_current full_scale;
228 enum lp8788_bl_ramp_step rise_time;
229 enum lp8788_bl_ramp_step fall_time;
230 enum pwm_polarity pwm_pol;
231 unsigned int period_ns;
232 };
233
234
235
236
237
238
239
240
241 struct lp8788_led_platform_data {
242 char *name;
243 enum lp8788_isink_scale scale;
244 enum lp8788_isink_number num;
245 int iout_code;
246 };
247
248
249
250
251
252
253
254
255
256 struct lp8788_vib_platform_data {
257 char *name;
258 enum lp8788_isink_scale scale;
259 enum lp8788_isink_number num;
260 int iout_code;
261 int pwm_code;
262 };
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 struct lp8788_platform_data {
281
282 int (*init_func) (struct lp8788 *lp);
283
284
285 struct regulator_init_data *buck_data[LP8788_NUM_BUCKS];
286 struct regulator_init_data *dldo_data[LP8788_NUM_DLDOS];
287 struct regulator_init_data *aldo_data[LP8788_NUM_ALDOS];
288 struct lp8788_buck1_dvs *buck1_dvs;
289 struct lp8788_buck2_dvs *buck2_dvs;
290
291
292 struct lp8788_charger_platform_data *chg_pdata;
293
294
295 enum lp8788_alarm_sel alarm_sel;
296
297
298 struct lp8788_backlight_platform_data *bl_pdata;
299
300
301 struct lp8788_led_platform_data *led_pdata;
302 struct lp8788_vib_platform_data *vib_pdata;
303
304
305 struct iio_map *adc_pdata;
306 };
307
308
309
310
311
312
313
314
315
316 struct lp8788 {
317 struct device *dev;
318 struct regmap *regmap;
319 struct irq_domain *irqdm;
320 int irq;
321 struct lp8788_platform_data *pdata;
322 };
323
324 int lp8788_irq_init(struct lp8788 *lp, int chip_irq);
325 void lp8788_irq_exit(struct lp8788 *lp);
326 int lp8788_read_byte(struct lp8788 *lp, u8 reg, u8 *data);
327 int lp8788_read_multi_bytes(struct lp8788 *lp, u8 reg, u8 *data, size_t count);
328 int lp8788_write_byte(struct lp8788 *lp, u8 reg, u8 data);
329 int lp8788_update_bits(struct lp8788 *lp, u8 reg, u8 mask, u8 data);
330 #endif