20 #include <linux/module.h>
22 #include <linux/i2c.h>
24 #include <linux/input.h>
28 #include <linux/slab.h>
29 #include <linux/bitops.h>
38 #define REPORT_MODE_MOUSE 0x1
44 #define REPORT_MODE_VENDOR 0x3
46 #define REPORT_MODE_MTTOUCH 0x4
48 #define MAX_SUPPORT_POINTS 5
50 #define EVENT_VALID_OFFSET 7
51 #define EVENT_VALID_MASK (0x1 << EVENT_VALID_OFFSET)
52 #define EVENT_ID_OFFSET 2
53 #define EVENT_ID_MASK (0xf << EVENT_ID_OFFSET)
54 #define EVENT_IN_RANGE (0x1 << 1)
55 #define EVENT_DOWN_UP (0X1 << 0)
57 #define MAX_I2C_DATA_LEN 10
59 #define EGALAX_MAX_X 32760
60 #define EGALAX_MAX_Y 32760
61 #define EGALAX_MAX_TRIES 100
71 struct input_dev *input_dev = ts->
input_dev;
92 x = (buf[3] << 8) | buf[2];
93 y = (buf[5] << 8) | buf[4];
94 z = (buf[7] << 8) | buf[6];
108 dev_dbg(&client->
dev,
"%s id:%d x:%d y:%d z:%d",
109 down ?
"down" :
"up",
id, x, y, z);
118 input_sync(input_dev);
124 static int egalax_wake_up_device(
struct i2c_client *client)
133 gpio = of_get_named_gpio(np,
"wakeup-gpios", 0);
134 if (!gpio_is_valid(gpio))
140 "request gpio failed, cannot wake up controller: %d\n",
172 struct input_dev *input_dev;
178 dev_err(&client->
dev,
"Failed to allocate memory\n");
182 input_dev = input_allocate_device();
184 dev_err(&client->
dev,
"Failed to allocate memory\n");
193 error = egalax_wake_up_device(client);
195 dev_err(&client->
dev,
"Failed to wake up the controller\n");
199 ret = egalax_firmware_version(client);
201 dev_err(&client->
dev,
"Failed to read firmware version\n");
206 input_dev->name =
"EETI eGalax Touch Screen";
207 input_dev->id.bustype =
BUS_I2C;
208 input_dev->dev.parent = &client->
dev;
216 input_set_abs_params(input_dev,
218 input_set_abs_params(input_dev,
222 input_set_drvdata(input_dev, ts);
228 dev_err(&client->
dev,
"Failed to register interrupt\n");
232 error = input_register_device(ts->
input_dev);
236 i2c_set_clientdata(client, ts);
242 input_free_device(input_dev);
251 struct egalax_ts *ts = i2c_get_clientdata(client);
267 #ifdef CONFIG_PM_SLEEP
268 static int egalax_ts_suspend(
struct device *
dev)
271 0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
277 return ret > 0 ? 0 :
ret;
280 static int egalax_ts_resume(
struct device *
dev)
284 return egalax_wake_up_device(client);
291 { .compatible =
"eeti,egalax_ts" },
299 .pm = &egalax_ts_pm_ops,
302 .id_table = egalax_ts_id,
303 .probe = egalax_ts_probe,