From 40eb7e6dd710bcb168c88810a21debf56fd4316d Mon Sep 17 00:00:00 2001 From: litong Date: Mon, 20 Jul 2020 17:55:57 +0800 Subject: [PATCH] Initialize usb state when registering the usb notification If power supply supplier registered brfore touchscreen, ps_notify_callback will not receive PSY_EVENT_PROP_ADDED event, and will cause miss to set TP into charger state. So check PS state in probe. NO_PROP_NEEDED: Change-Id: Ib2c190fe06bc9167a5e0108304e34389aa16ff5b Reviewed-on: https://gerrit.mot.com/1685838 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jichao Zou Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- .../touchscreen_mmi/touchscreen_mmi_notif.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_notif.c b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_notif.c index 66d2ef1c70cc..2f144fabcd31 100644 --- a/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_notif.c +++ b/drivers/input/touchscreen/touchscreen_mmi/touchscreen_mmi_notif.c @@ -309,7 +309,7 @@ static int ts_mmi_refresh_rate_cb(struct notifier_block *nb, return 0; } -static int ts_mmi_ps_get_state(struct power_supply *psy, bool *present) +static inline int ts_mmi_ps_get_state(struct power_supply *psy, bool *present) { union power_supply_propval pval = {0}; int ret; @@ -424,10 +424,25 @@ int ts_mmi_notifiers_register(struct ts_mmi_dev *touch_cdev) goto FIFO_ALLOC_FAILED; if (touch_cdev->pdata.usb_detection) { + struct power_supply *psy = NULL; + bool present; touch_cdev->ps_notif.notifier_call = ts_mmi_charger_cb; ret = power_supply_reg_notifier(&touch_cdev->ps_notif); if (ret) goto PS_NOTIF_REGISTER_FAILED; + + psy = power_supply_get_by_name("usb"); + if (psy) { + ret = ts_mmi_ps_get_state(psy, &present); + if (!ret) { + touch_cdev->ps_is_present = present; + kfifo_put(&touch_cdev->cmd_pipe, TS_MMI_DO_PS); + schedule_delayed_work(&touch_cdev->work, 0); + } + power_supply_put(psy); + dev_info(DEV_MMI, "%s: USB initial status=%d\n", + __func__, touch_cdev->ps_is_present); + } } /*