Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /***************************************************************************** |
2 | * | |
3 | * Filename: | |
4 | * --------- | |
5 | * linear_charging.c | |
6 | * | |
7 | * Project: | |
8 | * -------- | |
9 | * ALPS_Software | |
10 | * | |
11 | * Description: | |
12 | * ------------ | |
13 | * This file implements the interface between BMT and ADC scheduler. | |
14 | * | |
15 | * Author: | |
16 | * ------- | |
17 | * Oscar Liu | |
18 | * | |
19 | *============================================================================ | |
20 | * $Revision: 1.0 $ | |
21 | * $Modtime: 11 Aug 2005 10:28:16 $ | |
22 | * $Log: //mtkvs01/vmdata/Maui_sw/archives/mcu/hal/peripheral/inc/bmt_chr_setting.h-arc $ | |
23 | * HISTORY | |
24 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! | |
25 | *------------------------------------------------------------------------------ | |
26 | *------------------------------------------------------------------------------ | |
27 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! | |
28 | *============================================================================ | |
29 | ****************************************************************************/ | |
30 | #include <linux/kernel.h> | |
31 | #include <mach/battery_common.h> | |
32 | #include <mach/charging.h> | |
33 | #include "cust_charging.h" | |
34 | #include <mach/mt_boot.h> | |
35 | #include <mach/battery_meter.h> | |
36 | ||
37 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
38 | #include <linux/mutex.h> | |
39 | #include <linux/wakelock.h> | |
40 | #include <linux/delay.h> | |
41 | #if !defined(TA_AC_CHARGING_CURRENT) | |
42 | #include "cust_pe.h" | |
43 | #endif | |
44 | #endif | |
45 | ||
46 | #ifdef CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT | |
47 | #include <mach/diso.h> | |
48 | #endif | |
49 | ||
50 | /* ============================================================ // */ | |
51 | /* define */ | |
52 | /* ============================================================ // */ | |
53 | /* cut off to full */ | |
54 | #define POST_CHARGING_TIME 30 * 60 /* 30mins */ | |
55 | #define FULL_CHECK_TIMES 6 | |
56 | ||
57 | /* ============================================================ // */ | |
58 | /* global variable */ | |
59 | /* ============================================================ // */ | |
60 | kal_uint32 g_bcct_flag = 0; | |
61 | kal_uint32 g_bcct_value = 0; | |
62 | kal_uint32 g_full_check_count = 0; | |
63 | CHR_CURRENT_ENUM g_temp_CC_value = CHARGE_CURRENT_0_00_MA; | |
64 | CHR_CURRENT_ENUM g_temp_input_CC_value = CHARGE_CURRENT_0_00_MA; | |
65 | kal_uint32 g_usb_state = USB_UNCONFIGURED; | |
66 | static bool usb_unlimited=false; | |
67 | ||
68 | /* ///////////////////////////////////////////////////////////////////////////////////////// */ | |
69 | /* // PUMP EXPRESS */ | |
70 | /* ///////////////////////////////////////////////////////////////////////////////////////// */ | |
71 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
72 | struct wake_lock TA_charger_suspend_lock; | |
73 | kal_bool ta_check_chr_type = KAL_TRUE; | |
74 | kal_bool ta_cable_out_occur = KAL_FALSE; | |
75 | kal_bool is_ta_connect = KAL_FALSE; | |
76 | kal_bool ta_vchr_tuning = KAL_TRUE; | |
77 | int ta_v_chr_org = 0; | |
78 | #endif | |
4b9e9796 S |
79 | /* [PLATFORM]-Add-BEGIN by TCTSZ.leo.guo, 04/15/2015, modify ntc temperature function */ |
80 | #ifdef MTK_BATTERY_PROTECT_FEATURE | |
81 | kal_bool high_temp_stop_charge = KAL_FALSE; | |
82 | #endif | |
83 | /* [PLATFORM]-Add-END by TCTSZ.leo.guo */ | |
6fa3eb70 S |
84 | |
85 | /* ///////////////////////////////////////////////////////////////////////////////////////// */ | |
86 | /* // JEITA */ | |
87 | /* ///////////////////////////////////////////////////////////////////////////////////////// */ | |
88 | #if defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
89 | int g_temp_status = TEMP_POS_10_TO_POS_45; | |
90 | kal_bool temp_error_recovery_chr_flag = KAL_TRUE; | |
91 | #endif | |
92 | ||
93 | ||
94 | ||
95 | /* ============================================================ // */ | |
96 | /* function prototype */ | |
97 | /* ============================================================ // */ | |
98 | ||
99 | ||
100 | /* ============================================================ // */ | |
101 | /* extern variable */ | |
102 | /* ============================================================ // */ | |
103 | extern int g_platform_boot_mode; | |
104 | ||
105 | /* ============================================================ // */ | |
106 | /* extern function */ | |
107 | /* ============================================================ // */ | |
108 | ||
109 | ||
110 | /* ============================================================ // */ | |
111 | void BATTERY_SetUSBState(int usb_state_value) | |
112 | { | |
113 | #if defined(CONFIG_POWER_EXT) | |
114 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY_SetUSBState] in FPGA/EVB, no service\r\n"); | |
115 | #else | |
116 | if ((usb_state_value < USB_SUSPEND) || ((usb_state_value > USB_CONFIGURED))) { | |
117 | battery_xlog_printk(BAT_LOG_CRTI, | |
118 | "[BATTERY] BAT_SetUSBState Fail! Restore to default value\r\n"); | |
119 | usb_state_value = USB_UNCONFIGURED; | |
120 | } else { | |
121 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] BAT_SetUSBState Success! Set %d\r\n", | |
122 | usb_state_value); | |
123 | g_usb_state = usb_state_value; | |
124 | } | |
125 | #endif | |
126 | } | |
127 | ||
128 | ||
129 | kal_uint32 get_charging_setting_current(void) | |
130 | { | |
131 | return g_temp_CC_value; | |
132 | } | |
133 | ||
134 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
135 | static DEFINE_MUTEX(ta_mutex); | |
136 | ||
137 | static void set_ta_charging_current(void) | |
138 | { | |
139 | int real_v_chrA = 0; | |
140 | ||
141 | real_v_chrA = battery_meter_get_charger_voltage(); | |
142 | battery_xlog_printk(BAT_LOG_CRTI, "set_ta_charging_current, chrA=%d, chrB=%d\n", | |
143 | ta_v_chr_org, real_v_chrA); | |
144 | ||
145 | if((real_v_chrA - ta_v_chr_org) > 3000) { | |
146 | g_temp_input_CC_value = TA_AC_9V_INPUT_CURRENT; //TA = 9V | |
147 | g_temp_CC_value = TA_AC_CHARGING_CURRENT; | |
148 | } else if((real_v_chrA - ta_v_chr_org) > 1000) { | |
149 | g_temp_input_CC_value = TA_AC_7V_INPUT_CURRENT; //TA = 7V | |
150 | g_temp_CC_value = TA_AC_CHARGING_CURRENT; | |
151 | } | |
152 | } | |
153 | ||
154 | static void mtk_ta_reset_vchr(void) | |
155 | { | |
156 | CHR_CURRENT_ENUM chr_current = CHARGE_CURRENT_70_00_MA; | |
157 | ||
158 | battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT,&chr_current); | |
159 | msleep(250); // reset Vchr to 5V | |
160 | ||
161 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_reset_vchr(): reset Vchr to 5V \n"); | |
162 | } | |
163 | ||
164 | static void mtk_ta_increase(void) | |
165 | { | |
166 | kal_bool ta_current_pattern = KAL_TRUE; // TRUE = increase | |
167 | ||
168 | if(ta_cable_out_occur == KAL_FALSE) { | |
169 | battery_charging_control(CHARGING_CMD_SET_TA_CURRENT_PATTERN, &ta_current_pattern); | |
170 | } else { | |
171 | ta_check_chr_type = KAL_TRUE; | |
172 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_increase() Cable out \n"); | |
173 | } | |
174 | } | |
175 | ||
176 | static kal_bool mtk_ta_retry_increase(void) | |
177 | { | |
178 | int real_v_chrA; | |
179 | int real_v_chrB; | |
180 | kal_bool retransmit = KAL_TRUE; | |
181 | kal_uint32 retransmit_count=0; | |
182 | ||
183 | do { | |
184 | real_v_chrA = battery_meter_get_charger_voltage(); | |
185 | mtk_ta_increase(); //increase TA voltage to 7V | |
186 | real_v_chrB = battery_meter_get_charger_voltage(); | |
187 | ||
188 | if(real_v_chrB - real_v_chrA >= 1000) { /* 1.0V */ | |
189 | retransmit = KAL_FALSE; | |
190 | } else { | |
191 | retransmit_count++; | |
192 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_detector(): retransmit_count =%d, chrA=%d, chrB=%d\n", | |
193 | retransmit_count, real_v_chrA, real_v_chrB); | |
194 | } | |
195 | ||
196 | if((retransmit_count == 3) || (BMT_status.charger_exist == KAL_FALSE)) { | |
197 | retransmit = KAL_FALSE; | |
198 | } | |
199 | ||
200 | } while((retransmit == KAL_TRUE) && (ta_cable_out_occur == KAL_FALSE)); | |
201 | ||
202 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_retry_increase() real_v_chrA=%d, real_v_chrB=%d, retry=%d\n", | |
203 | real_v_chrA, real_v_chrB,retransmit_count); | |
204 | ||
205 | if(retransmit_count == 3) | |
206 | return KAL_FALSE; | |
207 | else | |
208 | return KAL_TRUE; | |
209 | } | |
210 | ||
211 | static void mtk_ta_detector(void) | |
212 | { | |
213 | int real_v_chrB = 0; | |
214 | ||
215 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_detector() start\n"); | |
216 | ||
217 | ta_v_chr_org = battery_meter_get_charger_voltage(); | |
218 | mtk_ta_retry_increase(); | |
219 | real_v_chrB = battery_meter_get_charger_voltage(); | |
220 | ||
221 | if(real_v_chrB - ta_v_chr_org >= 1000) | |
222 | is_ta_connect = KAL_TRUE; | |
223 | else | |
224 | is_ta_connect = KAL_FALSE; | |
225 | ||
226 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_detector() end, is_ta_connect=%d\n",is_ta_connect); | |
227 | } | |
228 | ||
229 | static void mtk_ta_init(void) | |
230 | { | |
231 | is_ta_connect = KAL_FALSE; | |
232 | ta_cable_out_occur = KAL_FALSE; | |
233 | ||
234 | #ifdef TA_9V_SUPPORT | |
235 | ta_vchr_tuning = KAL_FALSE; | |
236 | #endif | |
237 | ||
238 | battery_charging_control(CHARGING_CMD_INIT,NULL); | |
239 | } | |
240 | ||
241 | static void battery_pump_express_charger_check(void) | |
242 | { | |
243 | if (KAL_TRUE == ta_check_chr_type && | |
244 | STANDARD_CHARGER == BMT_status.charger_type && | |
245 | BMT_status.SOC >= TA_START_BATTERY_SOC && | |
246 | BMT_status.SOC < TA_STOP_BATTERY_SOC) { | |
247 | ||
248 | mutex_lock(&ta_mutex); | |
249 | wake_lock(&TA_charger_suspend_lock); | |
250 | ||
251 | mtk_ta_reset_vchr(); | |
252 | ||
253 | mtk_ta_init(); | |
254 | mtk_ta_detector(); | |
255 | ||
256 | /* need to re-check if the charger plug out during ta detector */ | |
257 | if(KAL_TRUE == ta_cable_out_occur) | |
258 | ta_check_chr_type = KAL_TRUE; | |
259 | else | |
260 | ta_check_chr_type = KAL_FALSE; | |
261 | ||
262 | wake_unlock(&TA_charger_suspend_lock); | |
263 | mutex_unlock(&ta_mutex); | |
264 | } else { | |
265 | battery_xlog_printk(BAT_LOG_CRTI, | |
266 | "Stop battery_pump_express_charger_check, SOC=%d, ta_check_chr_type = %d, charger_type = %d \n", | |
267 | BMT_status.SOC, ta_check_chr_type, BMT_status.charger_type); | |
268 | } | |
269 | } | |
270 | ||
271 | static void battery_pump_express_algorithm_start(void) | |
272 | { | |
273 | kal_int32 charger_vol; | |
274 | kal_uint32 charging_enable = KAL_FALSE; | |
275 | ||
276 | mutex_lock(&ta_mutex); | |
277 | wake_lock(&TA_charger_suspend_lock); | |
278 | ||
279 | if(KAL_TRUE == is_ta_connect) { | |
280 | /* check cable impedance */ | |
281 | charger_vol = battery_meter_get_charger_voltage(); | |
282 | if(KAL_FALSE == ta_vchr_tuning) { | |
283 | mtk_ta_retry_increase(); /* increase TA voltage to 9V */ | |
284 | charger_vol = battery_meter_get_charger_voltage(); | |
285 | ta_vchr_tuning = KAL_TRUE; | |
286 | } else if(BMT_status.SOC > TA_STOP_BATTERY_SOC) { | |
287 | /* disable charging, avoid Iterm issue */ | |
288 | battery_charging_control(CHARGING_CMD_ENABLE,&charging_enable); | |
289 | mtk_ta_reset_vchr(); //decrease TA voltage to 5V | |
290 | charger_vol = battery_meter_get_charger_voltage(); | |
291 | if(abs(charger_vol - ta_v_chr_org) <= 1000) /* 1.0V */ | |
292 | is_ta_connect = KAL_FALSE; | |
293 | ||
294 | battery_xlog_printk(BAT_LOG_CRTI, "Stop battery_pump_express_algorithm, SOC=%d is_ta_connect =%d, TA_STOP_BATTERY_SOC: %d\n", | |
295 | BMT_status.SOC, is_ta_connect, TA_STOP_BATTERY_SOC); | |
296 | } | |
297 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] check cable impedance, VA(%d) VB(%d) delta(%d).\n", | |
298 | ta_v_chr_org, charger_vol, charger_vol - ta_v_chr_org); | |
299 | ||
300 | battery_xlog_printk(BAT_LOG_CRTI, "mtk_ta_algorithm() end\n"); | |
301 | } else { | |
302 | battery_xlog_printk(BAT_LOG_CRTI, "It's not a TA charger, bypass TA algorithm\n"); | |
303 | } | |
304 | ||
305 | wake_unlock(&TA_charger_suspend_lock); | |
306 | mutex_unlock(&ta_mutex); | |
307 | } | |
308 | #endif | |
309 | ||
310 | #if defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
311 | ||
312 | static BATTERY_VOLTAGE_ENUM select_jeita_cv(void) | |
313 | { | |
314 | BATTERY_VOLTAGE_ENUM cv_voltage; | |
315 | ||
316 | if (g_temp_status == TEMP_ABOVE_POS_60) { | |
317 | cv_voltage = JEITA_TEMP_ABOVE_POS_60_CV_VOLTAGE; | |
318 | } else if (g_temp_status == TEMP_POS_45_TO_POS_60) { | |
319 | cv_voltage = JEITA_TEMP_POS_45_TO_POS_60_CV_VOLTAGE; | |
320 | } else if (g_temp_status == TEMP_POS_10_TO_POS_45) { | |
321 | #ifdef HIGH_BATTERY_VOLTAGE_SUPPORT | |
4b9e9796 | 322 | cv_voltage = BATTERY_VOLT_04_360000_V; |
6fa3eb70 S |
323 | #else |
324 | cv_voltage = JEITA_TEMP_POS_10_TO_POS_45_CV_VOLTAGE; | |
325 | #endif | |
326 | } else if (g_temp_status == TEMP_POS_0_TO_POS_10) { | |
327 | cv_voltage = JEITA_TEMP_POS_0_TO_POS_10_CV_VOLTAGE; | |
328 | } else if (g_temp_status == TEMP_NEG_10_TO_POS_0) { | |
329 | cv_voltage = JEITA_TEMP_NEG_10_TO_POS_0_CV_VOLTAGE; | |
330 | } else if (g_temp_status == TEMP_BELOW_NEG_10) { | |
331 | cv_voltage = JEITA_TEMP_BELOW_NEG_10_CV_VOLTAGE; | |
332 | } else { | |
333 | cv_voltage = BATTERY_VOLT_04_200000_V; | |
334 | } | |
335 | ||
336 | return cv_voltage; | |
337 | } | |
338 | ||
339 | PMU_STATUS do_jeita_state_machine(void) | |
340 | { | |
341 | BATTERY_VOLTAGE_ENUM cv_voltage; | |
342 | ||
343 | /* JEITA battery temp Standard */ | |
344 | ||
345 | if (BMT_status.temperature >= TEMP_POS_60_THRESHOLD) { | |
346 | battery_xlog_printk(BAT_LOG_CRTI, | |
347 | "[BATTERY] Battery Over high Temperature(%d) !!\n\r", | |
348 | TEMP_POS_60_THRESHOLD); | |
349 | ||
350 | g_temp_status = TEMP_ABOVE_POS_60; | |
351 | ||
352 | return PMU_STATUS_FAIL; | |
353 | } else if (BMT_status.temperature > TEMP_POS_45_THRESHOLD) /* control 45c to normal behavior */ | |
354 | { | |
355 | if ((g_temp_status == TEMP_ABOVE_POS_60) | |
356 | && (BMT_status.temperature >= TEMP_POS_60_THRES_MINUS_X_DEGREE)) { | |
357 | battery_xlog_printk(BAT_LOG_CRTI, | |
358 | "[BATTERY] Battery Temperature between %d and %d,not allow charging yet!!\n\r", | |
359 | TEMP_POS_60_THRES_MINUS_X_DEGREE, | |
360 | TEMP_POS_60_THRESHOLD); | |
361 | ||
362 | return PMU_STATUS_FAIL; | |
363 | } else { | |
364 | battery_xlog_printk(BAT_LOG_CRTI, | |
365 | "[BATTERY] Battery Temperature between %d and %d !!\n\r", | |
366 | TEMP_POS_45_THRESHOLD, TEMP_POS_60_THRESHOLD); | |
367 | ||
368 | g_temp_status = TEMP_POS_45_TO_POS_60; | |
369 | } | |
370 | } else if (BMT_status.temperature >= TEMP_POS_10_THRESHOLD) { | |
371 | if (((g_temp_status == TEMP_POS_45_TO_POS_60) | |
372 | && (BMT_status.temperature >= TEMP_POS_45_THRES_MINUS_X_DEGREE)) | |
373 | || ((g_temp_status == TEMP_POS_0_TO_POS_10) | |
374 | && (BMT_status.temperature <= TEMP_POS_10_THRES_PLUS_X_DEGREE))) { | |
375 | battery_xlog_printk(BAT_LOG_CRTI, | |
376 | "[BATTERY] Battery Temperature not recovery to normal temperature charging mode yet!!\n\r"); | |
377 | } else { | |
378 | battery_xlog_printk(BAT_LOG_CRTI, | |
379 | "[BATTERY] Battery Normal Temperature between %d and %d !!\n\r", | |
380 | TEMP_POS_10_THRESHOLD, TEMP_POS_45_THRESHOLD); | |
381 | g_temp_status = TEMP_POS_10_TO_POS_45; | |
382 | } | |
383 | } else if (BMT_status.temperature >= TEMP_POS_0_THRESHOLD) { | |
384 | if ((g_temp_status == TEMP_NEG_10_TO_POS_0 || g_temp_status == TEMP_BELOW_NEG_10) | |
385 | && (BMT_status.temperature <= TEMP_POS_0_THRES_PLUS_X_DEGREE)) { | |
386 | if (g_temp_status == TEMP_NEG_10_TO_POS_0) { | |
387 | battery_xlog_printk(BAT_LOG_CRTI, | |
388 | "[BATTERY] Battery Temperature between %d and %d !!\n\r", | |
389 | TEMP_POS_0_THRES_PLUS_X_DEGREE, | |
390 | TEMP_POS_10_THRESHOLD); | |
391 | } | |
392 | if (g_temp_status == TEMP_BELOW_NEG_10) { | |
393 | battery_xlog_printk(BAT_LOG_CRTI, | |
394 | "[BATTERY] Battery Temperature between %d and %d,not allow charging yet!!\n\r", | |
395 | TEMP_POS_0_THRESHOLD, | |
396 | TEMP_POS_0_THRES_PLUS_X_DEGREE); | |
397 | return PMU_STATUS_FAIL; | |
398 | } | |
399 | } else { | |
400 | battery_xlog_printk(BAT_LOG_CRTI, | |
401 | "[BATTERY] Battery Temperature between %d and %d !!\n\r", | |
402 | TEMP_POS_0_THRESHOLD, TEMP_POS_10_THRESHOLD); | |
403 | ||
404 | g_temp_status = TEMP_POS_0_TO_POS_10; | |
405 | } | |
406 | } else if (BMT_status.temperature >= TEMP_NEG_10_THRESHOLD) { | |
407 | if ((g_temp_status == TEMP_BELOW_NEG_10) | |
408 | && (BMT_status.temperature <= TEMP_NEG_10_THRES_PLUS_X_DEGREE)) { | |
409 | battery_xlog_printk(BAT_LOG_CRTI, | |
410 | "[BATTERY] Battery Temperature between %d and %d,not allow charging yet!!\n\r", | |
411 | TEMP_NEG_10_THRESHOLD, TEMP_NEG_10_THRES_PLUS_X_DEGREE); | |
412 | ||
413 | return PMU_STATUS_FAIL; | |
414 | } else { | |
415 | battery_xlog_printk(BAT_LOG_CRTI, | |
416 | "[BATTERY] Battery Temperature between %d and %d !!\n\r", | |
417 | TEMP_NEG_10_THRESHOLD, TEMP_POS_0_THRESHOLD); | |
418 | ||
419 | g_temp_status = TEMP_NEG_10_TO_POS_0; | |
420 | } | |
421 | } else { | |
422 | battery_xlog_printk(BAT_LOG_CRTI, | |
423 | "[BATTERY] Battery below low Temperature(%d) !!\n\r", | |
424 | TEMP_NEG_10_THRESHOLD); | |
425 | g_temp_status = TEMP_BELOW_NEG_10; | |
426 | ||
427 | return PMU_STATUS_FAIL; | |
428 | } | |
429 | ||
430 | /* set CV after temperature changed */ | |
431 | ||
432 | cv_voltage = select_jeita_cv(); | |
433 | battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE, &cv_voltage); | |
434 | ||
435 | return PMU_STATUS_OK; | |
436 | } | |
437 | ||
438 | ||
439 | static void set_jeita_charging_current(void) | |
440 | { | |
441 | #ifdef CONFIG_USB_IF | |
442 | if (BMT_status.charger_type == STANDARD_HOST) | |
443 | return; | |
444 | #endif | |
445 | ||
446 | if (g_temp_status == TEMP_NEG_10_TO_POS_0) { | |
447 | g_temp_CC_value = CHARGE_CURRENT_350_00_MA; | |
448 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
449 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] JEITA set charging current : %d\r\n", | |
450 | g_temp_CC_value); | |
451 | } | |
452 | } | |
453 | ||
454 | #endif | |
455 | ||
456 | bool get_usb_current_unlimited(void) | |
457 | { | |
458 | if (BMT_status.charger_type == STANDARD_HOST || BMT_status.charger_type == CHARGING_HOST) | |
459 | return usb_unlimited; | |
460 | else | |
461 | return false; | |
462 | } | |
463 | ||
464 | void set_usb_current_unlimited(bool enable) | |
465 | { | |
466 | usb_unlimited = enable; | |
467 | } | |
468 | ||
469 | void select_charging_curret_bcct(void) | |
470 | { | |
471 | if ((BMT_status.charger_type == STANDARD_HOST) || | |
472 | (BMT_status.charger_type == NONSTANDARD_CHARGER)) { | |
473 | if (g_bcct_value < 100) | |
474 | g_temp_input_CC_value = CHARGE_CURRENT_0_00_MA; | |
475 | else if (g_bcct_value < 500) | |
476 | g_temp_input_CC_value = CHARGE_CURRENT_100_00_MA; | |
477 | else if (g_bcct_value < 800) | |
478 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
479 | else if (g_bcct_value == 800) | |
480 | g_temp_input_CC_value = CHARGE_CURRENT_800_00_MA; | |
481 | else | |
482 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
483 | } else if ((BMT_status.charger_type == STANDARD_CHARGER) || | |
484 | (BMT_status.charger_type == CHARGING_HOST)) { | |
485 | g_temp_input_CC_value = CHARGE_CURRENT_MAX; | |
486 | ||
487 | /* --------------------------------------------------- */ | |
488 | /* set IOCHARGE */ | |
489 | if (g_bcct_value < 550) | |
490 | g_temp_CC_value = CHARGE_CURRENT_0_00_MA; | |
491 | else if (g_bcct_value < 650) | |
492 | g_temp_CC_value = CHARGE_CURRENT_550_00_MA; | |
493 | else if (g_bcct_value < 750) | |
494 | g_temp_CC_value = CHARGE_CURRENT_650_00_MA; | |
495 | else if (g_bcct_value < 850) | |
496 | g_temp_CC_value = CHARGE_CURRENT_750_00_MA; | |
497 | else if (g_bcct_value < 950) | |
498 | g_temp_CC_value = CHARGE_CURRENT_850_00_MA; | |
499 | else if (g_bcct_value < 1050) | |
500 | g_temp_CC_value = CHARGE_CURRENT_950_00_MA; | |
501 | else if (g_bcct_value < 1150) | |
502 | g_temp_CC_value = CHARGE_CURRENT_1050_00_MA; | |
503 | else if (g_bcct_value < 1250) | |
504 | g_temp_CC_value = CHARGE_CURRENT_1150_00_MA; | |
505 | else if (g_bcct_value == 1250) | |
506 | g_temp_CC_value = CHARGE_CURRENT_1250_00_MA; | |
507 | else | |
508 | g_temp_CC_value = CHARGE_CURRENT_650_00_MA; | |
509 | /* --------------------------------------------------- */ | |
510 | ||
511 | } else { | |
512 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
513 | } | |
514 | } | |
515 | ||
516 | static void pchr_turn_on_charging(void); | |
517 | kal_uint32 set_bat_charging_current_limit(int current_limit) | |
518 | { | |
519 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] set_bat_charging_current_limit (%d)\r\n", | |
520 | current_limit); | |
521 | ||
522 | if (current_limit != -1) { | |
523 | g_bcct_flag = 1; | |
524 | g_bcct_value = current_limit; | |
525 | ||
526 | if (current_limit < 70) | |
527 | g_temp_CC_value = CHARGE_CURRENT_0_00_MA; | |
528 | else if (current_limit < 200) | |
529 | g_temp_CC_value = CHARGE_CURRENT_70_00_MA; | |
530 | else if (current_limit < 300) | |
531 | g_temp_CC_value = CHARGE_CURRENT_200_00_MA; | |
532 | else if (current_limit < 400) | |
533 | g_temp_CC_value = CHARGE_CURRENT_300_00_MA; | |
534 | else if (current_limit < 450) | |
535 | g_temp_CC_value = CHARGE_CURRENT_400_00_MA; | |
536 | else if (current_limit < 550) | |
537 | g_temp_CC_value = CHARGE_CURRENT_450_00_MA; | |
538 | else if (current_limit < 650) | |
539 | g_temp_CC_value = CHARGE_CURRENT_550_00_MA; | |
540 | else if (current_limit < 700) | |
541 | g_temp_CC_value = CHARGE_CURRENT_650_00_MA; | |
542 | else if (current_limit < 800) | |
543 | g_temp_CC_value = CHARGE_CURRENT_700_00_MA; | |
544 | else if (current_limit < 900) | |
545 | g_temp_CC_value = CHARGE_CURRENT_800_00_MA; | |
546 | else if (current_limit < 1000) | |
547 | g_temp_CC_value = CHARGE_CURRENT_900_00_MA; | |
548 | else if (current_limit < 1100) | |
549 | g_temp_CC_value = CHARGE_CURRENT_1000_00_MA; | |
550 | else if (current_limit < 1200) | |
551 | g_temp_CC_value = CHARGE_CURRENT_1100_00_MA; | |
552 | else if (current_limit < 1300) | |
553 | g_temp_CC_value = CHARGE_CURRENT_1200_00_MA; | |
554 | else if (current_limit < 1400) | |
555 | g_temp_CC_value = CHARGE_CURRENT_1300_00_MA; | |
556 | else if (current_limit < 1500) | |
557 | g_temp_CC_value = CHARGE_CURRENT_1400_00_MA; | |
558 | else if (current_limit < 1600) | |
559 | g_temp_CC_value = CHARGE_CURRENT_1500_00_MA; | |
560 | else if (current_limit == 1600) | |
561 | g_temp_CC_value = CHARGE_CURRENT_1600_00_MA; | |
562 | else | |
563 | g_temp_CC_value = CHARGE_CURRENT_450_00_MA; | |
564 | } else { | |
565 | /* change to default current setting */ | |
566 | g_bcct_flag = 0; | |
567 | } | |
568 | ||
569 | /* wake_up_bat(); */ | |
570 | pchr_turn_on_charging(); | |
571 | ||
572 | return g_bcct_flag; | |
573 | } | |
574 | ||
575 | ||
576 | void select_charging_curret(void) | |
577 | { | |
578 | if (g_ftm_battery_flag) { | |
579 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] FTM charging : %d\r\n", | |
580 | charging_level_data[0]); | |
581 | g_temp_CC_value = charging_level_data[0]; | |
582 | ||
583 | if (g_temp_CC_value == CHARGE_CURRENT_450_00_MA) { | |
584 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
585 | } else { | |
586 | g_temp_input_CC_value = CHARGE_CURRENT_MAX; | |
587 | g_temp_CC_value = AC_CHARGER_CURRENT; | |
588 | ||
589 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] set_ac_current \r\n"); | |
590 | } | |
591 | } else { | |
592 | if (BMT_status.charger_type == STANDARD_HOST) { | |
593 | #ifdef CONFIG_USB_IF | |
594 | { | |
595 | g_temp_input_CC_value = CHARGE_CURRENT_MAX; | |
596 | if (g_usb_state == USB_SUSPEND) { | |
597 | g_temp_CC_value = USB_CHARGER_CURRENT_SUSPEND; | |
598 | } else if (g_usb_state == USB_UNCONFIGURED) { | |
599 | g_temp_CC_value = USB_CHARGER_CURRENT_UNCONFIGURED; | |
600 | } else if (g_usb_state == USB_CONFIGURED) { | |
601 | g_temp_CC_value = USB_CHARGER_CURRENT_CONFIGURED; | |
602 | } else { | |
603 | g_temp_CC_value = USB_CHARGER_CURRENT_UNCONFIGURED; | |
604 | } | |
605 | ||
606 | battery_xlog_printk(BAT_LOG_CRTI, | |
607 | "[BATTERY] STANDARD_HOST CC mode charging : %d on %d state\r\n", | |
608 | g_temp_CC_value, g_usb_state); | |
609 | } | |
610 | #else | |
611 | { | |
612 | g_temp_input_CC_value = USB_CHARGER_CURRENT; | |
613 | g_temp_CC_value = USB_CHARGER_CURRENT; | |
614 | } | |
615 | #endif | |
616 | } else if (BMT_status.charger_type == NONSTANDARD_CHARGER) { | |
617 | g_temp_input_CC_value = NON_STD_AC_CHARGER_CURRENT; | |
618 | g_temp_CC_value = NON_STD_AC_CHARGER_CURRENT; | |
619 | ||
620 | } else if (BMT_status.charger_type == STANDARD_CHARGER) { | |
621 | g_temp_input_CC_value = AC_CHARGER_CURRENT; | |
622 | g_temp_CC_value = AC_CHARGER_CURRENT; | |
623 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
624 | if(is_ta_connect == KAL_TRUE) | |
625 | set_ta_charging_current(); | |
626 | #endif | |
627 | } else if (BMT_status.charger_type == CHARGING_HOST) { | |
628 | g_temp_input_CC_value = CHARGING_HOST_CHARGER_CURRENT; | |
629 | g_temp_CC_value = CHARGING_HOST_CHARGER_CURRENT; | |
630 | } else if (BMT_status.charger_type == APPLE_2_1A_CHARGER) { | |
631 | g_temp_input_CC_value = APPLE_2_1A_CHARGER_CURRENT; | |
632 | g_temp_CC_value = APPLE_2_1A_CHARGER_CURRENT; | |
633 | } else if (BMT_status.charger_type == APPLE_1_0A_CHARGER) { | |
634 | g_temp_input_CC_value = APPLE_1_0A_CHARGER_CURRENT; | |
635 | g_temp_CC_value = APPLE_1_0A_CHARGER_CURRENT; | |
636 | } else if (BMT_status.charger_type == APPLE_0_5A_CHARGER) { | |
637 | g_temp_input_CC_value = APPLE_0_5A_CHARGER_CURRENT; | |
638 | g_temp_CC_value = APPLE_0_5A_CHARGER_CURRENT; | |
639 | } else { | |
640 | g_temp_input_CC_value = CHARGE_CURRENT_500_00_MA; | |
641 | g_temp_CC_value = CHARGE_CURRENT_500_00_MA; | |
642 | } | |
643 | ||
644 | ||
645 | #if defined(CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT) | |
646 | if (DISO_data.diso_state.cur_vdc_state == DISO_ONLINE) { | |
647 | g_temp_input_CC_value = AC_CHARGER_CURRENT; | |
648 | g_temp_CC_value = AC_CHARGER_CURRENT; | |
649 | } | |
650 | #endif | |
651 | ||
652 | #if defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
653 | set_jeita_charging_current(); | |
654 | #endif | |
655 | } | |
656 | ||
657 | ||
658 | } | |
659 | ||
660 | ||
661 | static kal_uint32 charging_full_check(void) | |
662 | { | |
4b9e9796 | 663 | kal_uint32 status = KAL_FALSE; |
6fa3eb70 S |
664 | |
665 | battery_charging_control(CHARGING_CMD_GET_CHARGING_STATUS, &status); | |
666 | if (status == KAL_TRUE) { | |
667 | g_full_check_count++; | |
4b9e9796 S |
668 | if (g_full_check_count >= FULL_CHECK_TIMES){ |
669 | /* [PLATFORM]-Add-BEGIN by TCTSZ.leo.guo, 04/15/2015, modify ntc temperature function */ | |
670 | #ifdef MTK_BATTERY_PROTECT_FEATURE | |
671 | if (BMT_status.temperature < MAX_LIMIT_CHARGE_TEMPERATURE) { | |
672 | return KAL_TRUE; | |
673 | } | |
674 | else { | |
675 | high_temp_stop_charge = KAL_TRUE; | |
676 | return KAL_FALSE; | |
677 | } | |
678 | #else | |
6fa3eb70 | 679 | return KAL_TRUE; |
4b9e9796 S |
680 | |
681 | #endif | |
682 | /* [PLATFORM]-Add-END by TCTSZ.leo.guo */ | |
683 | } | |
684 | else{ | |
6fa3eb70 | 685 | return KAL_FALSE; |
4b9e9796 | 686 | } |
6fa3eb70 S |
687 | } else { |
688 | g_full_check_count = 0; | |
689 | return status; | |
690 | } | |
691 | } | |
692 | ||
693 | ||
694 | static void pchr_turn_on_charging(void) | |
695 | { | |
696 | #if !defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
697 | BATTERY_VOLTAGE_ENUM cv_voltage; | |
698 | #endif | |
699 | kal_uint32 charging_enable = KAL_TRUE; | |
700 | ||
701 | #if defined(CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT) | |
702 | if(KAL_TRUE == BMT_status.charger_exist) | |
703 | charging_enable = KAL_TRUE; | |
704 | else | |
705 | charging_enable = KAL_FALSE; | |
706 | #endif | |
707 | ||
708 | if (BMT_status.bat_charging_state == CHR_ERROR) { | |
709 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Charger Error, turn OFF charging !\n"); | |
710 | ||
711 | charging_enable = KAL_FALSE; | |
712 | ||
713 | } else if ((g_platform_boot_mode == META_BOOT) || (g_platform_boot_mode == ADVMETA_BOOT)) { | |
714 | battery_xlog_printk(BAT_LOG_CRTI, | |
715 | "[BATTERY] In meta or advanced meta mode, disable charging.\n"); | |
716 | charging_enable = KAL_FALSE; | |
717 | } else { | |
718 | /*HW initialization */ | |
719 | battery_charging_control(CHARGING_CMD_INIT, NULL); | |
720 | ||
721 | battery_xlog_printk(BAT_LOG_FULL, "charging_hw_init\n"); | |
722 | ||
723 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
724 | battery_pump_express_algorithm_start(); | |
725 | #endif | |
726 | ||
727 | /* Set Charging Current */ | |
728 | if (get_usb_current_unlimited()) { | |
729 | g_temp_input_CC_value = AC_CHARGER_CURRENT; | |
730 | g_temp_CC_value = AC_CHARGER_CURRENT; | |
731 | battery_xlog_printk(BAT_LOG_FULL, | |
732 | "USB_CURRENT_UNLIMITED, use AC_CHARGER_CURRENT\n"); | |
733 | } else if (g_bcct_flag == 1) { | |
734 | select_charging_curret_bcct(); | |
735 | ||
736 | battery_xlog_printk(BAT_LOG_FULL, | |
737 | "[BATTERY] select_charging_curret_bcct !\n"); | |
738 | } else { | |
739 | select_charging_curret(); | |
740 | ||
741 | battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] select_charging_curret !\n"); | |
742 | } | |
743 | battery_xlog_printk(BAT_LOG_CRTI, | |
744 | "[BATTERY] Default CC mode charging : %d, input current = %d\r\n", | |
745 | g_temp_CC_value, g_temp_input_CC_value); | |
746 | if (g_temp_CC_value == CHARGE_CURRENT_0_00_MA | |
747 | || g_temp_input_CC_value == CHARGE_CURRENT_0_00_MA) { | |
748 | ||
749 | charging_enable = KAL_FALSE; | |
750 | ||
751 | battery_xlog_printk(BAT_LOG_CRTI, | |
752 | "[BATTERY] charging current is set 0mA, turn off charging !\r\n"); | |
753 | } else { | |
754 | battery_charging_control(CHARGING_CMD_SET_INPUT_CURRENT, | |
755 | &g_temp_input_CC_value); | |
756 | battery_charging_control(CHARGING_CMD_SET_CURRENT, &g_temp_CC_value); | |
757 | ||
758 | /*Set CV Voltage */ | |
759 | #if !defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
760 | #ifdef HIGH_BATTERY_VOLTAGE_SUPPORT | |
4b9e9796 | 761 | cv_voltage = BATTERY_VOLT_04_360000_V; |
6fa3eb70 S |
762 | #else |
763 | cv_voltage = BATTERY_VOLT_04_200000_V; | |
764 | #endif | |
4b9e9796 S |
765 | /* [PLATFORM]-Add-BEGIN by TCTSZ.leo.guo, 05/28/2015, modify ntc temperature function */ |
766 | #ifdef MTK_BATTERY_PROTECT_FEATURE | |
767 | /*Battery temperature more than 45 degree or less than 55 degree, try to limit max voltage*/ | |
768 | if((BMT_status.temperature >= MAX_LIMIT_CHARGE_TEMPERATURE) && (BMT_status.temperature <= MAX_CHARGE_TEMPERATURE) ) | |
769 | { | |
770 | cv_voltage = BATTERY_VOLT_04_100000_V; | |
771 | battery_xlog_printk(BAT_LOG_CRTI, | |
772 | "[BATTERY] temperature more than 45 degree or less than 55 degree, try to limit max voltage !\r\n"); | |
773 | } | |
774 | #endif | |
775 | /* [PLATFORM]-Add-END by TCTSZ.leo.guo */ | |
6fa3eb70 S |
776 | battery_charging_control(CHARGING_CMD_SET_CV_VOLTAGE, &cv_voltage); |
777 | #endif | |
778 | } | |
779 | } | |
780 | ||
781 | /* enable/disable charging */ | |
782 | battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable); | |
783 | ||
784 | battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] pchr_turn_on_charging(), enable =%d !\r\n", | |
785 | charging_enable); | |
786 | } | |
787 | ||
788 | ||
789 | PMU_STATUS BAT_PreChargeModeAction(void) | |
790 | { | |
791 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Pre-CC mode charge, timer=%d on %d !!\n\r", | |
792 | BMT_status.PRE_charging_time, BMT_status.total_charging_time); | |
793 | ||
794 | BMT_status.PRE_charging_time += BAT_TASK_PERIOD; | |
795 | BMT_status.CC_charging_time = 0; | |
796 | BMT_status.TOPOFF_charging_time = 0; | |
797 | BMT_status.total_charging_time += BAT_TASK_PERIOD; | |
798 | ||
799 | /* Enable charger */ | |
800 | pchr_turn_on_charging(); | |
801 | ||
802 | if (BMT_status.UI_SOC == 100) { | |
803 | BMT_status.bat_charging_state = CHR_BATFULL; | |
804 | BMT_status.bat_full = KAL_TRUE; | |
805 | g_charging_full_reset_bat_meter = KAL_TRUE; | |
806 | } else if (BMT_status.bat_vol > V_PRE2CC_THRES) { | |
807 | BMT_status.bat_charging_state = CHR_CC; | |
808 | } | |
809 | ||
810 | ||
811 | ||
812 | return PMU_STATUS_OK; | |
813 | } | |
814 | ||
815 | ||
816 | PMU_STATUS BAT_ConstantCurrentModeAction(void) | |
817 | { | |
818 | battery_xlog_printk(BAT_LOG_FULL, "[BATTERY] CC mode charge, timer=%d on %d !!\n\r", | |
819 | BMT_status.CC_charging_time, BMT_status.total_charging_time); | |
820 | ||
821 | BMT_status.PRE_charging_time = 0; | |
822 | BMT_status.CC_charging_time += BAT_TASK_PERIOD; | |
823 | BMT_status.TOPOFF_charging_time = 0; | |
824 | BMT_status.total_charging_time += BAT_TASK_PERIOD; | |
825 | ||
826 | /* Enable charger */ | |
827 | pchr_turn_on_charging(); | |
828 | ||
829 | if (charging_full_check() == KAL_TRUE) { | |
830 | BMT_status.bat_charging_state = CHR_BATFULL; | |
831 | BMT_status.bat_full = KAL_TRUE; | |
832 | g_charging_full_reset_bat_meter = KAL_TRUE; | |
833 | } | |
834 | ||
835 | return PMU_STATUS_OK; | |
836 | } | |
837 | ||
838 | ||
839 | PMU_STATUS BAT_BatteryFullAction(void) | |
840 | { | |
841 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Battery full !!\n\r"); | |
842 | ||
843 | BMT_status.bat_full = KAL_TRUE; | |
844 | BMT_status.total_charging_time = 0; | |
845 | BMT_status.PRE_charging_time = 0; | |
846 | BMT_status.CC_charging_time = 0; | |
847 | BMT_status.TOPOFF_charging_time = 0; | |
848 | BMT_status.POSTFULL_charging_time = 0; | |
849 | BMT_status.bat_in_recharging_state = KAL_FALSE; | |
850 | ||
851 | if (charging_full_check() == KAL_FALSE) { | |
852 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Battery Re-charging !!\n\r"); | |
853 | ||
854 | BMT_status.bat_in_recharging_state = KAL_TRUE; | |
855 | BMT_status.bat_charging_state = CHR_CC; | |
856 | battery_meter_reset(); | |
857 | } | |
858 | ||
859 | ||
860 | return PMU_STATUS_OK; | |
861 | } | |
862 | ||
863 | ||
864 | PMU_STATUS BAT_BatteryHoldAction(void) | |
865 | { | |
866 | kal_uint32 charging_enable; | |
867 | ||
868 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] Hold mode !!\n\r"); | |
869 | ||
870 | if (BMT_status.bat_vol < TALKING_RECHARGE_VOLTAGE || g_call_state == CALL_IDLE) { | |
871 | BMT_status.bat_charging_state = CHR_CC; | |
872 | battery_xlog_printk(BAT_LOG_CRTI, | |
873 | "[BATTERY] Exit Hold mode and Enter CC mode !!\n\r"); | |
874 | } | |
875 | ||
876 | /* Disable charger */ | |
877 | charging_enable = KAL_FALSE; | |
878 | battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable); | |
879 | ||
880 | return PMU_STATUS_OK; | |
881 | } | |
882 | ||
883 | ||
884 | PMU_STATUS BAT_BatteryStatusFailAction(void) | |
885 | { | |
886 | kal_uint32 charging_enable; | |
887 | ||
888 | battery_xlog_printk(BAT_LOG_CRTI, "[BATTERY] BAD Battery status... Charging Stop !!\n\r"); | |
889 | ||
890 | #if defined(CONFIG_MTK_JEITA_STANDARD_SUPPORT) | |
891 | if ((g_temp_status == TEMP_ABOVE_POS_60) || (g_temp_status == TEMP_BELOW_NEG_10)) { | |
892 | temp_error_recovery_chr_flag = KAL_FALSE; | |
893 | } | |
894 | if ((temp_error_recovery_chr_flag == KAL_FALSE) && (g_temp_status != TEMP_ABOVE_POS_60) | |
895 | && (g_temp_status != TEMP_BELOW_NEG_10)) { | |
896 | temp_error_recovery_chr_flag = KAL_TRUE; | |
897 | BMT_status.bat_charging_state = CHR_PRE; | |
898 | } | |
899 | #endif | |
900 | ||
901 | BMT_status.total_charging_time = 0; | |
902 | BMT_status.PRE_charging_time = 0; | |
903 | BMT_status.CC_charging_time = 0; | |
904 | BMT_status.TOPOFF_charging_time = 0; | |
905 | BMT_status.POSTFULL_charging_time = 0; | |
906 | ||
907 | /* Disable charger */ | |
908 | charging_enable = KAL_FALSE; | |
909 | battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable); | |
910 | ||
911 | return PMU_STATUS_OK; | |
912 | } | |
913 | ||
914 | ||
915 | void mt_battery_charging_algorithm(void) | |
916 | { | |
917 | battery_charging_control(CHARGING_CMD_RESET_WATCH_DOG_TIMER, NULL); | |
918 | ||
919 | #if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT) | |
920 | battery_pump_express_charger_check(); | |
921 | #endif | |
922 | switch (BMT_status.bat_charging_state) { | |
923 | case CHR_PRE: | |
924 | BAT_PreChargeModeAction(); | |
925 | break; | |
926 | ||
927 | case CHR_CC: | |
928 | BAT_ConstantCurrentModeAction(); | |
929 | break; | |
930 | ||
931 | case CHR_BATFULL: | |
932 | BAT_BatteryFullAction(); | |
933 | break; | |
934 | ||
935 | case CHR_HOLD: | |
936 | BAT_BatteryHoldAction(); | |
937 | break; | |
938 | ||
939 | case CHR_ERROR: | |
940 | BAT_BatteryStatusFailAction(); | |
941 | break; | |
942 | } | |
943 | ||
944 | battery_charging_control(CHARGING_CMD_DUMP_REGISTER, NULL); | |
945 | } |