From ffc0a5711ccfd46b2863c916a6c747cbfd52afdb Mon Sep 17 00:00:00 2001 From: Wen Xie Date: Mon, 27 Aug 2018 16:40:52 +0800 Subject: [PATCH] sx9325: When system suspend,disable hardware irq scan. - the current driver only disable system irq, and not disable hardware irq,maybe cause irq imbalances; - update reset method. Change-Id: I14bea213005916ae858f492f6893a08c2d821fd3 Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1233351 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Nan Wu Reviewed-by: Wang Wang Submit-Approved: Jira Key --- drivers/misc/sx9325/sx9325_sar.c | 36 +++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/misc/sx9325/sx9325_sar.c b/drivers/misc/sx9325/sx9325_sar.c index 33355481760b..b60b76398c5c 100644 --- a/drivers/misc/sx9325/sx9325_sar.c +++ b/drivers/misc/sx9325/sx9325_sar.c @@ -941,11 +941,19 @@ static void ps_notify_callback_work(struct work_struct *work) input_top = pDevice->pbuttonInformation->input_top; input_bottom = pDevice->pbuttonInformation->input_bottom; - LOG_INFO("Usb insert,going to force calibrate\n"); - ret = write_register(this, SX932x_STAT2_REG, 0x0f); - if (ret < 0) - LOG_ERR(" Usb insert,calibrate cap sensor failed\n"); - + mutex_lock(&this->mutex); + if (mEnabled) { + LOG_INFO("Usb insert,going to force calibrate\n"); + ret = write_register(this, SX932x_CTRL1_REG, 0x00); + if (ret < 0) + LOG_ERR(" Usb insert,calibrate cap sensor failed\n"); + msleep(100); + ret = write_register(this, SX932x_CTRL1_REG, + this->board->cust_prox_ctrl0); + if (ret < 0) + LOG_ERR(" Usb insert,enabel cap sensor failed\n"); + } + mutex_unlock(&this->mutex); input_report_abs(input_top, ABS_DISTANCE, 0); input_sync(input_top); input_report_abs(input_bottom, ABS_DISTANCE, 0); @@ -1618,15 +1626,29 @@ static void sx93XX_worker_func(struct work_struct *work) void sx93XX_suspend(psx93XX_t this) { if (this) { - LOG_INFO("sx9325 suspend: disable irq!\n"); + write_register(this, SX932x_CTRL1_REG, + this->board->cust_prox_ctrl0&0xdf); + if (sx9325_debug_enable) + LOG_INFO("sx9325 suspend: disable irq!\n"); disable_irq(this->irq); } } void sx93XX_resume(psx93XX_t this) { if (this) { - LOG_INFO("sx9325 resume: enable irq!\n"); + if (sx9325_debug_enable) + LOG_INFO("sx9325 resume: enable irq!\n"); +#ifdef USE_THREADED_IRQ + mutex_lock(&this->mutex); + /* Just in case need to reset any uncaught interrupts */ + sx93XX_process_interrupt(this, 0); + mutex_unlock(&this->mutex); +#else + sx93XX_schedule_work(this, 0); +#endif enable_irq(this->irq); + write_register(this, SX932x_CTRL1_REG, + this->board->cust_prox_ctrl0|0x20); } }