qc3p:Set AICL thres at qc3p pmic charging

At hvdcp more than 15w project.
AICL threshold will set to higher than 5V
which result pmic charging current unstable.

Change-Id: If1a0e9174dbaf5df656442bbdd1247b231636c48
Signed-off-by: xuwei9 <xuwei9@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1980875
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
xuwei9 2021-06-16 13:00:11 +08:00 • committed by Wei Xu
commit 1c1bf99fc9

View file

@ -367,10 +367,10 @@ void mmi_chrg_enable_all_cp(struct mmi_charger_manager *chip, int val)
#define DISABLE_CHRG_LIMIT -1
#define CP_CHRG_SOC_LIMIT 90
#define PD_CONT_PWR_CNT 5
#define AICL_DEFALLT_THREHOLD 4500
#define QC3P_V_STEP 20000
#define CURR_TO_VOLT_STEP 5
#define DEFAULT_HVDCP_POWER_MAX 15000
void mmi_chrg_policy_clear(struct mmi_charger_manager *chip) {
struct mmi_cp_policy_dev *chrg_list = &g_chrg_list;
chrg_dev_init(chip, &g_chrg_list);
@ -389,6 +389,35 @@ void mmi_chrg_policy_clear(struct mmi_charger_manager *chip) {
return;
}
int qc3p_config_aicl_threshold(struct mmi_charger_manager *chip, int threshold)
{
int rc;
union power_supply_propval prop = {0,};
int prev_threshold = 0;
if(threshold < AICL_DEFALLT_THREHOLD)
return -1;
if(!chip->batt_psy) {
chip->batt_psy = power_supply_get_by_name("qcom_battery");
if(!chip->batt_psy)
return -ENODEV;
}
rc = power_supply_get_property(chip->batt_psy,
POWER_SUPPLY_PROP_QC3P_AICL_THRESHOLD,&prop);
if(!rc)
prev_threshold = prop.intval;
if(threshold != prev_threshold){
prop.intval = threshold;
rc = power_supply_set_property(chip->batt_psy,
POWER_SUPPLY_PROP_QC3P_AICL_THRESHOLD, &prop);
}
return 0;
}
static void mmi_chrg_sm_work_func(struct work_struct *work)
{
struct mmi_charger_manager *chip = container_of(work,
@ -717,6 +746,10 @@ static void mmi_chrg_sm_work_func(struct work_struct *work)
mmi_chrg_dbg(chip, PR_MOTO, "Continue to SW charging, "
"vbatt %d uV, ibatt %d uA\n",
vbatt_volt, ibatt_curr);
if(chip->hvdcp_power_max > DEFAULT_HVDCP_POWER_MAX)
qc3p_config_aicl_threshold(chip,AICL_DEFALLT_THREHOLD);
heartbeat_dely_ms = HEARTBEAT_lOOP_WAIT_MS;
}
break;