Merge tag 'lsk-v4.4-16.06-android'
[firefly-linux-kernel-4.4.55.git] / drivers / power / rk818_battery.h
1 /*
2 *rk818-battery.h - Battery fuel gauge driver structures
3  *
4  */
5 #ifndef RK818_BATTERY
6 #define  RK818_BATTERY
7
8 #define VB_MOD_REG                                      0x21
9 #define THERMAL_REG                                     0x22
10 #define DCDC_EN_REG                                     0x23
11 #define NT_STS_MSK_REG2                         0x4f
12 #define DCDC_ILMAX_REG                          0x90
13 #define CHRG_COMP_REG1                          0x99
14 #define CHRG_COMP_REG2                          0x9A
15 #define SUP_STS_REG                                     0xA0
16 #define USB_CTRL_REG                            0xA1
17 #define CHRG_CTRL_REG1                          0xA3
18 #define CHRG_CTRL_REG2                          0xA4
19 #define CHRG_CTRL_REG3                          0xA5
20 #define BAT_CTRL_REG                            0xA6
21 #define BAT_HTS_TS1_REG                 0xA8
22 #define BAT_LTS_TS1_REG                 0xA9
23 #define BAT_HTS_TS2_REG                 0xAA
24 #define BAT_LTS_TS2_REG                 0xAB
25
26
27 #define TS_CTRL_REG                                     0xAC
28 #define ADC_CTRL_REG                            0xAD
29
30 #define ON_SOURCE                                       0xAE
31 #define OFF_SOURCE                                      0xAF
32
33 #define GGCON                                           0xB0
34 #define GGSTS                                           0xB1
35 #define FRAME_SMP_INTERV_REG            0xB2
36 #define AUTO_SLP_CUR_THR_REG            0xB3
37
38 #define GASCNT_CAL_REG3                 0xB4
39 #define GASCNT_CAL_REG2                 0xB5
40 #define GASCNT_CAL_REG1                 0xB6
41 #define GASCNT_CAL_REG0                 0xB7
42 #define GASCNT3                                         0xB8
43 #define GASCNT2                                         0xB9
44 #define GASCNT1                                         0xBA
45 #define GASCNT0                                         0xBB
46
47 #define BAT_CUR_AVG_REGH                        0xBC
48 #define BAT_CUR_AVG_REGL                        0xBD
49
50 #define TS1_ADC_REGH                            0xBE
51 #define TS1_ADC_REGL                            0xBF
52 #define TS2_ADC_REGH                            0xC0
53 #define TS2_ADC_REGL                            0xC1
54
55 #define BAT_OCV_REGH                            0xC2
56 #define BAT_OCV_REGL                            0xC3
57 #define BAT_VOL_REGH                            0xC4
58 #define BAT_VOL_REGL                            0xC5
59
60 #define RELAX_ENTRY_THRES_REGH  0xC6
61 #define RELAX_ENTRY_THRES_REGL  0xC7
62 #define RELAX_EXIT_THRES_REGH           0xC8
63 #define RELAX_EXIT_THRES_REGL           0xC9
64
65 #define RELAX_VOL1_REGH                 0xCA
66 #define RELAX_VOL1_REGL                 0xCB
67 #define RELAX_VOL2_REGH                 0xCC
68 #define RELAX_VOL2_REGL                 0xCD
69
70 #define BAT_CUR_R_CALC_REGH             0xCE
71 #define BAT_CUR_R_CALC_REGL             0xCF
72 #define BAT_VOL_R_CALC_REGH             0xD0
73 #define BAT_VOL_R_CALC_REGL             0xD1
74
75 #define CAL_OFFSET_REGH                 0xD2
76 #define CAL_OFFSET_REGL                 0xD3
77
78 #define NON_ACT_TIMER_CNT_REG   0xD4
79
80 #define VCALIB0_REGH                            0xD5
81 #define VCALIB0_REGL                            0xD6
82 #define VCALIB1_REGH                            0xD7
83 #define VCALIB1_REGL                            0xD8
84
85 #define IOFFSET_REGH                            0xDD
86 #define IOFFSET_REGL                            0xDE
87
88
89 /*0xE0 ~0xF2  data register,*/
90 #define  SOC_REG                                                0xE0
91
92 #define  REMAIN_CAP_REG3                        0xE1
93 #define  REMAIN_CAP_REG2                        0xE2
94 #define  REMAIN_CAP_REG1                        0xE3
95 #define  REMAIN_CAP_REG0                        0xE4
96
97 #define UPDAT_LEVE_REG                          0xE5
98
99 #define  NEW_FCC_REG3                           0xE6
100 #define  NEW_FCC_REG2                           0xE7
101 #define  NEW_FCC_REG1                           0xE8
102 #define  NEW_FCC_REG0                           0xE9
103
104 #define NON_ACT_TIMER_CNT_REG_SAVE              0xEA
105 #define OCV_VOL_VALID_REG                       0xEB
106 #define REBOOT_CNT_REG                          0xEC
107 #define PCB_IOFFSET_REG                         0xED
108 #define MISC_MARK_REG                           0xEE
109
110 #define PLUG_IN_INT                             (0)
111 #define PLUG_OUT_INT                            (1)
112 #define CHRG_CVTLMT_INT                         (6)
113
114 #define CHRG_EN_MASK                            (1 << 7)
115 #define CHRG_EN                                 (1 << 7)
116 #define CHRG_DIS                                (0 << 7)
117
118 #define OTG_EN_MASK                             (1 << 7)
119 #define OTG_EN                                  (1 << 7)
120 #define OTG_DIS                                 (0 << 7)
121
122 /* gasgauge module enable bit 0: disable  1:enabsle
123 TS_CTRL_REG  0xAC*/
124 #define GG_EN                                           (1<<7)
125
126 /*ADC_CTRL_REG*/
127 /*
128 if GG_EN = 0 , then the ADC of BAT voltage controlled by the
129 bit 0:diabsle 1:enable
130 */
131 #define ADC_VOL_EN                                      (1<<7)
132 /*
133 if GG_EN = 0, then the ADC of BAT current controlled by the
134 bit  0: disable 1: enable
135 */
136 #define ADC_CUR_EN                                      (1<<6)
137 /*the ADC of TS1 controlled by the bit 0:disabsle 1:enable */
138 #define ADC_TS1_EN                                      (1<<5)
139 /*the ADC of TS2 controlled by the bit 0:disabsle 1:enable */
140 #define ADC_TS2_EN                                      (1<<4)
141 /*ADC colock phase  0:normal 1:inverted*/
142 #define ADC_PHASE                                       (1<<3)
143 #define ADC_CLK_SEL                                     7
144 /*****************************************************
145 #define ADC_CLK_SEL_2M                          0x000
146 #define ADC_CLK_SEL_1M                          0x001
147 #define ADC_CLK_SEL_500K                        0x002
148 #define ADC_CLK_SEL_250K                        0x003
149 #define ADC_CLK_SEL_125K                        0x004
150 ******************************************************/
151 /*GGCON*/
152 /* ADC bat current continue sample times  00:8  01:16 10:32 11:64*/
153 #define CUR_SAMPL_CON_TIMES             (3<<6)
154 /*ADC offset calibreation interval time 00:8min 01:16min 10:32min 11:48min*/
155 #define ADC_OFF_CAL_INTERV                      (3<<4)
156 /*OCV sampling interval time 00:8min 01:16min 10:32min :11:48min*/
157 #define OCV_SAMPL_INTERV                        (3<<2)
158
159 /*ADC working in current voltage collection mode*/
160 #define ADC_CUR_VOL_MODE                        (1<<1)
161 /*ADC working in resistor calculation mode 0:disable 1:enable*/
162 #define ADC_RES_MODE                            1
163
164 /*GGSTS*/
165 /*average current filter times 00:1/2  01:1/4 10:1/8 11:1/16*/
166 #define RES_CUR_AVG_SEL                         (3<<5)
167 /*battery first connection,edge trigger 0:NOT  1:YES*/
168 #define BAT_CON                                         (1<<4)
169 /*battery voltage1 update in relax status 0: NOT 1:YE*/
170 #define RELAX_VOL1_UPD                          (1<<3)
171 /*battery voltage2 update in relax status 0: NOT 1:YE*/
172 #define RELAX_VOL2_UPD                          (1<<2)
173 /*battery coming into relax status  0: NOT 1:YE*/
174 #define RELAX_STS                                       (1<<1)
175 /*battery average voltage and current updated status 0: NOT 1:YES*/
176 #define IV_AVG_UPD_STS                          (1<<0)
177
178 /*FRAME_SMP_INTERV_REG*/
179 #define AUTO_SLP_EN                                     (1<<5)
180 /* auto sleep mode 0:disable 1:enable*/
181 #define FRAME_SMP_INTERV_TIME           0x1F
182
183 /*VB_MOD_REG*/
184 #define PLUG_IN_STS                                     (1<<6)
185
186 /*SUP_STS_REG*/
187 #define BAT_EXS                                         (1<<7)
188 #define CHARGE_OFF                                      (0x00<<4)
189 #define DEAD_CHARGE                                     (0x01<<4)
190 #define TRICKLE_CHARGE                          (0x02<<4)
191 #define CC_OR_CV                                                (0x03<<4)
192 #define CHARGE_FINISH                           (0x04<<4)
193 #define USB_OVER_VOL                            (0x05<<4)
194 #define BAT_TMP_ERR                                     (0x06<<4)
195 #define TIMER_ERR                                       (0x07<<4)
196 /* usb is exists*/
197 #define USB_EXIST                                       (1<<1)
198 /* usb is effective*/
199 #define USB_EFF                                         (1<<0)
200
201 /*USB_CTRL_REG*/
202 #define CHRG_CT_EN                                      (1<<7)
203 /* USB_VLIM_SEL*/
204 /*
205 #define VLIM_4000MV                                     (0x00<<4)
206 #define VLIM_4100MV                                     (0x01<<4)
207 #define VLIM_4200MV                                     (0x02<<4)
208 #define VLIM_4300MV                                     (0x03<<4)
209 #define VLIM_4400MV                                     (0x04<<4)
210 #define VLIM_4500MV                                     (0x05<<4)
211 #define VLIM_4600MV                                     (0x06<<4)
212 #define VLIM_4700MV                                     (0x07<<4)
213 */
214
215 /*USB_ILIM_SEL*/
216 #define ILIM_450MA                                      (0x00)
217 #define ILIM_800MA                                      (0x01)
218 #define ILIM_850MA                                      (0x02)
219 #define ILIM_1000MA                                     (0x03)
220 #define ILIM_1250MA                                     (0x04)
221 #define ILIM_1500MA                                     (0x05)
222 #define ILIM_1750MA                                     (0x06)
223 #define ILIM_2000MA                                     (0x07)
224 #define ILIM_2250MA                                     (0x08)
225 #define ILIM_2500MA                                     (0x09)
226 #define ILIM_2750MA                                     (0x0A)
227 #define ILIM_3000MA                                     (0x0B)
228
229 /*CHRG_VOL_SEL*/
230 #define CHRG_VOL4050                            (0x00<<4)
231 #define CHRG_VOL4100                            (0x01<<4)
232 #define CHRG_VOL4150                            (0x02<<4)
233 #define CHRG_VOL4200                            (0x03<<4)
234 #define CHRG_VOL4300                            (0x04<<4)
235 #define CHRG_VOL4350                            (0x05<<4)
236
237 /*CHRG_CUR_SEL*/
238 #define CHRG_CUR1000mA                  (0x00)
239 #define CHRG_CUR1200mA                  (0x01)
240 #define CHRG_CUR1400mA                  (0x02)
241 #define CHRG_CUR1600mA                  (0x03)
242 #define CHRG_CUR1800mA                  (0x04)
243 #define CHRG_CUR2000mA                  (0x05)
244 #define CHRG_CUR2200mA                  (0x06)
245 #define CHRG_CUR2400mA                  (0x07)
246 #define CHRG_CUR2600mA                  (0x08)
247 #define CHRG_CUR2800mA                  (0x09)
248 #define CHRG_CUR3000mA                  (0x0A)
249
250 /*CHRG_CTRL_REG2*/
251 #define FINISH_100MA                            (0x00<<6)
252 #define FINISH_150MA                            (0x01<<6)
253 #define FINISH_200MA                            (0x02<<6)
254 #define FINISH_250MA                            (0x03<<6)
255
256 /*temp feed back degree*/
257 #define TEMP_85C                        (0x00 << 2)
258 #define TEMP_95C                        (0x01 << 2)
259 #define TEMP_105C                       (0x02 << 2)
260 #define TEMP_115C                       (0x03 << 2)
261
262
263 /* CHRG_CTRL_REG3*/
264 #define CHRG_TERM_ANA_SIGNAL            (0 << 5)
265 #define CHRG_TERM_DIG_SIGNAL            (1 << 5)
266 #define CHRG_TIMER_CCCV_EN              (1 << 2)
267
268 /*CHRG_CTRL_REG2*/
269 #define CHG_CCCV_4HOUR                  (0x00)
270 #define CHG_CCCV_5HOUR                  (0x01)
271 #define CHG_CCCV_6HOUR                  (0x02)
272 #define CHG_CCCV_8HOUR                  (0x03)
273 #define CHG_CCCV_10HOUR                 (0x04)
274 #define CHG_CCCV_12HOUR                 (0x05)
275 #define CHG_CCCV_14HOUR                 (0x06)
276 #define CHG_CCCV_16HOUR                 (0x07)
277
278 /*GGCON*/
279 #define SAMP_TIME_8MIN                          (0X00<<4)
280 #define SAMP_TIME_16MIN                         (0X01<<4)
281 #define SAMP_TIME_32MIN                         (0X02<<4)
282 #define SAMP_TIME_48MIN                         (0X03<<4)
283
284 #define ADC_CURRENT_MODE                        (1 << 1)
285 #define ADC_VOLTAGE_MODE                        (0 << 1)
286
287 #define DRIVER_VERSION                          "4.0.0"
288 #define ROLEX_SPEED                                     (100 * 1000)
289
290 #define CHARGING                                        0x01
291 #define DISCHARGING                                     0x00
292
293 #define TIMER_MS_COUNTS                 1000
294 #define MAX_CHAR                                        0x7F
295 #define MAX_UNSIGNED_CHAR                       0xFF
296 #define MAX_INT                                         0x7FFF
297 #define MAX_UNSIGNED_INT                        0xFFFF
298 #define MAX_INT8                                        0x7F
299 #define MAX_UINT8                                       0xFF
300
301 /* Gas Gauge Constatnts */
302 #define TEMP_0C                 2732
303 #define MAX_CAPACITY            0x7fff
304 #define MAX_SOC                 100
305 #define MAX_PERCENTAGE          100
306
307 /* Num, cycles with no Learning, after this many cycles, the gauge
308    start adjusting FCC, based on Estimated Cell Degradation */
309 #define NO_LEARNING_CYCLES      25
310 /* Size of the OCV Lookup table */
311 #define OCV_TABLE_SIZE          21
312 /*
313  * OCV Config
314  */
315 struct ocv_config {
316         /*voltage_diff, current_diff: Maximal allowed deviation
317         of the voltage and the current from one reading to the
318         next that allows the fuel gauge to apply an OCV correction.
319         The main purpose of these thresholds is to filter current
320         and voltage spikes. Recommended value: these value are
321         highly depend on the load nature. if the load creates a lot
322         of current spikes .the value may need to be increase*/
323         uint8_t voltage_diff;
324         uint8_t current_diff;
325         /* sleep_enter_current: if the current remains under
326         this threshold for [sleep_enter_samples]
327         consecutive samples. the gauge enters the SLEEP MODE*/
328         uint16_t sleep_enter_current;
329         /*sleep_enter_samples: the number of samples that
330         satis fy asleep enter or exit condition in order
331         to actually enter of exit SLEEP mode*/
332         uint8_t sleep_enter_samples;
333         /*sleep_exit_samples: to exit SLEEP mode , average
334         current should pass this threshold first. then
335         current should remain above this threshold for
336         [sleep_exit_samples] consecutive samples*/
337         uint16_t sleep_exit_current;
338         /*sleep_exit_samples: to exit SLEEP mode, average
339         current should pass this threshold first, then current
340         should remain above this threshold for [sleep_exit_samples]
341         consecutive samples.*/
342         uint8_t sleep_exit_samples;
343         /*relax_period: defines the number of seconds the
344         fuel gauge should spend in the SLEEP mode
345         before entering the OCV mode, this setting makes
346         the gauge wait for a cell voltage recovery after
347         a charge or discharge operation*/
348         uint16_t relax_period;
349         /* flat_zone_low : flat_zone_high :if soc falls into
350         the flat zone low% - flat zone high %.the fuel gauge
351         wait for a cell voltage recovery after a charge or
352         discharge operation.*/
353         uint8_t flat_zone_low;
354         uint8_t flat_zone_high;
355         /*FCC leaning is disqualified if the discharge capacity
356         in the OCV mode is greater than this threshold*/
357         uint16_t max_ocv_discharge;
358         /*the 21-point OCV table*/
359         uint16_t table[OCV_TABLE_SIZE];
360         /*uint16_t *table;*/
361 };
362
363 /* EDV Point */
364 struct edv_point {
365         int16_t voltage;
366         uint8_t percent;
367 };
368
369 /* EDV Point tracking data */
370 struct edv_state {
371         int16_t voltage;
372         uint8_t percent;
373         int16_t min_capacity;
374         uint8_t edv_cmp;
375 };
376
377 /* EDV Configuration */
378 struct edv_config {
379         /*avieraging: True = evokes averaging on voltage
380         reading to detect an EDV condition.
381         False = no averaging of voltage readings to detect an
382         EDV conditation.*/
383         bool averaging;
384         /*sequential_edv: the sequential_edv setting defines
385         how many times in a row the battery should
386         pass the EDV threshold to detect an EDV condition.
387         this setting is intended to fiter short voltage spikes
388         cause by current spikes*/
389         uint8_t sequential_edv;
390         /*filter_light: difine the calculated EDV voltage
391         recovery IIR filter strength
392         light-lsetting : for light load (below Qmax/5)
393         heavy setting : for ligh load (above Qmax/5)
394         the filter is applied only if the load is greater than
395         Qmax/3. if average = True. then the Qmax/5 threshold
396         is compared to averge current.otherwise it is compared
397         to current.
398         Recommended value: 15-255. 255---disabsle the filter
399         */
400         uint8_t filter_light;
401         uint8_t filter_heavy;
402         /*overload_current: the current level above which an
403         EDV condition will not be detected and
404         capacity not reconciled*/
405         int16_t overload_current;
406
407         struct edv_point edv[3];
408         /*edv: the end-of-discharge voltage-to-capactiy
409         correlation points.*/
410         /*struct edv_point *edv;*/
411 };
412
413 /* General Battery Cell Gauging Configuration */
414 struct cell_config {
415         bool cc_polarity;  /*To Be Determined*/
416         bool cc_out;
417         /*ocv_below_edv1: if set (True), OCV correction allowed
418         bellow EDV1 point*/
419         bool ocv_below_edv1;
420         /*cc_voltage: the charge complete voltage threshold(e.g. 4.2v)
421         of the battery. charge cannot be considered complete if the
422         battery voltage is below this threshold*/
423         int16_t cc_voltage;
424         /*cc_current:the charge complete current threshold(e.g. c/20).
425         charge cannot  be considered complete when charge
426         current and average current are greater than this threshold*/
427         int16_t cc_current;
428         /*design_capacity: design capacity of the battery.
429         the battery datasheet should provide this value*/
430         uint16_t design_capacity;
431         /*design_qmax: the calculated discharge capacity of
432         the OCV discharge curve*/
433         int16_t design_qmax;
434         /*r_sense: the resistance of the current sence element.
435         the sense resistor needs to be slelected to
436         ensure accurate current measuremen and integration
437         at currents >OFF consumption*/
438         uint8_t r_sense;
439         /*qmax_adjust: the value decremented from QMAX
440         every cycle for aging compensation.*/
441         uint8_t qmax_adjust;
442         /*fcc_adjust: the value decremented from the FCC
443         when no learning happen for 25 cycles in a row*/
444         uint8_t fcc_adjust;
445         /*max_overcharge: the fuel gauge tracks the capacity
446         that goes into the battery after a termination
447         condition is detected. this improve gauging accuracy
448         if the charger's charge termination condition does't
449         match to the fuel gauge charge termination condition.*/
450         uint16_t max_overcharge;
451         /*electronics_load: the current that the system consumes
452         int the OFF mode(MPU low power, screen  OFF)*/
453         uint16_t electronics_load;
454         /*max_increment: the maximum increment of FCC if the
455         learned capacity is much greater than the exiting
456         FCC. recommentded value 150mAh*/
457         int16_t max_increment;
458         /*max_decrement: the maximum increment of FCC if the
459         learned capacity is much lower than the exiting FCC*/
460         int16_t max_decrement;
461         /*low_temp: the correlation between voltage and remaining
462         capacity is considered inaccurate below this temperature.
463         any leaning will be disqualified, if the battery temperature
464         is below this threshold
465         */
466         uint8_t low_temp;
467         /*deep_dsg_voltage:in order to qualify capacity learning on
468         the discharge, the battery voltage should
469         be within EDV-deep-dsg_voltage and EDV.*/
470         uint16_t deep_dsg_voltage;
471         /*
472         max_dsg_voltage:limits the amount of the estimated
473         discharge when learning is in progress. if the amount of
474         the capacity estimation get greater than this threshold,
475         the learning gets disqualified
476         */
477         uint16_t max_dsg_estimate;
478         /*
479         light_load: FCC learning on discharge disqualifies if
480         the load is below this threshold when the
481         when EDV2 is reached.
482         */
483         uint8_t light_load;
484         /*
485         near_full: this defines a capacity zone from FCC
486         to FCC - near_full. A discharge cycles start
487         from this capacity zone qualifies for FCC larning.
488         */
489         uint16_t near_full;
490         /*
491         cycle_threshold: the amount of capacity that should
492         be dicharged from the battery to increment the cycle
493         count by 1.cycle counting happens on the discharge only.
494         */
495         uint16_t cycle_threshold;
496         /*recharge: the voltage of recharge.*/
497         uint16_t recharge;
498         /*
499         mode_swtich_capacity: this defines how much capacity
500         should pass through the coulomb counter to cause a cycle
501         count start condition (either charge or discharge). the gauge
502         support 2 cycle typeds.charge and discharge. a cycle starts
503         when mode_switch_capacity passes through the coulomb counter
504         the cycle get canceled and switches to the opposite direciton
505         if mode_switch_capacity passes though
506         the coulomb counter in oppositer direciton.
507         */
508         uint8_t mode_switch_capacity;
509         /*call_period: approximate time between fuel gauge calls.*/
510         uint8_t call_period;
511
512         struct ocv_config *ocv;
513         struct edv_config *edv;
514 };
515
516 /* Cell State */
517 /*
518 light-load: ( < C/40)
519
520 */
521 struct cell_state {
522         /*
523         SOC : state-of-charge of the battery in %,it represents
524         the % full of the battery from the system empty voltage.
525         SOC = NAC/FCC,  SOC = 1 -DOD
526         */
527         int16_t soc;
528         /*
529         nac :nominal avaiable charge of the battery in mAh.
530         it represents the present remain capacity of the battery
531         to the system empty voltage under nominal conditions
532         */
533         int16_t nac;
534         /*
535         fcc: full battery capacity .this represents the discharge capacity
536         of the battery from the defined full condition to the system empty
537         voltage(EDV0) under nominal conditions.the value is learned by
538         the algorithm on qualified charge and discharge cycleds
539         */
540         int16_t fcc;
541         /* qmax: the battery capacity(mAh) at the OCV curve discharge rate*/
542         int16_t qmax;
543
544         int16_t voltage;
545         int16_t av_voltage;
546         int16_t cur;
547         int16_t av_current;
548
549         int16_t temperature;
550         /*
551         cycle_count: it represents how many charge or discharge
552         cycles a battery has experience. this is used to estimate the
553         change of impedance of the battery due to "aging"
554         */
555         int16_t cycle_count;
556         /*
557         sleep : in this mode ,the battery fuel gauge is counting
558         discharge with the coulomb counter and checking for the
559         battery relaxed condition, if a relaxed battery is destected
560         the fuel gauge enters OCV mode
561         */
562         bool sleep;
563         bool relax;
564
565         bool chg;
566         bool dsg;
567
568         bool edv0;
569         bool edv1;
570         bool edv2;
571         bool ocv;
572         bool cc;
573         bool full;
574
575         bool eocl;
576         bool vcq;
577         bool vdq;
578         bool init;
579
580         struct timeval sleep_timer;
581         struct timeval el_sleep_timer;
582         uint16_t cumulative_sleep;
583
584         int16_t prev_soc;
585         int16_t learn_q;
586         uint16_t dod_eoc;
587         int16_t learn_offset;
588         uint16_t learned_cycle;
589         int16_t new_fcc;
590         int16_t ocv_total_q;
591         int16_t ocv_enter_q;
592         int16_t negative_q;
593         int16_t overcharge_q;
594         int16_t charge_cycle_q;
595         int16_t discharge_cycle_q;
596         int16_t cycle_q;
597         uint8_t sequential_cc;
598         uint8_t sleep_samples;
599         uint8_t sequential_edvs;
600
601         uint16_t electronics_load;
602         uint16_t cycle_dsg_estimate;
603
604         struct edv_state edv;
605
606         bool updated;
607         bool calibrate;
608
609         struct cell_config *config;
610 };
611
612 struct battery_platform_data {
613         int *battery_tmp_tbl;
614         unsigned int tblsize;
615         u32 *battery_ocv;
616         unsigned int  ocv_size;
617
618         unsigned int monitoring_interval;
619         unsigned int max_charger_ilimitmA;
620         unsigned int max_charger_currentmA;
621         unsigned int max_charger_voltagemV;
622         unsigned int termination_currentmA;
623
624         unsigned int max_bat_voltagemV;
625         unsigned int low_bat_voltagemV;
626         unsigned int chrg_diff_vol;
627         unsigned int power_off_thresd;
628         unsigned int sense_resistor_mohm;
629
630         /* twl6032 */
631         unsigned long features;
632         unsigned long errata;
633
634         struct cell_config *cell_cfg;
635 };
636
637 enum fg_mode {
638         FG_NORMAL_MODE = 0,/*work normally*/
639         TEST_POWER_MODE,   /*work without battery*/
640 };
641
642 enum hw_support_adp {
643         HW_ADP_TYPE_USB = 0,/*'HW' means:hardware*/
644         HW_ADP_TYPE_DC,
645         HW_ADP_TYPE_DUAL
646 };
647
648
649 /* don't change the following ID, they depend on usb check
650  * interface: dwc_otg_check_dpdm()
651  */
652 enum charger_type {
653         NO_CHARGER = 0,
654         USB_CHARGER,
655         AC_CHARGER,
656         DC_CHARGER,
657         DUAL_CHARGER
658 };
659
660 enum charger_state {
661         OFFLINE = 0,
662         ONLINE
663 };
664
665 void kernel_power_off(void);
666 #if defined(CONFIG_ARCH_ROCKCHIP)
667 int dwc_vbus_status(void);
668 int get_gadget_connect_flag(void);
669 void rk_send_wakeup_key(void);
670 #else
671
672 static inline int get_gadget_connect_flag(void)
673 {
674         return 0;
675 }
676
677 static inline int dwc_otg_check_dpdm(bool wait)
678 {
679         return 0;
680 }
681
682 static inline void rk_send_wakeup_key(void)
683 {
684 }
685 #endif
686
687 #endif