Input: elants_i2c - fix wake-on-touch
When sending "SLEEP" command to the controller it ceases scanning completely and is unable to wake the system up from sleep, so if it is configured as a wakeup source we should simply configure interrupt for wakeup and rely on idle logic within the controller to reduce power consumption while it is not used. Signed-off-by: James Chen <james.chen@emc.com.tw> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
3eab4588c9
commit
478e5ed1c3
|
@ -1316,7 +1316,13 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
|
|||
|
||||
disable_irq(client->irq);
|
||||
|
||||
if (device_may_wakeup(dev) || ts->keep_power_in_suspend) {
|
||||
if (device_may_wakeup(dev)) {
|
||||
/*
|
||||
* The device will automatically enter idle mode
|
||||
* that has reduced power consumption.
|
||||
*/
|
||||
ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
|
||||
} else if (ts->keep_power_in_suspend) {
|
||||
for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
|
||||
error = elants_i2c_send(client, set_sleep_cmd,
|
||||
sizeof(set_sleep_cmd));
|
||||
|
@ -1326,10 +1332,6 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
|
|||
dev_err(&client->dev,
|
||||
"suspend command failed: %d\n", error);
|
||||
}
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
ts->wake_irq_enabled =
|
||||
(enable_irq_wake(client->irq) == 0);
|
||||
} else {
|
||||
elants_i2c_power_off(ts);
|
||||
}
|
||||
|
@ -1345,10 +1347,11 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
|
|||
int retry_cnt;
|
||||
int error;
|
||||
|
||||
if (device_may_wakeup(dev) && ts->wake_irq_enabled)
|
||||
disable_irq_wake(client->irq);
|
||||
|
||||
if (ts->keep_power_in_suspend) {
|
||||
if (device_may_wakeup(dev)) {
|
||||
if (ts->wake_irq_enabled)
|
||||
disable_irq_wake(client->irq);
|
||||
elants_i2c_sw_reset(client);
|
||||
} else if (ts->keep_power_in_suspend) {
|
||||
for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
|
||||
error = elants_i2c_send(client, set_active_cmd,
|
||||
sizeof(set_active_cmd));
|
||||
|
|
Loading…
Reference in New Issue