mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
charging: add sem lock to protect dpdm detected
In some case, quickly remove and insert qc3 charger, it can't detected qc3 charger, so need to add sem lock to protect dpdm when qc3 detected. Change-Id: I4cef829648a7e09edabbedb71fcd868064fd5bb9 Signed-off-by: mahj8 <mahj8@motorola.com> Reviewed-on: https://gerrit.mot.com/2136191 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
98374fea4d
commit
1d6b347ce3
3 changed files with 25 additions and 6 deletions
|
|
@ -164,6 +164,7 @@ struct bq2589x {
|
|||
|
||||
/*mmi qc3*/
|
||||
bool mmi_qc3_support;
|
||||
struct semaphore sem_dpdm;
|
||||
struct task_struct *mmi_qc3_authen_task;
|
||||
wait_queue_head_t mmi_qc3_wait_que;
|
||||
bool mmi_qc3_trig_flag;
|
||||
|
|
@ -1708,6 +1709,8 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
if (kthread_should_stop())
|
||||
break;
|
||||
|
||||
down(&bq->sem_dpdm);
|
||||
dev_info(bq->dev, "mmi_hvdcp_detect_kthread begin\n");
|
||||
bq->mmi_qc3_trig_flag = false;
|
||||
bq->mmi_is_qc3_authen = true;
|
||||
bq2589x_set_input_current_limit(bq, MMI_HVDCP_DETECT_ICL_LIMIT);
|
||||
|
|
@ -1740,6 +1743,8 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
out:
|
||||
bq2589x_set_input_current_limit(bq, bq->input_current_cache);
|
||||
bq->mmi_is_qc3_authen = false;
|
||||
up(&bq->sem_dpdm);
|
||||
dev_info(bq->dev, "mmi_hvdcp_detect_kthread end\n");
|
||||
}while(!kthread_should_stop());
|
||||
|
||||
dev_dbg(bq->dev, "qc3 kthread stop\n");
|
||||
|
|
@ -1748,14 +1753,16 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
|
||||
static void mmi_start_hvdcp_detect(struct bq2589x *bq)
|
||||
{
|
||||
dev_err(bq->dev, "start hvdcp detect\n");
|
||||
|
||||
if (bq->mmi_qc3_support
|
||||
&& bq->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP
|
||||
&& !bq->mmi_is_qc3_authen) {
|
||||
&& bq->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP) {
|
||||
//down(&bq->sem_dpdm);
|
||||
dev_info(bq->dev, "start hvdcp detect\n");
|
||||
bq->mmi_qc3_trig_flag = true;
|
||||
wake_up_interruptible(&bq->mmi_qc3_wait_que);
|
||||
//up(&bq->sem_dpdm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void bq2589x_adapter_in_func(struct bq2589x *bq)
|
||||
|
|
@ -1766,8 +1773,10 @@ static void bq2589x_adapter_in_func(struct bq2589x *bq)
|
|||
bq->vbus_type == BQ2589X_VBUS_NONSTAND ||
|
||||
bq->vbus_type == BQ2589X_VBUS_UNKNOWN)
|
||||
&& (!bq->typec_apsd_rerun_done)) {
|
||||
down(&bq->sem_dpdm);
|
||||
dev_err(bq->dev, "rerun apsd for 0x%x\n", bq->vbus_type);
|
||||
bq2589x_rerun_apsd_if_required(bq);
|
||||
up(&bq->sem_dpdm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2367,6 +2376,8 @@ static int bq2589x_charger_probe(struct i2c_client *client,
|
|||
|
||||
g_bq = bq;
|
||||
|
||||
sema_init(&bq->sem_dpdm, 1);
|
||||
|
||||
if (client->dev.of_node)
|
||||
bq2589x_parse_dt(&client->dev, bq);
|
||||
|
||||
|
|
|
|||
|
|
@ -1439,6 +1439,8 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
if (kthread_should_stop())
|
||||
break;
|
||||
|
||||
down(&sgm->sem_dpdm);
|
||||
dev_info(sgm->dev, "mmi_hvdcp_detect_kthread begin\n");
|
||||
sgm->mmi_qc3_trig_flag = false;
|
||||
sgm->mmi_is_qc3_authen = true;
|
||||
sgm4154x_set_input_curr_lim(sgm, MMI_HVDCP_DETECT_ICL_LIMIT);
|
||||
|
|
@ -1471,6 +1473,8 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
out:
|
||||
sgm4154x_set_input_curr_lim(sgm, sgm->input_current_cache);
|
||||
sgm->mmi_is_qc3_authen = false;
|
||||
up(&sgm->sem_dpdm);
|
||||
dev_info(sgm->dev, "mmi_hvdcp_detect_kthread end\n");
|
||||
}while(!kthread_should_stop());
|
||||
|
||||
dev_dbg(sgm->dev, "qc3 kthread stop\n");
|
||||
|
|
@ -1479,11 +1483,10 @@ static int mmi_hvdcp_detect_kthread(void *param)
|
|||
|
||||
static void mmi_start_hvdcp_detect(struct sgm4154x_device *sgm)
|
||||
{
|
||||
dev_err(sgm->dev, "start hvdcp detect\n");
|
||||
|
||||
if (sgm->mmi_qc3_support
|
||||
&& sgm->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP
|
||||
&& !sgm->mmi_is_qc3_authen) {
|
||||
&& sgm->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP) {
|
||||
dev_info(sgm->dev, "start hvdcp detect\n");
|
||||
sgm->mmi_qc3_trig_flag = true;
|
||||
wake_up_interruptible(&sgm->mmi_qc3_wait_que);
|
||||
}
|
||||
|
|
@ -1536,8 +1539,10 @@ static void charger_detect_work_func(struct work_struct *work)
|
|||
(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;
|
||||
}
|
||||
|
||||
|
|
@ -2353,6 +2358,8 @@ static int sgm4154x_probe(struct i2c_client *client,
|
|||
return ret;
|
||||
}
|
||||
|
||||
sema_init(&sgm->sem_dpdm, 1);
|
||||
|
||||
// Customer customization
|
||||
ret = sgm4154x_parse_dt(sgm);
|
||||
if (ret) {
|
||||
|
|
|
|||
|
|
@ -324,6 +324,7 @@ struct sgm4154x_device {
|
|||
|
||||
/*mmi qc3*/
|
||||
bool mmi_qc3_support;
|
||||
struct semaphore sem_dpdm;
|
||||
struct task_struct *mmi_qc3_authen_task;
|
||||
wait_queue_head_t mmi_qc3_wait_que;
|
||||
bool mmi_qc3_trig_flag;
|
||||
|
|
|
|||
Loading…
Reference in a new issue