From 8a8052a6769ccd5c60d0bb2e6b2c8cc7aee1c229 Mon Sep 17 00:00:00 2001 From: tinno18 Date: Wed, 30 Mar 2022 16:20:19 +0800 Subject: [PATCH] Hawao: Fix NFC power consumption in sleep mode. [Cause of problem] Logic of NFC HAL: after sending the commands, HAL will pull down NFC GPIO0 and notify NFC chip that it can sleep after wait for 1 second. If power key is pressed, AP will sleeps quickly, so that the 1 second timeout processing of NFC HAL can not be executed, so the NFC chip cannot sleep. But there is no issue if enter sleep is by screen auto time-out [Solution] In the NFc driver suspend call, check whether the hal has pulled down NFC GPIO0. If not, prevent the system go to sleep 1 second. [Side-effect] None (The time to prevent go to sleep is 1 second, this can be ignored in power consumption) Change-Id: If344d4510b02fef66bb23bfe05942c20280b9e02 Reviewed-on: https://gerrit.mot.com/2229464 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wang Wang Reviewed-by: Zhenghai Pan Reviewed-by: Submit-Approved: Jira Key --- drivers/nfc/samsung/sec_nfc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nfc/samsung/sec_nfc.c b/drivers/nfc/samsung/sec_nfc.c index 33eaa8358a6b..b934f996997d 100644 --- a/drivers/nfc/samsung/sec_nfc.c +++ b/drivers/nfc/samsung/sec_nfc.c @@ -810,13 +810,20 @@ static const struct file_operations sec_nfc_fops = { static int sec_nfc_suspend(struct device *dev) { struct sec_nfc_info *info = SEC_NFC_GET_INFO(dev); + struct sec_nfc_platform_data *pdata = info->pdata; int ret = 0; + int value = 0; mutex_lock(&info->mutex); if (info->mode == SEC_NFC_MODE_BOOTLOADER) ret = -EPERM; + value = gpio_get_value(pdata->wake); + if(value > 0){ + pr_info("%s: hal is still active, block suspend.\n", __func__); + ret = -EPERM; + } mutex_unlock(&info->mutex); return ret;