[Galaxy Ace S5830i Android Development] Rafael.Baugis:
Samsung scaling batery from 3,4v up to 4,2v fully plugged in charger!

I managed voltage from 3,0v up to 4,2v, but the battery gauge scaling is wrong!

Now I reverted to original!

part1

/*Macros to control schedule frequency of charging monitor work queue - with
* and without charger present */
#define BATTERY_LVL_MON_INTERVAL_WHILE_CHARGING	10000
#define	BATTERY_LVL_MON_INTERVAL	60000 /* 1 min */
//#define BATTERY_LVL_MON_INTERVAL_WHILE_CHARGING	10000 /* 10 sec */
//#define	BATTERY_LVL_MON_INTERVAL	30000 /* 30 sec */
#define BAT_TEMP_EXCEED_LIMIT_COUNT_MAX	3
#define BATTERY_CHARGING_HYSTERESIS	10
#define SUCCESS 0	/* request is successfull */
#define USB_PREENUM_CURR	90
#if defined(CONFIG_BOARD_COOPERVE)
#define USB_PREENUM_CURR_REQ_VAL MAX8986_CHARGING_CURR_550MA
#else
#define USB_PREENUM_CURR_REQ_VAL MAX8986_CHARGING_CURR_450MA
#endif

#if defined(CONFIG_BOARD_COOPERVE)
#define BATT_RECHARGE_VOLT	4120	//4130
#else
#define BATT_RECHARGE_VOLT	4130
#endif

#define BATT_LOW_VOLT	3400

#define BAT_PERCENT_INIT_VALUE 1

#if 0
#define BATT_FULL_VOLT	4200
#define BATT_LEVEL5_VOLT	3970
#define BATT_LEVEL4_VOLT	3870
#define BATT_LEVEL3_VOLT	3790
#define BATT_LEVEL2_VOLT	3740
#define BATT_LEVEL1_VOLT	3700
#define BATT_LEVEL0_VOLT	3600
#define BATT_LEVEL0_1_VOLT	3540
#define BATT_LOW_VOLT	3400
#endif
#if defined(CONFIG_BOARD_COOPERVE)
#define HIGH_SUSPEND_TEMP	600	//Spec was changed from 65 to 60 degree
#define LOW_SUSPEND_TEMP	-40
#define HIGH_RECOVER_TEMP	400	//Spec was changed from 43 to 40
#define LOW_RECOVER_TEMP	0
#else
#define HIGH_SUSPEND_TEMP	650
#define LOW_SUSPEND_TEMP	-50
#define HIGH_RECOVER_TEMP	430
#define LOW_RECOVER_TEMP	0
#endif

part 2

int calculate_batt_level(int batt_volt)
{
struct max8986_power *max8986_power;
int scaled_level = 0;

if(!power_device)
return;
max8986_power = platform_get_drvdata(power_device);
max8986_power->level = 0;

if(batt_volt >= BATT_FULL_VOLT) {	//100%
scaled_level = 100;
max8986_power->level = 6;
}
else if(batt_volt >= BATT_LEVEL5_VOLT) {	//99% ~ 80%
scaled_level = ((batt_volt -BATT_LEVEL5_VOLT+1)*20)/(BATT_FULL_VOLT-BATT_LEVEL5_VOLT);
scaled_level = scaled_level+80;
max8986_power->level = 5;
}
else if(batt_volt >= BATT_LEVEL4_VOLT) {	//79% ~ 65%
scaled_level = ((batt_volt -BATT_LEVEL4_VOLT)*15)/(BATT_LEVEL5_VOLT-BATT_LEVEL4_VOLT);
scaled_level = scaled_level+65;
max8986_power->level = 4;
}
else if(batt_volt >= BATT_LEVEL3_VOLT) {	//64% ~ 50%
scaled_level = ((batt_volt -BATT_LEVEL3_VOLT)*15)/(BATT_LEVEL4_VOLT-BATT_LEVEL3_VOLT);
scaled_level = scaled_level+50;
max8986_power->level = 3;
}
else if(batt_volt >= BATT_LEVEL2_VOLT) {	//49% ~ 35%
scaled_level = ((batt_volt -BATT_LEVEL2_VOLT)*15)/(BATT_LEVEL3_VOLT-BATT_LEVEL2_VOLT);
scaled_level = scaled_level+35;
max8986_power->level = 2;
}
else if(batt_volt >= BATT_LEVEL1_VOLT) {	//34% ~ 20%
scaled_level = ((batt_volt -BATT_LEVEL1_VOLT)*15)/(BATT_LEVEL2_VOLT-BATT_LEVEL1_VOLT);
scaled_level = scaled_level+20;
max8986_power->level = 1;
}
else if(batt_volt >= BATT_LEVEL0_VOLT) {	//19% ~ 5%
scaled_level = ((batt_volt -BATT_LEVEL0_VOLT)*15)/(BATT_LEVEL1_VOLT-BATT_LEVEL0_VOLT);
scaled_level = scaled_level+5;
}
else if(batt_volt >= BATT_LEVEL0_1_VOLT) {	// 4% ~ 3%
scaled_level = ((batt_volt -BATT_LEVEL0_1_VOLT)*2)/(BATT_LEVEL0_VOLT-BATT_LEVEL0_1_VOLT);
scaled_level = scaled_level+3;
}
else if(batt_volt > BATT_LOW_VOLT) {	// 2% ~ 1%
scaled_level = ((batt_volt -BATT_LOW_VOLT)*2)/(BATT_LEVEL0_VOLT-BATT_LOW_VOLT);
scaled_level = scaled_level+1;
}
else {
scaled_level = 1;
}
return scaled_level;
}