16 #include <linux/module.h>
18 #include <linux/i2c.h>
21 #include <linux/input.h>
23 #include <linux/slab.h>
26 #define MCS5000_TS_STATUS 0x00
27 #define STATUS_OFFSET 0
28 #define STATUS_NO (0 << STATUS_OFFSET)
29 #define STATUS_INIT (1 << STATUS_OFFSET)
30 #define STATUS_SENSING (2 << STATUS_OFFSET)
31 #define STATUS_COORD (3 << STATUS_OFFSET)
32 #define STATUS_GESTURE (4 << STATUS_OFFSET)
33 #define ERROR_OFFSET 4
34 #define ERROR_NO (0 << ERROR_OFFSET)
35 #define ERROR_POWER_ON_RESET (1 << ERROR_OFFSET)
36 #define ERROR_INT_RESET (2 << ERROR_OFFSET)
37 #define ERROR_EXT_RESET (3 << ERROR_OFFSET)
38 #define ERROR_INVALID_REG_ADDRESS (8 << ERROR_OFFSET)
39 #define ERROR_INVALID_REG_VALUE (9 << ERROR_OFFSET)
41 #define MCS5000_TS_OP_MODE 0x01
42 #define RESET_OFFSET 0
43 #define RESET_NO (0 << RESET_OFFSET)
44 #define RESET_EXT_SOFT (1 << RESET_OFFSET)
45 #define OP_MODE_OFFSET 1
46 #define OP_MODE_SLEEP (0 << OP_MODE_OFFSET)
47 #define OP_MODE_ACTIVE (1 << OP_MODE_OFFSET)
48 #define GESTURE_OFFSET 4
49 #define GESTURE_DISABLE (0 << GESTURE_OFFSET)
50 #define GESTURE_ENABLE (1 << GESTURE_OFFSET)
51 #define PROXIMITY_OFFSET 5
52 #define PROXIMITY_DISABLE (0 << PROXIMITY_OFFSET)
53 #define PROXIMITY_ENABLE (1 << PROXIMITY_OFFSET)
54 #define SCAN_MODE_OFFSET 6
55 #define SCAN_MODE_INTERRUPT (0 << SCAN_MODE_OFFSET)
56 #define SCAN_MODE_POLLING (1 << SCAN_MODE_OFFSET)
57 #define REPORT_RATE_OFFSET 7
58 #define REPORT_RATE_40 (0 << REPORT_RATE_OFFSET)
59 #define REPORT_RATE_80 (1 << REPORT_RATE_OFFSET)
61 #define MCS5000_TS_SENS_CTL 0x02
62 #define MCS5000_TS_FILTER_CTL 0x03
63 #define PRI_FILTER_OFFSET 0
64 #define SEC_FILTER_OFFSET 4
66 #define MCS5000_TS_X_SIZE_UPPER 0x08
67 #define MCS5000_TS_X_SIZE_LOWER 0x09
68 #define MCS5000_TS_Y_SIZE_UPPER 0x0A
69 #define MCS5000_TS_Y_SIZE_LOWER 0x0B
71 #define MCS5000_TS_INPUT_INFO 0x10
72 #define INPUT_TYPE_OFFSET 0
73 #define INPUT_TYPE_NONTOUCH (0 << INPUT_TYPE_OFFSET)
74 #define INPUT_TYPE_SINGLE (1 << INPUT_TYPE_OFFSET)
75 #define INPUT_TYPE_DUAL (2 << INPUT_TYPE_OFFSET)
76 #define INPUT_TYPE_PALM (3 << INPUT_TYPE_OFFSET)
77 #define INPUT_TYPE_PROXIMITY (7 << INPUT_TYPE_OFFSET)
78 #define GESTURE_CODE_OFFSET 3
79 #define GESTURE_CODE_NO (0 << GESTURE_CODE_OFFSET)
81 #define MCS5000_TS_X_POS_UPPER 0x11
82 #define MCS5000_TS_X_POS_LOWER 0x12
83 #define MCS5000_TS_Y_POS_UPPER 0x13
84 #define MCS5000_TS_Y_POS_LOWER 0x14
85 #define MCS5000_TS_Z_POS 0x15
86 #define MCS5000_TS_WIDTH 0x16
87 #define MCS5000_TS_GESTURE_VAL 0x17
88 #define MCS5000_TS_MODULE_REV 0x20
89 #define MCS5000_TS_FIRMWARE_VER 0x21
92 #define MCS5000_MAX_XC 0x3ff
93 #define MCS5000_MAX_YC 0x3ff
123 dev_err(&client->
dev,
"%s, err[%d]\n", __func__, err);
156 dev_err(&client->
dev,
"Unknown ts input type %d\n",
157 buffer[READ_INPUT_INFO]);
177 platform_data->
x_size >> 8);
179 platform_data->
x_size & 0xff);
181 platform_data->
y_size >> 8);
183 platform_data->
y_size & 0xff);
194 struct input_dev *input_dev;
197 if (!client->
dev.platform_data)
201 input_dev = input_allocate_device();
202 if (!data || !input_dev) {
203 dev_err(&client->
dev,
"Failed to allocate memory\n");
212 input_dev->name =
"MELPAS MCS-5000 Touchscreen";
213 input_dev->id.bustype =
BUS_I2C;
214 input_dev->dev.parent = &client->
dev;
222 input_set_drvdata(input_dev, data);
231 dev_err(&client->
dev,
"Failed to register interrupt\n");
235 ret = input_register_device(data->
input_dev);
239 mcs5000_ts_phys_init(data);
240 i2c_set_clientdata(client, data);
247 input_free_device(input_dev);
257 input_unregister_device(data->
input_dev);
264 static int mcs5000_ts_suspend(
struct device *
dev)
274 static int mcs5000_ts_resume(
struct device *
dev)
279 mcs5000_ts_phys_init(data);
293 static struct i2c_driver mcs5000_ts_driver = {
294 .probe = mcs5000_ts_probe,
297 .name =
"mcs5000_ts",
299 .pm = &mcs5000_ts_pm,
302 .id_table = mcs5000_ts_id,