35 #include <linux/module.h>
37 #include <linux/i2c.h>
39 #include <linux/input.h>
40 #include <linux/slab.h>
41 #include <linux/bitops.h>
44 #define GENERNAL_STATUS_REG 0x00
45 #define GENERNAL_CONF_REG 0x01
46 #define MESURE_RES_CONF_REG 0x02
47 #define MESURE_AVER_CONF_REG 0x03
48 #define ADC_SAMPLE_TIME_CONF_REG 0x04
49 #define PANEL_SETUPTIME_CONF_REG 0x05
50 #define DELAY_CONVERSION_CONF_REG 0x06
51 #define TOUCH_DETECT_PULLUP_CONF_REG 0x07
52 #define AUTO_MODE_TIME_CONF_REG 0x08
53 #define APERTURE_CONF_REG 0x09
54 #define AUX_MESURE_CONF_REG 0x0a
55 #define OP_MODE_CONF_REG 0x0b
58 #define FIFO_RD_CMD (0x50 << 1)
59 #define MAX11801_FIFO_INT (1 << 2)
60 #define MAX11801_FIFO_OVERFLOW (1 << 3)
63 #define XY_BUF_OFFSET 4
65 #define MAX11801_MAX_X 0xfff
66 #define MAX11801_MAX_Y 0xfff
68 #define MEASURE_TAG_OFFSET 2
69 #define MEASURE_TAG_MASK (3 << MEASURE_TAG_OFFSET)
70 #define EVENT_TAG_OFFSET 0
71 #define EVENT_TAG_MASK (3 << EVENT_TAG_OFFSET)
72 #define MEASURE_X_TAG (0 << MEASURE_TAG_OFFSET)
73 #define MEASURE_Y_TAG (1 << MEASURE_TAG_OFFSET)
124 for (i = 0; i <
XY_BUFSIZE; i += XY_BUFSIZE / 2) {
136 switch (buf[1] & EVENT_TAG_MASK) {
181 struct input_dev *input_dev;
185 input_dev = input_allocate_device();
186 if (!data || !input_dev) {
187 dev_err(&client->
dev,
"Failed to allocate memory\n");
195 input_dev->name =
"max11801_ts";
196 input_dev->id.bustype =
BUS_I2C;
197 input_dev->dev.parent = &client->
dev;
204 input_set_drvdata(input_dev, data);
206 max11801_ts_phy_init(data);
210 "max11801_ts", data);
212 dev_err(&client->
dev,
"Failed to register interrupt\n");
216 error = input_register_device(data->
input_dev);
220 i2c_set_clientdata(client, data);
226 input_free_device(input_dev);
236 input_unregister_device(data->
input_dev);
248 static struct i2c_driver max11801_ts_driver = {
250 .name =
"max11801_ts",
253 .id_table = max11801_ts_id,
254 .probe = max11801_ts_probe,