static BOOL __ds2746_battery_adc_udpate(struct battery_type *battery) { UINT8 reg[12]; if (!__ds2746_get_reg_data((UINT8 *) ®)) { printk(DRIVER_ZONE " get ds2746 data failed...\n"); return FALSE; } #if HTC_ENABLE_POWER_DEBUG printk(DRIVER_ZONE " [x0]%x [x8]%x %x %x %x %x %x %x %x %x %x\n", reg[0], reg[2], reg[3], reg[4], reg[5], reg[6], reg[7], reg[8], reg[9], reg[10], reg[11]); #endif if (!(reg[0] & DS2746_STATUS_AIN0) || !(reg[0] & DS2746_STATUS_AIN1)) { printk(DRIVER_ZONE " AIN not ready...\n"); return FALSE; } if (reg[0] & DS2746_STATUS_PORF) { battery->is_power_on_reset = TRUE; } else{ battery->is_power_on_reset = FALSE; } /* adc register value*/ battery->voltage_adc = MAKEWORD(reg[7], reg[6]) >> 4; battery->current_adc = MAKEWORD(reg[9], reg[8]); if (battery->current_adc & 0x8000) { battery->current_adc = -(0x10000 - battery->current_adc); } battery->current_adc /= 4; battery->charge_counter_adc = MAKEWORD(reg[11], reg[10]); if (battery->charge_counter_adc & 0x8000) { battery->charge_counter_adc = -(0x10000 - battery->charge_counter_adc); } battery->id_adc = MAKEWORD(reg[5], reg[4]) >> 4; battery->temp_adc = MAKEWORD(reg[3], reg[2]) >> 4; if (support_ds2746_gauge_ic) { /* we preserve 500mAh for capacity lower than 0%, however the 500mAh is still drained out...we need to do predict for correct ACR*/ if ((battery->charge_counter_adc & 0xFFFF) >= 0xF000){ printk(DRIVER_ZONE " ACR out of range (x%x)...\n", battery->charge_counter_adc); battery->is_power_on_reset = TRUE; } } return TRUE; }
static BOOL __ds2746_battery_adc_udpate(struct battery_type *battery) { UINT8 reg[12]; if (!__ds2746_get_reg_data((UINT8 *) ®)) { printk(DRIVER_ZONE " get ds2746 data failed...\n"); return FALSE; } #if HTC_PARAM_DS2746_DEBUG_ENABLE printk(DRIVER_ZONE " [x0]%x [x8]%x %x %x %x %x %x %x %x %x %x\n", reg[0], reg[2], reg[3], reg[4], reg[5], reg[6], reg[7], reg[8], reg[9], reg[10], reg[11]); #endif if (!(reg[0] & DS2746_STATUS_AIN0) || !(reg[0] & DS2746_STATUS_AIN1)) { printk(DRIVER_ZONE " AIN not ready...\n"); return FALSE; } if (reg[0] & DS2746_STATUS_PORF) { battery->is_power_on_reset = TRUE; } else{ battery->is_power_on_reset = FALSE; } battery->voltage_adc = MAKEWORD(reg[7], reg[6]) >> 4; battery->current_adc = MAKEWORD(reg[9], reg[8]); if (battery->current_adc & 0x8000) { battery->current_adc = -(0x10000 - battery->current_adc); } battery->current_adc /= 4; battery->charge_counter_adc = MAKEWORD(reg[11], reg[10]); if (battery->charge_counter_adc & 0x8000) { battery->charge_counter_adc = -(0x10000 - battery->charge_counter_adc); } battery->id_adc = MAKEWORD(reg[5], reg[4]) >> 4; battery->temp_adc = MAKEWORD(reg[3], reg[2]) >> 4; if (support_ds2746_gauge_ic) { if ((battery->charge_counter_adc & 0xFFFF) >= 0xF000){ printk(DRIVER_ZONE " ACR out of range (x%x)...\n", battery->charge_counter_adc); battery->is_power_on_reset = TRUE; } } return TRUE; }