Commit 478e5ed1 authored by James Chen's avatar James Chen Committed by Dmitry Torokhov

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: default avatarJames Chen <james.chen@emc.com.tw>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 3eab4588
...@@ -1316,7 +1316,13 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) ...@@ -1316,7 +1316,13 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
disable_irq(client->irq); 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++) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
error = elants_i2c_send(client, set_sleep_cmd, error = elants_i2c_send(client, set_sleep_cmd,
sizeof(set_sleep_cmd)); sizeof(set_sleep_cmd));
...@@ -1326,10 +1332,6 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) ...@@ -1326,10 +1332,6 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
dev_err(&client->dev, dev_err(&client->dev,
"suspend command failed: %d\n", error); "suspend command failed: %d\n", error);
} }
if (device_may_wakeup(dev))
ts->wake_irq_enabled =
(enable_irq_wake(client->irq) == 0);
} else { } else {
elants_i2c_power_off(ts); elants_i2c_power_off(ts);
} }
...@@ -1345,10 +1347,11 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) ...@@ -1345,10 +1347,11 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
int retry_cnt; int retry_cnt;
int error; int error;
if (device_may_wakeup(dev) && ts->wake_irq_enabled) if (device_may_wakeup(dev)) {
if (ts->wake_irq_enabled)
disable_irq_wake(client->irq); disable_irq_wake(client->irq);
elants_i2c_sw_reset(client);
if (ts->keep_power_in_suspend) { } else if (ts->keep_power_in_suspend) {
for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
error = elants_i2c_send(client, set_active_cmd, error = elants_i2c_send(client, set_active_cmd,
sizeof(set_active_cmd)); sizeof(set_active_cmd));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment