26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/i2c.h>
30 #include <linux/input.h>
31 #include <linux/slab.h>
39 #define QT1070_CHIP_ID 0x2E
41 #define FW_VERSION 0x01
42 #define QT1070_FW_VERSION 0x15
44 #define DET_STATUS 0x02
46 #define KEY_STATUS 0x03
49 #define CALIBRATE_CMD 0x38
50 #define QT1070_CAL_TIME 200
54 #define QT1070_RESET_TIME 255
57 static const unsigned short qt1070_key2code[] = {
77 "can not read register, returned %d\n", ret);
89 "can not write register, returned %d\n", ret);
99 id = qt1070_read(client,
CHIP_ID);
101 dev_err(&client->
dev,
"ID %d not supported\n",
id);
108 dev_err(&client->
dev,
"could not read the firmware version\n");
112 dev_info(&client->
dev,
"AT42QT1070 firmware version %x\n", ver);
123 u8 new_keys, keyval,
mask = 0x01;
131 for (i = 0; i <
ARRAY_SIZE(qt1070_key2code); i++) {
132 keyval = new_keys &
mask;
134 input_report_key(input, data->
keycodes[i], keyval);
147 struct input_dev *
input;
153 dev_err(&client->
dev,
"%s adapter not supported\n",
159 dev_err(&client->
dev,
"please assign the irq to this device\n");
164 if (!qt1070_identify(client))
168 input = input_allocate_device();
169 if (!data || !input) {
170 dev_err(&client->
dev,
"insufficient memory\n");
179 input->name =
"AT42QT1070 QTouch Sensor";
180 input->dev.parent = &client->
dev;
185 input->keycodesize =
sizeof(data->
keycodes[0]);
186 input->keycodemax =
ARRAY_SIZE(qt1070_key2code);
190 for (i = 0; i <
ARRAY_SIZE(qt1070_key2code); i++) {
192 __set_bit(qt1070_key2code[i], input->keybit);
200 qt1070_write(client,
RESET, 1);
205 client->
dev.driver->name, data);
207 dev_err(&client->
dev,
"fail to request irq\n");
212 err = input_register_device(data->
input);
214 dev_err(&client->
dev,
"Failed to register input device\n");
218 i2c_set_clientdata(client, data);
228 input_free_device(input);
235 struct qt1070_data *data = i2c_get_clientdata(client);
240 input_unregister_device(data->
input);
257 .id_table = qt1070_id,
258 .probe = qt1070_probe,