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