power: pm8921-bms: handle restart without pmic power on

There are situation when the system undergoes a restart but the
pmic does not execute its power on sequence. In such case the OCV
value is not updated and the CC value is not cleared. Since OCV
and CC values came from the previous boot, we don't have to use
shutdown soc in this case. The use of shutdown soc without reset
of CC increase error of soc. So this patch remove use of shutdown
soc in restart case.

b/7327066

Change-Id: I2c5c5974a4c8ace076c1f8c56c856718b7140fb8
This commit is contained in:
choongryeol.lee
2012-10-22 14:47:48 -07:00
committed by Iliyan Malchev
parent c1e865f993
commit ccbdadfb5e

View File

@@ -55,6 +55,8 @@
#define TEMP_IAVG_STORAGE 0x105
#define TEMP_IAVG_STORAGE_USE_MASK 0x0F
#define CC_RAW_5MAH 0x00110000
enum pmic_bms_interrupts {
PM8921_BMS_SBI_WRITE_OK,
PM8921_BMS_CC_THR,
@@ -1005,7 +1007,6 @@ static int ocv_ir_compensation(struct pm8921_bms_chip *chip, int ocv)
return compensated_ocv;
}
static int read_soc_params_raw(struct pm8921_bms_chip *chip,
struct pm8921_soc_params *raw)
{
@@ -1031,6 +1032,13 @@ static int read_soc_params_raw(struct pm8921_bms_chip *chip,
raw->last_good_ocv_uv = ocv_ir_compensation(chip,
raw->last_good_ocv_uv);
chip->last_ocv_uv = raw->last_good_ocv_uv;
if (raw->cc > CC_RAW_5MAH) {
shutdown_soc_invalid = 1;
pr_info("cc_raw = 0x%x greater than 5mAh 0x%x\n",
raw->cc, CC_RAW_5MAH);
}
pr_debug("PON_OCV_UV = %d\n", chip->last_ocv_uv);
} else if (chip->prev_last_good_ocv_raw != raw->last_good_ocv_raw) {
chip->prev_last_good_ocv_raw = raw->last_good_ocv_raw;
@@ -2155,8 +2163,8 @@ static int calculate_state_of_charge(struct pm8921_bms_chip *chip,
- cc_uah
- unusable_charge_uah;
soc = DIV_ROUND_CLOSEST((remaining_usable_charge_uah * 100),
(fcc_uah - unusable_charge_uah));
soc = (remaining_usable_charge_uah * 100)/
(fcc_uah - unusable_charge_uah);
pr_debug("DONE for shutdown_soc = %d soc is %d, adjusted ocv to %duV\n",
shutdown_soc, soc, chip->last_ocv_uv);