qpnp-fg-gen3: expose a fake battery SOC for debug board

When a debug board is present, battery ID will be something like
7 Kohms. Expose a fake battery SOC when this is detected. This
will help avoiding the device shutdown if a low battery voltage
is seen by FG and state of charge goes to 0.

Change-Id: I750b2adfb00f12960f74bd552a5896f66ecaece6
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2016-11-03 12:02:52 -07:00
parent 85d7e134cc
commit e5f967c5a9
2 changed files with 27 additions and 4 deletions

View file

@ -222,7 +222,6 @@ struct fg_batt_props {
int float_volt_uv;
int vbatt_full_mv;
int fastchg_curr_ma;
int batt_id_kohm;
};
struct fg_cyc_ctr_data {
@ -278,7 +277,7 @@ struct fg_chip {
u32 batt_soc_base;
u32 batt_info_base;
u32 mem_if_base;
int batt_id;
int batt_id_kohms;
int status;
int charge_done;
int last_soc;

View file

@ -655,12 +655,36 @@ static int fg_get_msoc_raw(struct fg_chip *chip, int *val)
return 0;
}
#define DEBUG_BATT_ID_KOHMS 7
static bool is_debug_batt_id(struct fg_chip *chip)
{
int batt_id_delta = 0;
if (!chip->batt_id_kohms)
return false;
batt_id_delta = abs(chip->batt_id_kohms - DEBUG_BATT_ID_KOHMS);
if (batt_id_delta <= 1) {
fg_dbg(chip, FG_POWER_SUPPLY, "Debug battery id: %dKohms\n",
chip->batt_id_kohms);
return true;
}
return false;
}
#define FULL_CAPACITY 100
#define FULL_SOC_RAW 255
#define DEBUG_BATT_SOC 67
static int fg_get_prop_capacity(struct fg_chip *chip, int *val)
{
int rc, msoc;
if (is_debug_batt_id(chip)) {
*val = DEBUG_BATT_SOC;
return 0;
}
if (chip->charge_full) {
*val = FULL_CAPACITY;
return 0;
@ -725,7 +749,7 @@ static int fg_get_batt_profile(struct fg_chip *chip)
}
batt_id /= 1000;
chip->batt_id = batt_id;
chip->batt_id_kohms = batt_id;
batt_node = of_find_node_by_name(node, "qcom,battery-data");
if (!batt_node) {
pr_err("Batterydata not available\n");
@ -2612,7 +2636,7 @@ static int fg_parse_dt(struct fg_chip *chip)
rc = fg_get_batt_profile(chip);
if (rc < 0)
pr_warn("profile for batt_id=%dKOhms not found..using OTP, rc:%d\n",
chip->batt_id, rc);
chip->batt_id_kohms, rc);
/* Read all the optional properties below */
rc = of_property_read_u32(node, "qcom,fg-cutoff-voltage", &temp);