mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 12:25:00 -04:00
qg: add sdam-magic-number parameter
add sdam-magic-number parameter to judge if using the different battery profile. we need clear sdam when using different battery profile. Change-Id: I248edf52f767abbadb1934328b88f8048af4a782 Signed-off-by: mahj8 <mahj8@lenovo.com> Reviewed-on: https://gerrit.mot.com/1549720 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Lu Chai <chailu1@motorola.com> Reviewed-by: Yonghua Yan <yanyh2@motorola.com> Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1553272 Reviewed-on: https://gerrit.mot.com/1771064
This commit is contained in:
parent
3b3a3844ac
commit
dc8fd61192
2 changed files with 12 additions and 4 deletions
|
|
@ -21,6 +21,7 @@ struct qg_batt_props {
|
|||
int vbatt_full_mv;
|
||||
int fastchg_curr_ma;
|
||||
int qg_profile_version;
|
||||
u32 sdam_magic_number;
|
||||
};
|
||||
|
||||
struct qg_irq_info {
|
||||
|
|
|
|||
|
|
@ -3037,6 +3037,7 @@ static int get_batt_id_ohm(struct qpnp_qg *chip, u32 *batt_id_ohm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define SDAM_MAGIC_NUMBER 0x12345678
|
||||
static int qg_load_battery_profile(struct qpnp_qg *chip)
|
||||
{
|
||||
struct device_node *node = chip->dev->of_node;
|
||||
|
|
@ -3106,6 +3107,13 @@ static int qg_load_battery_profile(struct qpnp_qg *chip)
|
|||
chip->bp.fastchg_curr_ma = -EINVAL;
|
||||
}
|
||||
|
||||
rc = of_property_read_u32(profile_node, "qcom,sdam-magic-number",
|
||||
&chip->bp.sdam_magic_number);
|
||||
if (rc < 0) {
|
||||
pr_err("Failed to read sdam magic number rc:%d\n", rc);
|
||||
chip->bp.sdam_magic_number = SDAM_MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the max fcc values based on QG subtype including
|
||||
* error margins.
|
||||
|
|
@ -3458,7 +3466,6 @@ static int qg_set_wa_flags(struct qpnp_qg *chip)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define SDAM_MAGIC_NUMBER 0x12345678
|
||||
static int qg_sanitize_sdam(struct qpnp_qg *chip)
|
||||
{
|
||||
int rc = 0;
|
||||
|
|
@ -3470,10 +3477,10 @@ static int qg_sanitize_sdam(struct qpnp_qg *chip)
|
|||
return rc;
|
||||
}
|
||||
|
||||
if (data == SDAM_MAGIC_NUMBER) {
|
||||
if (data == chip->bp.sdam_magic_number) {
|
||||
qg_dbg(chip, QG_DEBUG_PON, "SDAM valid\n");
|
||||
} else if (data == 0) {
|
||||
rc = qg_sdam_write(SDAM_MAGIC, SDAM_MAGIC_NUMBER);
|
||||
rc = qg_sdam_write(SDAM_MAGIC, chip->bp.sdam_magic_number);
|
||||
if (!rc)
|
||||
qg_dbg(chip, QG_DEBUG_PON, "First boot. SDAM initilized\n");
|
||||
chip->first_profile_load = true;
|
||||
|
|
@ -3482,7 +3489,7 @@ static int qg_sanitize_sdam(struct qpnp_qg *chip)
|
|||
rc = qg_sdam_clear();
|
||||
if (!rc) {
|
||||
pr_err("SDAM uninitialized, SDAM reset\n");
|
||||
rc = qg_sdam_write(SDAM_MAGIC, SDAM_MAGIC_NUMBER);
|
||||
rc = qg_sdam_write(SDAM_MAGIC, chip->bp.sdam_magic_number);
|
||||
}
|
||||
chip->first_profile_load = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue