1
2
3
4
5
6
7
8#ifndef _AB8500_BM_H
9#define _AB8500_BM_H
10
11#include <linux/kernel.h>
12#include <linux/mfd/abx500.h>
13
14
15
16
17
18#define AB8500_MAIN_WDOG_CTRL_REG 0x01
19#define AB8500_LOW_BAT_REG 0x03
20#define AB8500_BATT_OK_REG 0x04
21
22
23
24
25#define AB8500_USB_LINE_STAT_REG 0x80
26#define AB8500_USB_LINE_CTRL2_REG 0x82
27#define AB8500_USB_LINK1_STAT_REG 0x94
28
29
30
31
32
33#define AB8500_CH_STATUS1_REG 0x00
34#define AB8500_CH_STATUS2_REG 0x01
35#define AB8500_CH_USBCH_STAT1_REG 0x02
36#define AB8500_CH_USBCH_STAT2_REG 0x03
37#define AB8540_CH_USBCH_STAT3_REG 0x04
38#define AB8500_CH_STAT_REG 0x05
39
40
41
42
43
44#define AB8500_CH_VOLT_LVL_REG 0x40
45#define AB8500_CH_VOLT_LVL_MAX_REG 0x41
46#define AB8500_CH_OPT_CRNTLVL_REG 0x42
47#define AB8500_CH_OPT_CRNTLVL_MAX_REG 0x43
48#define AB8500_CH_WD_TIMER_REG 0x50
49#define AB8500_CHARG_WD_CTRL 0x51
50#define AB8500_BTEMP_HIGH_TH 0x52
51#define AB8500_LED_INDICATOR_PWM_CTRL 0x53
52#define AB8500_LED_INDICATOR_PWM_DUTY 0x54
53#define AB8500_BATT_OVV 0x55
54#define AB8500_CHARGER_CTRL 0x56
55#define AB8500_BAT_CTRL_CURRENT_SOURCE 0x60
56
57
58
59
60
61#define AB8500_MCH_CTRL1 0x80
62#define AB8500_MCH_CTRL2 0x81
63#define AB8500_MCH_IPT_CURLVL_REG 0x82
64#define AB8500_CH_WD_REG 0x83
65
66
67
68
69
70#define AB8500_USBCH_CTRL1_REG 0xC0
71#define AB8500_USBCH_CTRL2_REG 0xC1
72#define AB8500_USBCH_IPT_CRNTLVL_REG 0xC2
73#define AB8540_USB_PP_MODE_REG 0xC5
74#define AB8540_USB_PP_CHR_REG 0xC6
75
76
77
78
79
80#define AB8500_GASG_CC_CTRL_REG 0x00
81#define AB8500_GASG_CC_ACCU1_REG 0x01
82#define AB8500_GASG_CC_ACCU2_REG 0x02
83#define AB8500_GASG_CC_ACCU3_REG 0x03
84#define AB8500_GASG_CC_ACCU4_REG 0x04
85#define AB8500_GASG_CC_SMPL_CNTRL_REG 0x05
86#define AB8500_GASG_CC_SMPL_CNTRH_REG 0x06
87#define AB8500_GASG_CC_SMPL_CNVL_REG 0x07
88#define AB8500_GASG_CC_SMPL_CNVH_REG 0x08
89#define AB8500_GASG_CC_CNTR_AVGOFF_REG 0x09
90#define AB8500_GASG_CC_OFFSET_REG 0x0A
91#define AB8500_GASG_CC_NCOV_ACCU 0x10
92#define AB8500_GASG_CC_NCOV_ACCU_CTRL 0x11
93#define AB8500_GASG_CC_NCOV_ACCU_LOW 0x12
94#define AB8500_GASG_CC_NCOV_ACCU_MED 0x13
95#define AB8500_GASG_CC_NCOV_ACCU_HIGH 0x14
96
97
98
99
100
101#define AB8500_IT_SOURCE2_REG 0x01
102#define AB8500_IT_SOURCE21_REG 0x14
103
104
105
106
107
108#define AB8500_RTC_BACKUP_CHG_REG 0x0C
109#define AB8500_RTC_CC_CONF_REG 0x01
110#define AB8500_RTC_CTRL_REG 0x0B
111#define AB8500_RTC_CTRL1_REG 0x11
112
113
114
115
116
117#define AB8500_OTP_CONF_15 0x0E
118
119
120#define ADC_RESOLUTION 1024
121#define ADC_CH_MAIN_MIN 0
122#define ADC_CH_MAIN_MAX 20030
123#define ADC_CH_VBUS_MIN 0
124#define ADC_CH_VBUS_MAX 20030
125#define ADC_CH_VBAT_MIN 2300
126#define ADC_CH_VBAT_MAX 4800
127#define ADC_CH_BKBAT_MIN 0
128#define ADC_CH_BKBAT_MAX 3200
129
130
131#define MAIN_CH_IP_CUR_0P9A 0x80
132#define MAIN_CH_IP_CUR_1P0A 0x90
133#define MAIN_CH_IP_CUR_1P1A 0xA0
134#define MAIN_CH_IP_CUR_1P2A 0xB0
135#define MAIN_CH_IP_CUR_1P3A 0xC0
136#define MAIN_CH_IP_CUR_1P4A 0xD0
137#define MAIN_CH_IP_CUR_1P5A 0xE0
138
139
140#define CH_VOL_LVL_3P5 0x00
141#define CH_VOL_LVL_4P0 0x14
142#define CH_VOL_LVL_4P05 0x16
143#define CH_VOL_LVL_4P1 0x1B
144#define CH_VOL_LVL_4P15 0x20
145#define CH_VOL_LVL_4P2 0x25
146#define CH_VOL_LVL_4P6 0x4D
147
148
149#define CH_OP_CUR_LVL_0P1 0x00
150#define CH_OP_CUR_LVL_0P2 0x01
151#define CH_OP_CUR_LVL_0P3 0x02
152#define CH_OP_CUR_LVL_0P4 0x03
153#define CH_OP_CUR_LVL_0P5 0x04
154#define CH_OP_CUR_LVL_0P6 0x05
155#define CH_OP_CUR_LVL_0P7 0x06
156#define CH_OP_CUR_LVL_0P8 0x07
157#define CH_OP_CUR_LVL_0P9 0x08
158#define CH_OP_CUR_LVL_1P4 0x0D
159#define CH_OP_CUR_LVL_1P5 0x0E
160#define CH_OP_CUR_LVL_1P6 0x0F
161#define CH_OP_CUR_LVL_2P 0x3F
162
163
164#define BTEMP_HIGH_TH_57_0 0x00
165#define BTEMP_HIGH_TH_52 0x01
166#define BTEMP_HIGH_TH_57_1 0x02
167#define BTEMP_HIGH_TH_62 0x03
168
169
170#define USB_0P1A 100
171#define USB_0P2A 200
172#define USB_0P3A 300
173#define USB_0P4A 400
174#define USB_0P5A 500
175
176#define LOW_BAT_3P1V 0x20
177#define LOW_BAT_2P3V 0x00
178#define LOW_BAT_RESET 0x01
179#define LOW_BAT_ENABLE 0x01
180
181
182#define BUP_ICH_SEL_50UA 0x00
183#define BUP_ICH_SEL_150UA 0x04
184#define BUP_ICH_SEL_300UA 0x08
185#define BUP_ICH_SEL_700UA 0x0C
186
187enum bup_vch_sel {
188 BUP_VCH_SEL_2P5V,
189 BUP_VCH_SEL_2P6V,
190 BUP_VCH_SEL_2P8V,
191 BUP_VCH_SEL_3P1V,
192
193
194
195
196
197 BUP_VCH_SEL_2P7V,
198 BUP_VCH_SEL_2P9V,
199 BUP_VCH_SEL_3P0V,
200 BUP_VCH_SEL_3P2V,
201 BUP_VCH_SEL_3P3V,
202};
203
204#define BUP_VCH_RANGE 0x02
205#define VBUP33_VRTCN 0x01
206
207
208#define BATT_OVV_ENA 0x02
209#define BATT_OVV_TH_3P7 0x00
210#define BATT_OVV_TH_4P75 0x01
211
212
213#define BATT_OVV_VALUE 4750
214
215
216#define VBUS_OVV_SELECT_MASK 0x78
217#define VBUS_OVV_SELECT_5P6V 0x00
218#define VBUS_OVV_SELECT_5P7V 0x08
219#define VBUS_OVV_SELECT_5P8V 0x10
220#define VBUS_OVV_SELECT_5P9V 0x18
221#define VBUS_OVV_SELECT_6P0V 0x20
222#define VBUS_OVV_SELECT_6P1V 0x28
223#define VBUS_OVV_SELECT_6P2V 0x30
224#define VBUS_OVV_SELECT_6P3V 0x38
225
226#define VBUS_AUTO_IN_CURR_LIM_ENA 0x04
227
228
229#define RESET_ACCU 0x02
230#define READ_REQ 0x01
231#define CC_DEEP_SLEEP_ENA 0x02
232#define CC_PWR_UP_ENA 0x01
233#define CC_SAMPLES_40 0x28
234#define RD_NCONV_ACCU_REQ 0x01
235#define CC_CALIB 0x08
236#define CC_INTAVGOFFSET_ENA 0x10
237#define CC_MUXOFFSET 0x80
238#define CC_INT_CAL_N_AVG_MASK 0x60
239#define CC_INT_CAL_SAMPLES_16 0x40
240#define CC_INT_CAL_SAMPLES_8 0x20
241#define CC_INT_CAL_SAMPLES_4 0x00
242
243
244#define RTC_BUP_CH_ENA 0x10
245
246
247#define BAT_CTRL_7U_ENA 0x01
248#define BAT_CTRL_20U_ENA 0x02
249#define BAT_CTRL_18U_ENA 0x01
250#define BAT_CTRL_16U_ENA 0x02
251#define BAT_CTRL_60U_ENA 0x01
252#define BAT_CTRL_120U_ENA 0x02
253#define BAT_CTRL_CMP_ENA 0x04
254#define FORCE_BAT_CTRL_CMP_HIGH 0x08
255#define BAT_CTRL_PULL_UP_ENA 0x10
256
257
258#define BATTERY_UNKNOWN 00
259
260
261#define AB8505_RTC_PCUT_CTL_STATUS_REG 0x12
262#define AB8505_RTC_PCUT_TIME_REG 0x13
263#define AB8505_RTC_PCUT_MAX_TIME_REG 0x14
264#define AB8505_RTC_PCUT_FLAG_TIME_REG 0x15
265#define AB8505_RTC_PCUT_RESTART_REG 0x16
266#define AB8505_RTC_PCUT_DEBOUNCE_REG 0x17
267
268
269#define BUS_VSYS_VOL_SELECT_MASK 0x06
270#define BUS_VSYS_VOL_SELECT_3P6V 0x00
271#define BUS_VSYS_VOL_SELECT_3P325V 0x02
272#define BUS_VSYS_VOL_SELECT_3P9V 0x04
273#define BUS_VSYS_VOL_SELECT_4P3V 0x06
274#define BUS_POWER_PATH_MODE_ENA 0x01
275#define BUS_PP_PRECHG_CURRENT_MASK 0x0E
276#define BUS_POWER_PATH_PRECHG_ENA 0x01
277
278
279
280
281
282
283
284
285struct res_to_temp {
286 int temp;
287 int resist;
288};
289
290
291
292
293
294
295
296struct batres_vs_temp {
297 int temp;
298 int resist;
299};
300
301
302struct ab8500_fg;
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332struct ab8500_fg_parameters {
333 int recovery_sleep_timer;
334 int recovery_total_time;
335 int init_timer;
336 int init_discard_time;
337 int init_total_time;
338 int high_curr_time;
339 int accu_charging;
340 int accu_high_curr;
341 int high_curr_threshold;
342 int lowbat_threshold;
343 int battok_falling_th_sel0;
344 int battok_raising_th_sel1;
345 int user_cap_limit;
346 int maint_thres;
347 bool pcut_enable;
348 u8 pcut_max_time;
349 u8 pcut_flag_time;
350 u8 pcut_max_restart;
351 u8 pcut_debunce_time;
352};
353
354
355
356
357
358
359
360
361struct ab8500_maxim_parameters {
362 bool ena_maxi;
363 int chg_curr;
364 int wait_cycles;
365 int charger_curr_step;
366};
367
368
369
370
371
372
373
374
375
376struct ab8500_bm_capacity_levels {
377 int critical;
378 int low;
379 int normal;
380 int high;
381 int full;
382};
383
384
385
386
387
388
389
390
391struct ab8500_bm_charger_parameters {
392 int usb_volt_max;
393 int usb_curr_max;
394 int ac_volt_max;
395 int ac_curr_max;
396};
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428struct ab8500_bm_data {
429 int temp_under;
430 int temp_low;
431 int temp_high;
432 int temp_over;
433 int temp_interval_chg;
434 int temp_interval_nochg;
435 int main_safety_tmr_h;
436 int usb_safety_tmr_h;
437 int bkup_bat_v;
438 int bkup_bat_i;
439 bool no_maintenance;
440 bool capacity_scaling;
441 bool chg_unknown_bat;
442 bool enable_overshoot;
443 enum abx500_adc_therm adc_therm;
444 int fg_res;
445 int n_btypes;
446 int batt_id;
447 int interval_charging;
448 int interval_not_charging;
449 int temp_hysteresis;
450 int gnd_lift_resistance;
451 const struct ab8500_maxim_parameters *maxi;
452 const struct ab8500_bm_capacity_levels *cap_levels;
453 const struct ab8500_bm_charger_parameters *chg_params;
454 const struct ab8500_fg_parameters *fg_params;
455};
456
457struct ab8500_btemp;
458struct ab8500_gpadc;
459struct ab8500_fg;
460
461#ifdef CONFIG_AB8500_BM
462extern struct abx500_bm_data ab8500_bm_data;
463
464void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA);
465struct ab8500_btemp *ab8500_btemp_get(void);
466int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp);
467int ab8500_btemp_get_temp(struct ab8500_btemp *btemp);
468struct ab8500_fg *ab8500_fg_get(void);
469int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev);
470int ab8500_fg_inst_curr_start(struct ab8500_fg *di);
471int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);
472int ab8500_fg_inst_curr_started(struct ab8500_fg *di);
473int ab8500_fg_inst_curr_done(struct ab8500_fg *di);
474
475#else
476static struct abx500_bm_data ab8500_bm_data;
477#endif
478#endif
479