diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2020-08-22 10:40:30 +0800 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2020-08-28 11:35:10 +0800 |
commit | d7b31b66781bdc1712889ae0a40b368c393544bd (patch) | |
tree | 11c8f1bd826100157a8335b9d76639115dc19b29 | |
parent | c30d8961c92da496ca42f141bfe5ab9d38da616c (diff) |
ANDROID: crqgt4: add simple suspend/resume hooklinaro-m4-squid-2020_08_28
Right now, touch will stop working after a suspend/resume cycle, if we
try to wake up system with a screen tap. This is because crqgt4
interrupt handler starts running earlier than it should when system
resumes. Due to the pending crqgt4 interrupt, the handler gets running
right away before I2C bus driver is resumed, and hence causes the issue.
It adds a pair of pm hooks to disable the interrupt (in software) on
suspend and enable it back on resume, so that the interrupt handler
will starts running only after I2C & crqgt4 driver are fully resumed.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-rw-r--r-- | drivers/square/crqgt4-i2c/crqgt4-i2c.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/square/crqgt4-i2c/crqgt4-i2c.c b/drivers/square/crqgt4-i2c/crqgt4-i2c.c index 23a39c8053aa..a0c63069a1d6 100644 --- a/drivers/square/crqgt4-i2c/crqgt4-i2c.c +++ b/drivers/square/crqgt4-i2c/crqgt4-i2c.c @@ -2245,6 +2245,33 @@ static int gt4_remove(struct i2c_client *client) return 0; } + +static int __maybe_unused gt4_suspend(struct device *dev) +{ + struct gt4_drvdata *drvdata = dev_get_drvdata(dev); + + /* + * The call disable_irq() is here to avoid undesired running of + * IRQ handler gt4_interrupt() before the driver gets resumed. + * The IRQ is actually left unmasked in hardware, as we enable + * it as a wake-up source. + */ + disable_irq(drvdata->irq); + + return 0; +} + +static int __maybe_unused gt4_resume(struct device *dev) +{ + struct gt4_drvdata *drvdata = dev_get_drvdata(dev); + + enable_irq(drvdata->irq); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(gt4_pm, gt4_suspend, gt4_resume); + /*****************************************************************************/ static const struct i2c_device_id gt4_i2c_id[] = { { "crqgt4-i2c", 0 }, @@ -2266,6 +2293,7 @@ static struct i2c_driver gt4_i2c_driver = { .name = gt4_driver_name, .owner = THIS_MODULE, .of_match_table = crqgt4_match_table, + .pm = >4_pm, }, .probe = gt4_probe, .remove = gt4_remove, |