/
0037-CHROMIUM-Input-atmel_mxt_ts-Wait-on-auto-calibration.patch
121 lines (107 loc) · 4.13 KB
/
0037-CHROMIUM-Input-atmel_mxt_ts-Wait-on-auto-calibration.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From c2cb3071e8749979472e1dd14125e2e042e66eaf Mon Sep 17 00:00:00 2001
From: Yufeng Shen <miletus@chromium.org>
Date: Wed, 16 May 2012 14:52:02 -0400
Subject: [PATCH 37/57] CHROMIUM: Input: atmel_mxt_ts - Wait on auto
calibration msg in suspend
If the atmel chip enters suspend mode and wants to be able to
wakeup from suspend, T9 object has to be enabled during suspend.
If T9 is enalbed from a disabled state, the chip will perform an
auto calibration and send back the status of the calibration.
We have to wait for these messages to be read before entering
suspend, otherwise these message will wakeup the system automatically.
Signed-off-by: Yufeng Shen <miletus@chromium.org>
BUG=chrome-os-partner:8722
TEST=run powerd_suspend to put system into sleep and make sure it
does not wakeup automatically. And touch the TS/TP to wake the
system up
Change-Id: Iaf8175c8e6d523edfd152172e1966303ac8fd65f
Reviewed-on: https://gerrit.chromium.org/gerrit/22842
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Yufeng Shen <miletus@chromium.org>
Commit-Ready: Yufeng Shen <miletus@chromium.org>
v3.7 rebase:
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 39 +++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 3dbaa3c..bac30d1f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -325,6 +325,9 @@ struct mxt_data {
struct mutex object_str_mutex;
char *object_str;
size_t object_str_size;
+
+ /* for auto-calibration in suspend */
+ struct completion auto_cal_completion;
};
/* global root node of the atmel_mxt_ts debugfs directory. */
@@ -821,6 +824,8 @@ static int mxt_proc_messages(struct mxt_data *data, u8 count)
data->config_csum = mxt_extract_T6_csum(&payload[1]);
dev_dbg(dev, "Status: %02x Config Checksum: %06x\n",
status, data->config_csum);
+ if (status == 0x00)
+ complete(&data->auto_cal_completion);
} else if (mxt_is_T9_message(data, msg)) {
int id = reportid - data->T9_reportid_min;
mxt_input_touchevent(data, msg, id);
@@ -2170,6 +2175,7 @@ static int __devinit mxt_probe(struct i2c_client *client,
data->irq = client->irq;
init_completion(&data->bl_completion);
+ init_completion(&data->auto_cal_completion);
if (mxt_in_bootloader(data)) {
dev_info(&client->dev, "Device in bootloader at probe\n");
@@ -2239,6 +2245,30 @@ static int mxt_remove(struct i2c_client *client)
}
#ifdef CONFIG_PM_SLEEP
+
+static void mxt_suspend_enable_T9(struct mxt_data *data)
+{
+ struct device *dev = &data->client->dev;
+ u8 T9_ctrl = 0x03;
+ int ret;
+ unsigned long timeout = msecs_to_jiffies(350);
+
+ INIT_COMPLETION(data->auto_cal_completion);
+
+ /* Enable T9 object */
+ ret = mxt_set_regs(data, MXT_TOUCH_MULTI_T9, 0, 0,
+ &T9_ctrl, 1);
+ if (ret) {
+ dev_err(dev, "Set T9 ctrl config failed, %d\n", ret);
+ return;
+ }
+
+ ret = wait_for_completion_interruptible_timeout(
+ &data->auto_cal_completion, timeout);
+ if (ret <= 0)
+ dev_err(dev, "Wait for auto cal completion failed.\n");
+}
+
static int mxt_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
@@ -2247,7 +2277,6 @@ static int mxt_suspend(struct device *dev)
static const u8 T7_config_idle[3] = { 0xfe, 0xfe, 0x00 };
static const u8 T7_config_deepsleep[3] = { 0x00, 0x00, 0x00 };
const u8 *power_config;
- u8 T9_ctrl = 0x03;
int ret;
if (mxt_in_bootloader(data))
@@ -2287,11 +2316,9 @@ static int mxt_suspend(struct device *dev)
dev_err(dev, "Save T9 ctrl config failed, %d\n", ret);
data->T9_ctrl_valid = (ret == 0);
- /* Enable T9 object */
- ret = mxt_set_regs(data, MXT_TOUCH_MULTI_T9, 0, 0,
- &T9_ctrl, 1);
- if (ret)
- dev_err(dev, "Set T9 ctrl config failed, %d\n", ret);
+ /* Enable T9 only if it is not currently enabled */
+ if (data->T9_ctrl_valid && !(data->T9_ctrl & 0x01))
+ mxt_suspend_enable_T9(data);
/* Enable wake from IRQ */
data->irq_wake = (enable_irq_wake(data->irq) == 0);
--
1.8.2.1