mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
charging: avoid to report usb type before apsd done
don't report usb type before rerun apsd done, to avoid input current limit auto changed to 500ma by charger IC. Change-Id: If148bded78a3ae8a628353ca70c7fa15f2b1363c Signed-off-by: mahj8 <mahj8@motorola.com> Reviewed-on: https://gerrit.mot.com/2154207 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
264b8e8d71
commit
5a998abf5d
3 changed files with 30 additions and 11 deletions
|
|
@ -2303,6 +2303,8 @@ static void bq2589x_charger_irq_workfunc(struct work_struct *work)
|
|||
bool reapsd_complete = false;
|
||||
|
||||
ret = bq2589x_sync_state(bq, &state);
|
||||
if (ret < 0)
|
||||
return;
|
||||
mutex_lock(&bq->lock);
|
||||
bq->state = state;
|
||||
mutex_unlock(&bq->lock);
|
||||
|
|
|
|||
|
|
@ -749,7 +749,7 @@ static int sgm4154x_get_state(struct sgm4154x_device *sgm,
|
|||
if (ret){
|
||||
ret = regmap_read(sgm->regmap, SGM4154x_CHRG_STAT, &chrg_stat);
|
||||
if (ret){
|
||||
pr_err("%s read SGM4154x_CHRG_STAT fail\n",__func__);
|
||||
pr_err("%s read SGM4154x_CHRG_STAT fail: %d\n",__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
@ -1349,7 +1349,7 @@ static void sgm4154x_rerun_apsd_work_func(struct work_struct *work)
|
|||
if (rc < 0)
|
||||
dev_err(sgm->dev, "Couldn't to enable DPDM rc=%d\n", rc);
|
||||
|
||||
sgm->typec_apsd_rerun_done = true;
|
||||
sgm->typec_apsd_rerun_status = MMI_APSD_RERUN_START;
|
||||
sgm4154x_rerun_apsd(sgm);
|
||||
|
||||
while(check_count < 10) {
|
||||
|
|
@ -1362,6 +1362,7 @@ static void sgm4154x_rerun_apsd_work_func(struct work_struct *work)
|
|||
check_count ++;
|
||||
}
|
||||
|
||||
sgm->typec_apsd_rerun_status = MMI_APSD_RERUN_DONE;
|
||||
schedule_work(&sgm->charge_detect_work);
|
||||
}
|
||||
|
||||
|
|
@ -1424,7 +1425,7 @@ static void sgm4154x_vbus_remove(struct sgm4154x_device * sgm)
|
|||
qc3p_update_policy(sgm);
|
||||
#endif
|
||||
sgm->pulse_cnt = 0;
|
||||
sgm->typec_apsd_rerun_done = false;
|
||||
sgm->typec_apsd_rerun_status = MMI_APSD_RERUN_NO_START;
|
||||
sgm->chg_dev->noti.apsd_done = false;
|
||||
sgm->chg_dev->noti.hvdcp_done = false;
|
||||
sgm->real_charger_type = POWER_SUPPLY_TYPE_UNKNOWN;
|
||||
|
|
@ -1713,6 +1714,9 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
__pm_stay_awake(sgm->charger_wakelock);
|
||||
|
||||
ret = sgm4154x_get_state(sgm, &state);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
mutex_lock(&sgm->lock);
|
||||
sgm->state = state;
|
||||
mutex_unlock(&sgm->lock);
|
||||
|
|
@ -1742,13 +1746,20 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
#if defined(__SGM41542_CHIP_ID__)|| defined(__SGM41516D_CHIP_ID__)
|
||||
if (((sgm->state.chrg_type == SGM4154x_USB_SDP) ||
|
||||
(sgm->state.chrg_type == SGM4154x_NON_STANDARD) ||
|
||||
(sgm->state.chrg_type == SGM4154x_UNKNOWN))
|
||||
&& (!sgm->typec_apsd_rerun_done)) {
|
||||
down(&sgm->sem_dpdm);
|
||||
dev_err(sgm->dev, "rerun apsd for 0x%x\n", sgm->state.chrg_type);
|
||||
schedule_work(&sgm->rerun_apsd_work);
|
||||
up(&sgm->sem_dpdm);
|
||||
goto err;
|
||||
(sgm->state.chrg_type == SGM4154x_UNKNOWN))) {
|
||||
|
||||
if (sgm->typec_apsd_rerun_status == MMI_APSD_RERUN_NO_START) {
|
||||
down(&sgm->sem_dpdm);
|
||||
dev_err(sgm->dev, "rerun apsd for 0x%x\n", sgm->state.chrg_type);
|
||||
sgm->typec_apsd_rerun_status = MMI_APSD_RERUN_START;
|
||||
schedule_work(&sgm->rerun_apsd_work);
|
||||
up(&sgm->sem_dpdm);
|
||||
goto err;
|
||||
} else if (sgm->typec_apsd_rerun_status != MMI_APSD_RERUN_DONE) {
|
||||
dev_info(sgm->dev, "wait for rerun apsd done\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch(sgm->state.chrg_type) {
|
||||
|
|
|
|||
|
|
@ -227,6 +227,12 @@ enum {
|
|||
MMI_POWER_SUPPLY_DP_DM_DM_PULSE = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
MMI_APSD_RERUN_NO_START = 0,
|
||||
MMI_APSD_RERUN_START = 1,
|
||||
MMI_APSD_RERUN_DONE = 2,
|
||||
};
|
||||
|
||||
struct sgm4154x_iio {
|
||||
struct iio_channel *usbin_v_chan;
|
||||
};
|
||||
|
|
@ -323,7 +329,7 @@ struct sgm4154x_device {
|
|||
struct regulator *otg_vbus_reg;
|
||||
struct mutex regulator_lock;
|
||||
bool dpdm_enabled;
|
||||
bool typec_apsd_rerun_done;
|
||||
int typec_apsd_rerun_status;
|
||||
int real_charger_type;
|
||||
|
||||
struct work_struct rerun_apsd_work;
|
||||
|
|
|
|||
Loading…
Reference in a new issue