charging: optimize PD capacity select algorithm

In order to be compatible with more 3rd PD charger, optimize
PD capacity select algorithm.

Change-Id: Ieab59321a9ca300bb1e12b1f7b6a12d0f4ade707
Signed-off-by: Haijian Ma <mahj8@motorola.com>
Reviewed-on: https://gerrit.mot.com/2280621
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Lu Chai <chailu1@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Haijian Ma 2022-05-26 17:16:24 +08:00
commit fb5f11ae52
2 changed files with 7 additions and 1 deletions

View file

@ -959,6 +959,8 @@ int mmi_charger_update_pd_capacity(struct mmi_charger_manager *chip)
int ret = 0, i = 0;
int maxwatt = 0, max_mv = 0, max_ma = 0;
chip->pd_pps_support = false;
chip->mmi_pd_pdo_idx = 0;
ret = mmi_charger_read_iio_chan(chip, SMB5_USB_PD_ACTIVE, &val.intval);
if (ret) {
mmi_chrg_err(chip, "Unable to read PD ACTIVE: %d\n", ret);
@ -988,10 +990,13 @@ int mmi_charger_update_pd_capacity(struct mmi_charger_manager *chip)
for (i = 0; i < chip->mmi_pdo_info.nr; i++) {
if ((chip->mmi_pdo_info.type[i] == MMI_PD_APDO)
&& (chip->mmi_pdo_info.max_mv[i] * 1000) >= PUMP_CHARGER_PPS_MIN_VOLT
&& (chip->mmi_pdo_info.max_mv[i] * 1000) <= PUMP_CHARGER_PPS_MAX_VOLT
&& (chip->mmi_pdo_info.ma[i] * 1000) >= chip->typec_middle_current) {
chip->pd_pps_support = true;
if ((chip->mmi_pdo_info.max_mv[i] * 1000) > PUMP_CHARGER_PPS_MAX_VOLT) {
chip->mmi_pdo_info.max_mv[i] = PUMP_CHARGER_PPS_MAX_VOLT / 1000;
chip->mmi_pdo_info.maxwatt[i] = chip->mmi_pdo_info.ma[i] * chip->mmi_pdo_info.max_mv[i];
}
if (maxwatt == 0) {
maxwatt = chip->mmi_pdo_info.maxwatt[i];

View file

@ -262,6 +262,7 @@ static void clear_chg_manager(struct mmi_charger_manager *chip)
chip->batt_therm_cooling = false;
chip->batt_therm_cooling_cnt = 0;
chip->pps_start = false;
chip->mmi_pd_pdo_idx = 0;
memset(&chip->mmi_pdo_info, 0,
sizeof(struct adapter_power_cap));