diff --git a/drivers/power/sd77426_fg_mmi/battery_config.h b/drivers/power/sd77426_fg_mmi/battery_config.h index 4c72680a8326..30b407d44422 100644 --- a/drivers/power/sd77426_fg_mmi/battery_config.h +++ b/drivers/power/sd77426_fg_mmi/battery_config.h @@ -1,38 +1,37 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. +* Copyright(c) BMT, 2021. All rights reserved * -* O2Micro [OZ8806] Source Code Reference Design -* File:[battery_config.h] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* BMT [oz8806] Source Code Reference Design +* File:[bmulib.c] +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ -#ifndef __O2_BATTERY_CONFIG_H +#ifndef __O2_BATTERY_CONFIG_H #define __O2_BATTERY_CONFIG_H __FILE__ #define OZ88106_I2C_NUM 2 - //#define EXT_THERMAL_READ - -#define OZ8806_VOLTAGE 4350 -#define O2_CONFIG_CAPACITY 5158 -#define O2_CONFIG_RSENSE 10000 //Expanded 1000 times -#define O2_CONFIG_EOC 200 -#define OZ8806_EOD 3400 -#define O2_CONFIG_BOARD_OFFSET 12 -#define O2_SOC_START_THRESHOLD_VOL 3700 -#define O2_CONFIG_RECHARGE 100 -#define O2_TEMP_PULL_UP_R 121000 //121K -#define O2_TEMP_REF_VOLTAGE 1800 //mv + +#define OZ8806_VOLTAGE 4350 +#define O2_CONFIG_CAPACITY 5000 +#define O2_CONFIG_RSENSE 10000//Expanded 1000 times +#define O2_CONFIG_EOC 200 +#define OZ8806_EOD 3400 +#define O2_CONFIG_BOARD_OFFSET 12 +#define O2_SOC_START_THRESHOLD_VOL 3700 +#define O2_CONFIG_RECHARGE 100 +#define O2_TEMP_PULL_UP_R 121000 //121K +#define O2_TEMP_REF_VOLTAGE 1800 //mv #define BATTERY_WORK_INTERVAL 10 #define RPULL (68000) diff --git a/drivers/power/sd77426_fg_mmi/bmulib.c b/drivers/power/sd77426_fg_mmi/bmulib.c index e5213096f3da..784c968ccfc9 100644 --- a/drivers/power/sd77426_fg_mmi/bmulib.c +++ b/drivers/power/sd77426_fg_mmi/bmulib.c @@ -1,31 +1,28 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. -* -* O2Micro [OZ8806] Source Code Reference Design +* Copyright(c) BMT, 2021. All rights reserved. +* +* BMT [oz8806] Source Code Reference Design * File:[bmulib.c] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ - /**************************************************************************************** - + ****************************************************************************************/ #include -#include +#include #include - #include #include - #include #include "parameter.h" @@ -33,13 +30,11 @@ #include "table.h" #include - #include #include #include #include #include - #include #include #include @@ -54,19 +49,14 @@ //#define FCC_UPDATA_CHARGE -#define VERSION "2021.08.12/7.00.06 disable otp and expand rsense" -#define charge_step parameter->charge_pursue_step -#define discharge_step parameter->discharge_pursue_step -#define discharge_th parameter->discharge_pursue_th -#define config_data parameter->config +#define VERSION "2021.08.12/7.00.06 disable otp and expand rsense" +#define charge_step parameter->charge_pursue_step +#define discharge_step parameter->discharge_pursue_step +#define discharge_th parameter->discharge_pursue_th +#define config_data parameter->config #define RETRY_CNT 8 - -#define FORCE_OTP_MAPPING 0 - - - - +#define FORCE_OTP_MAPPING 0 #define SHUTDOWN_HI 50 #define SHUTDOWN_TH1 100 @@ -78,8 +68,6 @@ //#define FCC_LOWER_LIMIT 80 #define FCC_LOWER_LIMIT 70 //for lianxiang - - #define charge_full_voltage (config_data->charge_cv_voltage - 26) //#define full_charge_data (gas_gauge->fcc_data + config_data->design_capacity / 100 - 1) #define full_charge_data (gas_gauge->fcc_data + gas_gauge->fcc_data / 100 - 1) @@ -90,44 +78,38 @@ #define MAX_SUSPEND_CONSUME (MAX_SUSPEND_CURRENT*10/36) //H7 add wakup CAR range check, max suspend consumption(1000*mah) #define MAX_SUSPEND_CHARGE (1800*10/36)//H7 add wakup CAR range check, max suspend charge(1000*mah) - - - #define ABS(a, b) ((a>b)?(a-b):(b-a)) - /***************************************************************************** * static variables section ****************************************************************************/ static unsigned long bmu_kernel_memaddr; - bmu_data_t *batt_info; - gas_gauge_t *gas_gauge; - parameter_data_t parameter_customer; - parameter_data_t *parameter; +bmu_data_t *batt_info; +gas_gauge_t *gas_gauge; +parameter_data_t parameter_customer; +parameter_data_t *parameter; - int *rc_table; - int *xaxis_table; - int *yaxis_table; - int *zaxis_table; +int *rc_table; +int *xaxis_table; +int *yaxis_table; +int *zaxis_table; - int32_t calculate_mah = 0; - int32_t calculate_soc = 0; +int32_t calculate_mah = 0; +int32_t calculate_soc = 0; static int car_error = 0; -static char * BATT_CAPACITY= NULL;//"/data/sCaMAH.dat"; -static char * BATT_FCC = NULL;//"/data/fcc.dat"; -static char * OCV_FLAG = NULL;//"/data/ocv_flag.dat"; +static char * BATT_CAPACITY = NULL;//"/data/sCaMAH.dat"; +static char * BATT_FCC = NULL;//"/data/fcc.dat"; +static char * OCV_FLAG = NULL;//"/data/ocv_flag.dat"; static char * BATT_OFFSET = NULL;//"/data/offset.dat"; -static uint8_t oz8806_pec_check = 0; -static uint8_t oz8806_cell_num = 1; -static int32_t res_divider_ratio = 2000; -static uint8_t charge_end_flag = 0; +static uint8_t oz8806_pec_check = 0; +static uint8_t oz8806_cell_num = 1; +static int32_t res_divider_ratio = 2000; +static uint8_t charge_end_flag = 0; - - - int32_t one_percent_rc = 0; +int32_t one_percent_rc = 0; //static uint8_t wait_dc_charger= 0; //static uint8_t wait_voltage_end = 0; @@ -138,7 +120,7 @@ static uint8_t wait_ocv_flag = 0; //static uint8_t oz8806_in_suspend = 0; //static uint8_t start_chg_count_flag = 0; - uint8_t battery_ri = 100; +uint8_t battery_ri = 100; //static uint8_t charge_end = 0; //static uint8_t charge_fcc_update = 0; @@ -154,11 +136,7 @@ static int32_t fRSOC_PRE; static uint8_t discharge_end_flag = 0; static uint8_t sleep_ocv_flag = 0; -//static struct timex time_x; //static struct rtc_time rtc_time; - - - static uint32_t previous_loop_timex = 0; static uint8_t set_soc_from_ext = 0; @@ -224,9 +202,6 @@ static void check_board_offset(void); static void check_shutdwon_voltage(void); static void trim_bmu_VD23(void); - - - //static int32_t oz8806_write_byte_pec(uint8_t addr,uint8_t index, uint8_t data); void bmu_init_parameter_more(parameter_data_t *paramter_temp) @@ -258,14 +233,13 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) if (paramter_temp->fix_car_init) fix_car_init = paramter_temp->fix_car_init; - // if (paramter_temp->power_on_retry_times) + //if (paramter_temp->power_on_retry_times) power_on_retry_times = paramter_temp->power_on_retry_times; if (!paramter_temp->bmu_sys_rw_kernel) bmu_sys_rw_kernel = paramter_temp->bmu_sys_rw_kernel; - //pr_err("%s\n%s\n%s\n%s\n", BATT_CAPACITY, BATT_FCC, OCV_FLAG, BATT_OFFSET); - pr_err("oz8806_cell_num:%d, res_divider_ratio: %d,file_not_ok_cap:%d, set_soc_from_ext: %d, fix_car_init:%d,power_on_retry_times:%d, bmu_sys_rw_kernel:%d\n", + bmt_dbg("oz8806_cell_num:%d, res_divider_ratio: %d,file_not_ok_cap:%d, set_soc_from_ext: %d, fix_car_init:%d,power_on_retry_times:%d, bmu_sys_rw_kernel:%d\n", oz8806_cell_num, res_divider_ratio,file_not_ok_cap, set_soc_from_ext, fix_car_init,power_on_retry_times, bmu_sys_rw_kernel); } /***************************************************************************** @@ -280,7 +254,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) { int32_t ret; - //uint16_t value; + //uint16_t value; uint8_t i; int32_t data; uint8_t * addr; @@ -290,7 +264,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) byte_num = sizeof(config_data_t) + sizeof(bmu_data_t) + sizeof(gas_gauge_t); memset((uint8_t *)bmu_kernel_memaddr,num_0,byte_num); - + parameter = paramter_temp; addr = (uint8_t *)(parameter->config); for(byte_num = num_0;byte_num < sizeof(config_data_t);byte_num++) @@ -311,19 +285,17 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) gas_gauge = (gas_gauge_t *)((uint8_t *)bmu_kernel_memaddr + byte_num); byte_num += sizeof(gas_gauge_t); //-------------------------------------------------------------------------------------------------- - gas_gauge->bmu_init_ok = 0; + gas_gauge->bmu_init_ok = 0; gas_gauge->charge_end = num_0; gas_gauge->charge_end_current_th2 = CHARGE_END_CURRENT2; gas_gauge->charge_strategy = 1; gas_gauge->charge_max_ratio = 3500; //gas_gauge->charge_max_ratio = 10000; // for lianxiang - - + gas_gauge->discharge_end = num_0; gas_gauge->discharge_current_th = DISCH_CURRENT_TH; gas_gauge->discharge_strategy = 1; gas_gauge->discharge_max_ratio = 8000; // for lianxiang - gas_gauge->dsg_end_voltage_hi = SHUTDOWN_HI; gas_gauge->batt_ri = 120; // charging. It is related to voltage when full charging condition. @@ -340,7 +312,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) gas_gauge->lower_capacity_soc_start =30; gas_gauge->percent_10_reserve = 0; - //add this for oinom, end + //add this for oinom, end //this for test gas gaugue if(parameter->config->debug) @@ -350,47 +322,22 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) gas_gauge->dsg_count_2 = num_0; gas_gauge->overflow_data = num_32768 * num_5 * 1000 / config_data->fRsense; - bmu_dbg("yyyy gas_gauge->overflow_data is %d\n",gas_gauge->overflow_data); + batt_dbg("yyyy gas_gauge->overflow_data is %d\n",gas_gauge->overflow_data); bmu_init_gg(gas_gauge); //-------------------------------------------------------------------------------------------------- -#ifdef OZ8806_API - //bmu_init_charge_data(((uint8_t *)bmu_kernel_memaddr + byte_num), 4*gas_gauge->charge_table_num* 2); - //byte_num += 4 * gas_gauge->charge_table_num * 2; - - xaxis_table = (int *)((uint8_t *)bmu_kernel_memaddr + byte_num); - bmu_init_XAxisElement(((uint8_t *)bmu_kernel_memaddr + byte_num), 4*gas_gauge->rc_x_num ); - byte_num += 4*gas_gauge->rc_x_num ; - - yaxis_table = (int *)((uint8_t *)bmu_kernel_memaddr + byte_num); - bmu_init_YAxisElement(((uint8_t *)bmu_kernel_memaddr + byte_num), 4*gas_gauge->rc_y_num); - byte_num += 4*gas_gauge->rc_y_num; - - zaxis_table = (int *)((uint8_t *)bmu_kernel_memaddr + byte_num); - bmu_init_ZAxisElement(((uint8_t *)bmu_kernel_memaddr + byte_num), 4*gas_gauge->rc_z_num); - byte_num += 4*gas_gauge->rc_z_num; - - rc_table = (int *)((uint8_t *)bmu_kernel_memaddr + byte_num); - bmu_init_RCtable(((uint8_t *)bmu_kernel_memaddr + byte_num), 4*gas_gauge->rc_x_num *gas_gauge->rc_y_num*gas_gauge->rc_z_num); - byte_num += 4*gas_gauge->rc_x_num *gas_gauge->rc_y_num*gas_gauge->rc_z_num; - -#else bmu_init_table(&xaxis_table, &yaxis_table, &zaxis_table, &rc_table); -#endif - - pr_err("byte_num is %d\n",byte_num); - + batt_dbg("byte_num is %d\n",byte_num); power_on_flag = num_0; bmu_sleep_flag = num_0; - one_percent_rc = config_data->design_capacity / num_100; - pr_err("AAAA O2MICRO OZ8806 DRIVER VERSION is %s\n",VERSION); + batt_dbg("AAAA BMT fgu DRIVER VERSION is %s\n",VERSION); - pr_err("OZ8806 test parameter:Rsense:%d, RTempPullup:%d, VTempRef:%d, CarLSB:%d, CurLSB:%d, VolLSB:%d, FCC:%d, CV:%d, EOC:%d, EOD:%d, BoardOffset:%d, Debug:%d\n", + batt_dbg("BMT fgu test parameter:Rsense:%d, RTempPullup:%d, VTempRef:%d, CarLSB:%d, CurLSB:%d, VolLSB:%d, FCC:%d, CV:%d, EOC:%d, EOD:%d, BoardOffset:%d, Debug:%d\n", config_test->fRsense, config_test->temp_pull_up, config_test->temp_ref_voltage, @@ -405,7 +352,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) config_test->debug ); - + //check_pec_control(); //move check_oz8806_status here to avoid iic-commu-issue check_oz8806_staus(); @@ -416,15 +363,15 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) */ if (oz8806_get_boot_up_time() < 625) { - pr_err("AAAA wait for current offset detection\n"); + batt_dbg("AAAA wait for current offset detection\n"); msleep(625 - oz8806_get_boot_up_time()); afe_register_read_word(OZ8806_OP_BOARD_OFFSET,(uint16_t *)&data); } - bmu_dbg("AAAAAAAAAAAAA Register BOARD_OFFSET: 0x%02x\n",data); - + batt_dbg("AAAAAAAAAAAAA Register BOARD_OFFSET: 0x%02x\n",data); + ret = afe_read_board_offset(&data); - pr_err("AAAA board_offset is %d mA\n",data); + batt_dbg("AAAA board_offset is %d mA\n",data); if(ret >= num_0) @@ -440,7 +387,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) //wake up OZ8806 into FullPower mode - pr_err("oz8806_cell_num is %d\n",oz8806_cell_num); + batt_dbg("BMT fgu cell_num is %d\n",oz8806_cell_num); if(oz8806_cell_num > num_1) afe_register_write_byte(OZ8806_OP_CTRL,num_0x2c); @@ -448,7 +395,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) afe_register_write_byte(OZ8806_OP_CTRL,num_0x20); ret = afe_register_read_byte(OZ8806_OP_CTRL,&i); - pr_err("first read reg[0x09]= 0x%02x, ret = %d\n", i, ret); + batt_dbg("first read reg[0x09]= 0x%02x, ret = %d\n", i, ret); if((i & num_0x40) || (ret < num_0)) { @@ -458,14 +405,13 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) } else afe_register_write_byte(OZ8806_OP_CTRL,0x20); - bmu_dbg("Wake up oz8806 write op_ctrl 0x20 \n"); + batt_dbg("Wake up BMT fgu write op_ctrl 0x20 \n"); ret = afe_register_read_byte(OZ8806_OP_CTRL,&i); - pr_err("second read reg[0x09]= 0x%02x, ret = %d\n", i, ret); - + batt_dbg("second read reg[0x09]= 0x%02x, ret = %d\n", i, ret); } - - pr_err("O2MICRO OZ8806 parameter %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", + + batt_dbg("BMT fgu parameter %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", config_data->fRsense, config_data->temp_pull_up, config_data->temp_ref_voltage, @@ -478,7 +424,6 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) config_data->discharge_end_voltage, config_data->board_offset, config_data->debug - ); //check_oz8806_staus(); @@ -499,24 +444,25 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) { int32_t ret; - uint16_t value; + uint16_t value; uint8_t i; int32_t data; #if 1 - if (oz8806_get_boot_up_time() < 2000) // ocv can be stable after oz8806 is wakeuped for 2 s + if (oz8806_get_boot_up_time() < 1500)// ocv can be stable after oz8806 is wakeuped for 1.375 s { - pr_err("wait ocv flag register ready 1\n"); - msleep(2000 - oz8806_get_boot_up_time()); + batt_dbg("wait ocv flag register ready 1\n"); + msleep(1500 - oz8806_get_boot_up_time()); oz8806_get_boot_up_time(); //return; } - +/* if (oz8806_get_power_on_time() < 2250) { - pr_err("wait ocv flag register ready 2\n"); + batt_dbg("wait ocv flag register ready 2\n"); msleep(2250 - oz8806_get_power_on_time()); oz8806_get_power_on_time(); } +*/ #endif wait_ocv_flag = 1; @@ -528,17 +474,15 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) { if ((value & POWER_OCV_FLAG) || (value & SLEEP_OCV_FLAG)) { - if (oz8806_get_power_on_time() < 4250)//2250+2000 + if (oz8806_get_power_on_time() < 2250)//2250+2000 { - pr_err("ocv or sleep_ocv: wait for normal scan cycle\n"); - msleep(4250 - oz8806_get_power_on_time()); + batt_dbg("ocv or sleep_ocv: wait for normal scan cycle\n"); oz8806_get_power_on_time(); } } else if (oz8806_get_boot_up_time() < 2250) { - pr_err("normal ok: wait for normal scan cycle\n"); - msleep(2250 - oz8806_get_boot_up_time()); + batt_dbg("normal ok: wait for normal scan cycle\n"); } break; } @@ -552,14 +496,13 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) batt_info->fRSOC = batt_info->fRC * num_100; batt_info->fRSOC = batt_info->fRSOC / config_data->design_capacity ; - - pr_err("read batt_info.fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); - pr_err("read batt_info.fRC is %d\n",batt_info->fRC); - pr_err("read batt_info.fCurr is %d\n",batt_info->fCurr); - pr_err("read ocv flag ret is 0x%02x,value is 0x%02x\n",ret,value); - pr_err("read fCellTemp is %d\n",batt_info->fCellTemp); - if (ret >= num_0 ) + batt_dbg("read batt_info.fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); + batt_dbg("read batt_info.fRC is %d\n",batt_info->fRC); + batt_dbg("read batt_info.fCurr is %d\n",batt_info->fCurr); + batt_dbg("read ocv flag ret is 0x%02x,value is 0x%02x\n",ret,value); + batt_dbg("read fCellTemp is %d\n",batt_info->fCellTemp); + if (ret >= num_0 ) { // OZ8806 First power on if (value & POWER_OCV_FLAG) @@ -568,72 +511,65 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) afe_read_ocv_volt(&batt_info->fOCVVolt); afe_read_cell_volt(&batt_info->fVolt); - if(oz8806_cell_num > num_1) batt_info->fOCVVolt = batt_info->fVolt; - - pr_err("AAAA ocv volt is %d\n",(batt_info->fOCVVolt * oz8806_cell_num)); - pr_err("AAAA volt is %d\n",(batt_info->fVolt * oz8806_cell_num)); - - - if(batt_info->fOCVVolt > (config_data->charge_cv_voltage + 70)){ + batt_dbg("AAAA ocv volt is %d\n",(batt_info->fOCVVolt * oz8806_cell_num)); + batt_dbg("AAAA volt is %d\n",(batt_info->fVolt * oz8806_cell_num)); + if(batt_info->fOCVVolt > (config_data->charge_cv_voltage + 150)){ + if (oz8806_get_power_on_time() < 2250)//2250+2000 + { + batt_dbg("ocv wait for normal scan cycle\n"); + msleep(2250 - oz8806_get_power_on_time()); + oz8806_get_power_on_time(); + } + afe_read_cell_volt(&batt_info->fVolt); batt_info->fOCVVolt = batt_info->fVolt; - pr_err("AAAAA ocv data errror ,so batt_info->fVolt is %d\n",batt_info->fVolt); + batt_dbg("AAAAA ocv data errror ,so batt_info->fVolt is %d\n",batt_info->fVolt); } afe_read_current(&batt_info->fCurr); - pr_err("AAAA batt_info.fCurr is %d\n",batt_info->fCurr); + batt_dbg("AAAA batt_info.fCurr is %d\n",batt_info->fCurr); if(batt_info->fCurr > num_50) data = batt_info->fOCVVolt - num_100; else data = batt_info->fOCVVolt; - batt_info->fRSOC = one_latitude_table(parameter->ocv_data_num,parameter->ocv,data); - pr_err("find ocv table batt_info.fRSOC is %d\n",batt_info->fRSOC); - + batt_dbg("find ocv table batt_info.fRSOC is %d\n",batt_info->fRSOC); if((batt_info->fRSOC >num_100) || (batt_info->fRSOC < num_0)) batt_info->fRSOC = num_50; batt_info->fRC = batt_info->fRSOC * config_data->design_capacity / num_100; - afe_read_current(&batt_info->fCurr); - - - if(batt_info->fRC >= (gas_gauge->overflow_data -num_10)) { batt_info->fRC = gas_gauge->overflow_data - gas_gauge->overflow_data /num_100; - batt_info->fRCPrev = batt_info->fRC; + batt_info->fRCPrev = batt_info->fRC; } - afe_write_car(batt_info->fRC); batt_info->fRCPrev = batt_info->fRC; gas_gauge->fcc_data= config_data->design_capacity * 100/100; - - pr_err("Power on mode is activated \n"); + batt_dbg("Power on mode is activated \n"); - batt_info->sCaMAH = batt_info->fRSOC * config_data->design_capacity / num_100; gas_gauge->sCtMAH = batt_info->sCaMAH; gas_gauge->discharge_sCtMAH = config_data->design_capacity - batt_info->sCaMAH; - } else if(value & SLEEP_OCV_FLAG) { afe_read_ocv_volt(&batt_info->fOCVVolt); sleep_ocv_flag = 1; - pr_err("Sleep ocv mode is activated \n"); + batt_dbg("Sleep ocv mode is activated \n"); } else - pr_err("Normal mode is activated \n"); + batt_dbg("Normal mode is activated \n"); } else { - pr_err("AAAA O2MICRO OZ8806 DRIVER \n"); - pr_err("AAAA O2MICRO OZ8806 read OZ8806_OP_OCV_LOW\n"); + batt_dbg("AAAA BMT fgu DRIVER \n"); + batt_dbg("AAAA BMT fgu read BMT_OP_OCV_LOW\n"); } @@ -642,23 +578,19 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) afe_read_car(&batt_info->fRC); if((batt_info->fRC < (one_percent_rc)) && (batt_info->fRC > -3000)) { - bmu_dbg("yyyy fRC will over fRC is %d\n",batt_info->fRC); - + batt_dbg("yyyy fRC will over fRC is %d\n",batt_info->fRC); batt_info->fRC = one_percent_rc - num_1; afe_write_car(batt_info->fRC); batt_info->fRCPrev = batt_info->fRC; } afe_read_car(&batt_info->fRC); - pr_err("fRC is %d\n",batt_info->fRC); + batt_dbg("fRC is %d\n",batt_info->fRC); #endif - - - afe_register_read_byte(num_0,&i); - pr_err("O2micro regeidter 0x00 is 0x%02x\n",i); + batt_dbg("BMT fgu regeidter 0x00 is 0x%02x\n",i); afe_register_read_byte(num_9,&i); - pr_err("O2micro regeidter 0x09 is 0x%02x\n",i); + batt_dbg("BMT fgu regeidter 0x09 is 0x%02x\n",i); } /***************************************************************************** @@ -669,14 +601,13 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) * Return: * None *****************************************************************************/ - void trim_bmu_VD23(void) +void trim_bmu_VD23(void) { int32_t ret; uint8_t i; uint16_t value; uint8_t data; uint8_t temp; - for(i = 0;i < 3;i++) { @@ -685,13 +616,13 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) } if(ret < 0) { - pr_err("READ OZ8806_OP_VD23 fail and return:%d\n",ret); + batt_dbg("READ BMT_OP_VD23 fail and return:%d\n",ret); return; } - pr_err("READ oz8806 REG 0x03 is 0x%02x\n",value); + batt_dbg("READ BMT REG 0x03 is 0x%02x\n",value); data = ((value >> 6) & 0x02) | ((value >> 8) & 0x01); data &= 0x03; - pr_err("So trim is 0x%02x\n",data); + batt_dbg("So trim is 0x%02x\n",data); for(i = 0;i < 3;i++) { @@ -700,27 +631,21 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) } if(ret < 0) { - pr_err("READ OZ8806_OP_PEC_CTRL fail and return:%d\n",ret); + batt_dbg("READ BMT_OP_PEC_CTRL fail and return:%d\n",ret); return; } + batt_dbg("READ BMT fgu REG 0x08 is 0x%02x\n",temp); - - - pr_err("READ oz8806 REG 0x08 is 0x%02x\n",temp); - - temp &= (~0x03); - if(data != 0x02) { temp |= data; for(i = 0;i < 3;i++) { ret = afe_register_write_byte(OZ8806_OP_PEC_CTRL,temp); - pr_err("write1 oz8806 REG 0x08 is 0x%02x\n",temp); + batt_dbg("write1 BMT fgu REG 0x08 is 0x%02x\n",temp); if(ret >= 0)break; } - } else { @@ -728,14 +653,12 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) for(i = 0;i < 3;i++) { ret = afe_register_write_byte(OZ8806_OP_PEC_CTRL,temp); - pr_err("write2 oz8806 REG 0x08 is 0x%02x\n",temp); + batt_dbg("write2 BMT fgu REG 0x08 is 0x%02x\n",temp); if(ret >= 0)break; } - } - ret = afe_register_read_byte(OZ8806_OP_PEC_CTRL,&temp); - pr_err("oz8806 REG 0x08 is 0x%02x\n",temp); + batt_dbg("BMT fgu REG 0x08 is 0x%02x\n",temp); } @@ -747,7 +670,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) * Return: * None *****************************************************************************/ - void check_shutdwon_voltage(void) +void check_shutdwon_voltage(void) { //int32_t ret; //uint8_t i; @@ -755,12 +678,10 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) //int32_t infVolt; afe_read_cell_volt(&batt_info->fVolt); - if(!sleep_ocv_flag) return; - + temp = one_latitude_table(parameter->ocv_data_num,parameter->ocv,batt_info->fOCVVolt); - pr_err("Sleep data is %d \n",temp); - + batt_dbg("Sleep data is %d \n",temp); // select higher data if(calculate_soc > temp) @@ -770,18 +691,17 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) if((batt_info->fRSOC - temp) > 20 || (batt_info->fVolt < (config_data->discharge_end_voltage - 50) && temp <= 5)) { - //batt_info->fRSOC -= 5; batt_info->fRSOC = temp; if(batt_info->fRSOC < 0) batt_info->fRSOC = 0; - + batt_info->sCaMAH = batt_info->fRSOC * gas_gauge->fcc_data/ 100; batt_info->fRC= batt_info->sCaMAH; if(batt_info->fRC > (gas_gauge->overflow_data - 20)) batt_info->fRC = gas_gauge->overflow_data - 20; afe_write_car(batt_info->fRC); - + batt_info->fRCPrev = batt_info->fRC; gas_gauge->sCtMAH = batt_info->sCaMAH; @@ -790,13 +710,8 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) else gas_gauge->discharge_sCtMAH = 0; } - - } - - - /***************************************************************************** * Description: * check_oz8806_staus @@ -808,13 +723,7 @@ void bmu_init_parameter_more(parameter_data_t *paramter_temp) static void check_oz8806_staus(void) { - } - - - - - /***************************************************************************** * Description: * bmu_wait_ready @@ -829,20 +738,18 @@ static void bmu_wait_ready(void) //int32_t fcc; uint8_t i; int32_t ret; - uint16_t value; - + uint16_t value; int32_t calculate_soc_temp; - int32_t file_soc_temp; - pr_err("AAAA bmu wait times %d \n",times); + batt_dbg("AAAA bmu wait times %d \n",times); times ++; //wake up OZ8806 into FullPower mode oz8806_wakeup_full_power(); ret = afe_register_read_byte(OZ8806_OP_CTRL,&i); batt_info->Battery_ok = i & BI_STATUS; - pr_err("bmu_wait_ready read 0x09 ret is %d,i is 0x%02x\n",ret,i); + batt_dbg("bmu_wait_ready read 0x09 ret is %d,i is 0x%02x\n",ret,i); if((i & 0x40) || (ret < 0)) { @@ -852,51 +759,59 @@ static void bmu_wait_ready(void) } else afe_register_write_byte(OZ8806_OP_CTRL,0x20); - pr_err("oz8806 wake up function\n"); + batt_dbg("BMT fgu wake up function\n"); ret = afe_register_read_byte(OZ8806_OP_CTRL,&i); - pr_err("bmu_wait_ready read 0x09 ret is %d,i is 0x%02x\n",ret,i); + batt_dbg("bmu_wait_ready read 0x09 ret is %d,i is 0x%02x\n",ret,i); } //do we need add check ocv flag now? ret = afe_register_read_word(OZ8806_OP_OCV_LOW,&value); - if ((ret >= 0) && (value & POWER_OCV_FLAG)) + if ((ret >= 0) && (value & POWER_OCV_FLAG)) { - pr_err("read flag too late\n"); + batt_dbg("read flag too late\n"); wait_ocv_flag_fun(); } - if (oz8806_get_power_on_time() < 2250) + afe_read_car(&batt_info->fRC); + if((batt_info->fRC < 5)|| (power_on_flag)) { - pr_err("wait for normal scan cycle"); - msleep(2250 - oz8806_get_power_on_time()); + + if (oz8806_get_power_on_time() < 2250) + { + batt_dbg("wait for normal scan cycle and return \n"); + return; + //msleep(2250 - oz8806_get_power_on_time()); + } + else + batt_dbg("normal scan cycle delay ok\n"); } + else + batt_dbg("means normal boot,no need delay\n"); afe_read_cell_temp(&batt_info->fCellTemp); afe_read_cell_volt(&batt_info->fVolt); afe_read_current(&batt_info->fCurr); - afe_read_car(&batt_info->fRC); - - pr_err("fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); - pr_err("fCurr is %d\n",batt_info->fCurr); - pr_err("ftemp is %d\n",batt_info->fCellTemp); - pr_err("fRC is %d\n",batt_info->fRC); + batt_dbg("fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); + batt_dbg("fCurr is %d\n",batt_info->fCurr); + batt_dbg("ftemp is %d\n",batt_info->fCellTemp); + batt_dbg("fRC is %d\n",batt_info->fRC); // every time we check this and print to see if the voltage and temp and current is abnormal // how about if rc_result error - + calculate_soc_temp = calculate_soc_result(); calculate_soc = calculate_soc_temp; calculate_mah = calculate_soc * config_data->design_capacity / num_100; - + calculate_times++; #if 0 if (calculate_times <= calculate_retry_times) return; #endif - pr_err("calculate_times: %d\n",calculate_times); + batt_dbg("calculate_times: %d\n",calculate_times); gas_gauge->fcc_data = config_data->design_capacity; @@ -904,33 +819,32 @@ static void bmu_wait_ready(void) { store_rc = batt_info->fRC; //calculate_retry_times = 0; - pr_err("Success to get soc from car :%d\n", batt_info->fRC); + batt_dbg("Success to get soc from car :%d\n", batt_info->fRC); goto file_ok; } - +/* if (oz8806_get_boot_up_time() < 5000) // voltage can be stable after oz8806 is powered for 5 s { - pr_err("wait oz8806 ADC ready\n"); + batt_dbg("wait oz8806 ADC ready\n"); return; } - - + */ if((set_soc_from_ext)) { soc_external = oz8806_get_soc_from_ext(); - pr_err("soc from external: %d\n", soc_external); + batt_dbg("soc from external: %d\n", soc_external); if (soc_external == -1) { - pr_err("wait for external soc:%d, retry:%d\n", soc_external, retry_times); + batt_dbg("wait for external soc:%d, retry:%d\n", soc_external, retry_times); if(retry_times >= 0) { - pr_err("fail to get externl soc, retry_times:%d \n",retry_times); + batt_dbg("fail to get externl soc, retry_times:%d \n",retry_times); retry_times = 0; set_soc_from_ext = 0; - pr_err("can't get external soc,so make set_soc_from_ext 0\n"); + batt_dbg("can't get external soc,so make set_soc_from_ext 0\n"); } else { @@ -940,24 +854,24 @@ static void bmu_wait_ready(void) } else if ((soc_external <= 100) && (soc_external >= 0)) { - pr_err("Success to get soc from external :%d\n", soc_external); + batt_dbg("Success to get soc from external :%d\n", soc_external); store_rc = soc_external * gas_gauge->fcc_data / 100; store_rc += gas_gauge->fcc_data / 200; // + fcc / 100 * / 2 - pr_err("stored RC:%d\n", store_rc); + batt_dbg("stored RC:%d\n", store_rc); goto file_ok; } else { - pr_err("Error to get wrong soc from external :%d\n", soc_external); + batt_dbg("Error to get wrong soc from external :%d\n", soc_external); retry_times = 0; set_soc_from_ext = 0; - pr_err("can't get external soc,so make set_soc_from_ext 0\n"); + batt_dbg("can't get external soc,so make set_soc_from_ext 0\n"); } } - if (bmu_sys_rw_kernel) + if (bmu_sys_rw_kernel)// this ok { /* wait for sysfs to capacity from file*/ store_rc = bmu_read_data(BATT_CAPACITY); @@ -965,10 +879,10 @@ static void bmu_wait_ready(void) //check file ,if file not exit, goto file fail if(store_rc < 0) { - pr_err("open BATT_CAPACITY fail, retry_times:%d \n", retry_times); + batt_dbg("open BATT_CAPACITY fail, retry_times:%d \n", retry_times); if(retry_times >= power_on_retry_times) { - pr_err("BATT_CAPACITY file fail\n"); + batt_dbg("BATT_CAPACITY file fail\n"); batt_info->sCaMAH = calculate_mah; goto file_fail; } @@ -978,27 +892,27 @@ static void bmu_wait_ready(void) return; } } - pr_err("open BATT_CAPACITY success, retry_times:%d \n", retry_times); - pr_err("AAAA read battery capacity data is %d\n", store_rc); + batt_dbg("open BATT_CAPACITY success, retry_times:%d \n", retry_times); + batt_dbg("AAAA read battery capacity data is %d\n", store_rc); } else { store_rc = oz8806_get_save_capacity(); - - pr_err("RC from file:%d\n", store_rc); + batt_dbg("RC from file:%d\n", store_rc); if (store_rc == INIT_CAP) - { - pr_err("wait for reading file:%s, retry:%d\n", BATT_CAPACITY, retry_times); - if(retry_times > 10) - { - pr_err("fail to get save_capacity, retry_times:%d \n",retry_times); - goto file_fail; + { + batt_dbg("wait for reading file:%s, retry:%d\n", BATT_CAPACITY, retry_times); + if(retry_times > 10) + { + batt_dbg("fail to get save_capacity, retry_times:%d \n",retry_times); + goto file_fail; } - retry_times++; - return; - } - else if (store_rc == NO_FILE) { - pr_err("no file %s, retry_times:%d \n", BATT_CAPACITY, retry_times); + retry_times++; + return; + } + else if (store_rc == NO_FILE) + { + batt_dbg("no file %s, retry_times:%d \n", BATT_CAPACITY, retry_times); goto file_fail; } } @@ -1014,34 +928,34 @@ file_ok: //file ok, if ocv power on if(power_on_flag) { - pr_err("bmu_wait_ready, power on ok \n"); + batt_dbg("bmu_wait_ready, power on ok \n"); gas_gauge->ocv_flag = 1; //file_soc_temp: soc read from file //batt_info->fRSOC: calculated using OCV //calculated_soc: calculated using VI - pr_err("soc from file:%d, vi soc:%d, ocv soc:%d \n", + batt_dbg("soc from file:%d, vi soc:%d, ocv soc:%d \n", file_soc_temp, calculate_soc, batt_info->fRSOC); - pr_err("RC from file:%d, vi RC:%d, ocv RC:%d \n", + batt_dbg("RC from file:%d, vi RC:%d, ocv RC:%d \n", store_rc, calculate_mah, batt_info->sCaMAH); if((batt_info->fRSOC > 90)&& (file_soc_temp > 90)) { batt_info->sCaMAH = store_rc; - pr_err("start sCaMAH high USE file\n"); + batt_dbg("start sCaMAH high USE file\n"); } else if(batt_info->fCurr >= 0) { if( ABS(calculate_soc,file_soc_temp) > 30) { batt_info->sCaMAH = calculate_mah; - pr_err("start sCaMAH chg USE vi\n"); + batt_dbg("start sCaMAH chg USE vi\n"); } else // file { batt_info->sCaMAH = store_rc; - pr_err("start sCaMAH chg USE file\n"); + batt_dbg("start sCaMAH chg USE file\n"); } } else //discharging @@ -1050,22 +964,22 @@ file_ok: || (batt_info->fVolt < (config_data->discharge_end_voltage - 50) && file_soc_temp<=5)) { batt_info->sCaMAH = calculate_mah; - pr_err("start sCaMAH USE vi\n"); + batt_dbg("start sCaMAH USE vi\n"); } else { batt_info->sCaMAH = store_rc; - pr_err("start sCaMAH USE file\n"); + batt_dbg("start sCaMAH USE file\n"); } } } //if not ocv power on else - { pr_err("bmu_wait_ready, normal ok \n"); + { batt_dbg("bmu_wait_ready, normal ok \n"); gas_gauge->ocv_flag = 0; afe_read_car(&batt_info->fRC); - pr_err("RC from file: %d ,RC from register: %d\n", store_rc, batt_info->fRC); + batt_dbg("RC from file: %d ,RC from register: %d\n", store_rc, batt_info->fRC); if ((batt_info->fCurr > 0 && batt_info->fRC <= 2) || (batt_info->fCurr <= 0 && batt_info->fRC <= 0))//power on, no ocv flag @@ -1074,12 +988,12 @@ file_ok: || (batt_info->fVolt < (config_data->discharge_end_voltage - 50) && file_soc_temp<=5)) { batt_info->sCaMAH = calculate_mah; - pr_err("file ok but USE vi,fRC<=0\n"); + batt_dbg("file ok but USE vi,fRC<=0\n"); } else { batt_info->sCaMAH = store_rc; - pr_err("file ok USE file\n"); + batt_dbg("file ok USE file\n"); } } else @@ -1088,7 +1002,7 @@ file_ok: if(( ABS(batt_info->fRC,store_rc) > (one_percent_rc))) { batt_info->sCaMAH = batt_info->fRC; - pr_err("file ok USE RC\n"); + batt_dbg("file ok USE RC\n"); } else { @@ -1097,50 +1011,50 @@ file_ok: &&(batt_info->fRC > store_rc) &&(batt_info->fRC - store_rc <= one_percent_rc)) { - pr_err("file ok USE RC\n"); + batt_dbg("file ok USE RC\n"); batt_info->sCaMAH = batt_info->fRC; } else { batt_info->sCaMAH = store_rc; - pr_err("file ok USE file\n"); + batt_dbg("file ok USE file\n"); } } } - } - + } + file_fail: if(store_rc<0) //fail to red fil or no file exist { if(power_on_flag) { - pr_err("fVolt %dmv, oz8806_cell_num:%d, power_on_100_vol:%dmv\n",batt_info->fVolt,oz8806_cell_num,gas_gauge->power_on_100_vol); + batt_dbg("fVolt %dmv,cell_num:%d, power_on_100_vol:%dmv\n",batt_info->fVolt,oz8806_cell_num,gas_gauge->power_on_100_vol); if((batt_info->fVolt * oz8806_cell_num)>= gas_gauge->power_on_100_vol) batt_info->sCaMAH = full_charge_data; else batt_info->sCaMAH = calculate_mah; - pr_err("bmu_wait_ready, power on ok and file fail \n"); - pr_err("file fail USE vi\n"); + batt_dbg("bmu_wait_ready, power on ok and file fail \n"); + batt_dbg("file fail USE vi\n"); } else { - pr_err("bmu_wait_ready, normal on ok and file fail \n"); + batt_dbg("bmu_wait_ready, normal on ok and file fail \n"); afe_read_car(&batt_info->fRC); - pr_err("RC from register: %d, RC from vi: %d\n", batt_info->fRC, calculate_mah); + batt_dbg("RC from register: %d, RC from vi: %d\n", batt_info->fRC, calculate_mah); if ((batt_info->fCurr > 0 && batt_info->fRC <= 2) || (batt_info->fCurr <= 0 && batt_info->fRC <= 0))//power on, no ocv flag { - pr_err("big error first power on and ocv flag not set: %d ,%d\n", batt_info->fRC, calculate_mah); + batt_dbg("big error first power on and ocv flag not set: %d ,%d\n", batt_info->fRC, calculate_mah); batt_info->sCaMAH = calculate_mah; - pr_err("file fail USE vi\n"); + batt_dbg("file fail USE vi\n"); } else { #if 0 batt_info->sCaMAH = batt_info->fRC; - pr_err("file fail USE RC\n"); + batt_dbg("file fail USE RC\n"); #else if(batt_info->fRC < one_percent_rc ) //if CAR < 1% @@ -1149,58 +1063,54 @@ file_fail: if( ABS(batt_info->fRC,calculate_mah) > (file_not_ok_cap * config_data->design_capacity / num_100)) { batt_info->sCaMAH = calculate_mah; - pr_err("file fail USE vi\n"); + batt_dbg("file fail USE vi\n"); } else { batt_info->sCaMAH = batt_info->fRC; - pr_err("file fail USE RC\n"); + batt_dbg("file fail USE RC\n"); } if(fix_car_init) { batt_info->sCaMAH = batt_info->fRC; - pr_err("file fail fix fRC: %d,%d \n",batt_info->sCaMAH,batt_info->fRC); + batt_dbg("file fail fix fRC: %d,%d \n",batt_info->sCaMAH,batt_info->fRC); } #endif } } - } - + } + if(batt_info->sCaMAH <= num_0) { - pr_err("calculate_soc is %d\n",calculate_soc); + batt_dbg("calculate_soc is %d\n",calculate_soc); afe_read_cell_volt(&batt_info->fVolt); batt_info->fRSOC = calculate_soc; if((batt_info->fRSOC >num_100) || (batt_info->fRSOC < num_0)) batt_info->fRSOC = num_50; - pr_err("batt_info->fRSOC is %d\n",batt_info->fRSOC); + batt_dbg("batt_info->fRSOC is %d\n",batt_info->fRSOC); batt_info->fRC = batt_info->fRSOC * config_data->design_capacity / num_100; - pr_err("batt_info->fRC is %d\n",batt_info->fRC); + batt_dbg("batt_info->fRC is %d\n",batt_info->fRC); if(batt_info->fRC >= (gas_gauge->overflow_data -num_10)) { batt_info->fRC = gas_gauge->overflow_data - gas_gauge->overflow_data/num_100; - batt_info->fRCPrev = batt_info->fRC; + batt_info->fRCPrev = batt_info->fRC; } + batt_dbg("batt_info->fRC is %d\n",batt_info->fRC); - pr_err("batt_info->fRC is %d\n",batt_info->fRC); - afe_write_car(batt_info->fRC); batt_info->fRCPrev = batt_info->fRC; - - batt_info->sCaMAH = batt_info->fRC; - + batt_info->sCaMAH = batt_info->fRC; } - if(batt_info->sCaMAH > full_charge_data) { batt_info->sCaMAH = full_charge_data; } - pr_err("batt_info->sCaMAH is %d\n",batt_info->sCaMAH); - + batt_dbg("batt_info->sCaMAH is %d\n",batt_info->sCaMAH); + batt_info->fRSOC = batt_info->sCaMAH * num_100; batt_info->fRSOC = batt_info->fRSOC / gas_gauge->fcc_data ; @@ -1214,21 +1124,20 @@ file_fail: if(batt_info->fRC >= (gas_gauge->overflow_data -num_10)) { batt_info->fRC = gas_gauge->overflow_data - gas_gauge->overflow_data/num_100; - batt_info->fRCPrev = batt_info->fRC; + batt_info->fRCPrev = batt_info->fRC; } - gas_gauge->sCtMAH = batt_info->sCaMAH; - pr_err("AAAA batt_info->fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); - pr_err("AAAA batt_info->fRSOC is %d\n",batt_info->fRSOC); - pr_err("AAAA batt_info->sCaMAH is %d\n",batt_info->sCaMAH); - pr_err("AAAA gas_gauge->sCtMAH is %d\n",gas_gauge->sCtMAH); - pr_err("AAAA fcc is %d\n",gas_gauge->fcc_data); - pr_err("AAAA batt_info->fRC is %d\n",batt_info->fRC); - pr_err("AAAA batt_info->fCurr is %d\n",batt_info->fCurr); - - afe_write_car(batt_info->fRC); - batt_info->fRCPrev = batt_info->fRC; + batt_dbg("AAAA batt_info->fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); + batt_dbg("AAAA batt_info->fRSOC is %d\n",batt_info->fRSOC); + batt_dbg("AAAA batt_info->sCaMAH is %d\n",batt_info->sCaMAH); + batt_dbg("AAAA gas_gauge->sCtMAH is %d\n",gas_gauge->sCtMAH); + batt_dbg("AAAA fcc is %d\n",gas_gauge->fcc_data); + batt_dbg("AAAA batt_info->fRC is %d\n",batt_info->fRC); + batt_dbg("AAAA batt_info->fCurr is %d\n",batt_info->fCurr); + + afe_write_car(batt_info->fRC); + batt_info->fRCPrev = batt_info->fRC; if(gas_gauge->fcc_data > batt_info->sCaMAH) gas_gauge->discharge_sCtMAH = gas_gauge->fcc_data- batt_info->sCaMAH; @@ -1258,19 +1167,18 @@ file_fail: check_shutdwon_voltage(); fRSOC_PRE = batt_info->fRSOC; - + // double check if (bmu_sys_rw_kernel) { store_rc = bmu_read_data(BATT_CAPACITY); if(store_rc != batt_info->sCaMAH) - { + { bmu_write_data(BATT_CAPACITY,batt_info->sCaMAH); bmu_write_data(BATT_FCC, gas_gauge->fcc_data); - //pr_err("init write sCaMAH %d,%d\n",batt_info->sCaMAH,store_rc); + //batt_dbg("init write sCaMAH %d,%d\n",batt_info->sCaMAH,store_rc); } } - gas_gauge->bmu_init_ok = num_1; } @@ -1284,7 +1192,6 @@ file_fail: *****************************************************************************/ void bmu_power_down_chip(void) { - afe_read_cell_temp(&batt_info->fCellTemp); afe_read_cell_volt(&batt_info->fVolt); afe_read_current(&batt_info->fCurr); @@ -1295,16 +1202,14 @@ void bmu_power_down_chip(void) else afe_register_write_byte(OZ8806_OP_CTRL,SLEEP_MODE | SLEEP_OCV_EN); - - if(parameter->config->debug){ - pr_err("eeee power down oz8806 \n"); - pr_err("eeee batt_info->fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); - pr_err("eeee batt_info->fRSOC is %d\n",batt_info->fRSOC); - pr_err("eeee batt_info->sCaMAH is %d\n",batt_info->sCaMAH); - pr_err("eeee batt_info->fRC is %d\n",batt_info->fRC); - pr_err("eeee batt_info->fCurr is %d\n",batt_info->fCurr); + if(parameter->config->debug){ + batt_dbg("eeee power down BMT fgu \n"); + batt_dbg("eeee batt_info->fVolt is %d\n",(batt_info->fVolt * oz8806_cell_num)); + batt_dbg("eeee batt_info->fRSOC is %d\n",batt_info->fRSOC); + batt_dbg("eeee batt_info->sCaMAH is %d\n",batt_info->sCaMAH); + batt_dbg("eeee batt_info->fRC is %d\n",batt_info->fRC); + batt_dbg("eeee batt_info->fCurr is %d\n",batt_info->fCurr); } - } /***************************************************************************** @@ -1326,36 +1231,36 @@ void bmu_wake_up_chip(void) int32_t car_wakeup = 0; int8_t adapter_status = 0; - pr_err("fCurr is %d\n",batt_info->fCurr); - + batt_dbg("fCurr is %d\n",batt_info->fCurr); + adapter_status = get_adapter_status(); if ((batt_info->fCurr <= gas_gauge->discharge_current_th) || (adapter_status == O2_CHARGER_BATTERY)) { discharge_flag = 1; } - - pr_err("adapter_status: %d\n", adapter_status); + + batt_dbg("adapter_status: %d\n", adapter_status); bmu_sleep_flag = 1; - + time_sec = oz8806_get_system_boot_time(); sleep_time = time_sec - previous_loop_timex; - pr_err("sleep time: %d s\n",sleep_time); + batt_dbg("sleep time: %d s\n",sleep_time); oz8806_wakeup_full_power(); ret = afe_register_read_byte(OZ8806_OP_CTRL,&data);//wake up OZ8806 into FullPower mode if((data & 0x40) || (ret < 0)) { - pr_err("bmu_wake_up_chip read 0x09 ret is %d,i is %d \n",ret,data); + batt_dbg("bmu_wake_up_chip read 0x09 ret is %d,i is %d \n",ret,data); if(oz8806_cell_num > 1) { afe_register_write_byte(OZ8806_OP_CTRL,0x2c); } else afe_register_write_byte(OZ8806_OP_CTRL,0x20); - pr_err("oz8806 wake up function\n"); + batt_dbg("BMT fgu wake up function\n"); } @@ -1364,20 +1269,19 @@ void bmu_wake_up_chip(void) if(batt_info->fRSOC >= num_100) batt_info->fRSOC = num_100; if(batt_info->sCaMAH > (full_charge_data)) { - pr_err("oz8806 wake up batt_info.sCaMAH big error is %d\n",batt_info->sCaMAH); + batt_dbg("BMT fgu wake up batt_info.sCaMAH big error is %d\n",batt_info->sCaMAH); batt_info->sCaMAH = full_charge_data; - } } - + afe_read_current(&batt_info->fCurr); afe_read_cell_volt(&batt_info->fVolt); - pr_err("sCaMAH:%d,fRC:%d,fcurr:%d,volt:%d,sCtMAH:%d\n", + batt_dbg("sCaMAH:%d,fRC:%d,fcurr:%d,volt:%d,sCtMAH:%d\n", batt_info->sCaMAH,batt_info->fRC,batt_info->fCurr, (batt_info->fVolt * oz8806_cell_num), gas_gauge->sCtMAH); - + for(i = num_0;i< num_3;i++) { ret = afe_read_car(&car_wakeup); @@ -1386,7 +1290,7 @@ void bmu_wake_up_chip(void) if ((car_wakeup == 0) || ((!discharge_flag) && (car_wakeup < 0))) { car_error += 1; - pr_err("test fRC read: %d, %d\n",car_error, car_wakeup); //H7 Test Version + batt_dbg("test fRC read: %d, %d\n",car_error, car_wakeup); //H7 Test Version } else break; @@ -1407,16 +1311,16 @@ void bmu_wake_up_chip(void) if (((value * 1000) - sleep_time) < 0) //over max car range { value = (sleep_time / 1000); - pr_err("Ab CAR:%d,mod:%d\n",car_wakeup,value); + batt_dbg("Ab CAR:%d,mod:%d\n",car_wakeup,value); car_wakeup = value + batt_info->fRC; afe_write_car(car_wakeup); } } - pr_err("CAR Prev:%d,CAR Now:%d\n",batt_info->fRC,car_wakeup); + batt_dbg("CAR Prev:%d,CAR Now:%d\n",batt_info->fRC,car_wakeup); //*******CAR zero reading Workaround****************************** if(car_wakeup <= 0) { - pr_err("fRC is %d\n",car_wakeup); + batt_dbg("fRC is %d\n",car_wakeup); //oz8806_over_flow_prevent(); gas_gauge->charge_fcc_update = num_0; gas_gauge->discharge_fcc_update = num_0; @@ -1438,7 +1342,7 @@ void bmu_wake_up_chip(void) batt_info->fRC = car_wakeup; batt_info->fRCPrev = batt_info->fRC; } - + if(discharge_flag) { check_shutdwon_voltage(); @@ -1472,23 +1376,22 @@ void bmu_wake_up_chip(void) if ((discharge_flag) && (car_wakeup > batt_info->fRC)) { - pr_err("it seems error 1\n"); + batt_dbg("it seems error 1\n"); value = car_wakeup - batt_info->fRC; car_wakeup = batt_info->fRC - value; afe_write_car(car_wakeup); } if ((!discharge_flag) && (car_wakeup < batt_info->fRC)) { - pr_err("it seems error 2\n"); + batt_dbg("it seems error 2\n"); value = batt_info->fRC - car_wakeup; car_wakeup = batt_info->fRC + value; - afe_write_car(car_wakeup); + afe_write_car(car_wakeup); } - bmu_dbg("tttt final wakeup car is %d\n",car_wakeup); + batt_dbg("tttt final wakeup car is %d\n",car_wakeup); } - /***************************************************************************** * Description: * check_board_offset @@ -1511,18 +1414,15 @@ static void check_board_offset(void) afe_write_board_offset(config_data->board_offset); return; } - + ret = bmu_read_data(BATT_OFFSET); - - - //pr_err("AAAA board_offset is %d\n",data); - + //batt_dbg("AAAA board_offset is %d\n",data); if(ret < num_0) { if((data > num_10) || (data <= num_0)) afe_write_board_offset(7); - + if(ret2 >= num_0) { if((data < num_10) && (data > num_0) && (data != num_0)) @@ -1530,11 +1430,11 @@ static void check_board_offset(void) ret = bmu_write_data(BATT_OFFSET,data); if(ret num_10) || (data <= num_0)) afe_write_board_offset(num_7); - + afe_read_board_offset(&data); - pr_err("AAAA board_offset is %dmA\n",data); + batt_dbg("AAAA board_offset is %dmA\n",data); } /***************************************************************************** @@ -1568,16 +1468,14 @@ void bmu_polling_loop(void) int32_t ret; uint8_t i; static uint8_t error_times = 0; -#if (FORCE_OTP_MAPPING) - uint32_t force_otp_time = 0; -#endif + int8_t adapter_status = 0; uint8_t retry = 0; uint8_t val = 0; if(is_battery_exchanged()){ //battery was exchanged, oz8806 in start-up mode gas_gauge->bmu_init_ok = 0; batt_info->i2c_error_times = 0; - pr_err("battery was exchanged, init SOC again\n"); + batt_dbg("battery was exchanged, init SOC again\n"); retry_wakeup: //wake up this stupid chip @@ -1586,11 +1484,11 @@ retry_wakeup: ret = afe_register_read_byte(OZ8806_OP_CTRL,&val); if((val & 0x40) || (ret < 0)) { - pr_err("bmu_wake_up_chip read 0x09 ret is %d,i is %d \n",ret,val); + batt_dbg("bmu_wake_up_chip read 0x09 ret is %d,i is %d \n",ret,val); retry++; if(retry>10){ - pr_err("fail wakeup ic"); + batt_dbg("fail wakeup ic"); } goto retry_wakeup; } @@ -1602,7 +1500,7 @@ retry_wakeup: wait_ocv_flag_fun(); } - bmu_dbg("-----------------------bmu_polling_loop start------------------\n"); + batt_dbg("-----------------------bmu_polling_loop start------------------\n"); if(!(gas_gauge->bmu_init_ok)) { @@ -1611,7 +1509,7 @@ retry_wakeup: else bmu_wait_ready(); - if(gas_gauge->bmu_init_ok) + if(gas_gauge->bmu_init_ok) check_board_offset(); goto end; @@ -1628,15 +1526,15 @@ retry_wakeup: ret = afe_read_car(&data); if(parameter->config->debug) { if (data == 0) car_error++; - pr_err("CAR is %d, %d\n",data, car_error); + batt_dbg("CAR is %d, %d\n",data, car_error); } - + if((ret >= 0) && (data > 0)) { // for big current charge // 10% if (ABS(batt_info->fRCPrev, data) < (10 * config_data->design_capacity / num_100)) - { + { batt_info->fRC = data; error_times = 0; } @@ -1645,7 +1543,7 @@ retry_wakeup: error_times++; if(error_times > 3) { - pr_err("CAR error_times is %d\n",error_times); + batt_dbg("CAR error_times is %d\n",error_times); error_times = 0; afe_write_car(batt_info->sCaMAH); batt_info->fRCPrev = batt_info->sCaMAH; @@ -1653,8 +1551,8 @@ retry_wakeup: } } } - - bmu_dbg("first sCaMAH:%d,fRC:%d,fRCPrev:%d,fcurr:%d,volt:%d\n", + + batt_dbg("first sCaMAH:%d,fRC:%d,fRCPrev:%d,fcurr:%d,volt:%d\n", batt_info->sCaMAH,batt_info->fRC,batt_info->fRCPrev, batt_info->fCurr,(batt_info->fVolt * oz8806_cell_num)); @@ -1662,20 +1560,19 @@ retry_wakeup: //H7====LOW VOLTAGE CHARGE PREVENT====== if ((batt_info->fVolt < config_data->discharge_end_voltage) && (batt_info->fCurr > 0)) //charge and voltage < 3300 { - pr_err("Low voltage %d charge current %d detected\n",batt_info->fVolt,batt_info->fCurr); + batt_dbg("Low voltage %d charge current %d detected\n",batt_info->fVolt,batt_info->fCurr); if (batt_info->fRC > batt_info->fRCPrev) //CAR increased { - pr_err("Low voltage fRC limit triggered %d\n",batt_info->fRCPrev); + batt_dbg("Low voltage fRC limit triggered %d\n",batt_info->fRCPrev); batt_info->fRC = batt_info->fRCPrev; //Limit CAR as previous afe_write_car(batt_info->fRC); //write back CAR } } //H7====LOW VOLTAGE CHARGE PREVENT====== - gas_gauge->sCtMAH += batt_info->fRC - batt_info->fRCPrev; gas_gauge->discharge_sCtMAH += batt_info->fRCPrev - batt_info->fRC; - + if(gas_gauge->sCtMAH < num_0) gas_gauge->sCtMAH = num_0; if(gas_gauge->discharge_sCtMAH < num_0) gas_gauge->discharge_sCtMAH = num_0; @@ -1688,27 +1585,24 @@ retry_wakeup: else charge_process(); - bmu_dbg("second sCaMAH:%d,fRC:%d,fRCPrev:%d,fcurr:%d,volt:%d\n", + batt_dbg("second sCaMAH:%d,fRC:%d,fRCPrev:%d,fcurr:%d,volt:%d\n", batt_info->sCaMAH,batt_info->fRC,batt_info->fRCPrev, batt_info->fCurr,(batt_info->fVolt * oz8806_cell_num)); if(gas_gauge->charge_end) { if(!charge_end_flag) - { - pr_err("enter 8806 charge end\n"); + { + batt_dbg("enter BMT fgu charge end\n"); charge_end_flag = num_1; charge_end_process(); } - } else { charge_end_flag = num_0; } - - if(gas_gauge->discharge_end) { if(!discharge_end_flag) @@ -1716,7 +1610,6 @@ retry_wakeup: discharge_end_flag = num_1; discharge_end_process(); } - } else { @@ -1734,24 +1627,22 @@ retry_wakeup: discharge_end_process(); } */ - - //gas_gauge->bmu_tick++; previous_loop_timex = time_sec; time_sec = oz8806_get_system_boot_time(); - bmu_dbg("----------------------------------------------------\n" - "VERSION: %s\n" - "TABLEVERSION: %s\n" - "battery_ok: %d,time_x: %d\n" - "chg_fcc_update: %d, disg_fcc_update: %d\n" - "fVolt: %d fCurr: %d fCellTemp: %d fRSOC: %d\n" - "sCaMAH: %d, sCtMAH1: %d, sCtMAH2: %d\n" - "fcc: %d, fRC: %d\n" - "i2c_error_times: %d\n" - "charge_end: %d, discharge_end: %d\n" - "adapter_status: %d\n" - "----------------------------------------------------\n", - VERSION, get_table_version(),batt_info->Battery_ok,time_sec, + batt_dbg("----------------------------------------------------\n" + "[bmt]:VERSION: %s-%x\n" + "[bmt]:TABLEVERSION: %s\n" + "[bmt]:battery_ok: %d,time_x: %d\n" + "[bmt]:chg_fcc_update: %d, disg_fcc_update: %d\n" + "[bmt]:fVolt: %d fCurr: %d fCellTemp: %d fRSOC: %d\n" + "[bmt]:sCaMAH: %d, sCtMAH1: %d, sCtMAH2: %d\n" + "[bmt]:fcc: %d, fRC: %d\n" + "[bmt]:i2c_error_times: %d\n" + "[bmt]:charge_end: %d, discharge_end: %d\n" + "[bmt]:adapter_status: %d\n" + "[bmt]:----------------------------------------------------\n", + VERSION,calculate_version,get_table_version(),batt_info->Battery_ok,time_sec, gas_gauge->charge_fcc_update,gas_gauge->discharge_fcc_update, (batt_info->fVolt * oz8806_cell_num),batt_info->fCurr,batt_info->fCellTemp,batt_info->fRSOC, batt_info->sCaMAH,gas_gauge->sCtMAH,gas_gauge->discharge_sCtMAH, @@ -1762,13 +1653,13 @@ retry_wakeup: if(batt_info->sCaMAH > (full_charge_data)) { - pr_err("big error sCaMAH is %d\n",batt_info->sCaMAH); + batt_dbg("big error sCaMAH is %d\n",batt_info->sCaMAH); batt_info->sCaMAH = full_charge_data; } if(batt_info->sCaMAH < (gas_gauge->fcc_data / 100 - 1)) { - //pr_err("big error sCaMAH is %d\n",batt_info->sCaMAH); + //batt_dbg("big error sCaMAH is %d\n",batt_info->sCaMAH); batt_info->sCaMAH = gas_gauge->fcc_data / 100 - 1; } @@ -1778,7 +1669,7 @@ retry_wakeup: gas_gauge->fcc_data= config_data->design_capacity * FCC_UPPER_LIMIT / 100 ; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("fcc error is %d\n",gas_gauge->fcc_data); + batt_dbg("fcc error is %d\n",gas_gauge->fcc_data); } if((gas_gauge->fcc_data <= 0) || (gas_gauge->fcc_data < (config_data->design_capacity * FCC_LOWER_LIMIT / 100))) @@ -1786,7 +1677,7 @@ retry_wakeup: gas_gauge->fcc_data = config_data->design_capacity * FCC_LOWER_LIMIT /100; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("fcc error is %d\n",gas_gauge->fcc_data); + batt_dbg("fcc error is %d\n",gas_gauge->fcc_data); } */ @@ -1796,22 +1687,21 @@ retry_wakeup: if (bmu_sys_rw_kernel) { data = bmu_read_data(BATT_CAPACITY); - //bmu_dbg("read from RAM batt_info->sCaMAH is %d\n",data); + //batt_dbg("read from RAM batt_info->sCaMAH is %d\n",data); if(data >= num_0) { if(fRSOC_PRE != batt_info->fRSOC) { fRSOC_PRE = batt_info->fRSOC; bmu_write_data(BATT_CAPACITY,batt_info->sCaMAH); - // bmu_dbg("o2 back batt_info->sCaMAH num_1 is %d\n",batt_info->sCaMAH); + // batt_dbg("o2 back batt_info->sCaMAH num_1 is %d\n",batt_info->sCaMAH); //return; goto end; - } if(((batt_info->sCaMAH - data)> (gas_gauge->fcc_data/200))||((data - batt_info->sCaMAH)> (gas_gauge->fcc_data/200))){ bmu_write_data(BATT_CAPACITY,batt_info->sCaMAH); - // bmu_dbg("o2 back batt_info->sCaMAH 2 is %d\n",batt_info->sCaMAH); + // batt_dbg("o2 back batt_info->sCaMAH 2 is %d\n",batt_info->sCaMAH); } } else bmu_write_data(BATT_CAPACITY,batt_info->sCaMAH); @@ -1821,7 +1711,7 @@ retry_wakeup: if(fRSOC_PRE != batt_info->fRSOC) { fRSOC_PRE = batt_info->fRSOC; - //bmu_dbg("o2 back batt_info->sCaMAH num_1 is %d\n",batt_info->sCaMAH); + //batt_dbg("o2 back batt_info->sCaMAH num_1 is %d\n",batt_info->sCaMAH); goto end; } } @@ -1834,17 +1724,17 @@ retry_wakeup: if((i & num_0x40) || (ret < num_0)) { - bmu_dbg("bmu_polling_loop read 0x09 ret is %d,i is %d \n",ret,i); + batt_dbg("bmu_polling_loop read 0x09 ret is %d,i is %d \n",ret,i); if(oz8806_cell_num > 1) { afe_register_write_byte(OZ8806_OP_CTRL,num_0x2c); } else afe_register_write_byte(OZ8806_OP_CTRL,num_0x20); - //pr_err("oz8806 wake up function\n"); + //batt_dbg("oz8806 wake up function\n"); } - + ret = afe_read_board_offset(&data); if (ret >= 0) { @@ -1854,37 +1744,32 @@ retry_wakeup: if(ABS(data, config_data->board_offset) > 3) { afe_write_board_offset(config_data->board_offset); - pr_err("oz8806 board offset error1 is %d \n",data); + batt_dbg("BMT fgu board offset error1 is %d \n",data); } } else { if((data > 10) || (data <= 0)) { - pr_err("oz8806 board offset error2 is %d \n",data); + batt_dbg("BMT fgu board offset error2 is %d \n",data); afe_write_board_offset(7); } - } } - - - bmu_dbg("test data is %d\n",batt_info->sCaMAH); - + batt_dbg("test data is %d\n",batt_info->sCaMAH); /* - + data = bmu_read_data(BATT_FCC); if(data != gas_gauge->fcc_data) { bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("test %d\n",gas_gauge->fcc_data); + batt_dbg("test %d\n",gas_gauge->fcc_data); } - */ - + end: - bmu_dbg("-----------------------bmu_polling_loop end--------------------\n"); + batt_dbg("-----------------------bmu_polling_loop end--------------------\n"); } /***************************************************************************** @@ -1900,7 +1785,7 @@ static void oz8806_over_flow_prevent(void) int32_t ret; int32_t data; - if((batt_info->fRSOC > num_0) && gas_gauge->discharge_end) + if((batt_info->fRSOC > num_0) && gas_gauge->discharge_end) gas_gauge->discharge_end = num_0; if((batt_info->fRSOC < num_100) && gas_gauge->charge_end) @@ -1909,17 +1794,17 @@ static void oz8806_over_flow_prevent(void) if(batt_info->fRC< num_0) { if(batt_info->fVolt >= (config_data->charge_cv_voltage - 200)) - { + { batt_info->fRC = gas_gauge->fcc_data -num_1; } else - { + { if(batt_info->fRSOC > 0) batt_info->fRC = batt_info->fRSOC * gas_gauge->fcc_data / num_100 - num_1; else batt_info->fRC = batt_info->sCaMAH; } - + afe_write_car(batt_info->fRC); batt_info->fRCPrev = batt_info->fRC; } @@ -1932,24 +1817,22 @@ static void oz8806_over_flow_prevent(void) ret = (int16_t)ret; if(ret >= (num_32768 - num_10 * config_data->fRsense)) { - if(parameter->config->debug)pr_err("yyyy CAR WILL UP OVER %d\n",ret); + if(parameter->config->debug)batt_dbg("yyyy CAR WILL UP OVER %d\n",ret); ret = 32768 - 15 * config_data->fRsense; oz8806_write_word(OZ8806_OP_CAR,(int16_t)ret); afe_read_car(&batt_info->fRC); batt_info->fRCPrev = batt_info->fRC; - } else if(ret <= (num_10 * config_data->fRsense)) { - if(parameter->config->debug)pr_err("yyyy CAR WILL DOWN OVER %d\n",ret); + if(parameter->config->debug)batt_dbg("yyyy CAR WILL DOWN OVER %d\n",ret); ret = num_15 * config_data->fRsense; oz8806_write_word(OZ8806_OP_CAR,(int16_t)ret); afe_read_car(&batt_info->fRC); - batt_info->fRCPrev = batt_info->fRC; - } - + batt_info->fRCPrev = batt_info->fRC; + } - } + } */ ret = afe_read_car(&data); @@ -1961,16 +1844,16 @@ static void oz8806_over_flow_prevent(void) afe_write_car(batt_info->sCaMAH); batt_info->fRCPrev = batt_info->sCaMAH; batt_info->fRC = batt_info->sCaMAH; - bmu_dbg("dddd car down is %d\n",data); + batt_dbg("dddd car down is %d\n",data); } else if(data > (32768 * parameter->config->dbCARLSB * 1000 / config_data->fRsense -5)) { afe_write_car(batt_info->sCaMAH); batt_info->fRCPrev = batt_info->sCaMAH; batt_info->fRC = batt_info->sCaMAH; - bmu_dbg("dddd car up is %d\n",data); + batt_dbg("dddd car up is %d\n",data); } - + if(ABS(batt_info->sCaMAH, data) > one_percent_rc) { if((batt_info->sCaMAH < gas_gauge->overflow_data ) && (batt_info->sCaMAH > 0)) @@ -1979,17 +1862,16 @@ static void oz8806_over_flow_prevent(void) batt_info->fRCPrev = batt_info->sCaMAH; batt_info->fRC = batt_info->sCaMAH; if(parameter->config->debug){ - pr_err("dddd write car batt_info->fRCPrev is %d\n",batt_info->fRCPrev); - pr_err("dddd write car batt_info->fRC is %d\n",batt_info->fRC); - pr_err("dddd write car batt_info->sCaMAH is %d\n",batt_info->sCaMAH); + batt_dbg("dddd write car batt_info->fRCPrev is %d\n",batt_info->fRCPrev); + batt_dbg("dddd write car batt_info->fRC is %d\n",batt_info->fRC); + batt_dbg("dddd write car batt_info->sCaMAH is %d\n",batt_info->sCaMAH); } } } - if(batt_info->fRC > (full_charge_data)) { - pr_err("more fRC %d\n",batt_info->fRC); + batt_dbg("more fRC %d\n",batt_info->fRC); batt_info->fRC = full_charge_data; batt_info->fRCPrev = batt_info->fRC; afe_write_car(batt_info->fRC); @@ -2017,16 +1899,16 @@ void charge_end_process(void) gas_gauge->fcc_data = gas_gauge->sCtMAH; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("charge1 fcc update is %d\n",gas_gauge->fcc_data); + batt_dbg("charge1 fcc update is %d\n",gas_gauge->fcc_data); } if(gas_gauge->fcc_data > (config_data->design_capacity *FCC_UPPER_LIMIT / 100)) - { + { gas_gauge->fcc_data= config_data->design_capacity * FCC_UPPER_LIMIT / 100 ; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - - pr_err("charge2 fcc update is %d\n",gas_gauge->fcc_data); + + batt_dbg("charge2 fcc update is %d\n",gas_gauge->fcc_data); } if((gas_gauge->fcc_data <= 0) || (gas_gauge->fcc_data < (config_data->design_capacity * FCC_LOWER_LIMIT / 100))) @@ -2034,11 +1916,11 @@ void charge_end_process(void) gas_gauge->fcc_data = config_data->design_capacity * FCC_LOWER_LIMIT / 100; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("charge3 fcc update is %d\n",gas_gauge->fcc_data); + batt_dbg("charge3 fcc update is %d\n",gas_gauge->fcc_data); } */ - + gas_gauge->fcc_data = config_data->design_capacity; batt_info->sCaMAH = full_charge_data;; @@ -2049,8 +1931,8 @@ void charge_end_process(void) if(gas_gauge->ocv_flag) bmu_write_data(OCV_FLAG,0); - - pr_err("yyyy end charge \n"); + + batt_dbg("yyyy end charge \n"); batt_info->fRSOC = num_100; gas_gauge->charge_end = num_1; charge_end_flag = num_1; @@ -2059,7 +1941,6 @@ void charge_end_process(void) gas_gauge->discharge_fcc_update = 1; gas_gauge->discharge_sCtMAH = 0; power_on_flag = 0; - } /***************************************************************************** @@ -2080,43 +1961,43 @@ void discharge_end_process(void) { gas_gauge->fcc_data = gas_gauge->discharge_sCtMAH; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("discharge1 fcc update is %d\n",gas_gauge->fcc_data); + batt_dbg("discharge1 fcc update is %d\n",gas_gauge->fcc_data); } if(gas_gauge->fcc_data > (config_data->design_capacity *FCC_UPPER_LIMIT / 100)) - { - gas_gauge->fcc_data= config_data->design_capacity * FCC_UPPER_LIMIT / 100 ; + { + gas_gauge->fcc_data= config_data->design_capacity * FCC_UPPER_LIMIT / 100 ; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("discharge2 fcc update is %d\n",gas_gauge->fcc_data); + batt_dbg("discharge2 fcc update is %d\n",gas_gauge->fcc_data); } if((gas_gauge->fcc_data <= 0) || (gas_gauge->fcc_data < (config_data->design_capacity * FCC_LOWER_LIMIT / 100))) - { + { gas_gauge->fcc_data = config_data->design_capacity * FCC_LOWER_LIMIT / 100; bmu_write_data(BATT_FCC,gas_gauge->fcc_data); - pr_err("discharge3 fcc update is %d\n",gas_gauge->fcc_data); + batt_dbg("discharge3 fcc update is %d\n",gas_gauge->fcc_data); } */ gas_gauge->fcc_data = config_data->design_capacity; if(gas_gauge->ocv_flag) bmu_write_data(OCV_FLAG,0); - + batt_info->sCaMAH = gas_gauge->fcc_data / 100 - 1; if (bmu_sys_rw_kernel) bmu_write_data(BATT_CAPACITY,batt_info->sCaMAH); - + afe_write_car(batt_info->sCaMAH); batt_info->fRCPrev = batt_info->sCaMAH; - - - pr_err("yyyy end discharge \n"); + + + batt_dbg("yyyy end discharge \n"); batt_info->fRSOC = num_0; gas_gauge->discharge_end = num_1; gas_gauge->discharge_fcc_update = 1; gas_gauge->charge_fcc_update = 1; gas_gauge->sCtMAH = num_0; - + } @@ -2136,7 +2017,7 @@ static int bmu_check_file(char * address) if(fd < num_0) { - //bmu_dbg(" bmu check file fail %s\n",address); + //batt_dbg(" bmu check file fail %s\n",address); return -num_1; } sys_close(fd); @@ -2152,7 +2033,7 @@ static int bmu_read_data(char * address) if(fd < num_0) { - bmu_dbg(" bmu read open file fail %s, return %ld\n",address, fd); + batt_dbg(" bmu read open file fail %s, return %ld\n",address, fd); return fd; } @@ -2171,7 +2052,7 @@ static int bmu_write_data(char * address,int data) if(fd < num_0) { - bmu_dbg("bmu wirte open file fail %s failed, return %ld\n",address, fd); + batt_dbg("bmu wirte open file fail %s failed, return %ld\n",address, fd); return fd; } *p = data; @@ -2193,12 +2074,12 @@ static int bmu_read_data(char * address) int ret = 0; int val = 0; - //pr_err("%s\n", __func__); + //batt_dbg("%s\n", __func__); fp = filp_open(address, O_RDONLY, 0644); if (IS_ERR(fp)) { - pr_err(" %s: open file fail %s\n", __func__, address); + batt_dbg(" %s: open file fail %s\n", __func__, address); return -1; } @@ -2208,14 +2089,14 @@ static int bmu_read_data(char * address) pos = 0; ret = vfs_read(fp, buf_r, sizeof(buf_r), &pos); if (ret < 0) - pr_err(" %s: read file fail %s\n", __func__, address); + batt_dbg(" %s: read file fail %s\n", __func__, address); buf_r[4] = '\0'; - bmu_dbg("%s: read: %s\n", __func__, buf_r); + batt_dbg("%s: read: %s\n", __func__, buf_r); ret = kstrtoint(buf_r, 10, &val); if (ret < 0) - pr_err(" %s: fail to get int from %s\n", __func__, address); + batt_dbg(" %s: fail to get int from %s\n", __func__, address); set_fs(fs); @@ -2242,12 +2123,12 @@ static int bmu_write_data(char * address,int data) ret = sprintf(buf, "%d", data); - //pr_err("%s\n", __func__); + //batt_dbg("%s\n", __func__); fp = filp_open(address, O_RDWR | O_CREAT, 0644); if (IS_ERR(fp)) { - pr_err(" %s: open file fail %s\n", __func__, address); + batt_dbg(" %s: open file fail %s\n", __func__, address); return -1; } @@ -2257,7 +2138,7 @@ static int bmu_write_data(char * address,int data) pos = 0; ret = vfs_write(fp, buf, sizeof(buf), &pos); if (ret < 0) - pr_err(" %s: write file fail %s\n", __func__, address); + batt_dbg(" %s: write file fail %s\n", __func__, address); else if (!strcmp(address, BATT_CAPACITY)) gas_gauge->stored_capacity = data; @@ -2267,13 +2148,13 @@ static int bmu_write_data(char * address,int data) pos = 0; ret = vfs_read(fp, buf_r, sizeof(buf_r), &pos); if (ret < 0) - pr_err(" %s: read file fail %s\n", __func__, address); + batt_dbg(" %s: read file fail %s\n", __func__, address); - bmu_dbg("%s: read: %s\n", __func__, buf_r); + batt_dbg("%s: read: %s\n", __func__, buf_r); ret = kstrtoint(buf_r, 10, &val); if (ret < 0) - pr_err(" %s: fail to get int from %s\n", __func__, address); + batt_dbg(" %s: fail to get int from %s\n", __func__, address); } set_fs(fs); @@ -2291,7 +2172,7 @@ static int bmu_check_file(char * address) fp = filp_open(address, O_RDONLY, 0644); if (IS_ERR(fp)) { - pr_err(" %s: open file fail %s\n", __func__, address); + batt_dbg(" %s: open file fail %s\n", __func__, address); return -1; } return 0; @@ -2316,13 +2197,13 @@ static int bmu_check_file(char * address) * index: oz8806 operation register * data: write data * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ #if 0 static int32_t oz8806_write_byte_pec(uint8_t addr,uint8_t index, uint8_t data) { int32_t ret; - + uint8_t pec_data = num_0; uint16_t temp = num_0; pec_data =pec_calculate(pec_data,addr); @@ -2336,8 +2217,6 @@ static int32_t oz8806_write_byte_pec(uint8_t addr,uint8_t index, uint8_t data) } #endif - - /**************************************************************************** * Description: * read oz8806 operation register @@ -2345,14 +2224,14 @@ static int32_t oz8806_write_byte_pec(uint8_t addr,uint8_t index, uint8_t data) * index: oz8806 operation register * buf: pointer to buffer to store read data * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_read_byte(uint8_t index) { int32_t ret; uint8_t pec_data = num_0; uint8_t temp; - + if(num_0) { @@ -2364,15 +2243,15 @@ static int32_t oz8806_read_byte(uint8_t index) temp = (uint8_t)(ret & 0xff); pec_data =pec_calculate(pec_data,temp); temp = (uint8_t)(ret >> 8); - + if(pec_data != temp) { - pr_err("33333333333333333 oz8806_read_byte\n"); - pr_err("33333333333333333 pec_data is %d\n",pec_data); - pr_err("33333333333333333 temp is %d\n",temp); + batt_dbg("33333333333333333 BMT_fgu_read_byte\n"); + batt_dbg("33333333333333333 pec_data is %d\n",pec_data); + batt_dbg("33333333333333333 temp is %d\n",temp); return -num_1; } - + return ret; } else @@ -2382,7 +2261,6 @@ static int32_t oz8806_read_byte(uint8_t index) } } - /**************************************************************************** * Description: * write oz8806 operation register @@ -2390,14 +2268,14 @@ static int32_t oz8806_read_byte(uint8_t index) * index: oz8806 operation register * data: write data * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_write_byte(uint8_t index, uint8_t data) { int32_t ret; uint8_t pec_data = num_0; uint16_t temp = num_0; - + if(oz8806_pec_check) { pec_data =pec_calculate(pec_data,0x5e); @@ -2422,7 +2300,7 @@ static int32_t oz8806_write_byte(uint8_t index, uint8_t data) * Parameters: * index: oz8806 operation register * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_read_word(uint8_t index) { @@ -2430,7 +2308,7 @@ static int32_t oz8806_read_word(uint8_t index) int32_t ret1 = num_0; uint8_t temp; uint8_t pec_data = num_0; - + if(num_0) { ret = i2c_smbus_read_word_data(parameter->client, index); @@ -2444,16 +2322,16 @@ static int32_t oz8806_read_word(uint8_t index) if(pec_data != temp) { - pr_err("index 0x%02x\n",index); - pr_err("0x%02x\n",(uint8_t)(ret & 0xff)); - pr_err("33333333333333333 oz8806_read_word num_1\n"); - pr_err("33333333333333333 pec_data is 0x%02x\n",pec_data); - pr_err("33333333333333333 temp is 0x%02x\n",temp); + batt_dbg("index 0x%02x\n",index); + batt_dbg("0x%02x\n",(uint8_t)(ret & 0xff)); + batt_dbg("33333333333333333 BMT_fgu_read_word num_1\n"); + batt_dbg("33333333333333333 pec_data is 0x%02x\n",pec_data); + batt_dbg("33333333333333333 temp is 0x%02x\n",temp); - pr_err("33333333333333333 ret is 0x%02x\n",ret); + batt_dbg("33333333333333333 ret is 0x%02x\n",ret); return -num_1; } - + ret1 = i2c_smbus_read_word_data(parameter->client, (index + num_1)); if(ret1 < num_0) return ret1; @@ -2467,18 +2345,18 @@ static int32_t oz8806_read_word(uint8_t index) if(pec_data != temp) { - pr_err("33333333333333333 oz8806_read_word 2\n"); - pr_err("33333333333333333 pec_data is %d\n",pec_data); - pr_err("33333333333333333 temp is %d\n",temp); + batt_dbg("33333333333333333 BMT_fgu_read_word 2\n"); + batt_dbg("33333333333333333 pec_data is %d\n",pec_data); + batt_dbg("33333333333333333 temp is %d\n",temp); return -num_1; } - + ret1 <<= 8; ret1 |= (uint8_t)(0xff & ret); return ret1; } else - { + { ret = i2c_smbus_read_word_data(parameter->client, index); return ret; } @@ -2491,7 +2369,7 @@ static int32_t oz8806_read_word(uint8_t index) * index: oz8806 operation register * data: write data * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_write_word( uint8_t index, uint16_t data) { @@ -2499,10 +2377,10 @@ static int32_t oz8806_write_word( uint8_t index, uint16_t data) uint8_t pec_data = num_0; uint16_t temp = num_0; - + if(oz8806_pec_check) { - + pec_data =pec_calculate(pec_data,0x5e); pec_data =pec_calculate(pec_data,index); pec_data =pec_calculate(pec_data,(uint8_t)data); @@ -2510,10 +2388,10 @@ static int32_t oz8806_write_word( uint8_t index, uint16_t data) temp <<= 8; temp |= (uint8_t)data; ret = i2c_smbus_write_word_data(parameter->client, index,temp); - + if(ret < num_0) return ret; pec_data = num_0; - + pec_data =pec_calculate(pec_data,0x5e); pec_data =pec_calculate(pec_data,(index +num_1)); pec_data =pec_calculate(pec_data,(uint8_t)(data>>8)); @@ -2537,17 +2415,17 @@ static int32_t oz8806_write_word( uint8_t index, uint16_t data) * Parameters: * voltage: cell voltage in mV, range from -5120mv to +5120mv * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_cell_voltage_read(int32_t *voltage) { int32_t ret; int32_t data; - + ret = oz8806_read_word(OZ8806_OP_CELL_VOLT); if (ret < num_0) return ret; - + data = ret & 0xFFFF; data = (int16_t)data / 16; // >> 4 and keep sign bit @@ -2556,12 +2434,12 @@ static int32_t oz8806_cell_voltage_read(int32_t *voltage) if (data > 5117 || data < 0) { - pr_err("%s:data: %d, reg:%x\n", __func__, data, ret); + batt_dbg("%s:data: %d, reg:%x\n", __func__, data, ret); return -1; } batt_info->i2c_error_times = 0; *voltage = data; - + return ret; } @@ -2571,16 +2449,16 @@ static int32_t oz8806_cell_voltage_read(int32_t *voltage) * Parameters: * voltage: voltage in mV, range from -5120mv to +5120mv with 2.5mV LSB * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_ocv_voltage_read(int32_t *voltage) { int32_t ret; int32_t data; - + ret = oz8806_read_word(OZ8806_OP_OCV_LOW); if (ret < num_0) return ret; - + data = ret & 0xFFFF; data = (int16_t)data / 16; // >> 4 and keep sign bit @@ -2589,12 +2467,12 @@ static int32_t oz8806_ocv_voltage_read(int32_t *voltage) if (data > 5117 || data < 0) { - pr_err("%s:data: %d, reg:%x\n", __func__, data, ret); + batt_dbg("%s:data: %d, reg:%x\n", __func__, data, ret); return -1; } *voltage = data; - + return ret; } @@ -2604,14 +2482,14 @@ static int32_t oz8806_ocv_voltage_read(int32_t *voltage) * Parameters: * current: in mA, range is +/-64mv / Rsense with 7.8uv LSB / Rsense * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_current_read(int32_t *data) { int32_t ret; int32_t temp; - + ret = oz8806_read_word(OZ8806_OP_CURRENT); if (ret < num_0) return ret; @@ -2632,18 +2510,18 @@ static int32_t oz8806_current_read(int32_t *data) * Parameters: * voltage: voltage value in mV, range is +/- 5120mV with 2.5mV LSB * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ int32_t oz8806_temp_read(int32_t *voltage) { int32_t ret; int32_t data; - + ret = oz8806_read_word(OZ8806_OP_CELL_TEMP); if (ret < num_0) return ret; - //pr_err("1111111111111 regeister is 0x%02x\n",ret); - + //batt_dbg("1111111111111 regeister is 0x%02x\n",ret); + data = ret & 0xFFFF; data = (int16_t)data / 16; // >> 4 and keep sign bit @@ -2652,14 +2530,14 @@ int32_t oz8806_temp_read(int32_t *voltage) if (data > 5117 || data < 0) { - pr_err("%s:data: %d, reg:%x\n", __func__, data, ret); + batt_dbg("%s:data: %d, reg:%x\n", __func__, data, ret); return -1; } *voltage = data; - //pr_err("1111111111111 voltage is %d\n",*voltage); - + //batt_dbg("1111111111111 voltage is %d\n",*voltage); + return ret; } @@ -2669,18 +2547,17 @@ int32_t oz8806_temp_read(int32_t *voltage) * Parameters: * car: in mAHr, range is +/- 163840 uvHr/ Rsense with 5 uvHr LSB / Rsense * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_car_read(int32_t *car) { int32_t ret; int32_t data; - + ret = oz8806_read_word(OZ8806_OP_CAR); if (ret < num_0) return ret; - data = (int16_t)ret; data = data * parameter->config->dbCARLSB; data = data * 1000 / parameter->config->fRsense; @@ -2690,20 +2567,19 @@ static int32_t oz8806_car_read(int32_t *car) return ret; } - /**************************************************************************** * Description: * write oz8806 CAR * Parameters: * data: in mAHr, range is +/- 163840 uvHr/ Rsense with 5 uvHr LSB / Rsense * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_car_write(int32_t data) { int32_t temp; int32_t ret; - + temp = data; temp = (temp * parameter->config->fRsense) / parameter->config->dbCARLSB; //transfer to CAR temp /= 1000; @@ -2718,18 +2594,18 @@ static int32_t oz8806_car_write(int32_t data) * Parameters: * data: in mA, +/- 8mV / Rsense with 7.8uV / Rsense * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_board_offset_read(int32_t *data) { int32_t ret; int32_t temp; - + ret = oz8806_read_word(OZ8806_OP_BOARD_OFFSET); if (ret < num_0) return ret; - + temp = (int16_t)ret; temp = temp & 0x7ff; if(temp & 0x0400)// if bit[10] is 1, it's negative @@ -2747,15 +2623,13 @@ static int32_t oz8806_board_offset_read(int32_t *data) * Parameters: * data: the data will be wrriten * Return: - * see I2C_STATUS_XXX define + * see I2C_STATUS_XXX define ****************************************************************************/ static int32_t oz8806_board_offset_write(int32_t data) { int32_t ret; int32_t over_data; - - - + if(data > num_0){ data = data * config_data->fRsense * num_10 / 78; data /= 1000; @@ -2777,7 +2651,6 @@ static int32_t oz8806_board_offset_write(int32_t data) return ret; } - /***************************************************************************** * Description: * wrapper function for operation register byte reading @@ -2798,7 +2671,7 @@ static int32_t afe_register_read_byte(uint8_t index, uint8_t *dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } @@ -2807,7 +2680,6 @@ static int32_t afe_register_read_byte(uint8_t index, uint8_t *dat) return ret; } - /***************************************************************************** * Description: * wrapper function for operation register byte writing @@ -2828,14 +2700,13 @@ static int32_t afe_register_write_byte(uint8_t index, uint8_t dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } return ret; } - /***************************************************************************** * Description: * wrapper function for operation register word reading @@ -2849,7 +2720,6 @@ static int32_t afe_register_read_word(uint8_t index, uint16_t *dat) { int32_t ret; uint8_t i; - for(i = num_0; i < RETRY_CNT; i++){ ret = oz8806_read_word(index); @@ -2857,7 +2727,7 @@ static int32_t afe_register_read_word(uint8_t index, uint16_t *dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } @@ -2866,7 +2736,6 @@ static int32_t afe_register_read_word(uint8_t index, uint16_t *dat) return ret; } - /***************************************************************************** * Description: * wrapper function for operation register word writing @@ -2888,7 +2757,7 @@ static int32_t afe_register_write_word(uint8_t index, uint16_t dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } @@ -2896,8 +2765,6 @@ static int32_t afe_register_write_word(uint8_t index, uint16_t dat) } #endif - - /***************************************************************************** * Description: * wrapper function to read cell voltage @@ -2922,22 +2789,21 @@ int32_t afe_read_cell_volt(int32_t *voltage) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } if(oz8806_cell_num > num_1) { //*voltage = buf * num_1000 / res_divider_ratio; - bmu_dbg("read from register %d mv \n",buf); + batt_dbg("read from register %d mv \n",buf); *voltage = buf * res_divider_ratio / num_1000; // res_divider_ratio = ((Rpull + Rdown) / Rdown) * 1000 *voltage /= oz8806_cell_num; } - else + else *voltage = buf; return ret; } - /***************************************************************************** * Description: * wrapper function to read cell ocv voltage @@ -2962,7 +2828,7 @@ static int32_t afe_read_ocv_volt(int32_t *voltage) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } @@ -2971,9 +2837,9 @@ static int32_t afe_read_ocv_volt(int32_t *voltage) *voltage = buf * num_1000 / res_divider_ratio; *voltage /= oz8806_cell_num; } - else + else *voltage = buf; - + return ret; } @@ -3001,14 +2867,13 @@ int32_t afe_read_current(int32_t *dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } *dat = buf; return ret; } - /***************************************************************************** * Description: * wrapper function to read CAR(accummulated current calculation) @@ -3033,15 +2898,13 @@ static int32_t afe_read_car(int32_t *dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } *dat = buf; return ret; } - - /***************************************************************************** * Description: * wrapper function to write car @@ -3065,7 +2928,7 @@ static int32_t afe_write_car(int32_t date) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } return ret; @@ -3093,7 +2956,7 @@ static int32_t afe_write_board_offset(int32_t date) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } return ret; @@ -3122,12 +2985,13 @@ static int32_t afe_read_board_offset(int32_t *dat) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } *dat = buf; return ret; } + /***************************************************************************** * Description: * wrapper function to read temp @@ -3155,11 +3019,10 @@ static int32_t afe_read_cell_temp(int32_t *data) } if(i >= RETRY_CNT){ batt_info->i2c_error_times++; - bmu_dbg("yyyy. %s failed, ret %d\n", __func__, ret); + batt_dbg("yyyy. %s failed, ret %d\n", __func__, ret); return ret; } - if((buf >= config_data->temp_ref_voltage)|| (buf <= num_0)){ *data = num_25; } @@ -3168,7 +3031,7 @@ static int32_t afe_read_cell_temp(int32_t *data) temp = temp / (config_data->temp_ref_voltage - buf); *data = one_latitude_table(parameter->cell_temp_num,parameter->temperature,temp); } - //pr_err("1111111111111 r is %d\n",temp); + //batt_dbg("1111111111111 r is %d\n",temp); return ret; } @@ -3181,7 +3044,7 @@ static int32_t afe_read_cell_temp(int32_t *data) * Return: * crc data * Note: - * + * *****************************************************************************/ static uint8_t pec_calculate (uint8_t ucCrc, uint8_t ucData) { @@ -3200,6 +3063,7 @@ static uint8_t pec_calculate (uint8_t ucCrc, uint8_t ucData) } return ucCrc; } + #if 0 /***************************************************************************** * Description: @@ -3207,7 +3071,7 @@ static uint8_t pec_calculate (uint8_t ucCrc, uint8_t ucData) * Parameters: * Return: * Note: - * + * *****************************************************************************/ static int32_t i2c_read_byte(uint8_t addr,uint8_t index,uint8_t *data) { @@ -3240,7 +3104,7 @@ static int32_t i2c_read_byte(uint8_t addr,uint8_t index,uint8_t *data) * Parameters: * Return: * Note: - * + * *****************************************************************************/ static int32_t i2c_write_byte(uint8_t addr,uint8_t index,uint8_t data) { @@ -3249,7 +3113,7 @@ static int32_t i2c_write_byte(uint8_t addr,uint8_t index,uint8_t data) struct i2c_adapter *adap=parameter->client->adapter; struct i2c_msg msg; int32_t scl_rate = num_100 * num_1000; - + char tx_buf[num_3]; tx_buf[num_0] = index; tx_buf[num_1] = data; @@ -3276,9 +3140,6 @@ static int32_t i2c_write_byte(uint8_t addr,uint8_t index,uint8_t data) } #endif - - - void bmu_reinit(int32_t mode) { if(mode) @@ -3312,11 +3173,7 @@ void bmu_reinit(int32_t mode) } EXPORT_SYMBOL(bmu_reinit); -#ifdef CONFIG_OZ8806_M -static int __init bmulib_init(void) -#else int bmulib_init(void) -#endif { int ret = 0; #if !defined(OZ8806_API) @@ -3324,24 +3181,21 @@ int bmulib_init(void) uint8_t * p = NULL; #endif - pr_err("%s\n", __func__); + bmt_dbg("%s\n", __func__); //NOTICE: Don't change the sequence of calling below functions - -#ifdef OZ8806_API - bmu_kernel_memaddr = oz8806_get_kernel_memaddr(); -#else + byte_num = sizeof(config_data_t) + sizeof(bmu_data_t) + sizeof(gas_gauge_t); p = kzalloc(byte_num, GFP_KERNEL); bmu_kernel_memaddr = (unsigned long)p; -#endif + if (!bmu_kernel_memaddr) goto fail_mem; parameter_customer.client = oz8806_get_client(); if (!parameter_customer.client) goto fail_i2c; - pr_err("i2c address:%x\n", parameter_customer.client->addr); + bmt_dbg("i2c address:%x\n", parameter_customer.client->addr); //struct oz8806_data *data = i2c_get_clientdata(parameter_customer.client); bmu_init_parameter(¶meter_customer); @@ -3360,20 +3214,16 @@ int bmulib_init(void) return ret; fail_mem: - pr_err("%s: bmu_kernel_memaddr error\n", __func__); + bmt_dbg("%s: bmu_kernel_memaddr error\n", __func__); fail_i2c: - pr_err("%s: oz8806 i2c register error\n", __func__); + bmt_dbg("%s: oz8806 i2c register error\n", __func__); return -1; } -#ifdef CONFIG_OZ8806_M -static void __exit bmulib_exit(void) -#else void bmulib_exit(void) -#endif { - pr_err("%s\n", __func__); + batt_dbg("%s\n", __func__); unregister_bmu_callback(); #if !defined(OZ8806_API) @@ -3383,13 +3233,3 @@ void bmulib_exit(void) #endif } -#ifdef CONFIG_OZ8806_M -//module_init(bmulib_init); -late_initcall(bmulib_init); -module_exit(bmulib_exit); - -MODULE_AUTHOR("O2Micro"); -MODULE_DESCRIPTION("o2micro oz8806 battery gauge driver"); -//MODULE_LICENSE("GPL"); -#endif - diff --git a/drivers/power/sd77426_fg_mmi/calculate.o b/drivers/power/sd77426_fg_mmi/calculate.o index 634c83461468..a8b9befaa9ea 100644 Binary files a/drivers/power/sd77426_fg_mmi/calculate.o and b/drivers/power/sd77426_fg_mmi/calculate.o differ diff --git a/drivers/power/sd77426_fg_mmi/oz8806_battery.c b/drivers/power/sd77426_fg_mmi/oz8806_battery.c index b9fb02ad97d3..5e66715f699f 100644 --- a/drivers/power/sd77426_fg_mmi/oz8806_battery.c +++ b/drivers/power/sd77426_fg_mmi/oz8806_battery.c @@ -1,17 +1,17 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. +* Copyright(c) BMT, 2021. All rights reserved. * -* O2Micro [OZ8806] Source Code Reference Design -* File:[oz8806_battery.c] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* BMT [oz8806] Source Code Reference Design +* File:[bmulib.c] +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ @@ -26,14 +26,12 @@ #include #include #include -//you must add these here for O2MICRO +//you must add these here for BMT #include "parameter.h" #include "table.h" #include "battery_config.h" #include "oz8806_regdef.h" -#define batt_dbg(fmt, args...) printk(KERN_ERR"[oz8806]:"pr_fmt(fmt)"\n", ## args) - /***************************************************************************** * static variables/functions section ****************************************************************************/ @@ -41,12 +39,7 @@ static int fg_hw_init_done = 0; static uint8_t bmu_init_done = 0; static int oz8806_suspend = 0; static DEFINE_MUTEX(update_mutex); -#ifdef OZ8806_API -struct mutex *update_mutex_ptr = &update_mutex; -bmu_data_t *batt_info_ptr = NULL; -#else static bmu_data_t *batt_info_ptr = NULL; -#endif static gas_gauge_t *gas_gauge_ptr = NULL; static uint8_t charger_finish = 0; static unsigned long ic_wakeup_time = 0; @@ -113,9 +106,9 @@ static int oz8806_battery_get_property(struct power_supply *psy, struct oz8806_data *data = (struct oz8806_data *)power_supply_get_drvdata(psy); switch (psp) { - + case POWER_SUPPLY_PROP_STATUS: - + if (adapter_status == O2_CHARGER_BATTERY) { val->intval = POWER_SUPPLY_STATUS_DISCHARGING; /*discharging*/ @@ -131,7 +124,6 @@ static int oz8806_battery_get_property(struct power_supply *psy, } else val->intval = POWER_SUPPLY_STATUS_DISCHARGING; - break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: val->intval = data->batt_info.batt_voltage * 1000; @@ -151,27 +143,21 @@ static int oz8806_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_HEALTH: val->intval = POWER_SUPPLY_HEALTH_GOOD; break; - case POWER_SUPPLY_PROP_TEMP: val->intval = data->batt_info.batt_temp * 10; break; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: val->intval = data->batt_info.batt_fcc_data; break; - case POWER_SUPPLY_PROP_CHARGE_NOW: val->intval = data->batt_info.batt_capacity; break; - case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: val->intval = data->batt_info.batt_fcc_data; break; - case POWER_SUPPLY_PROP_ENERGY_NOW: val->intval = data->batt_info.batt_capacity; break; - default: return -EINVAL; } @@ -190,7 +176,6 @@ static void oz8806_external_power_changed(struct power_supply *psy) static void oz8806_powersupply_init(struct oz8806_data *data) { - data->bat_desc.name = "battery"; data->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY; data->bat_desc.properties = oz8806_battery_props; @@ -204,7 +189,6 @@ static void oz8806_powersupply_init(struct oz8806_data *data) *write 0x20 into register 0x09 *example:echo 0920 > /sys/class/i2c-dev/i2c-2/device/2-002f/registers *****************************************************************************/ - static ssize_t oz8806_register_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t _count) { char data[num_3]; @@ -214,10 +198,10 @@ static ssize_t oz8806_register_store(struct device *dev, struct device_attribute int len; struct oz8806_data *oz8806; - len = strlen(buf); + len = strlen(buf); if(len < 5) return -EINVAL; - + if (&(the_oz8806->myclient->dev) == dev) oz8806 = dev_get_drvdata(dev); else //this device is the private device of power supply @@ -236,7 +220,7 @@ static ssize_t oz8806_register_store(struct device *dev, struct device_attribute && address != OZ8806_OP_BOARD_OFFSET && address != OZ8806_OP_BOARD_OFFSET+1) { - pr_err("register[0x%.2x] is read-only\n", address); + bmt_dbg("register[0x%.2x] is read-only\n", address); return _count; } @@ -248,7 +232,7 @@ static ssize_t oz8806_register_store(struct device *dev, struct device_attribute oz8806_write_byte(oz8806, address, value); - pr_err("write 0x%.2x into register[0x%.2x]\n", value, address); + bmt_dbg("write 0x%.2x into register[0x%.2x]\n", value, address); return _count; } @@ -257,12 +241,12 @@ static ssize_t oz8806_register_store(struct device *dev, struct device_attribute example:cat /sys/class/i2c-dev/i2c-2/device/2-002f/registers */ static ssize_t oz8806_register_show(struct device *dev, struct device_attribute *attr,char *buf) -{ +{ struct oz8806_data *oz8806; u8 i = 0; u8 data = 0; int result = 0; - + if (&(the_oz8806->myclient->dev) == dev) oz8806 = dev_get_drvdata(dev); else //this device is the private device of power supply @@ -276,22 +260,22 @@ static ssize_t oz8806_register_show(struct device *dev, struct device_attribute oz8806_read_byte(oz8806, OZ8806_OP_I2CCONFIG, &data); result += sprintf(buf + result, "[0x%.2x] = 0x%.2x\n", OZ8806_OP_I2CCONFIG, data); - for (i=0x00; i<=0x1a; i++) - { + for (i=0x00; i<=0x1a; i++) + { oz8806_read_byte(oz8806, i, &data); result += sprintf(buf + result, "[0x%.2x] = 0x%.2x\n", i, data); } - + return result; } // chip id: 0x38 static ssize_t oz8806_chip_id_show(struct device *dev, struct device_attribute *attr,char *buf) -{ +{ struct oz8806_data *oz8806; u8 data = 0; int result = 0; - + if (&(the_oz8806->myclient->dev) == dev) oz8806 = dev_get_drvdata(dev); else //this device is the private device of power supply @@ -322,16 +306,16 @@ static ssize_t oz8806_debug_store(struct device *dev, struct device_attribute *a if(val == 1) { config_data.debug = 1; - pr_err("DEBUG ON \n"); + bmt_dbg("DEBUG ON \n"); } else if (val == 0) { config_data.debug = 0; - pr_err("DEBUG CLOSE \n"); + bmt_dbg("DEBUG CLOSE \n"); } else { - pr_err("invalid command\n"); + bmt_dbg("invalid command\n"); return -EINVAL; } @@ -354,7 +338,7 @@ static ssize_t oz8806_bmu_init_done_store(struct device *dev, struct device_attr int val = 0; if (kstrtoint(buf, 10, &val)) return -EINVAL; - + bmu_init_done = 0; ic_wakeup_time = jiffies; @@ -363,18 +347,18 @@ static ssize_t oz8806_bmu_init_done_store(struct device *dev, struct device_attr if(val == 1) { - pr_err("reinit oz8806 from ocv\n"); + bmt_dbg("reinit BMT from ocv\n"); bmu_reinit(1);//bmu_init_done will be setted } else if (val == 0) { - pr_err("reinit oz8806,just wakeup ic\n"); + bmt_dbg("reinit BMT,just wakeup ic\n"); bmu_reinit(0); bmu_init_done = 1; } else { - pr_err("invalid command\n"); + bmt_dbg("invalid command\n"); return -EINVAL; } schedule_delayed_work(&the_oz8806->work, 0); @@ -383,13 +367,13 @@ static ssize_t oz8806_bmu_init_done_store(struct device *dev, struct device_attr static DEVICE_ATTR(registers, S_IRUGO | (S_IWUSR|S_IWGRP), oz8806_register_show, oz8806_register_store); static DEVICE_ATTR(chip_id, S_IRUGO, oz8806_chip_id_show, NULL); -static DEVICE_ATTR(debug, S_IRUGO | (S_IWUSR|S_IWGRP), oz8806_debug_show, oz8806_debug_store); +static DEVICE_ATTR(bmt_debug, S_IRUGO | (S_IWUSR|S_IWGRP), oz8806_debug_show, oz8806_debug_store); static DEVICE_ATTR(save_capacity, S_IRUGO, oz8806_save_capacity_show, NULL); static DEVICE_ATTR(bmu_init_done, S_IRUGO| (S_IWUSR|S_IWGRP), oz8806_bmu_init_done_show, oz8806_bmu_init_done_store); static struct attribute *oz8806_attributes[] = { &dev_attr_registers.attr, &dev_attr_chip_id.attr, - &dev_attr_debug.attr, + &dev_attr_bmt_debug.attr, &dev_attr_bmu_init_done.attr, &dev_attr_save_capacity.attr, NULL, @@ -403,10 +387,10 @@ static int oz8806_create_sys(struct device *dev, const struct attribute_group * { int err; - batt_dbg("oz8806_create_sysfs"); - + bmt_dbg("BMT_create_sysfs\n"); + if(NULL == dev){ - pr_err("[BATT]: failed to register battery\n"); + bmt_dbg("[BATT]: failed to register battery\n"); return -EINVAL; } @@ -414,11 +398,11 @@ static int oz8806_create_sys(struct device *dev, const struct attribute_group * if (!err) { - batt_dbg("creat oz8806 sysfs group ok"); + bmt_dbg("creat BMT sysfs group ok\n"); } else { - pr_err("creat oz8806 sysfs group fail\n"); + bmt_dbg("creat BMT sysfs group fail\n"); return -EIO; } return err; @@ -451,7 +435,7 @@ static int32_t oz8806_write_byte(struct oz8806_data *data, uint8_t index, uint8_ int32_t ret; uint8_t i; struct i2c_client *client = data->myclient; - + for(i = 0; i < 4; i++){ ret = i2c_smbus_write_byte_data(client, index, dat); if(ret >= 0) break; @@ -497,7 +481,7 @@ int oz8806_wakeup_full_power(void) struct oz8806_data *data = the_oz8806; ret = oz8806_read_byte(data, OZ8806_OP_CTRL, &val); - pr_err("OZ8806_OP_CTRL: 0x%02x\n", val); + bmt_dbg("BMT_OP_CTRL: 0x%02x\n", val); if ((val & SLEEP_MODE) != 0<<6) { @@ -505,19 +489,19 @@ int oz8806_wakeup_full_power(void) ret = oz8806_read_byte(data, OZ8806_OP_CTRL, &val); - pr_err("OZ8806_OP_CTRL: 0x%02x after writing\n", val); + bmt_dbg("BMT_OP_CTRL: 0x%02x after writing\n", val); if ((val & SLEEP_MODE) != (0 << 6)) - pr_err("fail to wake up oz8806 to full power mode\n"); + bmt_dbg("fail to wake up BMT to full power mode\n"); else { if (oz8806_get_boot_up_time() < 2000) ic_wakeup_time = jiffies + msecs_to_jiffies(2000 - oz8806_get_boot_up_time()); else ic_wakeup_time = jiffies; - pr_err("wake up oz8806 to full power mode\n"); + bmt_dbg("wake up BMT to full power mode\n"); } } - pr_err("ic_wakeup_time %lu\n",ic_wakeup_time); + bmt_dbg("ic_wakeup_time %lu\n",ic_wakeup_time); return ret; } @@ -544,17 +528,16 @@ static void discharge_end_fun(struct oz8806_data *data) */ if(batt_info_ptr->fVolt < (config_data.discharge_end_voltage - 100)) - { - - if(batt_info_ptr->fRSOC == 1) - { - batt_info_ptr->fRSOC = 0; - batt_info_ptr->sCaMAH = data->batt_info.batt_fcc_data / num_100 -1; - discharge_end_process(); - } - else if(batt_info_ptr->fRSOC > 0){ - batt_info_ptr->sCaMAH = batt_info_ptr->fRSOC * data->batt_info.batt_fcc_data / num_100 - 1; - batt_info_ptr->fRSOC--; + { + if(batt_info_ptr->fRSOC == 1) + { + batt_info_ptr->fRSOC = 0; + batt_info_ptr->sCaMAH = data->batt_info.batt_fcc_data / num_100 -1; + discharge_end_process(); + } + else if(batt_info_ptr->fRSOC > 0){ + batt_info_ptr->sCaMAH = batt_info_ptr->fRSOC * data->batt_info.batt_fcc_data / num_100 - 1; + batt_info_ptr->fRSOC--; } } } @@ -583,14 +566,14 @@ static void charge_end_fun(void) static unsigned long start_record_jiffies; static uint8_t start_record_flag = 0; #endif - + if (!gas_gauge_ptr || !batt_info_ptr) return; if (adapter_status != O2_CHARGER_BATTERY && check_charger_full()) { charger_finish = 1; - batt_dbg("charger is full, enter external charger finish"); + bmt_dbg("charger is full, enter external charger finish\n"); goto charger_full; } @@ -612,7 +595,7 @@ static void charge_end_fun(void) start_record_flag = 0; #endif return; - } + } if((batt_info_ptr->fVolt >= (config_data.charge_cv_voltage - 50))&&(batt_info_ptr->fCurr >= DISCH_CURRENT_TH) && (batt_info_ptr->fCurr < oz8806_eoc)&& (!gas_gauge_ptr->charge_end)) @@ -626,7 +609,7 @@ static void charge_end_fun(void) if (time_accumulation >= CHG_END_PERIOD_MS) { charger_finish = 1; - batt_dbg("enter external charger finish"); + bmt_dbg("enter external charger finish\n"); } else { @@ -641,19 +624,19 @@ static void charge_end_fun(void) } charger_full: - batt_dbg("%s, time_accumulation:%d, charger_finish:%d", + bmt_dbg("%s, time_accumulation:%d, charger_finish:%d\n", __func__, time_accumulation, charger_finish); - batt_dbg("voltage:%d, cv:%d, fcurr:%d, 8806 eoc:%d, gas_gauge_ptr->charge_end:%d", + bmt_dbg("voltage:%d, cv:%d, fcurr:%d, BMT eoc:%d, gas_gauge_ptr->charge_end:%d\n", batt_info_ptr->fVolt, config_data.charge_cv_voltage, batt_info_ptr->fCurr, oz8806_eoc, gas_gauge_ptr->charge_end); - + #ifdef ENABLE_10MIN_END_CHARGE_FUN if((batt_info_ptr->fRSOC == 99) &&(!start_record_flag) &&(batt_info_ptr->fCurr > oz8806_eoc)) { start_record_jiffies = jiffies; start_record_flag = 1; - batt_dbg("start_record_flag: %d, at %d ms",start_record_flag, jiffies_to_msecs(jiffies)); + bmt_dbg("start_record_flag: %d, at %d ms\n",start_record_flag, jiffies_to_msecs(jiffies)); } if((batt_info_ptr->fRSOC != 99) ||(batt_info_ptr->fCurr < oz8806_eoc)) { @@ -664,31 +647,29 @@ charger_full: { if(jiffies_to_msecs(jiffies - start_record_jiffies) > FORCE_FULL_MS) { - batt_dbg("start_record_flag: %d, at %d ms",start_record_flag, jiffies_to_msecs(jiffies)); + bmt_dbg("start_record_flag: %d, at %d ms\n",start_record_flag, jiffies_to_msecs(jiffies)); charger_finish = 1; start_record_flag = 0; - batt_dbg("enter charge timer finish"); + bmt_dbg("enter charge timer finish\n"); } } #endif - if(charger_finish) { if(!gas_gauge_ptr->charge_end) { if(batt_info_ptr->fRSOC < 100) { - static int32_t fRSOC_extern = 0; + static int32_t fRSOC_extern = 0; if(batt_info_ptr->fRSOC <= rsoc_pre){ - batt_dbg("fRSOC_extern:%d, soc:%d ",fRSOC_extern,batt_info_ptr->fRSOC); + bmt_dbg("fRSOC_extern:%d, soc:%d \n",fRSOC_extern,batt_info_ptr->fRSOC); if (!chgr_full_soc_pursue_start || fRSOC_extern != batt_info_ptr->fRSOC) { chgr_full_soc_pursue_start = jiffies; fRSOC_extern = batt_info_ptr->fRSOC ; } - chgr_full_soc_pursue_accumulation = jiffies_to_msecs(jiffies - chgr_full_soc_pursue_start); @@ -704,30 +685,26 @@ charger_full: if(batt_info_ptr->fRSOC > 100) { batt_info_ptr->fRSOC = 100; batt_info_ptr->sCaMAH = batt_info_ptr->fRSOC * the_oz8806->batt_info.batt_fcc_data / num_100; - batt_info_ptr->sCaMAH ++; + batt_info_ptr->sCaMAH ++; } - //update fRSOC_extern fRSOC_extern = batt_info_ptr->fRSOC ; - - batt_dbg("enter charger finsh update soc:%d",batt_info_ptr->fRSOC); + bmt_dbg("enter charger finsh update soc:%d\n",batt_info_ptr->fRSOC); } else { - batt_dbg("enter charger charge end"); + bmt_dbg("enter charger charge end\n"); gas_gauge_ptr->charge_end = 1; charge_end_process(); charger_finish = 0; chgr_full_soc_pursue_start = 0; } - } else { charger_finish = 0; chgr_full_soc_pursue_start = 0; } - } else chgr_full_soc_pursue_start = 0; } @@ -747,7 +724,6 @@ static void oz8806_wakeup_event(struct oz8806_data *data) } //this is very important code customer need change //customer should change charge discharge status according to your system -//O2micro static void system_charge_discharge_status(struct oz8806_data *data) { int8_t adapter_status_temp = O2_CHARGER_BATTERY; @@ -794,11 +770,10 @@ static void system_charge_discharge_status(struct oz8806_data *data) adapter_status_temp = O2_CHARGER_AC; } } - batt_dbg("val_ac.intval %d, val_usb.intval %d,adapter_status_temp %d",val_ac.intval,val_usb.intval,adapter_status_temp); + batt_dbg("val_ac.intval %d, val_usb.intval %d,adapter_status_temp %d\n",val_ac.intval,val_usb.intval,adapter_status_temp); #endif - adapter_status = adapter_status_temp; - batt_dbg("adapter_status:%d", adapter_status); + batt_dbg("adapter_status:%d\n", adapter_status); } static void oz8806_lock_soc(struct oz8806_data *data) @@ -809,7 +784,6 @@ static void oz8806_lock_soc(struct oz8806_data *data) //bmu ok if(bmu_init_done) { - pr_err("\n"); if(rsoc_pre < 0) rsoc_pre = 0; if(rsoc_pre > 100) rsoc_pre = 100; @@ -818,7 +792,7 @@ static void oz8806_lock_soc(struct oz8806_data *data) { if(data->batt_info.batt_voltage <= O2_SOC_START_THRESHOLD_VOL) { - pr_err("charge 1,lock soc to pre_soc,pre_soc=%d\n",rsoc_pre); + bmt_dbg("charge 1,lock soc to pre_soc,pre_soc=%d\n",rsoc_pre); if(0 == rsoc_pre) car = data->batt_info.batt_fcc_data / 100 -1; else @@ -826,7 +800,7 @@ static void oz8806_lock_soc(struct oz8806_data *data) temp = (car * config_data.fRsense) / config_data.dbCARLSB; //transfer to CAR temp /= 1000; - + i2c_smbus_write_word_data(data->myclient, OZ8806_OP_CAR,(unsigned short)temp); } } @@ -836,15 +810,15 @@ static void oz8806_lock_soc(struct oz8806_data *data) { if( (100 == rsoc_pre) && (data->batt_info.batt_voltage >= (config_data.charge_cv_voltage - O2_CONFIG_RECHARGE)) ) { - pr_err("charge 2,lock soc to pre_soc,pre_soc=%d\n",rsoc_pre); + bmt_dbg("charge 2,lock soc to pre_soc,pre_soc=%d\n",rsoc_pre); car = 101 * data->batt_info.batt_fcc_data / 100 - 2; batt_info_ptr->sCaMAH = car; batt_info_ptr->fRC = car; batt_info_ptr->fRCPrev = car; temp = (car * config_data.fRsense) / config_data.dbCARLSB; //transfer to CAR temp /= 1000; - - i2c_smbus_write_word_data(data->myclient, OZ8806_OP_CAR,(unsigned short)temp); + + i2c_smbus_write_word_data(data->myclient, OZ8806_OP_CAR,(unsigned short)temp); } } } @@ -858,7 +832,7 @@ static void oz8806_battery_func(struct oz8806_data *data) if(0 == cur_jiffies) cur_jiffies = jiffies; - pr_err("%s: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", __func__); + batt_dbg("BMT battery func: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); time_since_last_update_ms = jiffies_to_msecs(jiffies - cur_jiffies); cur_jiffies = jiffies; @@ -867,7 +841,7 @@ static void oz8806_battery_func(struct oz8806_data *data) rsoc_pre = data->batt_info.batt_soc; - //you must add this code here for O2MICRO + //you must add this code here for BMT //Notice: don't nest mutex #ifdef EXT_THERMAL_READ oz8806_update_batt_temp(data); @@ -892,12 +866,12 @@ static void oz8806_battery_func(struct oz8806_data *data) oz8806_wakeup_event(data); - batt_dbg("l=%d v=%d t=%d c=%d ch=%d", + batt_dbg("l=%d v=%d t=%d c=%d ch=%d\n", data->batt_info.batt_soc, data->batt_info.batt_voltage, data->batt_info.batt_temp, data->batt_info.batt_current, adapter_status); - power_supply_changed(data->bat); - batt_dbg("since last batt update = %lu ms", time_since_last_update_ms); + power_supply_changed(data->bat); + batt_dbg("since last batt update = %lu ms\n", time_since_last_update_ms); } static void oz8806_battery_work(struct work_struct *work) @@ -917,7 +891,7 @@ static void oz8806_battery_work(struct work_struct *work) schedule_delayed_work(&data->work, msecs_to_jiffies(data->interval)); } - batt_dbg("interval:%d ms", data->interval); + batt_dbg("interval:%d ms\n", data->interval); } int32_t is_battery_exchanged(void) @@ -931,20 +905,18 @@ static int oz8806_suspend_notifier(struct notifier_block *nb, void *dummy) { struct oz8806_data *data = container_of(nb, struct oz8806_data, pm_nb); - + switch (event) { case PM_SUSPEND_PREPARE: - pr_err("oz8806 PM_SUSPEND_PREPARE \n"); - cancel_delayed_work_sync(&data->work); + bmt_dbg("BMT PM_SUSPEND_PREPARE \n"); + cancel_delayed_work_sync(&data->work); system_charge_discharge_status(data); oz8806_suspend = 1; return NOTIFY_OK; case PM_POST_SUSPEND: - pr_err("oz8806 PM_POST_SUSPEND \n"); - + bmt_dbg("BMT PM_POST_SUSPEND \n"); system_charge_discharge_status(data); - mutex_lock(&update_mutex); // if AC charge can't wake up every 1 min,you must remove the if. if(adapter_status == O2_CHARGER_BATTERY) @@ -962,12 +934,10 @@ static int oz8806_suspend_notifier(struct notifier_block *nb, if (batt_info_ptr) batt_info_ptr->fCurr = -20; data->batt_info.batt_current = -20; - pr_err("drop current\n"); + bmt_dbg("drop current\n"); } } - oz8806_suspend = 0; - return NOTIFY_OK; default: @@ -989,7 +959,7 @@ static void oz8806_init_soc(struct oz8806_data *data) } if(i >= 5) { - batt_dbg("%s failed, reg value %x\n",__func__,ret); + bmt_dbg("BMT fgu init soc failed, reg value %x\n",ret); init_soc = 50; return; } @@ -1008,7 +978,7 @@ static void oz8806_init_soc(struct oz8806_data *data) else init_soc = 0; - batt_dbg("%s succeed, init soc is %d",__func__,init_soc); + bmt_dbg("BMT fgu init soc succeed, init soc is %d\n",init_soc); } static int oz8806_init_batt_info(struct oz8806_data *data) { @@ -1040,7 +1010,6 @@ static int oz8806_update_batt_info(struct oz8806_data *data) if (data->batt_info.batt_soc > 100) data->batt_info.batt_soc = 100; - data->batt_info.batt_voltage = batt_info_ptr->fVolt; data->batt_info.batt_current = batt_info_ptr->fCurr; data->batt_info.batt_capacity = batt_info_ptr->sCaMAH; @@ -1067,7 +1036,6 @@ static int oz8806_update_batt_temp(struct oz8806_data *data) data->batt_info.batt_temp = batt_info_ptr->fCellTemp; if (batt_info_ptr->fCellTemp != data->batt_info.batt_temp) batt_info_ptr->fCellTemp = data->batt_info.batt_temp; - end: return ret; } @@ -1087,7 +1055,6 @@ int oz8806_get_remaincap(void) } EXPORT_SYMBOL(oz8806_get_remaincap); - int oz8806_get_soc_from_ext(void) { int ret = -1; @@ -1129,7 +1096,7 @@ int oz8806_get_battry_current(void) if (ret < 0) { ret = -1; - batt_dbg("%s:oz8806 current adc error", __func__); + bmt_dbg("BMT current adc error\n"); } if (batt_info_ptr && ret >= 0) @@ -1155,7 +1122,7 @@ int oz8806_get_battery_voltage(void) if (ret < 0) { ret = -1; - batt_dbg("%s:oz8806 voltage adc error", __func__); + bmt_dbg("BMT voltage adc error\n"); } if (batt_info_ptr && ret >= 0) @@ -1186,7 +1153,7 @@ EXPORT_SYMBOL(oz8806_get_battery_temp); void oz8806_battery_update_data(void) { - batt_dbg("enter %s", __func__); + bmt_dbg("enter BMT fgu battery update data"); if (fg_hw_init_done && the_oz8806 && bmu_init_done) oz8806_battery_func(the_oz8806); } @@ -1201,11 +1168,11 @@ int32_t oz8806_vbus_voltage(void) if (ret < 0) { - batt_dbg("%s:oz8806 temp adc error", __func__); + bmt_dbg("BMT temp adc error\n"); return ret; } - batt_dbg("voltage from oz8806:%d", vbus_voltage); + bmt_dbg("voltage from BMT:%d\n", vbus_voltage); vbus_voltage = vbus_voltage * (RPULL + RDOWN) / RDOWN; return vbus_voltage; @@ -1224,7 +1191,7 @@ int32_t oz8806_get_init_status(void) return bmu_init_done; } EXPORT_SYMBOL(oz8806_get_init_status); - + int32_t gauge_int_done(void) { return fg_hw_init_done; @@ -1237,7 +1204,7 @@ struct i2c_client * oz8806_get_client(void) return the_oz8806->myclient; else { - pr_err("the_oz8806 is NULL, oz8806_probe didn't call\n"); + bmt_dbg("BMT is NULL, BMT_probe didn't call\n"); return NULL; } @@ -1307,7 +1274,7 @@ void oz8806_set_batt_info_ptr(bmu_data_t *batt_info) if (!batt_info) { - pr_err("%s: batt_info NULL\n", __func__); + bmt_dbg("BMT fgu batt_info NULL\n"); mutex_unlock(&update_mutex); return; } @@ -1324,7 +1291,7 @@ void oz8806_set_gas_gauge(gas_gauge_t *gas_gauge) if (!gas_gauge) { - pr_err("%s: gas_gauge NULL\n", __func__); + bmt_dbg("BMT fgu gas_gauge NULL\n"); mutex_unlock(&update_mutex); return; } @@ -1337,7 +1304,7 @@ void oz8806_set_gas_gauge(gas_gauge_t *gas_gauge) if (gas_gauge_ptr->discharge_current_th != 0) the_oz8806->batt_info.discharge_current_th = gas_gauge_ptr->discharge_current_th; - batt_dbg("batt_fcc_data:%d, discharge_current_th:%d", + bmt_dbg("batt_fcc_data:%d, discharge_current_th:%d\n", the_oz8806->batt_info.batt_fcc_data, the_oz8806->batt_info.discharge_current_th); gas_gauge_ptr->ext_temp_measure = ext_thermal_read; @@ -1358,8 +1325,8 @@ unsigned long oz8806_get_system_boot_time(void) unsigned long mod; time_sec = ktime_to_ns(ktime_get_boottime()); mod = do_div(time_sec,1000000); - batt_dbg("system boottime: %lu ms", (unsigned long)time_sec); - + batt_dbg("system boottime: %lu ms\n", (unsigned long)time_sec); + return time_sec; } EXPORT_SYMBOL(oz8806_get_system_boot_time); @@ -1370,7 +1337,7 @@ unsigned long oz8806_get_boot_up_time(void) struct timespec time; ktime_get_ts(&time); t = time.tv_sec * 1000 + time.tv_nsec / 1000000; - batt_dbg("boot up time: %lu ms", (unsigned long) t); + bmt_dbg("boot up time: %lu ms\n", (unsigned long) t); return t; } @@ -1379,10 +1346,10 @@ EXPORT_SYMBOL(oz8806_get_boot_up_time); unsigned long oz8806_get_power_on_time(void) { unsigned int t = 0; - pr_err("jiffies %lu,ic_wakeup_time %lu\n",jiffies,ic_wakeup_time); + bmt_dbg("jiffies %lu,ic_wakeup_time %lu\n",jiffies,ic_wakeup_time); t = jiffies_to_msecs(jiffies - ic_wakeup_time); - pr_err("IC wakeup time: %u ms\n", t); + bmt_dbg("IC wakeup time: %u ms\n", t); return (unsigned long)t; } @@ -1397,17 +1364,16 @@ static int oz8806_probe(struct i2c_client *client,const struct i2c_device_id *id .of_node = client->dev.of_node, }; - pr_err("%s start\n",__func__); + bmt_dbg("BMT fgu probe start\n"); /***************************************************************************** -* O2Micro Warning: +* BMT Warning: * bmulib_init 是非常重要的函数,芯片需要client来执行初始化以及自检校验等工作 * 不允许因为读不到I2C信息而提前于这个函数返回,这将引起非常严重的错误问题。 * 再次提醒,不允许因为读不到I2C信息而直接返回。 *****************************************************************************/ - data = devm_kzalloc(&client->dev, sizeof(struct oz8806_data), GFP_KERNEL); if (!data) { - dev_err(&client->dev, "Can't alloc oz8806_data struct\n"); + dev_err(&client->dev, "Can't alloc BMT_data struct\n"); return -ENOMEM; } @@ -1417,12 +1383,13 @@ static int oz8806_probe(struct i2c_client *client,const struct i2c_device_id *id the_oz8806 = data; data->myclient = client; //init battery information as soon as possible + oz8806_wakeup_full_power(); oz8806_init_batt_info(data); INIT_DELAYED_WORK(&data->work, oz8806_battery_work); /***************************************************************************** -* O2Micro Warning: This is a very important code here(bmulib_init). -* The chip needs i2c client processing opt mapping and self init first in bmulib_init. +* BMT Warning: This is a very important code here(bmulib_init). +* The chip needs i2c client processing opt mapping and self init first in bmulib_init. * You must not return before this code even if you read i2c error. * Remind you again that it will make serious mistake if you return before bmulib_init. *****************************************************************************/ @@ -1449,7 +1416,7 @@ static int oz8806_probe(struct i2c_client *client,const struct i2c_device_id *id psy_cfg.drv_data = data, data->bat = power_supply_register(&client->dev, &the_oz8806->bat_desc,&psy_cfg); if (!data->bat) { - pr_err("failed to register power_supply battery\n"); + bmt_dbg("failed to register power_supply battery\n"); goto register_fail; } /* @@ -1457,10 +1424,10 @@ static int oz8806_probe(struct i2c_client *client,const struct i2c_device_id *id */ ret = oz8806_create_sys(&(client->dev), &oz8806_attribute_group); if(ret){ - pr_err("[BATT]: Err failed to creat oz8806 attributes\n"); + bmt_dbg("[BATT]: Err failed to creat BMT attributes\n"); goto bat_failed; } - + //alternative suspend/resume method data->pm_nb.notifier_call = oz8806_suspend_notifier; register_pm_notifier(&data->pm_nb); @@ -1468,17 +1435,17 @@ static int oz8806_probe(struct i2c_client *client,const struct i2c_device_id *id ret = device_init_wakeup(&client->dev, true); if (ret) dev_err(&client->dev, "wakeup source init failed.\n"); - + fg_hw_init_done = 1; - + schedule_delayed_work(&data->work, 0); - pr_err("%s end\n",__func__); + bmt_dbg("BMT fgu probe end\n"); return 0; //return Ok bat_failed: power_supply_unregister(the_oz8806->bat); register_fail: - pr_err("%s() fail: return %d\n", __func__, ret); + bmt_dbg("BMT fgu probe () fail: return %d\n",ret); the_oz8806 = NULL; return ret; } @@ -1514,7 +1481,7 @@ static int oz8806_remove(struct i2c_client *client) static void oz8806_shutdown(struct i2c_client *client) { struct oz8806_data *data = i2c_get_clientdata(client); - pr_err("oz8806 shutdown\n"); + bmt_dbg("BMT fgu shutdown\n"); cancel_delayed_work(&data->work); @@ -1564,16 +1531,16 @@ static int __init oz8806_init(void) ret = i2c_add_driver(&oz8806_driver); if(ret != 0) - pr_err("failed to register oz8806 i2c driver.\n"); + bmt_dbg("failed to register BMT i2c driver.\n"); else - pr_err("Success to register oz8806 i2c driver.\n"); + bmt_dbg("Success to register BMT i2c driver.\n"); return ret; } static void __exit oz8806_exit(void) { - pr_err("%s\n", __func__); + bmt_dbg("BMT fgu exit\n"); i2c_del_driver(&oz8806_driver); } diff --git a/drivers/power/sd77426_fg_mmi/oz8806_regdef.h b/drivers/power/sd77426_fg_mmi/oz8806_regdef.h index eba2e835589f..0a96ee34256b 100644 --- a/drivers/power/sd77426_fg_mmi/oz8806_regdef.h +++ b/drivers/power/sd77426_fg_mmi/oz8806_regdef.h @@ -1,17 +1,17 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. +* Copyright(c) BMT, 2021. All rights reserved. * -* O2Micro [OZ8806] Source Code Reference Design -* File:[oz8806_regdef.h] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* BMT [oz8806] Source Code Reference Design +* File:[bmulib.c] +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ @@ -30,59 +30,58 @@ *****************************************************************************/ /* Operation register map define */ -#define OZ8806_OP_IDREV 0X00 //CHIP ID and Reversion - #define CHIP_ID_MASK 0xF8 //default CHIP_ID[7:3]=0x07 - #define CHIP_VER_MASK 0x07 //default CHIP_VER[2:0]=0x00 for 8806 +#define OZ8806_OP_IDREV 0X00 //CHIP ID and Reversion + #define CHIP_ID_MASK 0xF8 //default CHIP_ID[7:3]=0x07 + #define CHIP_VER_MASK 0x07 //default CHIP_VER[2:0]=0x00 for 8806 #define OZ8806_OP_VD23 0x03 // #define OZ8806_OP_I2CCONFIG 0x04 //I2C config register - #define I2C_ADDRESS_MASK 0x0E //default 0X07 + #define I2C_ADDRESS_MASK 0x0E //default 0X07 #define OZ8806_OP_PEC_CTRL 0x08 //PEC control register - #define PEC_EN 0x04 //PEC control register[2]: 1: PEC enable 0: PEC disable + #define PEC_EN 0x04 //PEC control register[2]: 1: PEC enable 0: PEC disable -#define OZ8806_OP_CTRL 0x09 //Status control register - #define SOFT_RESET 0x80 //Status control register[7]: 1: reset - #define SLEEP_MODE 0x40 //Status control register[6]: 1: sleep 0:active - #define SLEEP_OCV_EN 0x20 - #define CHARGE_ON 0x10 - #define VME_SEL 0x0c - #define CHG_SEL 0x02 - #define BI_STATUS 0x01 - +#define OZ8806_OP_CTRL 0x09 //Status control register + #define SOFT_RESET 0x80 //Status control register[7]: 1: reset + #define SLEEP_MODE 0x40 //Status control register[6]: 1: sleep 0:active + #define SLEEP_OCV_EN 0x20 + #define CHARGE_ON 0x10 + #define VME_SEL 0x0c + #define CHG_SEL 0x02 + #define BI_STATUS 0x01 -#define OZ8806_OP_VOLT_OFFSET 0X0A - #define VOLT_OFFSET_MASK 0xFC -#define OZ8806_OP_BATTERY_ID 0x0B - +#define OZ8806_OP_VOLT_OFFSET 0X0A + #define VOLT_OFFSET_MASK 0xFC + +#define OZ8806_OP_BATTERY_ID 0x0B + #define OZ8806_OP_CELL_TEMP 0x0C //cell temperature low byte,[7:4]->[3:0]of cell temp - #define CELL_TEMP_MASK 0x0FFF + #define CELL_TEMP_MASK 0x0FFF #define OZ8806_OP_CELL_TEMP_HIGH 0x0D //cell temperature high byte,[7:0]->[11:4]of cell temp - + #define OZ8806_OP_CELL_VOLT 0x0E //cell voltage low byte,[7:4]->[3:0]of cell volt - #define CELL_VOLT_MASK 0x0FFF + #define CELL_VOLT_MASK 0x0FFF #define OZ8806_OP_CELL_VOLT_HIGH 0x0f //cell voltage high byte,[7:0]->[11:4]of cell volt - -#define OZ8806_OP_OCV_LOW 0x10 //OCV low byte,[7:4]->[3:0]of OCV - #define OCV_LOW_MASK 0xF0 - #define SLEEP_OCV_FLAG 0X02 - #define POWER_OCV_FLAG 0X01 -#define OZ8806_OP_OCV_HIGH 0x11 //OCV high byte,[7:0]->[11:4]of OCV +#define OZ8806_OP_OCV_LOW 0x10 //OCV low byte,[7:4]->[3:0]of OCV + #define OCV_LOW_MASK 0xF0 + #define SLEEP_OCV_FLAG 0X02 + #define POWER_OCV_FLAG 0X01 + +#define OZ8806_OP_OCV_HIGH 0x11 //OCV high byte,[7:0]->[11:4]of OCV #define OZ8806_OP_CURRENT 0x12 //CURRENT low byte,[7:1]->[5:0]of CURRENT #define OZ8806_OP_CAR 0x14 //CAR low byte -#define OZ8806_OP_BOARD_OFFSET 0x18 +#define OZ8806_OP_BOARD_OFFSET 0x18 - /***************************************************************************** * function prototype section * add function prototype here diff --git a/drivers/power/sd77426_fg_mmi/parameter.c b/drivers/power/sd77426_fg_mmi/parameter.c index 3b8cc390816a..86127b28a78f 100644 --- a/drivers/power/sd77426_fg_mmi/parameter.c +++ b/drivers/power/sd77426_fg_mmi/parameter.c @@ -1,17 +1,17 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. +* Copyright(c) BMT, 2021. All rights reserved * -* O2Micro [OZ8806] Source Code Reference Design -* File:[parameter.c] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* BMT [oz8806] Source Code Reference Design +* File:[bmulib.c] +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ @@ -22,8 +22,7 @@ #include "table.h" #include "battery_config.h" - -one_latitude_data_t cell_temp_data[TEMPERATURE_DATA_NUM] = { +one_latitude_data_t cell_temp_data[TEMPERATURE_DATA_NUM] = { {681, 115}, {766, 113}, {865, 105}, {980, 100}, {1113, 95}, {1266, 90}, {1451, 85}, {1668, 80}, {1924, 75}, @@ -38,22 +37,21 @@ one_latitude_data_t cell_temp_data[TEMPERATURE_DATA_NUM] = { config_data_t config_data = { - .fRsense = O2_CONFIG_RSENSE, - .temp_pull_up = O2_TEMP_PULL_UP_R, + .fRsense = O2_CONFIG_RSENSE, + .temp_pull_up = O2_TEMP_PULL_UP_R, .temp_ref_voltage = O2_TEMP_REF_VOLTAGE, .dbCARLSB = 5, .dbCurrLSB = 781 , - .fVoltLSB = 250, + .fVoltLSB = 250, .design_capacity = O2_CONFIG_CAPACITY, .charge_cv_voltage = OZ8806_VOLTAGE, .charge_end_current = O2_CONFIG_EOC, .discharge_end_voltage = OZ8806_EOD, - .board_offset = O2_CONFIG_BOARD_OFFSET, - .debug = 1, + .board_offset = O2_CONFIG_BOARD_OFFSET, + .debug = 1, }; - /***************************************************************************** * bmu_init_parameter: * this implements a interface for customer initiating bmu parameters @@ -61,21 +59,14 @@ config_data_t config_data = { *****************************************************************************/ void bmu_init_parameter(parameter_data_t *parameter_customer) { - //如果选用88106,并且prg pin拉低,这一标志可以清0.以避免i2c通讯问题。 - //如果prg pin拉高,则这个标志需要写1,否则会导致电量不更新。此标志在 - //库中,默认拉高。 -#ifdef CONFIG_OZ115_SUPPORT - check_chip_function = 1; -#else - check_chip_function = 0; -#endif + check_chip_function = 0; parameter_customer->config = &config_data; parameter_customer->ocv = ocv_data; parameter_customer->temperature = cell_temp_data; parameter_customer->ocv_data_num = OCV_DATA_NUM; parameter_customer->cell_temp_num = TEMPERATURE_DATA_NUM; - parameter_customer->charge_pursue_step = 10; - parameter_customer->discharge_pursue_step = 6; + parameter_customer->charge_pursue_step = 10; + parameter_customer->discharge_pursue_step = 6; parameter_customer->discharge_pursue_th = 10; parameter_customer->wait_method = 2; @@ -97,7 +88,6 @@ void bmu_init_parameter(parameter_data_t *parameter_customer) } EXPORT_SYMBOL(bmu_init_parameter); - /***************************************************************************** * Description: * bmu_init_gg @@ -113,7 +103,7 @@ void bmu_init_gg(gas_gauge_t *gas_gauge) gas_gauge->discharge_current_th = DISCH_CURRENT_TH; gas_gauge->fcc_data = config_data.design_capacity; - pr_err("AAAA battery_id is %s\n", battery_id[0]); + bmt_dbg("AAAA battery_id is %s\n", battery_id[0]); gas_gauge->ri = 18; gas_gauge->line_impedance = 10; @@ -123,31 +113,11 @@ void bmu_init_gg(gas_gauge_t *gas_gauge) //add this for oinom gas_gauge->lower_capacity_reserve = 5; gas_gauge->lower_capacity_soc_start =30; - - //gas_gauge->percent_10_reserve = 66; #endif } EXPORT_SYMBOL(bmu_init_gg); - -#ifdef OZ8806_API - -#define BMU_INIT(x) \ -void bmu_init_##x(uint8_t *dest, uint32_t bytes)\ -{\ - memcpy(dest, (uint8_t *)x, bytes);\ -}\ -EXPORT_SYMBOL(bmu_init_##x);\ - -//BMU_INIT(charge_data) -BMU_INIT(XAxisElement) -BMU_INIT(YAxisElement) -BMU_INIT(ZAxisElement) -BMU_INIT(RCtable) - -#endif - void bmu_init_table(int **x, int **y, int **z, int **rc) { *x = (int *)((uint8_t *)XAxisElement); diff --git a/drivers/power/sd77426_fg_mmi/parameter.h b/drivers/power/sd77426_fg_mmi/parameter.h index e5436f11fb31..ec6e99597caa 100644 --- a/drivers/power/sd77426_fg_mmi/parameter.h +++ b/drivers/power/sd77426_fg_mmi/parameter.h @@ -1,17 +1,17 @@ /***************************************************************************** -* Copyright(c) O2Micro, 2019. All rights reserved. +* Copyright(c) BMT, 2021. All rights reserved. * -* O2Micro [OZ8806] Source Code Reference Design -* File:[parameter.h] -* -* This Source Code Reference Design for O2MICRO [OZ8806] access -* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, -* and contains confidential and privileged information of O2Micro International -* Limited. O2Micro shall have no liability to any PARTY FOR THE RELIABILITY, -* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any -* modification or attempted modification of the Reference Design by any party, or -* (ii) the combination, operation or use of the Reference Design with non-O2Micro -* Reference Design. Use of the Reference Design is at user's discretion to qualify +* BMT [oz8806] Source Code Reference Design +* File:[bmulib.c] +* +* This Source Code Reference Design for BMT [oz8806] access +* ("Reference Design") is solely for the use of PRODUCT INTEGRATION REFERENCE ONLY, +* and contains confidential and privileged information of BMT International +* Limited. BMT shall have no liability to any PARTY FOR THE RELIABILITY, +* SERVICEABILITY FOR THE RESULT OF PRODUCT INTEGRATION, or results from: (i) any +* modification or attempted modification of the Reference Design by any party, or +* (ii) the combination, operation or use of the Reference Design with non-BMT +* Reference Design. Use of the Reference Design is at user's discretion to qualify * the final work result. *****************************************************************************/ @@ -26,26 +26,18 @@ #include #include - /**************************************************************************** * #define section * add constant #define here if any ***************************************************************************/ -//#define MUTEX_TIMEOUT 5000 -#define MYDRIVER "oz8806" //"oz8806" - -//#define OZ8806_API -//#define BAT_STAT - -//two cells application -//#define OZ8806_VME_SEL +#define MYDRIVER "oz8806" //"oz8806" #define DISCH_CURRENT_TH -10 #define O2_OCV_100_VOLTAGE 8700 #define TEMPERATURE_DATA_NUM 28 #define num_0 0 -#define num_1 1 +#define num_1 1 #define num_32768 32768 #define num_5 5 #define num_0x2c 0x2c @@ -79,7 +71,6 @@ #define INIT_CAP (-2) #define NO_FILE (-1) - /**************************************************************************** * Struct section * add struct #define here if any @@ -93,16 +84,14 @@ enum charger_type_t { }; struct batt_data { - - int32_t batt_soc;//Relative State Of Charged, present percentage of battery capacity - int32_t batt_voltage;//Voltage of battery, in mV - int32_t batt_current;//Current of battery, in mA; plus value means charging, minus value means discharging - - int32_t batt_temp;//Temperature of battery - int32_t batt_capacity;//adjusted residual capacity - int32_t batt_fcc_data; - int32_t discharge_current_th; - uint8_t charge_end; + int32_t batt_soc;//Relative State Of Charged, present percentage of battery capacity + int32_t batt_voltage;//Voltage of battery, in mV + int32_t batt_current;//Current of battery, in mA; plus value means charging, minus value means discharging + int32_t batt_temp;//Temperature of battery + int32_t batt_capacity;//adjusted residual capacity + int32_t batt_fcc_data; + int32_t discharge_current_th; + uint8_t charge_end; }; struct oz8806_data @@ -111,53 +100,41 @@ struct oz8806_data struct power_supply_desc bat_desc; struct power_supply *ac_psy; struct power_supply *usb_psy; - struct delayed_work work; -#ifdef BAT_STAT - struct delayed_work bat_monitor_work; - int32_t bat_changed; -#endif unsigned int interval; - struct i2c_client *myclient; - struct notifier_block pm_nb; //alternative suspend/resume method struct batt_data batt_info; int status; }; - typedef struct tag_config_data { - int32_t fRsense; //= 20 * 1000; //Rsense value of chip, in mini ohm expand 1000 times - int32_t temp_pull_up; //230000; - int32_t temp_ref_voltage; //1800;1.8v - int32_t dbCARLSB; //= 5.0; //LSB of CAR, comes from spec - int32_t dbCurrLSB; //781 (7.8 *100 uV); //LSB of Current, comes from spec - int32_t fVoltLSB; //250 (2.5*100 mV); //LSB of Voltage, comes from spec - - int32_t design_capacity; //= 7000; //design capacity of the battery - int32_t charge_cv_voltage; //= 4200; //CV Voltage at fully charged - int32_t charge_end_current; //= 100; //the current threshold of End of Charged - int32_t discharge_end_voltage; //= 3550; //mV - int32_t board_offset; //0; //mA, not more than caculate data - uint8_t debug; // enable or disable O2MICRO debug information + int32_t fRsense; //= 20 * 1000; //Rsense value of chip, in mini ohm expand 1000 times + int32_t temp_pull_up; //230000; + int32_t temp_ref_voltage; //1800;1.8v + int32_t dbCARLSB; //= 5.0; //LSB of CAR, comes from spec + int32_t dbCurrLSB; //781 (7.8 *100 uV); //LSB of Current, comes from spec + int32_t fVoltLSB; //250 (2.5*100 mV); //LSB of Voltage, comes from spec + int32_t design_capacity; //= 7000; //design capacity of the battery + int32_t charge_cv_voltage; //= 4200; //CV Voltage at fully charged + int32_t charge_end_current; //= 100; //the current threshold of End of Charged + int32_t discharge_end_voltage; //= 3550; //mV + int32_t board_offset; //0; //mA, not more than caculate data + uint8_t debug; // enable or disable O2MICRO debug information }config_data_t; - typedef struct tag_parameter_data { int32_t ocv_data_num; int32_t cell_temp_num; one_latitude_data_t *ocv; one_latitude_data_t *temperature; config_data_t *config; - struct i2c_client *client; - - uint8_t charge_pursue_step; - uint8_t discharge_pursue_step; - uint8_t discharge_pursue_th; - uint8_t wait_method; + uint8_t charge_pursue_step; + uint8_t discharge_pursue_step; + uint8_t discharge_pursue_th; + uint8_t wait_method; char * BATT_CAPACITY ; char * BATT_FCC; char * OCV_FLAG; @@ -172,29 +149,26 @@ typedef struct tag_parameter_data { int8_t power_on_retry_times; }parameter_data_t; - typedef struct tag_bmu { - int32_t Battery_ok; - int32_t fRC; //= 0; //Remaining Capacity, indicates how many mAhr in battery - int32_t fRSOC; //50 = 50%; //Relative State Of Charged, present percentage of battery capacity - int32_t fVolt; //= 0; //Voltage of battery, in mV - int32_t fCurr; //= 0; //Current of battery, in mA; plus value means charging, minus value means discharging - int32_t fPrevCurr; //= 0; //last one current reading - int32_t fOCVVolt; //= 0; //Open Circuit Voltage - int32_t fCellTemp; //= 0; //Temperature of battery - int32_t fRCPrev; - int32_t sCaMAH; //= 0; //adjusted residual capacity - int32_t i2c_error_times; + int32_t Battery_ok; + int32_t fRC; //= 0; //Remaining Capacity, indicates how many mAhr in battery + int32_t fRSOC; //50 = 50%; //Relative State Of Charged, present percentage of battery capacity + int32_t fVolt; //= 0; //Voltage of battery, in mV + int32_t fCurr; //= 0; //Current of battery, in mA; plus value means charging, minus value means discharging + int32_t fPrevCurr; //= 0; //last one current reading + int32_t fOCVVolt; //= 0; //Open Circuit Voltage + int32_t fCellTemp; //= 0; //Temperature of battery + int32_t fRCPrev; + int32_t sCaMAH; //= 0; //adjusted residual capacity + int32_t i2c_error_times; }bmu_data_t; typedef struct tag_gas_gauge { - int32_t overflow_data; //unit: mAh, maximum capacity that the IC can measure uint8_t discharge_end; uint8_t charge_end; uint8_t charge_fcc_update; uint8_t discharge_fcc_update; - int32_t sCtMAH ; //be carefull, this must be int32_t int32_t fcc_data; int32_t discharge_sCtMAH ;//be carefull, this must be int32_t @@ -204,35 +178,28 @@ typedef struct tag_gas_gauge { //uint8_t discharge_count; //uint32_t bmu_tick; //uint32_t charge_tick; - //uint8_t charge_table_num; uint8_t rc_x_num; uint8_t rc_y_num; uint8_t rc_z_num; - - uint8_t charge_strategy; + uint8_t charge_strategy; int32_t charge_sCaUAH; int32_t charge_ratio; //this must be static uint8_t charge_table_flag; int32_t charge_end_current_th2; int32_t charge_max_ratio; - uint8_t discharge_strategy; int32_t discharge_sCaUAH; int32_t discharge_ratio; //this must be static uint8_t discharge_table_flag; int32_t discharge_current_th; uint32_t discharge_max_ratio; - int32_t dsg_end_voltage_hi; int32_t dsg_end_voltage_th1; int32_t dsg_end_voltage_th2; uint8_t dsg_count_2; - uint8_t ocv_flag; - uint8_t vbus_ok; - uint8_t charge_full; int32_t ri; int32_t batt_ri; @@ -244,16 +211,25 @@ typedef struct tag_gas_gauge { uint8_t charge_method_select; int32_t max_charge_current_fix; uint8_t ext_temp_measure; - uint8_t bmu_init_ok; + uint8_t bmu_init_ok; int32_t stored_capacity; - uint8_t lower_capacity_reserve; uint8_t lower_capacity_soc_start; - uint8_t percent_10_reserve; uint32_t power_on_100_vol; }gas_gauge_t; +/**************************************************************************** +* debug func * +***************************************************************************/ +#define bmt_dbg(fmt, args...) printk(KERN_ERR"[bmt]:"pr_fmt(fmt)"", ## args) + +#define batt_dbg(fmt, args...)\ +do {\ + if(parameter->config->debug)\ + printk(KERN_ERR"[bmt]:"pr_fmt(fmt)"", ## args);\ +} while(0) + /**************************************************************************** * extern variable/function declaration of table.c ***************************************************************************/ @@ -265,8 +241,8 @@ extern int ZAxisElement[ZAxis]; extern int RCtable[YAxis*ZAxis][XAxis]; //extern one_latitude_data_t charge_data[CHARGE_DATA_NUM]; -extern uint8_t battery_ri ; -extern int32_t one_percent_rc ; +extern uint8_t battery_ri; +extern int32_t one_percent_rc; /**************************************************************************** * extern variable/function defined by parameter.c @@ -283,24 +259,15 @@ extern int bmulib_init(void); extern void bmulib_exit(void); #endif -//bmulib extern -extern void bmu_polling_loop(void); -extern void bmu_wake_up_chip(void); -extern void bmu_power_down_chip(void); -extern void charge_end_process(void); -extern void discharge_end_process(void); -extern int32_t oz8806_temp_read(int32_t *voltage); -extern int32_t afe_read_current(int32_t *dat); -extern int32_t afe_read_cell_volt(int32_t *voltage); -//endif +extern void bmu_polling_loop(void); +extern void bmu_wake_up_chip(void); +extern void bmu_power_down_chip(void); +extern void charge_end_process(void); +extern void discharge_end_process(void); +extern int32_t oz8806_temp_read(int32_t *voltage); +extern int32_t afe_read_current(int32_t *dat); +extern int32_t afe_read_cell_volt(int32_t *voltage); -#ifdef OZ8806_API -//extern void bmu_init_charge_data(uint8_t *dest, uint32_t bytes); -extern void bmu_init_XAxisElement(uint8_t *dest, uint32_t bytes); -extern void bmu_init_YAxisElement(uint8_t *dest, uint32_t bytes); -extern void bmu_init_ZAxisElement(uint8_t *dest, uint32_t bytes); -extern void bmu_init_RCtable(uint8_t *dest, uint32_t bytes); -#endif extern void bmu_init_table(int **x, int **y, int **z, int **rc); extern const char * get_table_version(void); @@ -308,10 +275,6 @@ extern const char * get_table_version(void); /**************************************************************************** * extern variable/function defined by oz8806_battery.c ***************************************************************************/ -#ifdef OZ8806_API -extern bmu_data_t *batt_info_ptr; -extern struct mutex *update_mutex_ptr; -#endif extern int32_t oz8806_vbus_voltage(void); extern int32_t oz8806_get_simulated_temp(void); extern int32_t oz8806_get_init_status(void); //if return 1, battery capacity is initiated successfully @@ -349,26 +312,14 @@ extern void oz8806_reset_wkuptime(void); * extern variable/function defined by oz8806_api_dev.c. * This file is deprecated in Linux system. ***************************************************************************/ -#ifdef OZ8806_API -extern unsigned long oz8806_get_kernel_memaddr(void); -extern void bmu_call(void); -#endif extern int is_battery_exchanged(void); - - -#define bmu_dbg(fmt, args...)\ -do {\ - if(parameter->config->debug)\ - printk(KERN_ERR pr_fmt(fmt), ## args);\ -} while(0) extern int32_t calculate_soc_result(void); extern int32_t one_latitude_table(int32_t number,one_latitude_data_t *data,int32_t value); extern uint8_t OZ8806_LookUpRCTable(int infVolt,int infCurr, int infTemp, int *infCal); void charge_process(void); void discharge_process(void); - extern bmu_data_t *batt_info; extern gas_gauge_t *gas_gauge; extern parameter_data_t parameter_customer; @@ -379,14 +330,12 @@ extern int *xaxis_table; extern int *yaxis_table; extern int *zaxis_table; - extern int32_t calculate_mah; +extern int32_t calculate_mah; extern int32_t calculate_soc ; +extern uint32_t calculate_version; #define X_AXIS gas_gauge->rc_x_num #define Y_AXIS gas_gauge->rc_y_num #define Z_AXIS gas_gauge->rc_z_num - - - #endif //end _PARAMETER_H_ diff --git a/drivers/power/sd77426_fg_mmi/table.c b/drivers/power/sd77426_fg_mmi/table.c index c4a72b15fedd..a17eee99b121 100644 --- a/drivers/power/sd77426_fg_mmi/table.c +++ b/drivers/power/sd77426_fg_mmi/table.c @@ -1,129 +1,174 @@ -/***************************************************************************** -* Copyright(c) O2Micro, 2014. All rights reserved. -* -* O2Micro battery gauge driver -* File: table.c -* -* $Source: /data/code/CVS -* $Revision: 4.00.01 $ -* -* This program is free software and can be edistributed and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This Source Code Reference Design for O2MICRO Battery Gauge access (\u201cReference Design\u201d) -* is sole for the use of PRODUCT INTEGRATION REFERENCE ONLY, and contains confidential -* and privileged information of O2Micro International Limited. O2Micro shall have no -* liability to any PARTY FOR THE RELIABILITY, SERVICEABILITY FOR THE RESULT OF PRODUCT -* INTEGRATION, or results from: (i) any modification or attempted modification of the -* Reference Design by any party, or (ii) the combination, operation or use of the -* Reference Design with non-O2Micro Reference Design. -* -* Battery Manufacture: Lenovo -* Battery Model: BL244 -* Absolute Max Capacity(mAhr): 5158 -* Limited Charge Voltage(mV): 4350 -* Cutoff Discharge Voltage(mV): 3200 -* Equipment: "JY1-8","JY1-4","JY1-4","JY2-8","JY2-8","JY2-8","JY2-5","JY1-1","JY1-1","JY1-8","JY1-8","JY1-8","JY1-8","JY2-5","JY2-5","JY2-5","JY2-5","JY1-8","JY2-8","JY2-8","JY1-8","JY1-2","JY1-2","JY2-6","JY2-6","JY2-6","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY1-3","JY1-3","JY1-6","JY1-6","JY1-6","JY2-8","JY2-5","JY2-5" -* Tester: "SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ" -* Battery ID: "BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-3","BL244-3","BL244-3","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-1","BL244-2","BL244-02" -* Version = V00.13.00 -* Date = 2015.6.23 -* Comment = -* -*****************************************************************************/ - -#include -#include "table.h" - -/***************************************************************************** -* Global variables section - Exported -* add declaration of global variables that will be exported here -* e.g. -* int8_t foo; -****************************************************************************/ -const char * table_version = "V00.13.00-2015.6.23-BL244"; - -const char *battery_id[BATTERY_ID_NUM] = {"BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-3","BL244-3","BL244-3","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-1","BL244-2","BL244-02"}; - -one_latitude_data_t ocv_data[OCV_DATA_NUM] = {{3242, 0},{3248, 2},{3488, 3},{3597, 5},{3669, 6},{3685, 8},{3689, 9},{3691, 11},{3693, 13},{3700, 14},{3713, 16},{3720, 17},{3731, 19},{3739, 20},{3744, 22},{3749, 23},{3755, 25},{3761, 27},{3766, 28},{3771, 30},{3776, 31},{3780, 33},{3785, 34},{3789, 36},{3793, 38},{3797, 39},{3802, 41},{3808, 42},{3814, 44},{3819, 45},{3826, 47},{3833, 48},{3841, 50},{3848, 52},{3857, 53},{3867, 55},{3879, 56},{3893, 58},{3911, 59},{3928, 61},{3942, 63},{3955, 64},{3967, 66},{3976, 67},{3985, 69},{3996, 70},{4016, 72},{4041, 73},{4060, 75},{4070, 77},{4084, 78},{4100, 80},{4117, 81},{4135, 83},{4151, 84},{4168, 86},{4185, 88},{4203, 89},{4220, 91},{4238, 92},{4256, 94},{4274, 95},{4292, 97},{4311, 98},{4333, 100}}; - -//real current to soc -one_latitude_data_t charge_data[CHARGE_DATA_NUM] = {{100, 10000},{105, 9994},{110, 9988},{115, 9981},{120, 9976},{125, 9970},{130, 9963},{135, 9957},{140, 9951},{145, 9945},{150, 9940},{155, 9933},{160, 9927},{165, 9920},{170, 9915},{175, 9908},{180, 9902},{185, 9896},{190, 9890},{195, 9884},{200, 9878},{210, 9865},{220, 9854},{230, 9842},{240, 9830},{250, 9819},{260, 9806},{270, 9794},{280, 9782},{290, 9770},{300, 9758},{310, 9746},{320, 9734},{330, 9722},{340, 9711},{350, 9699},{360, 9687},{370, 9676},{380, 9664},{390, 9652},{400, 9640},{420, 9617},{440, 9594},{460, 9571},{480, 9548},{500, 9524},{520, 9501},{540, 9479},{560, 9455},{580, 9432},{600, 9409},{625, 9381},{650, 9352},{675, 9323},{700, 9295},{725, 9267},{750, 9238},{775, 9211},{800, 9182},{825, 9155},{850, 9128},{875, 9100},{900, 9073},{950, 9020},{1000, 9003}}; - -//RC table X Axis value, in mV format -int32_t XAxisElement[XAxis] = {3200, 3400, 3515, 3635, 3656, 3661, 3668, 3685, 3700, 3711, 3719, 3729, 3739, 3751, 3759, 3766, 3774, 3782, 3791, 3801, 3812, 3824, 3838, 3856, 3882, 3906, 3927, 3948, 3968, 3987, 4015, 4038, 4062, 4089, 4115, 4142, 4169, 4198, 4226, 4255, 4286, 4325}; - -//RC table Y Axis value, in mA format -int32_t YAxisElement[YAxis] = {200, 400, 600, 800, 1000, 1500, 2000}; - -// RC table Z Axis value, in 10*'C format -int32_t ZAxisElement[ZAxis] = {-49, 0, 100, 200, 250, 300, 400}; - -// contents of RC table, its unit is 10000C, 1C = DesignCapacity -int32_t RCtable[YAxis*ZAxis][XAxis]={ - - -//temp = -5.0 ^C -{385, 585, 861, 1845, 2149, 2234, 2377, 2813, 3414, 3870, 4138, 4427, 4676, 4949, 5113, 5251, 5404, 5536, 5689, 5844, 6013, 6189, 6393, 6666, 7020, 7238, 7381, 7507, 7631, 7786, 8110, 8321, 8535, 8774, 9005, 9244, 9462, 9683, 9865, 9979, 10000, 10000}, -{680, 1222, 1888, 3842, 4481, 4615, 4791, 5174, 5462, 5657, 5792, 5960, 6113, 6296, 6410, 6510, 6625, 6734, 6868, 7010, 7157, 7293, 7435, 7587, 7778, 7955, 8135, 8344, 8531, 8693, 8932, 9121, 9304, 9503, 9672, 9825, 9928, 9981, 10000, 10000, 10000, 10000}, -{1073, 2238, 3499, 6091, 6462, 6545, 6657, 6915, 7137, 7292, 7398, 7541, 7674, 7835, 7936, 8022, 8114, 8199, 8291, 8391, 8490, 8595, 8711, 8867, 9088, 9268, 9417, 9544, 9652, 9733, 9833, 9893, 9935, 9968, 9990, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{1124, 2221, 3822, 6241, 6542, 6612, 6711, 6934, 7129, 7259, 7354, 7467, 7570, 7692, 7767, 7831, 7898, 7968, 8046, 8128, 8221, 8319, 8441, 8604, 8833, 9027, 9186, 9341, 9474, 9587, 9737, 9833, 9901, 9950, 9982, 9999, 10000, 10000, 10000, 10000, 10000, 10000}, -{1650, 3381, 5594, 7729, 8093, 8181, 8305, 8608, 8868, 9055, 9168, 9288, 9384, 9473, 9521, 9558, 9594, 9624, 9658, 9691, 9723, 9754, 9782, 9818, 9857, 9890, 9913, 9935, 9952, 9968, 9987, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{2515, 5346, 7329, 9237, 9419, 9460, 9512, 9603, 9664, 9699, 9720, 9746, 9767, 9790, 9802, 9811, 9826, 9834, 9846, 9856, 9870, 9883, 9898, 9913, 9938, 9959, 9976, 9987, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{3939, 7150, 8855, 9807, 9833, 9839, 9849, 9866, 9881, 9888, 9898, 9906, 9915, 9926, 9933, 9939, 9946, 9951, 9957, 9967, 9976, 9985, 9991, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 0.0 ^C -{261, 403, 551, 1253, 1548, 1613, 1710, 1992, 2317, 2659, 2997, 3502, 3887, 4251, 4472, 4648, 4831, 5002, 5189, 5371, 5563, 5757, 5962, 6218, 6606, 6945, 7137, 7278, 7393, 7506, 7768, 8038, 8260, 8504, 8742, 8992, 9234, 9482, 9708, 9907, 9999, 10000}, -{476, 710, 1089, 2313, 2806, 2957, 3225, 3910, 4397, 4681, 4865, 5092, 5290, 5509, 5651, 5770, 5899, 6020, 6157, 6303, 6463, 6643, 6856, 7098, 7338, 7505, 7644, 7801, 8003, 8203, 8462, 8667, 8876, 9111, 9329, 9539, 9733, 9900, 9980, 10000, 10000, 10000}, -{1048, 1586, 2255, 4507, 5091, 5217, 5374, 5708, 5964, 6140, 6259, 6409, 6547, 6706, 6814, 6907, 7006, 7111, 7232, 7358, 7488, 7614, 7742, 7882, 8068, 8248, 8436, 8631, 8799, 8950, 9159, 9340, 9507, 9676, 9811, 9912, 9966, 9994, 10000, 10000, 10000, 10000}, -{930, 1787, 2854, 5497, 5878, 5967, 6082, 6343, 6561, 6714, 6824, 6959, 7087, 7241, 7337, 7422, 7514, 7595, 7690, 7780, 7877, 7973, 8087, 8229, 8456, 8672, 8852, 9018, 9176, 9314, 9507, 9651, 9777, 9884, 9945, 9980, 10000, 10000, 10000, 10000, 10000, 10000}, -{1371, 2608, 4230, 6652, 6947, 7012, 7104, 7313, 7493, 7618, 7704, 7816, 7921, 8036, 8113, 8174, 8241, 8304, 8378, 8456, 8540, 8630, 8737, 8878, 9073, 9235, 9367, 9489, 9597, 9685, 9798, 9869, 9920, 9960, 9986, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{1916, 4103, 6464, 8163, 8399, 8455, 8535, 8701, 8841, 8932, 8995, 9073, 9144, 9227, 9274, 9316, 9363, 9404, 9450, 9496, 9543, 9594, 9643, 9700, 9776, 9827, 9867, 9899, 9924, 9947, 9975, 9993, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{2698, 5808, 7704, 9103, 9267, 9304, 9350, 9451, 9527, 9570, 9603, 9641, 9670, 9705, 9723, 9742, 9759, 9774, 9791, 9808, 9825, 9842, 9861, 9886, 9916, 9942, 9961, 9981, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 10.0 ^C -{219, 334, 461, 731, 1085, 1275, 1423, 1638, 1889, 2091, 2298, 2610, 3038, 3582, 3866, 4086, 4320, 4525, 4749, 4970, 5192, 5408, 5633, 5884, 6205, 6516, 6837, 7069, 7218, 7326, 7492, 7765, 8023, 8272, 8508, 8754, 9000, 9255, 9500, 9738, 9958, 10000}, -{283, 428, 582, 1510, 1809, 1887, 2008, 2396, 2934, 3434, 3743, 4073, 4359, 4657, 4843, 4994, 5157, 5302, 5470, 5636, 5809, 5981, 6174, 6418, 6802, 7086, 7247, 7375, 7500, 7651, 7979, 8195, 8411, 8652, 8887, 9131, 9361, 9601, 9817, 9971, 10000, 10000}, -{315, 501, 756, 2088, 2595, 2748, 3012, 3707, 4198, 4485, 4678, 4906, 5112, 5339, 5482, 5604, 5734, 5857, 5993, 6139, 6292, 6457, 6655, 6910, 7180, 7351, 7485, 7640, 7844, 8051, 8311, 8518, 8731, 8975, 9199, 9425, 9641, 9845, 9964, 10000, 10000, 10000}, -{533, 806, 1341, 3258, 4058, 4220, 4428, 4851, 5179, 5388, 5530, 5706, 5866, 6046, 6164, 6262, 6372, 6478, 6602, 6735, 6888, 7045, 7212, 7377, 7567, 7733, 7908, 8128, 8323, 8490, 8735, 8932, 9133, 9353, 9550, 9737, 9884, 9968, 9997, 10000, 10000, 10000}, -{588, 1005, 1757, 4445, 4951, 5057, 5205, 5524, 5782, 5959, 6082, 6236, 6382, 6549, 6661, 6760, 6871, 6975, 7093, 7208, 7320, 7423, 7531, 7665, 7867, 8099, 8309, 8499, 8675, 8841, 9079, 9271, 9455, 9655, 9816, 9929, 9977, 10000, 10000, 10000, 10000, 10000}, -{1094, 2066, 3680, 6320, 6626, 6691, 6789, 7008, 7193, 7324, 7412, 7519, 7617, 7734, 7801, 7862, 7927, 7989, 8057, 8138, 8227, 8326, 8443, 8598, 8811, 8998, 9153, 9298, 9434, 9551, 9712, 9819, 9896, 9950, 9980, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, -{1439, 3084, 5568, 7455, 7698, 7753, 7826, 7994, 8134, 8228, 8298, 8377, 8457, 8555, 8617, 8673, 8736, 8792, 8867, 8937, 9018, 9100, 9192, 9303, 9462, 9591, 9689, 9779, 9841, 9886, 9932, 9964, 9984, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 20.0 ^C -{143, 253, 378, 608, 762, 887, 1236, 1499, 1755, 1937, 2123, 2408, 2699, 3182, 3487, 3733, 3997, 4221, 4469, 4709, 4948, 5182, 5423, 5680, 5978, 6232, 6484, 6813, 7052, 7193, 7363, 7579, 7869, 8121, 8357, 8604, 8849, 9106, 9350, 9600, 9850, 10000}, -{163, 290, 430, 1009, 1477, 1546, 1660, 1945, 2315, 2629, 2935, 3361, 3711, 4082, 4304, 4486, 4672, 4850, 5036, 5223, 5417, 5594, 5783, 5998, 6294, 6600, 6907, 7109, 7247, 7364, 7639, 7897, 8117, 8364, 8599, 8843, 9082, 9333, 9569, 9796, 9978, 10000}, -{214, 360, 521, 1592, 1928, 2024, 2180, 2652, 3249, 3660, 3917, 4208, 4465, 4752, 4931, 5072, 5226, 5364, 5517, 5666, 5824, 5973, 6140, 6352, 6691, 7016, 7199, 7340, 7476, 7662, 7976, 8189, 8404, 8653, 8885, 9126, 9356, 9595, 9806, 9964, 10000, 10000}, -{259, 426, 630, 2074, 2600, 2763, 3034, 3682, 4151, 4435, 4627, 4858, 5062, 5293, 5431, 5551, 5678, 5789, 5919, 6052, 6190, 6337, 6513, 6746, 7076, 7271, 7413, 7574, 7789, 7990, 8248, 8457, 8674, 8915, 9143, 9372, 9590, 9804, 9949, 10000, 10000, 10000}, -{346, 539, 865, 2913, 3708, 3874, 4090, 4543, 4889, 5110, 5262, 5448, 5613, 5802, 5919, 6015, 6124, 6228, 6350, 6477, 6620, 6778, 6963, 7162, 7371, 7540, 7725, 7945, 8140, 8309, 8559, 8763, 8968, 9200, 9413, 9626, 9811, 9945, 9993, 10000, 10000, 10000}, -{502, 868, 1860, 4929, 5343, 5433, 5558, 5827, 6056, 6211, 6326, 6461, 6596, 6755, 6857, 6948, 7046, 7132, 7226, 7318, 7409, 7499, 7607, 7757, 8005, 8234, 8421, 8603, 8775, 8935, 9168, 9353, 9533, 9719, 9865, 9950, 9989, 10000, 10000, 10000, 10000, 10000}, -{758, 1555, 3524, 6114, 6418, 6487, 6584, 6803, 6994, 7120, 7206, 7313, 7404, 7513, 7579, 7638, 7702, 7769, 7847, 7933, 8032, 8139, 8268, 8428, 8648, 8846, 9016, 9179, 9330, 9471, 9661, 9792, 9887, 9950, 9986, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 25.0 ^C -{148, 258, 383, 615, 761, 886, 1252, 1515, 1772, 1959, 2150, 2430, 2706, 3120, 3411, 3666, 3928, 4166, 4412, 4656, 4903, 5139, 5383, 5639, 5922, 6167, 6407, 6706, 6999, 7161, 7338, 7553, 7841, 8093, 8331, 8579, 8825, 9082, 9327, 9575, 9830, 10000}, -{162, 285, 425, 905, 1454, 1520, 1630, 1916, 2277, 2562, 2833, 3227, 3581, 3964, 4191, 4380, 4575, 4753, 4948, 5144, 5340, 5525, 5717, 5930, 6214, 6498, 6797, 7050, 7202, 7323, 7595, 7850, 8074, 8322, 8557, 8802, 9041, 9296, 9535, 9770, 9969, 10000}, -{233, 373, 531, 1570, 1898, 1990, 2135, 2579, 3103, 3520, 3791, 4093, 4359, 4658, 4837, 4984, 5145, 5286, 5446, 5601, 5757, 5907, 6072, 6273, 6585, 6920, 7145, 7294, 7431, 7611, 7921, 8136, 8352, 8599, 8832, 9072, 9303, 9547, 9767, 9949, 10000, 10000}, -{224, 378, 560, 1901, 2359, 2497, 2710, 3328, 3831, 4138, 4350, 4595, 4819, 5067, 5222, 5353, 5486, 5599, 5733, 5870, 6004, 6146, 6307, 6527, 6877, 7134, 7285, 7435, 7631, 7842, 8105, 8316, 8529, 8774, 9006, 9241, 9469, 9705, 9896, 9993, 10000, 10000}, -{256, 434, 678, 2466, 3163, 3349, 3601, 4097, 4484, 4729, 4902, 5107, 5284, 5488, 5615, 5719, 5829, 5934, 6050, 6173, 6307, 6451, 6626, 6858, 7136, 7313, 7474, 7685, 7892, 8070, 8325, 8534, 8748, 8988, 9213, 9440, 9661, 9865, 9976, 10000, 10000, 10000}, -{317, 587, 1382, 4310, 4793, 4893, 5031, 5342, 5595, 5760, 5877, 6022, 6159, 6319, 6420, 6512, 6614, 6712, 6830, 6943, 7064, 7170, 7281, 7422, 7650, 7890, 8088, 8279, 8454, 8623, 8869, 9068, 9265, 9489, 9685, 9860, 9958, 9998, 10000, 10000, 10000, 10000}, -{436, 957, 2570, 5495, 5829, 5902, 6006, 6242, 6452, 6591, 6693, 6819, 6935, 7059, 7139, 7201, 7272, 7338, 7420, 7501, 7599, 7702, 7830, 8003, 8241, 8452, 8633, 8813, 8983, 9137, 9357, 9527, 9701, 9863, 9947, 9988, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 30.0 ^C -{51, 163, 291, 527, 689, 824, 1215, 1450, 1708, 1903, 2121, 2397, 2673, 3020, 3298, 3551, 3823, 4061, 4316, 4569, 4815, 5052, 5302, 5561, 5839, 6085, 6325, 6590, 6897, 7098, 7297, 7528, 7794, 8051, 8294, 8542, 8788, 9049, 9292, 9543, 9801, 10000}, -{143, 266, 406, 856, 1431, 1495, 1606, 1889, 2248, 2532, 2777, 3128, 3473, 3862, 4102, 4293, 4492, 4674, 4876, 5075, 5276, 5469, 5659, 5871, 6153, 6424, 6690, 6985, 7170, 7306, 7572, 7820, 8044, 8294, 8531, 8777, 9017, 9272, 9509, 9747, 9961, 10000}, -{153, 291, 446, 1449, 1775, 1862, 2001, 2421, 2884, 3287, 3561, 3872, 4155, 4456, 4647, 4799, 4967, 5115, 5283, 5447, 5610, 5772, 5937, 6137, 6432, 6734, 7005, 7188, 7336, 7507, 7812, 8029, 8247, 8494, 8728, 8969, 9205, 9455, 9688, 9902, 10000, 10000}, -{197, 351, 527, 1847, 2290, 2417, 2610, 3187, 3694, 4001, 4221, 4467, 4697, 4947, 5102, 5235, 5368, 5494, 5630, 5760, 5898, 6039, 6195, 6398, 6718, 7019, 7196, 7355, 7545, 7749, 8011, 8224, 8440, 8683, 8914, 9152, 9378, 9621, 9831, 9979, 10000, 10000}, -{224, 394, 618, 2344, 2969, 3148, 3390, 3925, 4315, 4572, 4745, 4955, 5155, 5364, 5492, 5601, 5718, 5821, 5933, 6053, 6184, 6324, 6486, 6706, 7021, 7226, 7389, 7592, 7799, 7975, 8230, 8439, 8653, 8890, 9116, 9348, 9568, 9794, 9953, 10000, 10000, 10000}, -{258, 493, 1136, 3954, 4461, 4569, 4725, 5058, 5326, 5506, 5627, 5777, 5911, 6072, 6172, 6260, 6358, 6456, 6568, 6689, 6818, 6955, 7092, 7241, 7462, 7697, 7902, 8091, 8269, 8436, 8688, 8884, 9091, 9321, 9535, 9742, 9906, 9988, 10000, 10000, 10000, 10000}, -{336, 750, 2134, 5144, 5497, 5579, 5690, 5928, 6143, 6281, 6385, 6516, 6635, 6779, 6871, 6951, 7027, 7105, 7190, 7273, 7371, 7474, 7603, 7771, 8013, 8230, 8417, 8598, 8773, 8932, 9167, 9360, 9546, 9742, 9891, 9972, 10000, 10000, 10000, 10000, 10000, 10000}, - -//temp = 40.0 ^C -{0, 116, 250, 498, 759, 1053, 1252, 1500, 1755, 2011, 2245, 2502, 2744, 2983, 3244, 3501, 3768, 4005, 4259, 4510, 4759, 4999, 5245, 5501, 5756, 6000, 6252, 6509, 6755, 6997, 7257, 7504, 7745, 8007, 8253, 8502, 8745, 9005, 9251, 9499, 9752, 10000}, -{13, 142, 289, 825, 1372, 1448, 1569, 1882, 2272, 2559, 2760, 3010, 3330, 3729, 3963, 4156, 4363, 4546, 4750, 4956, 5160, 5355, 5546, 5742, 6013, 6287, 6539, 6799, 7039, 7212, 7495, 7730, 7960, 8215, 8457, 8702, 8943, 9197, 9437, 9676, 9910, 10000}, -{67, 207, 368, 1394, 1729, 1819, 1969, 2392, 2799, 3117, 3374, 3695, 3989, 4303, 4495, 4657, 4824, 4983, 5152, 5323, 5489, 5643, 5806, 6005, 6295, 6579, 6835, 7078, 7256, 7440, 7729, 7951, 8176, 8426, 8662, 8904, 9140, 9389, 9619, 9842, 9995, 10000}, -{94, 249, 424, 1730, 2170, 2292, 2473, 2959, 3442, 3772, 3993, 4258, 4489, 4753, 4919, 5053, 5198, 5329, 5472, 5607, 5744, 5881, 6035, 6236, 6537, 6823, 7058, 7259, 7458, 7649, 7920, 8134, 8356, 8604, 8832, 9072, 9305, 9547, 9766, 9948, 10000, 10000}, -{59, 231, 438, 2099, 2647, 2800, 3030, 3583, 4010, 4279, 4463, 4687, 4891, 5117, 5259, 5374, 5499, 5610, 5731, 5855, 5986, 6125, 6285, 6493, 6804, 7067, 7260, 7465, 7665, 7849, 8113, 8326, 8545, 8782, 9012, 9245, 9475, 9704, 9898, 9995, 10000, 10000}, -{140, 362, 931, 3614, 4173, 4289, 4446, 4805, 5098, 5287, 5414, 5572, 5717, 5881, 5983, 6066, 6164, 6258, 6368, 6482, 6608, 6746, 6903, 7089, 7348, 7582, 7783, 7981, 8169, 8340, 8590, 8797, 9005, 9234, 9454, 9671, 9857, 9974, 10000, 10000, 10000, 10000}, -{201, 567, 1823, 4820, 5204, 5292, 5407, 5664, 5880, 6031, 6138, 6263, 6384, 6528, 6622, 6702, 6792, 6880, 6979, 7077, 7188, 7308, 7439, 7611, 7859, 8083, 8272, 8460, 8634, 8800, 9041, 9239, 9434, 9645, 9827, 9948, 9995, 10000, 10000, 10000, 10000, 10000}, -}; +/***************************************************************************** +* Copyright(c) O2Micro, 2014. All rights reserved. +* +* O2Micro battery gauge driver +* File: table.c +* +* $Source: /data/code/CVS +* $Revision: 4.00.01 $ +* +* This program is free software and can be edistributed and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This Source Code Reference Design for O2MICRO Battery Gauge access (\u201cReference Design\u201d) +* is sole for the use of PRODUCT INTEGRATION REFERENCE ONLY, and contains confidential +* and privileged information of O2Micro International Limited. O2Micro shall have no +* liability to any PARTY FOR THE RELIABILITY, SERVICEABILITY FOR THE RESULT OF PRODUCT +* INTEGRATION, or results from: (i) any modification or attempted modification of the +* Reference Design by any party, or (ii) the combination, operation or use of the +* Reference Design with non-O2Micro Reference Design. +* +* Battery Manufacture: ATL +* Battery Model: M1892 +* Absolute Max Capacity(mAhr): 3661 +* Limited Charge Voltage(mV): 4400 +* Cutoff Discharge Voltage(mV): 3200 +* Equipment: "JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY2-5","JY2-5","JY2-5","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-5","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-8","JY1-8","JY1-8","JY1-8","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-8","JY1-7","JY1-7","JY1-7","JY1-7","JY1-7","JY1-7","JY1-3","JY1-3","JY1-3","JY1-5","JY1-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY1-8","JY1-8","JY1-2","JY1-2","JY1-2","JY2-6","JY2-6","JY2-6" +* Tester: "SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ" +* Battery ID: "M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_4","M1892_4","M1892_4","M1892_2","M1892_2","M1892_2" +* Version = V00.8D.00 +* Date = 2018.3.26 +* Comment = +* +*****************************************************************************/ + +#include +#include "table.h" + +/***************************************************************************** +* Global variables section - Exported +* add declaration of global variables that will be exported here +* e.g. +* int8_t foo; +****************************************************************************/ +const char * table_version = "V00.8D.00-2018.3.26-M1892"; + +const char *battery_id[BATTERY_ID_NUM] = {"M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_4","M1892_4","M1892_4","M1892_2","M1892_2","M1892_2"}; + +one_latitude_data_t ocv_data[OCV_DATA_NUM] = {{3200, 0},{3511, 2},{3607, 3},{3672, 5},{3687, 6},{3689, 8},{3690, 9},{3692, 11},{3701, 13},{3713, 14},{3721, 16},{3730, 17},{3737, 19},{3743, 20},{3748, 22},{3754, 23},{3761, 25},{3768, 27},{3774, 28},{3780, 30},{3785, 31},{3790, 33},{3795, 34},{3799, 36},{3804, 38},{3810, 39},{3815, 41},{3822, 42},{3828, 44},{3835, 45},{3843, 47},{3852, 48},{3860, 50},{3869, 52},{3880, 53},{3893, 55},{3910, 56},{3929, 58},{3946, 59},{3961, 61},{3973, 63},{3985, 64},{3998, 66},{4014, 67},{4030, 69},{4046, 70},{4062, 72},{4076, 73},{4092, 75},{4109, 77},{4126, 78},{4143, 80},{4161, 81},{4178, 83},{4196, 84},{4214, 86},{4233, 88},{4251, 89},{4269, 91},{4287, 92},{4306, 94},{4325, 95},{4344, 97},{4363, 98},{4390, 100}}; + +//real current to soc +one_latitude_data_t charge_data[CHARGE_DATA_NUM] = {{73, 9999},{74, 9998},{76, 9995},{78, 9993},{80, 9991},{82, 9988},{84, 9986},{86, 9983},{88, 9982},{90, 9979},{92, 9978},{94, 9974},{96, 9972},{98, 9970},{100, 9967},{105, 9961},{110, 9956},{115, 9949},{120, 9944},{125, 9937},{130, 9931},{135, 9926},{140, 9919},{145, 9913},{150, 9908},{155, 9901},{160, 9895},{165, 9890},{170, 9883},{175, 9877},{180, 9872},{185, 9865},{190, 9859},{195, 9853},{200, 9847},{210, 9834},{220, 9822},{230, 9811},{240, 9798},{250, 9786},{260, 9774},{270, 9763},{280, 9750},{290, 9738},{300, 9727},{310, 9715},{320, 9702},{330, 9691},{340, 9679},{350, 9668},{360, 9657},{370, 9645},{380, 9633},{390, 9623},{400, 9611},{425, 9583},{450, 9556},{475, 9529},{500, 9503},{525, 9477},{550, 9452},{575, 9427},{600, 9403},{650, 9356},{727, 9297}}; + +//RC table X Axis value, in mV format +int32_t XAxisElement[XAxis] = {3200, 3220, 3260, 3280, 3300, 3320, 3340, 3360, 3380, 3400, 3420, 3440, 3460, 3480, 3500, 3511, 3525, 3538, 3551, 3557, 3563, 3574, 3584, 3595, 3608, 3621, 3636, 3643, 3650, 3662, 3667, 3678, 3695, 3709, 3720, 3729, 3739, 3748, 3757, 3765, 3773, 3782, 3791, 3802, 3813, 3826, 3840, 3855, 3875, 3884, 3900, 3916, 3925, 3939, 3947, 3959, 3968, 3977, 3992, 4019, 4030, 4044, 4060, 4070, 4081, 4097, 4114, 4125, 4142, 4154, 4171, 4183, 4194, 4212, 4230, 4242, 4254, 4271, 4289, 4301, 4313, 4331, 4345, 4352, 4369, 4390}; + +//RC table Y Axis value, in mA format +int32_t YAxisElement[YAxis] = {200, 500, 800, 1000, 1200, 1500, 1800, 2000, 2500, 3000}; + +// RC table Z Axis value, in 10*'C format +int32_t ZAxisElement[ZAxis] = {-199, -99, 0, 100, 200, 300, 400, 500, 600}; + +// contents of RC table, its unit is 10000C, 1C = DesignCapacity +int32_t RCtable[YAxis*ZAxis][XAxis]={ + + +//temp = -20.0 ^C +{1599, 1756, 2111, 2306, 2524, 2745, 2986, 3235, 3508, 3782, 4073, 4368, 4683, 4988, 5320, 5539, 5725, 5942, 6159, 6270, 6368, 6584, 6772, 6969, 7218, 7481, 7787, 7937, 8096, 8470, 8681, 9096, 9474, 9615, 9683, 9726, 9765, 9793, 9816, 9836, 9853, 9867, 9881, 9895, 9908, 9922, 9935, 9946, 9960, 9965, 9972, 9979, 9982, 9986, 9988, 9990, 9992, 9994, 9996, 9998, 9998, 9999, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{3866, 4135, 4697, 4997, 5280, 5582, 5862, 6170, 6458, 6735, 7040, 7343, 7658, 8008, 8441, 8713, 9160, 9455, 9563, 9610, 9645, 9697, 9737, 9773, 9806, 9832, 9857, 9868, 9878, 9893, 9898, 9910, 9926, 9937, 9946, 9952, 9958, 9963, 9968, 9971, 9975, 9979, 9982, 9986, 9989, 9992, 9994, 9997, 9998, 9999, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{3866, 4135, 4697, 4997, 5280, 5582, 5862, 6170, 6458, 6735, 7040, 7343, 7658, 8008, 8441, 8713, 9160, 9455, 9563, 9610, 9645, 9697, 9737, 9773, 9806, 9832, 9857, 9868, 9878, 9893, 9898, 9910, 9926, 9937, 9946, 9952, 9958, 9963, 9968, 9971, 9975, 9979, 9982, 9986, 9989, 9992, 9994, 9997, 9998, 9999, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{8577, 8760, 9134, 9311, 9458, 9576, 9659, 9723, 9771, 9809, 9841, 9869, 9894, 9914, 9936, 9944, 9956, 9965, 9975, 9977, 9978, 9986, 9988, 9989, 9995, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{8577, 8760, 9134, 9311, 9458, 9576, 9659, 9723, 9771, 9809, 9841, 9869, 9894, 9914, 9936, 9944, 9956, 9965, 9975, 9977, 9978, 9986, 9988, 9989, 9995, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{8577, 8760, 9134, 9311, 9458, 9576, 9659, 9723, 9771, 9809, 9841, 9869, 9894, 9914, 9936, 9944, 9956, 9965, 9975, 9977, 9978, 9986, 9988, 9989, 9995, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{8577, 8760, 9134, 9311, 9458, 9576, 9659, 9723, 9771, 9809, 9841, 9869, 9894, 9914, 9936, 9944, 9956, 9965, 9975, 9977, 9978, 9986, 9988, 9989, 9995, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{9936, 9947, 9976, 9985, 9987, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{9936, 9947, 9976, 9985, 9987, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{9936, 9947, 9976, 9985, 9987, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = -10.0 ^C +{595, 609, 640, 657, 676, 695, 717, 740, 765, 794, 826, 862, 907, 959, 1026, 1069, 1136, 1205, 1288, 1335, 1382, 1478, 1559, 1656, 1768, 1892, 2052, 2131, 2216, 2372, 2447, 2629, 2977, 3362, 3710, 4021, 4320, 4546, 4746, 4908, 5066, 5232, 5384, 5560, 5724, 5902, 6084, 6269, 6507, 6611, 6796, 6972, 7059, 7179, 7242, 7330, 7399, 7465, 7576, 7818, 7933, 8066, 8208, 8297, 8393, 8529, 8673, 8766, 8910, 9009, 9150, 9247, 9333, 9470, 9602, 9683, 9758, 9852, 9932, 9968, 9990, 10000, 10000, 10000, 10000, 10000}, +{1574, 1690, 1951, 2101, 2259, 2435, 2621, 2825, 3038, 3269, 3525, 3776, 4045, 4344, 4643, 4815, 5032, 5226, 5431, 5540, 5623, 5796, 5944, 6115, 6308, 6539, 6711, 6812, 6899, 7069, 7130, 7270, 7476, 7638, 7763, 7869, 7979, 8074, 8177, 8257, 8340, 8433, 8520, 8630, 8732, 8853, 8980, 9100, 9266, 9330, 9448, 9545, 9599, 9678, 9715, 9765, 9800, 9829, 9870, 9928, 9946, 9962, 9977, 9985, 9991, 9997, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2254, 2418, 2794, 3019, 3247, 3485, 3755, 4044, 4328, 4630, 4934, 5245, 5552, 5848, 6142, 6308, 6492, 6688, 6859, 6942, 7022, 7160, 7294, 7429, 7595, 7743, 7916, 8008, 8093, 8223, 8275, 8389, 8567, 8706, 8804, 8893, 8987, 9063, 9134, 9196, 9250, 9315, 9381, 9446, 9509, 9581, 9645, 9703, 9769, 9795, 9832, 9866, 9883, 9906, 9919, 9932, 9943, 9953, 9966, 9986, 9991, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2767, 2964, 3411, 3665, 3926, 4219, 4510, 4802, 5097, 5402, 5704, 5990, 6248, 6527, 6786, 6935, 7102, 7258, 7414, 7486, 7562, 7691, 7804, 7924, 8067, 8213, 8378, 8445, 8505, 8609, 8656, 8771, 8958, 9074, 9157, 9226, 9295, 9357, 9407, 9454, 9502, 9547, 9588, 9637, 9679, 9726, 9770, 9812, 9855, 9874, 9899, 9922, 9935, 9950, 9957, 9967, 9976, 9981, 9988, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{3085, 3290, 3756, 4013, 4286, 4554, 4846, 5119, 5403, 5695, 5958, 6223, 6474, 6710, 6951, 7067, 7225, 7361, 7513, 7578, 7647, 7755, 7862, 7972, 8102, 8232, 8382, 8449, 8512, 8622, 8674, 8755, 8897, 9019, 9110, 9178, 9245, 9298, 9347, 9392, 9432, 9478, 9525, 9580, 9632, 9687, 9737, 9784, 9841, 9863, 9895, 9925, 9938, 9953, 9963, 9976, 9981, 9986, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{4092, 4327, 4839, 5128, 5402, 5676, 5959, 6229, 6493, 6768, 7024, 7319, 7573, 7817, 8126, 8269, 8449, 8621, 8790, 8862, 8922, 9041, 9137, 9238, 9353, 9447, 9541, 9577, 9612, 9666, 9685, 9724, 9774, 9805, 9831, 9850, 9864, 9881, 9895, 9906, 9914, 9926, 9935, 9946, 9959, 9967, 9976, 9985, 9995, 9997, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{4926, 5178, 5688, 5983, 6210, 6491, 6730, 6965, 7197, 7427, 7654, 7858, 8087, 8313, 8552, 8674, 8833, 8966, 9099, 9154, 9210, 9302, 9377, 9449, 9527, 9585, 9653, 9676, 9702, 9737, 9750, 9776, 9815, 9843, 9863, 9875, 9893, 9903, 9913, 9925, 9932, 9945, 9953, 9959, 9972, 9979, 9988, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{5489, 5739, 6227, 6469, 6706, 6937, 7160, 7386, 7607, 7824, 8043, 8251, 8456, 8653, 8864, 8974, 9097, 9205, 9307, 9348, 9392, 9461, 9519, 9573, 9632, 9676, 9725, 9747, 9765, 9792, 9806, 9827, 9855, 9882, 9896, 9908, 9921, 9928, 9942, 9946, 9957, 9967, 9971, 9976, 9987, 9993, 9995, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{8331, 8508, 8860, 9036, 9202, 9363, 9514, 9621, 9684, 9729, 9768, 9799, 9819, 9848, 9864, 9882, 9892, 9902, 9920, 9923, 9925, 9938, 9945, 9952, 9965, 9971, 9982, 9985, 9987, 9989, 9991, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{9172, 9288, 9489, 9567, 9625, 9670, 9705, 9737, 9764, 9794, 9816, 9841, 9856, 9873, 9899, 9906, 9922, 9928, 9943, 9948, 9952, 9962, 9972, 9974, 9985, 9988, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 0.0 ^C +{595, 609, 640, 657, 676, 695, 717, 740, 765, 794, 826, 862, 907, 959, 1026, 1069, 1136, 1205, 1288, 1335, 1382, 1478, 1559, 1656, 1768, 1892, 2052, 2131, 2216, 2372, 2447, 2629, 2977, 3362, 3710, 4021, 4320, 4546, 4746, 4908, 5066, 5232, 5384, 5560, 5724, 5902, 6084, 6269, 6507, 6611, 6796, 6972, 7059, 7179, 7242, 7330, 7399, 7465, 7576, 7818, 7933, 8066, 8208, 8297, 8393, 8529, 8673, 8766, 8910, 9009, 9150, 9247, 9333, 9470, 9602, 9683, 9758, 9852, 9932, 9968, 9990, 10000, 10000, 10000, 10000, 10000}, +{1109, 1163, 1279, 1346, 1420, 1503, 1592, 1689, 1801, 1913, 2040, 2178, 2328, 2498, 2685, 2805, 2951, 3104, 3271, 3356, 3432, 3600, 3746, 3925, 4142, 4379, 4657, 4805, 4931, 5162, 5250, 5454, 5753, 5932, 6085, 6206, 6332, 6447, 6556, 6649, 6745, 6845, 6947, 7068, 7185, 7321, 7462, 7604, 7781, 7860, 7985, 8105, 8175, 8286, 8348, 8443, 8525, 8597, 8712, 8920, 9004, 9105, 9220, 9288, 9360, 9461, 9567, 9628, 9716, 9772, 9841, 9883, 9914, 9955, 9980, 9991, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1431, 1527, 1757, 1891, 2063, 2207, 2362, 2544, 2737, 2937, 3160, 3390, 3634, 3911, 4190, 4350, 4570, 4766, 4972, 5070, 5159, 5339, 5501, 5667, 5854, 6049, 6274, 6369, 6454, 6619, 6682, 6819, 7024, 7182, 7294, 7394, 7506, 7595, 7683, 7763, 7834, 7903, 7980, 8097, 8206, 8312, 8424, 8539, 8686, 8751, 8869, 8987, 9047, 9146, 9197, 9271, 9324, 9377, 9462, 9598, 9649, 9709, 9768, 9802, 9836, 9877, 9915, 9936, 9958, 9972, 9986, 9994, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1573, 1682, 1927, 2086, 2254, 2433, 2641, 2852, 3084, 3323, 3580, 3849, 4132, 4426, 4727, 4890, 5110, 5316, 5515, 5607, 5702, 5864, 6013, 6166, 6344, 6530, 6718, 6804, 6891, 7036, 7098, 7224, 7402, 7555, 7661, 7757, 7855, 7937, 8024, 8095, 8167, 8245, 8325, 8415, 8502, 8606, 8714, 8818, 8962, 9025, 9140, 9238, 9295, 9377, 9423, 9484, 9530, 9574, 9642, 9747, 9785, 9828, 9870, 9891, 9912, 9940, 9961, 9973, 9986, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1805, 1928, 2228, 2399, 2592, 2800, 3030, 3264, 3530, 3800, 4078, 4370, 4661, 4965, 5276, 5441, 5651, 5844, 6028, 6118, 6197, 6350, 6481, 6627, 6791, 6947, 7123, 7205, 7281, 7409, 7465, 7583, 7751, 7890, 7996, 8079, 8173, 8253, 8331, 8397, 8459, 8534, 8606, 8692, 8771, 8868, 8969, 9068, 9203, 9259, 9356, 9441, 9486, 9559, 9594, 9647, 9681, 9716, 9769, 9847, 9873, 9899, 9927, 9942, 9954, 9974, 9985, 9993, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2254, 2413, 2783, 2992, 3220, 3468, 3726, 3988, 4271, 4562, 4861, 5165, 5461, 5754, 6043, 6188, 6382, 6552, 6711, 6787, 6861, 7001, 7118, 7246, 7387, 7530, 7688, 7763, 7835, 7962, 8007, 8111, 8268, 8394, 8487, 8563, 8642, 8717, 8784, 8846, 8906, 8966, 9034, 9103, 9174, 9253, 9338, 9417, 9518, 9556, 9624, 9689, 9720, 9769, 9791, 9823, 9843, 9864, 9890, 9935, 9948, 9960, 9978, 9984, 9990, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2760, 2951, 3358, 3587, 3835, 4097, 4388, 4666, 4953, 5253, 5544, 5829, 6109, 6369, 6638, 6786, 6978, 7128, 7257, 7315, 7378, 7491, 7600, 7719, 7849, 7977, 8123, 8192, 8247, 8364, 8408, 8505, 8646, 8761, 8840, 8910, 8981, 9040, 9104, 9156, 9203, 9262, 9317, 9377, 9430, 9497, 9563, 9622, 9699, 9724, 9774, 9820, 9837, 9868, 9880, 9904, 9918, 9927, 9947, 9974, 9982, 9990, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{3087, 3276, 3707, 3953, 4207, 4474, 4758, 5036, 5338, 5616, 5899, 6164, 6425, 6676, 6908, 7037, 7190, 7336, 7483, 7547, 7607, 7715, 7819, 7925, 8053, 8172, 8314, 8370, 8435, 8538, 8582, 8664, 8797, 8906, 8979, 9049, 9110, 9168, 9227, 9271, 9321, 9368, 9418, 9471, 9528, 9580, 9644, 9697, 9760, 9784, 9823, 9861, 9875, 9899, 9912, 9932, 9943, 9952, 9966, 9988, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{4088, 4307, 4809, 5076, 5338, 5611, 5885, 6145, 6403, 6647, 6895, 7117, 7342, 7570, 7788, 7897, 8036, 8167, 8286, 8349, 8402, 8500, 8587, 8681, 8788, 8887, 8991, 9043, 9086, 9164, 9200, 9257, 9358, 9429, 9481, 9523, 9571, 9603, 9637, 9670, 9690, 9722, 9743, 9775, 9803, 9827, 9854, 9881, 9912, 9923, 9941, 9956, 9969, 9981, 9983, 9990, 9993, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{5060, 5300, 5799, 6049, 6298, 6540, 6777, 7017, 7238, 7464, 7673, 7875, 8082, 8278, 8452, 8554, 8679, 8776, 8876, 8923, 8970, 9042, 9110, 9176, 9261, 9331, 9415, 9445, 9484, 9540, 9557, 9596, 9655, 9696, 9730, 9752, 9774, 9791, 9810, 9831, 9844, 9856, 9877, 9889, 9909, 9920, 9940, 9951, 9970, 9980, 9988, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 10.0 ^C +{255, 263, 284, 295, 307, 320, 334, 349, 366, 384, 403, 424, 446, 471, 499, 514, 535, 557, 579, 591, 602, 625, 650, 681, 732, 811, 978, 1121, 1288, 1460, 1522, 1659, 1909, 2162, 2425, 2687, 3063, 3423, 3713, 3937, 4146, 4361, 4566, 4789, 4998, 5218, 5437, 5638, 5871, 5965, 6143, 6323, 6424, 6583, 6674, 6795, 6874, 6943, 7052, 7271, 7376, 7525, 7680, 7769, 7868, 8010, 8159, 8257, 8404, 8508, 8654, 8760, 8852, 9003, 9156, 9257, 9357, 9496, 9637, 9728, 9815, 9925, 9982, 9996, 10000, 10000}, +{451, 466, 498, 518, 536, 558, 582, 607, 634, 667, 704, 749, 803, 870, 955, 1012, 1098, 1199, 1311, 1368, 1421, 1527, 1620, 1732, 1876, 2035, 2250, 2368, 2492, 2753, 2878, 3178, 3688, 4087, 4348, 4543, 4741, 4906, 5066, 5200, 5326, 5461, 5593, 5742, 5886, 6047, 6219, 6403, 6641, 6739, 6899, 7036, 7107, 7214, 7273, 7365, 7440, 7521, 7660, 7911, 8008, 8126, 8262, 8347, 8440, 8576, 8718, 8812, 8950, 9051, 9187, 9286, 9372, 9509, 9640, 9722, 9800, 9891, 9960, 9985, 9997, 10000, 10000, 10000, 10000, 10000}, +{653, 678, 739, 773, 812, 858, 910, 970, 1040, 1123, 1226, 1334, 1471, 1617, 1784, 1886, 2013, 2152, 2310, 2379, 2459, 2619, 2770, 2963, 3207, 3476, 3816, 3979, 4145, 4421, 4529, 4749, 5057, 5288, 5457, 5591, 5729, 5850, 5966, 6071, 6170, 6283, 6395, 6531, 6659, 6808, 6960, 7103, 7279, 7352, 7476, 7603, 7677, 7799, 7872, 7977, 8061, 8138, 8262, 8485, 8575, 8690, 8816, 8896, 8985, 9112, 9239, 9321, 9448, 9532, 9646, 9720, 9780, 9869, 9935, 9963, 9980, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{819, 857, 948, 1003, 1059, 1131, 1210, 1306, 1411, 1529, 1670, 1817, 1989, 2180, 2393, 2524, 2702, 2883, 3081, 3175, 3272, 3467, 3653, 3873, 4128, 4402, 4701, 4837, 4961, 5169, 5253, 5426, 5673, 5869, 6013, 6131, 6254, 6366, 6472, 6569, 6666, 6767, 6872, 6991, 7103, 7229, 7354, 7478, 7639, 7708, 7841, 7978, 8058, 8183, 8250, 8345, 8419, 8490, 8611, 8824, 8911, 9020, 9140, 9213, 9290, 9408, 9524, 9590, 9696, 9763, 9845, 9892, 9924, 9962, 9984, 9995, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{992, 1048, 1177, 1251, 1337, 1437, 1548, 1676, 1822, 1980, 2161, 2352, 2564, 2800, 3067, 3224, 3431, 3644, 3859, 3968, 4073, 4273, 4460, 4668, 4903, 5128, 5374, 5485, 5587, 5758, 5832, 5979, 6205, 6378, 6506, 6616, 6734, 6832, 6930, 7018, 7103, 7194, 7282, 7387, 7485, 7595, 7709, 7831, 7993, 8067, 8200, 8338, 8414, 8526, 8589, 8679, 8750, 8820, 8933, 9131, 9212, 9309, 9419, 9480, 9554, 9648, 9741, 9794, 9863, 9901, 9941, 9960, 9975, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1247, 1333, 1529, 1645, 1773, 1921, 2085, 2267, 2469, 2685, 2917, 3161, 3433, 3717, 4022, 4205, 4434, 4650, 4872, 4974, 5078, 5258, 5421, 5589, 5785, 5967, 6172, 6267, 6354, 6501, 6562, 6686, 6885, 7038, 7152, 7250, 7346, 7441, 7523, 7596, 7664, 7742, 7822, 7916, 8004, 8104, 8219, 8338, 8500, 8570, 8697, 8817, 8882, 8988, 9043, 9127, 9188, 9250, 9347, 9513, 9576, 9655, 9731, 9777, 9823, 9872, 9916, 9936, 9961, 9975, 9992, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1497, 1609, 1871, 2022, 2192, 2385, 2583, 2812, 3057, 3316, 3592, 3870, 4171, 4481, 4796, 4971, 5188, 5395, 5597, 5691, 5774, 5943, 6076, 6222, 6396, 6559, 6739, 6825, 6902, 7043, 7098, 7215, 7388, 7528, 7634, 7724, 7806, 7889, 7964, 8034, 8099, 8169, 8243, 8334, 8419, 8521, 8626, 8742, 8889, 8950, 9067, 9173, 9232, 9324, 9376, 9442, 9495, 9547, 9626, 9752, 9792, 9842, 9886, 9908, 9925, 9951, 9969, 9981, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1649, 1775, 2067, 2232, 2420, 2631, 2856, 3088, 3352, 3645, 3926, 4210, 4514, 4836, 5142, 5323, 5537, 5734, 5916, 6002, 6077, 6225, 6364, 6499, 6663, 6819, 6983, 7061, 7136, 7264, 7318, 7435, 7600, 7739, 7835, 7915, 7999, 8074, 8149, 8216, 8284, 8356, 8431, 8514, 8601, 8693, 8801, 8910, 9053, 9113, 9218, 9321, 9380, 9461, 9511, 9578, 9624, 9664, 9727, 9833, 9862, 9896, 9926, 9941, 9957, 9976, 9985, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2271, 2448, 2837, 3058, 3294, 3543, 3809, 4094, 4399, 4687, 5000, 5296, 5595, 5886, 6160, 6312, 6497, 6660, 6816, 6890, 6957, 7083, 7195, 7316, 7463, 7591, 7737, 7800, 7863, 7979, 8025, 8124, 8261, 8387, 8473, 8546, 8619, 8694, 8756, 8818, 8873, 8943, 9003, 9085, 9150, 9234, 9328, 9412, 9526, 9578, 9654, 9723, 9757, 9796, 9826, 9850, 9875, 9887, 9914, 9954, 9965, 9981, 9992, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{2933, 3136, 3591, 3842, 4099, 4389, 4676, 4957, 5259, 5549, 5831, 6098, 6372, 6629, 6871, 7004, 7157, 7308, 7441, 7507, 7577, 7686, 7781, 7891, 8012, 8127, 8257, 8323, 8375, 8475, 8518, 8603, 8735, 8848, 8921, 8988, 9055, 9121, 9179, 9226, 9278, 9333, 9389, 9453, 9511, 9574, 9643, 9708, 9776, 9804, 9837, 9877, 9888, 9911, 9926, 9938, 9955, 9963, 9976, 9993, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 20.0 ^C +{101, 108, 125, 134, 144, 156, 167, 182, 197, 212, 230, 249, 269, 292, 316, 331, 351, 370, 390, 401, 411, 431, 449, 471, 498, 529, 579, 616, 676, 946, 1172, 1351, 1598, 1827, 2066, 2309, 2578, 2888, 3195, 3447, 3686, 3931, 4159, 4409, 4644, 4892, 5137, 5361, 5611, 5706, 5866, 6025, 6124, 6293, 6382, 6509, 6605, 6692, 6829, 7064, 7163, 7308, 7469, 7561, 7662, 7806, 7957, 8057, 8205, 8309, 8457, 8562, 8653, 8805, 8958, 9059, 9161, 9303, 9455, 9553, 9652, 9800, 9900, 9942, 10000, 10000}, +{212, 221, 244, 256, 269, 284, 300, 317, 335, 355, 377, 401, 425, 454, 486, 505, 529, 557, 588, 606, 625, 668, 718, 795, 940, 1196, 1437, 1528, 1621, 1803, 1890, 2094, 2542, 3032, 3387, 3649, 3905, 4116, 4317, 4480, 4642, 4810, 4968, 5153, 5325, 5512, 5698, 5877, 6101, 6212, 6394, 6563, 6651, 6781, 6852, 6950, 7025, 7097, 7224, 7490, 7589, 7712, 7853, 7940, 8033, 8173, 8316, 8411, 8553, 8657, 8800, 8900, 8990, 9142, 9292, 9390, 9490, 9626, 9767, 9851, 9925, 9988, 10000, 10000, 10000, 10000}, +{295, 309, 338, 353, 370, 390, 409, 433, 457, 483, 512, 546, 586, 638, 702, 745, 808, 886, 988, 1049, 1115, 1259, 1388, 1530, 1705, 1898, 2164, 2316, 2486, 2843, 3016, 3367, 3823, 4146, 4371, 4552, 4740, 4891, 5046, 5173, 5295, 5425, 5557, 5701, 5845, 6005, 6178, 6357, 6584, 6675, 6826, 6965, 7038, 7152, 7220, 7320, 7407, 7493, 7626, 7864, 7958, 8077, 8211, 8296, 8386, 8522, 8664, 8755, 8896, 8997, 9134, 9235, 9323, 9468, 9608, 9700, 9785, 9891, 9966, 9987, 10000, 10000, 10000, 10000, 10000, 10000}, +{357, 374, 406, 426, 448, 470, 496, 525, 559, 597, 643, 696, 758, 840, 943, 1021, 1136, 1268, 1414, 1489, 1559, 1699, 1837, 2006, 2239, 2522, 2924, 3137, 3340, 3677, 3806, 4058, 4409, 4665, 4852, 5009, 5167, 5300, 5436, 5551, 5659, 5775, 5894, 6029, 6167, 6327, 6498, 6661, 6860, 6941, 7073, 7203, 7276, 7404, 7478, 7586, 7671, 7750, 7874, 8102, 8193, 8314, 8447, 8527, 8622, 8752, 8890, 8981, 9117, 9218, 9354, 9448, 9531, 9670, 9792, 9866, 9922, 9973, 9995, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{425, 443, 484, 510, 534, 568, 602, 642, 692, 749, 814, 889, 989, 1115, 1277, 1391, 1536, 1690, 1856, 1948, 2030, 2219, 2402, 2636, 2958, 3304, 3705, 3874, 4037, 4285, 4390, 4593, 4887, 5111, 5275, 5413, 5548, 5672, 5790, 5892, 5996, 6107, 6221, 6356, 6493, 6636, 6790, 6929, 7105, 7175, 7308, 7450, 7532, 7660, 7733, 7832, 7915, 7989, 8114, 8337, 8432, 8542, 8673, 8755, 8846, 8976, 9112, 9202, 9335, 9427, 9556, 9643, 9719, 9835, 9922, 9956, 9981, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{538, 566, 629, 668, 711, 761, 814, 884, 961, 1051, 1163, 1298, 1463, 1667, 1901, 2047, 2256, 2475, 2717, 2843, 2967, 3214, 3454, 3714, 4008, 4278, 4565, 4694, 4806, 4997, 5085, 5251, 5492, 5684, 5825, 5946, 6067, 6181, 6293, 6391, 6483, 6596, 6697, 6811, 6921, 7044, 7166, 7287, 7460, 7540, 7683, 7827, 7902, 8023, 8089, 8186, 8262, 8334, 8460, 8678, 8762, 8875, 9006, 9080, 9168, 9290, 9420, 9499, 9622, 9705, 9806, 9871, 9913, 9958, 9987, 9995, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{453, 478, 535, 571, 608, 655, 711, 769, 847, 938, 1050, 1181, 1364, 1616, 1950, 2166, 2463, 2763, 3071, 3226, 3365, 3623, 3838, 4064, 4310, 4535, 4788, 4894, 5000, 5179, 5255, 5403, 5632, 5818, 5956, 6072, 6193, 6303, 6411, 6501, 6588, 6686, 6782, 6880, 6981, 7092, 7211, 7349, 7531, 7613, 7755, 7898, 7971, 8092, 8158, 8255, 8330, 8402, 8529, 8752, 8839, 8955, 9082, 9160, 9252, 9385, 9526, 9609, 9735, 9817, 9903, 9940, 9965, 9990, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{578, 610, 685, 736, 785, 846, 919, 1005, 1104, 1230, 1389, 1589, 1859, 2197, 2604, 2848, 3159, 3456, 3744, 3873, 4001, 4206, 4389, 4580, 4792, 4996, 5218, 5315, 5410, 5579, 5647, 5784, 5999, 6172, 6305, 6419, 6531, 6631, 6727, 6811, 6887, 6968, 7052, 7148, 7237, 7354, 7483, 7615, 7792, 7867, 7999, 8137, 8209, 8326, 8388, 8484, 8558, 8631, 8753, 8966, 9051, 9160, 9280, 9360, 9445, 9567, 9686, 9764, 9861, 9909, 9955, 9972, 9989, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{857, 915, 1051, 1132, 1230, 1348, 1489, 1669, 1879, 2137, 2461, 2825, 3224, 3644, 4025, 4224, 4474, 4682, 4892, 4985, 5065, 5230, 5369, 5513, 5684, 5851, 6039, 6125, 6205, 6350, 6406, 6539, 6721, 6872, 6972, 7056, 7148, 7227, 7301, 7375, 7443, 7528, 7602, 7702, 7796, 7905, 8028, 8152, 8318, 8388, 8517, 8648, 8715, 8827, 8892, 8982, 9051, 9119, 9226, 9428, 9509, 9607, 9718, 9776, 9834, 9895, 9936, 9961, 9985, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1262, 1361, 1608, 1758, 1932, 2149, 2400, 2685, 3013, 3375, 3739, 4090, 4438, 4759, 5062, 5217, 5408, 5581, 5750, 5827, 5893, 6031, 6155, 6284, 6434, 6572, 6738, 6810, 6885, 6996, 7047, 7147, 7296, 7420, 7522, 7599, 7685, 7769, 7840, 7906, 7975, 8051, 8132, 8217, 8314, 8418, 8534, 8644, 8799, 8875, 8991, 9110, 9172, 9279, 9340, 9417, 9490, 9547, 9645, 9803, 9847, 9893, 9928, 9947, 9967, 9987, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 30.0 ^C +{1, 8, 23, 32, 43, 53, 66, 79, 94, 110, 127, 146, 167, 190, 215, 230, 250, 269, 290, 300, 310, 330, 349, 371, 399, 428, 472, 502, 547, 765, 992, 1251, 1505, 1749, 2011, 2263, 2510, 2748, 3003, 3255, 3501, 3757, 4000, 4261, 4502, 4758, 5014, 5249, 5507, 5598, 5750, 5907, 6000, 6156, 6256, 6403, 6506, 6600, 6747, 6997, 7100, 7252, 7406, 7501, 7600, 7749, 7900, 7999, 8147, 8253, 8400, 8504, 8598, 8750, 8902, 9004, 9105, 9249, 9400, 9499, 9599, 9749, 9856, 9904, 9991, 10000}, +{64, 72, 91, 103, 113, 126, 141, 157, 174, 192, 212, 233, 257, 284, 313, 331, 353, 376, 402, 415, 427, 453, 483, 526, 604, 737, 1087, 1243, 1353, 1530, 1614, 1813, 2211, 2629, 2971, 3256, 3537, 3768, 3983, 4157, 4329, 4510, 4688, 4885, 5073, 5275, 5474, 5666, 5892, 5991, 6164, 6350, 6447, 6593, 6671, 6781, 6864, 6944, 7073, 7338, 7442, 7569, 7709, 7797, 7895, 8034, 8179, 8274, 8420, 8520, 8662, 8762, 8854, 9006, 9157, 9257, 9359, 9501, 9652, 9747, 9839, 9950, 9993, 10000, 10000, 10000}, +{106, 117, 140, 152, 166, 182, 199, 217, 238, 260, 283, 310, 337, 370, 408, 433, 467, 510, 560, 594, 626, 705, 798, 958, 1203, 1420, 1674, 1798, 1934, 2226, 2368, 2704, 3241, 3621, 3887, 4083, 4283, 4460, 4623, 4765, 4905, 5055, 5198, 5361, 5518, 5688, 5869, 6045, 6280, 6383, 6556, 6712, 6795, 6918, 6987, 7087, 7176, 7260, 7398, 7640, 7736, 7856, 7992, 8078, 8169, 8304, 8446, 8539, 8681, 8781, 8920, 9018, 9110, 9262, 9410, 9508, 9608, 9744, 9874, 9939, 9981, 10000, 10000, 10000, 10000, 10000}, +{133, 145, 171, 186, 201, 219, 240, 259, 282, 308, 335, 365, 401, 445, 504, 541, 599, 672, 761, 817, 877, 1016, 1180, 1365, 1586, 1817, 2141, 2322, 2518, 2909, 3068, 3380, 3802, 4107, 4323, 4498, 4674, 4824, 4973, 5100, 5223, 5357, 5485, 5633, 5779, 5938, 6112, 6294, 6524, 6615, 6771, 6911, 6986, 7115, 7185, 7294, 7382, 7460, 7592, 7822, 7917, 8035, 8169, 8250, 8345, 8476, 8617, 8707, 8847, 8947, 9086, 9185, 9278, 9424, 9572, 9669, 9765, 9878, 9963, 9988, 10000, 10000, 10000, 10000, 10000, 10000}, +{165, 180, 209, 225, 243, 263, 285, 312, 336, 368, 402, 444, 495, 561, 644, 705, 798, 904, 1055, 1140, 1226, 1396, 1565, 1766, 2029, 2337, 2783, 3002, 3210, 3530, 3661, 3906, 4251, 4511, 4704, 4860, 5014, 5153, 5289, 5399, 5513, 5633, 5753, 5893, 6030, 6186, 6357, 6528, 6737, 6816, 6961, 7099, 7181, 7313, 7385, 7491, 7573, 7651, 7775, 8006, 8099, 8216, 8344, 8429, 8517, 8649, 8788, 8877, 9017, 9114, 9253, 9352, 9440, 9589, 9729, 9816, 9891, 9959, 9993, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{219, 234, 270, 294, 316, 341, 370, 405, 443, 492, 546, 611, 699, 805, 952, 1057, 1221, 1399, 1613, 1719, 1835, 2063, 2287, 2578, 2949, 3309, 3688, 3853, 3997, 4232, 4331, 4525, 4807, 5034, 5192, 5328, 5466, 5586, 5704, 5809, 5913, 6021, 6134, 6269, 6397, 6548, 6698, 6839, 7018, 7100, 7247, 7395, 7475, 7599, 7670, 7775, 7851, 7923, 8044, 8268, 8361, 8474, 8603, 8685, 8771, 8902, 9041, 9130, 9267, 9361, 9501, 9594, 9681, 9807, 9911, 9954, 9977, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{282, 304, 353, 380, 414, 448, 493, 542, 600, 667, 748, 851, 984, 1158, 1401, 1566, 1803, 2062, 2350, 2493, 2642, 2931, 3199, 3490, 3788, 4054, 4347, 4474, 4589, 4786, 4870, 5032, 5280, 5482, 5623, 5740, 5869, 5981, 6086, 6188, 6284, 6394, 6499, 6618, 6729, 6856, 6981, 7121, 7301, 7382, 7530, 7669, 7749, 7870, 7939, 8032, 8111, 8184, 8305, 8524, 8615, 8728, 8852, 8931, 9022, 9147, 9281, 9369, 9507, 9600, 9724, 9807, 9869, 9943, 9982, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{339, 363, 419, 458, 496, 541, 597, 657, 731, 818, 925, 1056, 1237, 1481, 1801, 2004, 2300, 2602, 2931, 3089, 3237, 3500, 3727, 3962, 4217, 4453, 4710, 4822, 4930, 5106, 5184, 5338, 5564, 5751, 5888, 5996, 6117, 6226, 6334, 6426, 6519, 6614, 6714, 6818, 6929, 7041, 7172, 7304, 7490, 7568, 7707, 7848, 7928, 8044, 8110, 8205, 8279, 8351, 8472, 8688, 8776, 8889, 9014, 9091, 9183, 9309, 9442, 9528, 9654, 9738, 9844, 9907, 9943, 9980, 9998, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{534, 574, 668, 724, 793, 869, 965, 1070, 1202, 1369, 1597, 1882, 2239, 2660, 3116, 3361, 3668, 3942, 4188, 4303, 4403, 4586, 4750, 4920, 5108, 5294, 5501, 5592, 5677, 5830, 5896, 6026, 6227, 6392, 6511, 6611, 6723, 6803, 6896, 6972, 7043, 7122, 7213, 7309, 7408, 7520, 7646, 7779, 7949, 8025, 8158, 8292, 8364, 8478, 8543, 8632, 8711, 8777, 8890, 9102, 9192, 9291, 9419, 9489, 9573, 9688, 9799, 9853, 9924, 9955, 9980, 9990, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{1374, 1489, 1778, 1949, 2150, 2372, 2625, 2887, 3189, 3511, 3858, 4209, 4559, 4915, 5241, 5401, 5589, 5732, 5864, 5919, 5973, 6079, 6203, 6334, 6494, 6642, 6819, 6901, 6970, 7105, 7149, 7269, 7430, 7569, 7674, 7762, 7851, 7927, 8016, 8082, 8156, 8231, 8316, 8405, 8501, 8612, 8725, 8848, 9014, 9081, 9202, 9333, 9393, 9506, 9557, 9641, 9700, 9748, 9824, 9906, 9928, 9952, 9969, 9979, 9987, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 40.0 ^C +{48, 55, 71, 81, 91, 102, 114, 128, 143, 159, 176, 196, 216, 240, 265, 280, 300, 319, 341, 351, 361, 381, 400, 422, 450, 480, 524, 554, 603, 883, 1161, 1327, 1602, 1855, 2146, 2368, 2587, 2762, 2949, 3177, 3423, 3685, 3926, 4191, 4436, 4703, 4957, 5201, 5458, 5546, 5688, 5833, 5927, 6082, 6173, 6316, 6428, 6532, 6683, 6940, 7050, 7198, 7352, 7446, 7547, 7694, 7848, 7946, 8097, 8200, 8349, 8452, 8545, 8700, 8854, 8954, 9054, 9199, 9354, 9454, 9557, 9712, 9825, 9878, 9984, 10000}, +{95, 103, 120, 131, 142, 157, 170, 185, 202, 219, 240, 261, 284, 310, 339, 356, 379, 400, 425, 437, 449, 474, 497, 533, 594, 708, 1042, 1250, 1366, 1550, 1632, 1833, 2228, 2571, 2846, 3091, 3363, 3602, 3828, 4015, 4194, 4380, 4565, 4771, 4965, 5174, 5380, 5567, 5782, 5874, 6037, 6209, 6312, 6474, 6557, 6677, 6762, 6846, 6982, 7248, 7352, 7481, 7625, 7712, 7810, 7950, 8097, 8192, 8339, 8442, 8585, 8685, 8777, 8930, 9081, 9183, 9286, 9429, 9586, 9688, 9788, 9921, 9986, 9998, 10000, 10000}, +{123, 133, 153, 167, 178, 195, 211, 227, 247, 268, 291, 315, 341, 372, 406, 427, 454, 486, 526, 549, 575, 637, 715, 835, 1089, 1358, 1615, 1736, 1870, 2127, 2246, 2534, 2999, 3401, 3667, 3880, 4098, 4279, 4449, 4599, 4744, 4902, 5048, 5220, 5382, 5557, 5735, 5906, 6125, 6221, 6397, 6568, 6655, 6791, 6864, 6968, 7054, 7138, 7283, 7525, 7624, 7743, 7885, 7968, 8060, 8200, 8344, 8436, 8579, 8679, 8818, 8919, 9012, 9162, 9311, 9417, 9520, 9665, 9814, 9898, 9961, 9999, 10000, 10000, 10000, 10000}, +{147, 155, 180, 194, 209, 223, 242, 259, 281, 303, 330, 357, 387, 422, 464, 493, 537, 593, 668, 710, 759, 876, 1026, 1237, 1470, 1702, 1996, 2150, 2316, 2637, 2786, 3093, 3549, 3878, 4106, 4288, 4480, 4637, 4788, 4922, 5055, 5192, 5332, 5480, 5629, 5793, 5964, 6134, 6357, 6454, 6618, 6768, 6853, 6983, 7056, 7167, 7252, 7336, 7466, 7702, 7795, 7918, 8053, 8137, 8232, 8360, 8502, 8596, 8733, 8834, 8974, 9076, 9165, 9318, 9470, 9569, 9674, 9811, 9933, 9975, 9998, 10000, 10000, 10000, 10000, 10000}, +{170, 179, 208, 222, 238, 257, 277, 296, 320, 348, 374, 407, 445, 494, 561, 608, 680, 769, 891, 965, 1040, 1222, 1397, 1597, 1853, 2106, 2486, 2681, 2876, 3216, 3354, 3627, 4000, 4288, 4479, 4645, 4810, 4953, 5092, 5214, 5333, 5462, 5589, 5726, 5867, 6023, 6189, 6359, 6578, 6666, 6814, 6959, 7042, 7172, 7249, 7352, 7438, 7515, 7645, 7874, 7965, 8081, 8215, 8299, 8393, 8523, 8661, 8755, 8893, 8992, 9134, 9232, 9320, 9473, 9626, 9726, 9819, 9926, 9987, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{200, 213, 242, 261, 278, 302, 324, 352, 378, 412, 457, 506, 573, 655, 775, 860, 993, 1152, 1345, 1448, 1554, 1768, 1967, 2210, 2535, 2899, 3313, 3493, 3655, 3919, 4028, 4241, 4545, 4780, 4955, 5092, 5237, 5367, 5489, 5598, 5706, 5822, 5931, 6065, 6195, 6345, 6508, 6664, 6855, 6936, 7088, 7234, 7315, 7438, 7509, 7611, 7686, 7763, 7885, 8114, 8204, 8321, 8450, 8535, 8620, 8750, 8887, 8978, 9114, 9213, 9355, 9454, 9544, 9696, 9835, 9906, 9960, 9994, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{303, 322, 366, 391, 418, 451, 485, 529, 582, 646, 722, 817, 944, 1114, 1338, 1496, 1705, 1943, 2199, 2324, 2461, 2740, 2997, 3287, 3599, 3876, 4169, 4304, 4414, 4614, 4700, 4865, 5126, 5323, 5472, 5597, 5719, 5831, 5930, 6026, 6119, 6220, 6326, 6439, 6554, 6683, 6821, 6957, 7136, 7222, 7357, 7495, 7567, 7690, 7755, 7851, 7926, 8001, 8121, 8336, 8425, 8532, 8661, 8737, 8831, 8956, 9092, 9183, 9322, 9424, 9566, 9665, 9752, 9881, 9955, 9983, 9999, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{368, 393, 440, 470, 508, 546, 591, 651, 713, 796, 901, 1027, 1200, 1408, 1688, 1877, 2140, 2421, 2721, 2876, 3030, 3306, 3546, 3796, 4054, 4289, 4555, 4668, 4773, 4958, 5035, 5187, 5429, 5611, 5746, 5867, 5980, 6094, 6196, 6288, 6378, 6477, 6576, 6688, 6801, 6929, 7055, 7196, 7373, 7457, 7589, 7729, 7809, 7928, 7990, 8087, 8164, 8236, 8356, 8580, 8669, 8773, 8904, 8982, 9072, 9202, 9338, 9429, 9568, 9670, 9796, 9872, 9923, 9971, 9993, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{517, 551, 635, 681, 744, 811, 889, 994, 1116, 1268, 1458, 1697, 2009, 2396, 2837, 3098, 3421, 3709, 3977, 4092, 4205, 4403, 4566, 4740, 4938, 5127, 5332, 5433, 5527, 5679, 5745, 5875, 6075, 6240, 6366, 6465, 6574, 6664, 6755, 6834, 6911, 6997, 7086, 7188, 7290, 7410, 7536, 7663, 7833, 7906, 8044, 8172, 8249, 8358, 8423, 8517, 8585, 8657, 8775, 8987, 9075, 9184, 9315, 9388, 9481, 9606, 9735, 9812, 9903, 9938, 9972, 9989, 9995, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{709, 761, 894, 974, 1077, 1188, 1331, 1503, 1722, 1999, 2352, 2751, 3182, 3610, 4007, 4214, 4454, 4666, 4873, 4958, 5043, 5210, 5339, 5493, 5653, 5817, 5995, 6082, 6160, 6290, 6358, 6470, 6646, 6790, 6899, 6985, 7074, 7163, 7244, 7315, 7390, 7465, 7549, 7638, 7734, 7843, 7963, 8092, 8248, 8322, 8449, 8576, 8644, 8762, 8819, 8916, 8983, 9057, 9170, 9385, 9465, 9575, 9693, 9761, 9831, 9904, 9948, 9965, 9990, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 50.0 ^C +{75, 82, 99, 109, 120, 131, 144, 158, 174, 191, 209, 229, 250, 274, 300, 315, 336, 356, 377, 389, 399, 421, 440, 463, 492, 524, 573, 614, 692, 1166, 1283, 1426, 1708, 2004, 2282, 2471, 2683, 2810, 2958, 3162, 3408, 3661, 3900, 4159, 4404, 4664, 4921, 5163, 5435, 5526, 5657, 5794, 5887, 6042, 6131, 6267, 6370, 6474, 6641, 6910, 7025, 7162, 7316, 7411, 7513, 7664, 7815, 7915, 8066, 8174, 8319, 8423, 8517, 8671, 8824, 8927, 9030, 9176, 9330, 9433, 9537, 9695, 9813, 9867, 9979, 10000}, +{120, 129, 146, 158, 170, 183, 198, 213, 231, 248, 269, 291, 315, 342, 369, 387, 410, 432, 458, 470, 481, 506, 531, 566, 633, 764, 1161, 1329, 1437, 1626, 1713, 1924, 2323, 2623, 2844, 3041, 3295, 3528, 3754, 3949, 4126, 4314, 4505, 4703, 4900, 5115, 5328, 5517, 5721, 5807, 5969, 6140, 6234, 6388, 6479, 6603, 6696, 6785, 6932, 7196, 7299, 7429, 7575, 7662, 7764, 7906, 8053, 8150, 8296, 8399, 8542, 8646, 8736, 8890, 9042, 9144, 9247, 9396, 9553, 9656, 9762, 9901, 9980, 9996, 10000, 10000}, +{146, 156, 178, 190, 203, 218, 235, 252, 271, 292, 315, 339, 367, 398, 430, 451, 479, 507, 545, 568, 591, 654, 735, 865, 1127, 1403, 1660, 1786, 1919, 2176, 2293, 2543, 2935, 3286, 3556, 3770, 3987, 4179, 4360, 4509, 4656, 4814, 4968, 5139, 5305, 5481, 5656, 5817, 6032, 6131, 6294, 6466, 6560, 6703, 6780, 6894, 6983, 7067, 7206, 7456, 7556, 7678, 7816, 7905, 8000, 8138, 8282, 8373, 8518, 8619, 8761, 8861, 8956, 9108, 9259, 9364, 9470, 9617, 9774, 9866, 9945, 9997, 10000, 10000, 10000, 10000}, +{166, 177, 199, 213, 229, 243, 262, 282, 301, 324, 350, 377, 408, 440, 479, 506, 547, 598, 666, 711, 760, 874, 1023, 1243, 1498, 1731, 2018, 2167, 2320, 2600, 2724, 2991, 3415, 3752, 3983, 4168, 4358, 4528, 4687, 4822, 4951, 5092, 5232, 5390, 5543, 5700, 5865, 6028, 6243, 6342, 6507, 6666, 6754, 6892, 6964, 7078, 7166, 7247, 7382, 7620, 7719, 7840, 7977, 8062, 8154, 8287, 8428, 8523, 8664, 8766, 8907, 9007, 9099, 9251, 9407, 9510, 9618, 9762, 9902, 9961, 9992, 10000, 10000, 10000, 10000, 10000}, +{186, 196, 222, 236, 253, 268, 289, 308, 333, 358, 385, 416, 450, 494, 550, 595, 663, 749, 871, 940, 1025, 1203, 1385, 1594, 1842, 2092, 2426, 2594, 2764, 3074, 3204, 3470, 3850, 4144, 4347, 4510, 4680, 4832, 4975, 5099, 5219, 5353, 5474, 5620, 5758, 5913, 6075, 6239, 6450, 6543, 6699, 6856, 6939, 7075, 7150, 7254, 7336, 7416, 7550, 7782, 7878, 7996, 8128, 8214, 8306, 8437, 8578, 8671, 8806, 8909, 9050, 9151, 9246, 9399, 9551, 9657, 9759, 9888, 9976, 9995, 10000, 10000, 10000, 10000, 10000, 10000}, +{207, 220, 250, 265, 283, 303, 327, 352, 380, 408, 445, 487, 547, 626, 738, 824, 955, 1109, 1301, 1402, 1511, 1722, 1921, 2140, 2431, 2742, 3132, 3320, 3485, 3755, 3864, 4076, 4392, 4635, 4811, 4958, 5103, 5235, 5361, 5471, 5578, 5696, 5816, 5946, 6080, 6225, 6377, 6536, 6740, 6826, 6975, 7127, 7205, 7331, 7401, 7506, 7586, 7664, 7785, 8013, 8110, 8223, 8355, 8437, 8528, 8654, 8796, 8887, 9026, 9127, 9270, 9370, 9460, 9618, 9765, 9860, 9930, 9984, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{240, 252, 289, 308, 329, 354, 382, 410, 450, 497, 554, 627, 721, 855, 1044, 1179, 1362, 1568, 1817, 1943, 2065, 2312, 2540, 2814, 3142, 3455, 3797, 3945, 4080, 4305, 4399, 4578, 4842, 5058, 5216, 5352, 5484, 5604, 5726, 5824, 5918, 6028, 6136, 6254, 6377, 6523, 6664, 6815, 7008, 7090, 7238, 7380, 7455, 7583, 7647, 7745, 7822, 7899, 8022, 8242, 8332, 8447, 8579, 8657, 8744, 8877, 9013, 9107, 9242, 9340, 9485, 9586, 9682, 9825, 9930, 9971, 9989, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{263, 283, 317, 342, 365, 396, 431, 469, 517, 582, 662, 756, 892, 1077, 1308, 1457, 1700, 1948, 2227, 2360, 2496, 2770, 3017, 3298, 3597, 3873, 4170, 4298, 4414, 4621, 4707, 4872, 5127, 5328, 5473, 5597, 5720, 5836, 5940, 6034, 6133, 6231, 6335, 6459, 6580, 6708, 6852, 6993, 7179, 7262, 7400, 7536, 7620, 7738, 7806, 7900, 7977, 8053, 8173, 8397, 8484, 8593, 8728, 8802, 8893, 9021, 9157, 9250, 9393, 9493, 9631, 9728, 9812, 9922, 9981, 9996, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{346, 372, 428, 466, 507, 562, 622, 698, 794, 906, 1058, 1255, 1488, 1791, 2194, 2445, 2768, 3084, 3386, 3540, 3663, 3901, 4092, 4299, 4520, 4724, 4951, 5055, 5153, 5319, 5388, 5535, 5753, 5928, 6051, 6169, 6274, 6372, 6471, 6549, 6629, 6729, 6816, 6927, 7028, 7155, 7279, 7415, 7595, 7669, 7813, 7945, 8017, 8129, 8194, 8288, 8367, 8435, 8552, 8764, 8853, 8956, 9082, 9167, 9259, 9385, 9518, 9611, 9750, 9832, 9917, 9961, 9978, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{463, 505, 599, 657, 730, 817, 922, 1056, 1223, 1423, 1671, 1977, 2392, 2862, 3325, 3566, 3852, 4101, 4343, 4450, 4543, 4728, 4877, 5045, 5227, 5399, 5598, 5684, 5768, 5909, 5970, 6098, 6290, 6441, 6554, 6651, 6750, 6842, 6922, 6998, 7076, 7163, 7246, 7352, 7446, 7566, 7689, 7809, 7979, 8052, 8185, 8313, 8379, 8497, 8553, 8650, 8720, 8786, 8898, 9115, 9203, 9304, 9432, 9516, 9596, 9726, 9832, 9899, 9951, 9974, 9991, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, + +//temp = 60.0 ^C +{159, 167, 185, 196, 207, 220, 233, 248, 264, 281, 300, 320, 344, 368, 396, 412, 432, 454, 476, 488, 499, 521, 543, 566, 596, 631, 696, 761, 925, 1385, 1446, 1616, 1902, 2238, 2465, 2651, 2811, 2916, 3044, 3224, 3448, 3690, 3917, 4175, 4410, 4664, 4914, 5160, 5442, 5538, 5676, 5799, 5883, 6032, 6124, 6256, 6357, 6460, 6617, 6899, 7010, 7150, 7303, 7397, 7502, 7648, 7804, 7903, 8054, 8160, 8308, 8411, 8505, 8661, 8816, 8919, 9021, 9168, 9327, 9433, 9540, 9703, 9826, 9888, 9996, 10000}, +{264, 273, 293, 304, 317, 331, 345, 361, 379, 398, 419, 442, 468, 496, 525, 542, 567, 590, 617, 629, 642, 668, 694, 734, 821, 1011, 1452, 1570, 1678, 1872, 1968, 2201, 2570, 2831, 3006, 3165, 3387, 3623, 3845, 4030, 4208, 4396, 4579, 4780, 4972, 5185, 5398, 5589, 5790, 5871, 6022, 6190, 6287, 6442, 6528, 6650, 6748, 6840, 6989, 7255, 7359, 7488, 7633, 7725, 7824, 7966, 8118, 8212, 8359, 8465, 8610, 8713, 8804, 8959, 9112, 9214, 9321, 9469, 9633, 9736, 9842, 9970, 10000, 10000, 10000, 10000}, +{328, 338, 361, 375, 387, 403, 418, 439, 458, 480, 504, 530, 559, 589, 624, 644, 673, 704, 744, 768, 796, 873, 969, 1137, 1433, 1688, 1942, 2076, 2214, 2467, 2571, 2780, 3088, 3369, 3621, 3830, 4049, 4240, 4414, 4558, 4707, 4859, 5014, 5184, 5347, 5525, 5699, 5852, 6055, 6145, 6315, 6481, 6578, 6723, 6802, 6921, 7010, 7096, 7236, 7485, 7587, 7710, 7852, 7937, 8035, 8173, 8316, 8411, 8556, 8657, 8801, 8901, 8994, 9149, 9307, 9412, 9517, 9672, 9833, 9924, 9988, 10000, 10000, 10000, 10000, 10000}, +{370, 381, 405, 418, 436, 450, 471, 491, 509, 534, 560, 587, 619, 654, 696, 721, 761, 820, 899, 950, 1007, 1154, 1321, 1548, 1797, 2025, 2329, 2474, 2617, 2850, 2954, 3169, 3540, 3861, 4097, 4286, 4475, 4642, 4798, 4933, 5066, 5205, 5346, 5501, 5649, 5805, 5960, 6119, 6327, 6416, 6586, 6747, 6841, 6978, 7055, 7172, 7256, 7339, 7476, 7717, 7816, 7935, 8075, 8159, 8252, 8391, 8530, 8628, 8769, 8869, 9013, 9115, 9207, 9359, 9517, 9623, 9724, 9869, 9979, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{383, 396, 421, 438, 454, 473, 493, 515, 539, 564, 593, 624, 657, 702, 762, 807, 885, 985, 1124, 1208, 1293, 1488, 1691, 1892, 2129, 2390, 2694, 2835, 2978, 3229, 3339, 3579, 3950, 4238, 4446, 4615, 4787, 4933, 5079, 5199, 5319, 5448, 5577, 5716, 5853, 6002, 6155, 6314, 6518, 6611, 6774, 6935, 7024, 7158, 7232, 7341, 7421, 7501, 7631, 7865, 7963, 8078, 8213, 8296, 8391, 8527, 8666, 8759, 8902, 9004, 9148, 9250, 9339, 9496, 9657, 9766, 9872, 9980, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{401, 413, 442, 461, 478, 499, 525, 550, 577, 610, 646, 685, 745, 829, 949, 1044, 1189, 1355, 1558, 1667, 1782, 2004, 2191, 2399, 2657, 2927, 3260, 3417, 3566, 3826, 3936, 4155, 4472, 4719, 4896, 5040, 5188, 5323, 5446, 5559, 5668, 5779, 5899, 6030, 6158, 6298, 6444, 6598, 6797, 6886, 7041, 7186, 7265, 7399, 7469, 7572, 7658, 7735, 7863, 8100, 8197, 8315, 8447, 8529, 8615, 8745, 8889, 8980, 9120, 9221, 9366, 9474, 9567, 9722, 9867, 9941, 9986, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{401, 413, 442, 461, 478, 499, 525, 550, 577, 610, 646, 685, 745, 829, 949, 1044, 1189, 1355, 1558, 1667, 1782, 2004, 2191, 2399, 2657, 2927, 3260, 3417, 3566, 3826, 3936, 4155, 4472, 4719, 4896, 5040, 5188, 5323, 5446, 5559, 5668, 5779, 5899, 6030, 6158, 6298, 6444, 6598, 6797, 6886, 7041, 7186, 7265, 7399, 7469, 7572, 7658, 7735, 7863, 8100, 8197, 8315, 8447, 8529, 8615, 8745, 8889, 8980, 9120, 9221, 9366, 9474, 9567, 9722, 9867, 9941, 9986, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{432, 445, 485, 511, 534, 560, 595, 635, 678, 744, 826, 932, 1067, 1256, 1486, 1652, 1893, 2142, 2399, 2526, 2642, 2877, 3085, 3335, 3610, 3877, 4177, 4314, 4432, 4638, 4721, 4893, 5138, 5334, 5474, 5597, 5717, 5837, 5946, 6039, 6133, 6239, 6351, 6472, 6590, 6722, 6867, 7008, 7195, 7273, 7412, 7553, 7625, 7748, 7809, 7910, 7987, 8058, 8183, 8407, 8499, 8614, 8746, 8826, 8915, 9044, 9186, 9277, 9415, 9519, 9666, 9762, 9842, 9954, 9992, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{420, 437, 487, 517, 550, 597, 656, 724, 806, 918, 1057, 1230, 1451, 1721, 2072, 2310, 2608, 2897, 3189, 3330, 3464, 3700, 3908, 4122, 4358, 4572, 4807, 4920, 5019, 5195, 5268, 5422, 5654, 5836, 5971, 6087, 6199, 6306, 6410, 6493, 6579, 6670, 6768, 6872, 6983, 7099, 7228, 7365, 7543, 7619, 7757, 7894, 7964, 8084, 8147, 8246, 8318, 8391, 8512, 8724, 8811, 8920, 9049, 9124, 9217, 9348, 9479, 9565, 9698, 9790, 9895, 9949, 9975, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +{477, 511, 585, 641, 703, 780, 875, 1001, 1144, 1322, 1542, 1802, 2123, 2533, 2971, 3223, 3532, 3813, 4075, 4194, 4314, 4506, 4669, 4843, 5033, 5213, 5419, 5515, 5600, 5750, 5822, 5952, 6153, 6311, 6436, 6537, 6638, 6735, 6825, 6907, 6985, 7077, 7163, 7268, 7367, 7487, 7609, 7742, 7911, 7976, 8111, 8238, 8311, 8413, 8477, 8567, 8643, 8709, 8830, 9040, 9126, 9229, 9351, 9427, 9516, 9632, 9761, 9834, 9919, 9962, 9987, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000}, +}; diff --git a/drivers/power/sd77426_fg_mmi/table.h b/drivers/power/sd77426_fg_mmi/table.h index d89c59e6bc42..50fcf8f332e3 100644 --- a/drivers/power/sd77426_fg_mmi/table.h +++ b/drivers/power/sd77426_fg_mmi/table.h @@ -1,69 +1,69 @@ -/***************************************************************************** -* Copyright(c) O2Micro, 2014. All rights reserved. -* -* O2Micro battery gauge driver -* File: table.h -* -* $Source: /data/code/CVS -* $Revision: 4.00.01 $ -* -* This program is free software and can be edistributed and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This Source Code Reference Design for O2MICRO Battery Gauge access (\u201cReference Design\u201d) -* is sole for the use of PRODUCT INTEGRATION REFERENCE ONLY, and contains confidential -* and privileged information of O2Micro International Limited. O2Micro shall have no -* liability to any PARTY FOR THE RELIABILITY, SERVICEABILITY FOR THE RESULT OF PRODUCT -* INTEGRATION, or results from: (i) any modification or attempted modification of the -* Reference Design by any party, or (ii) the combination, operation or use of the -* Reference Design with non-O2Micro Reference Design. -* -* Battery Manufacture: Lenovo -* Battery Model: BL244 -* Absolute Max Capacity(mAhr): 5158 -* Limited Charge Voltage(mV): 4350 -* Cutoff Discharge Voltage(mV): 3200 -* Equipment: "JY1-8","JY1-4","JY1-4","JY2-8","JY2-8","JY2-8","JY2-5","JY1-1","JY1-1","JY1-8","JY1-8","JY1-8","JY1-8","JY2-5","JY2-5","JY2-5","JY2-5","JY1-8","JY2-8","JY2-8","JY1-8","JY1-2","JY1-2","JY2-6","JY2-6","JY2-6","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY2-7","JY1-3","JY1-3","JY1-6","JY1-6","JY1-6","JY2-8","JY2-5","JY2-5" -* Tester: "SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ" -* Battery ID: "BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-1","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-2","BL244-3","BL244-3","BL244-3","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-4","BL244-1","BL244-2","BL244-02" -* Version = V00.13.00 -* Date = 2015.6.23 -* Comment = -* -*****************************************************************************/ - -#ifndef _TABLE_H_ -#define _TABLE_H_ - - -#define OCV_DATA_NUM 65 -#define CHARGE_DATA_NUM 65 - - -#define XAxis 42 -#define YAxis 7 -#define ZAxis 7 - -#define BATTERY_ID_NUM 52 - - -/**************************************************************************** -* Struct section -* add struct #define here if any -***************************************************************************/ -typedef struct tag_one_latitude_data { - int32_t x;// - int32_t y;// -} one_latitude_data_t; - - -/**************************************************************************** -* extern variable declaration section -***************************************************************************/ -extern const char *battery_id[] ; - -extern const char *table_version; - -#endif - +/***************************************************************************** +* Copyright(c) O2Micro, 2014. All rights reserved. +* +* O2Micro battery gauge driver +* File: table.h +* +* $Source: /data/code/CVS +* $Revision: 4.00.01 $ +* +* This program is free software and can be edistributed and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This Source Code Reference Design for O2MICRO Battery Gauge access (\u201cReference Design\u201d) +* is sole for the use of PRODUCT INTEGRATION REFERENCE ONLY, and contains confidential +* and privileged information of O2Micro International Limited. O2Micro shall have no +* liability to any PARTY FOR THE RELIABILITY, SERVICEABILITY FOR THE RESULT OF PRODUCT +* INTEGRATION, or results from: (i) any modification or attempted modification of the +* Reference Design by any party, or (ii) the combination, operation or use of the +* Reference Design with non-O2Micro Reference Design. +* +* Battery Manufacture: ATL +* Battery Model: M1892 +* Absolute Max Capacity(mAhr): 3661 +* Limited Charge Voltage(mV): 4400 +* Cutoff Discharge Voltage(mV): 3200 +* Equipment: "JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY1-5","JY2-5","JY2-5","JY2-5","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-6","JY2-5","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-8","JY1-8","JY1-8","JY1-8","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-6","JY1-8","JY1-7","JY1-7","JY1-7","JY1-7","JY1-7","JY1-7","JY1-3","JY1-3","JY1-3","JY1-5","JY1-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY2-5","JY1-8","JY1-8","JY1-2","JY1-2","JY1-2","JY2-6","JY2-6","JY2-6" +* Tester: "SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ","SZ" +* Battery ID: "M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_1","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_2","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_3","M1892_4","M1892_4","M1892_4","M1892_2","M1892_2","M1892_2" +* Version = V00.8D.00 +* Date = 2018.3.26 +* Comment = +* +*****************************************************************************/ + +#ifndef _TABLE_H_ +#define _TABLE_H_ + + +#define OCV_DATA_NUM 65 +#define CHARGE_DATA_NUM 65 + + +#define XAxis 86 +#define YAxis 10 +#define ZAxis 9 + +#define BATTERY_ID_NUM 93 + + +/**************************************************************************** +* Struct section +* add struct #define here if any +***************************************************************************/ +typedef struct tag_one_latitude_data { + int32_t x;// + int32_t y;// +} one_latitude_data_t; + + +/**************************************************************************** +* extern variable declaration section +***************************************************************************/ +extern const char *battery_id[] ; + +extern const char *table_version; + +#endif +