14 #include <linux/module.h>
16 #include <linux/i2c.h>
19 #include <linux/input.h>
21 #include <linux/slab.h>
25 #define MCS5000_TOUCHKEY_STATUS 0x04
26 #define MCS5000_TOUCHKEY_STATUS_PRESS 7
27 #define MCS5000_TOUCHKEY_FW 0x0a
28 #define MCS5000_TOUCHKEY_BASE_VAL 0x61
31 #define MCS5080_TOUCHKEY_STATUS 0x00
32 #define MCS5080_TOUCHKEY_STATUS_PRESS 3
33 #define MCS5080_TOUCHKEY_FW 0x01
34 #define MCS5080_TOUCHKEY_BASE_VAL 0x1
71 dev_err(&client->
dev,
"i2c read error [%d]\n", val);
81 key_val = val & (0xff >> (8 - chip->
pressbit));
90 input_report_key(input, data->
key_code, pressed);
94 pressed ?
"pressed" :
"released");
105 struct input_dev *input_dev;
111 pdata = client->
dev.platform_data;
113 dev_err(&client->
dev,
"no platform data defined\n");
120 input_dev = input_allocate_device();
121 if (!data || !input_dev) {
122 dev_err(&client->
dev,
"Failed to allocate memory\n");
138 data->
chip.press_invert = 1;
146 dev_err(&client->
dev,
"i2c read error[%d]\n", error);
149 dev_info(&client->
dev,
"Firmware version: %d\n", fw_ver);
151 input_dev->name =
"MELPAS MCS Touchkey";
152 input_dev->id.bustype =
BUS_I2C;
153 input_dev->dev.parent = &client->
dev;
157 input_dev->keycode = data->
keycodes;
158 input_dev->keycodesize =
sizeof(data->
keycodes[0]);
159 input_dev->keycodemax = pdata->
key_maxval + 1;
170 input_set_drvdata(input_dev, data);
182 client->
dev.driver->name, data);
184 dev_err(&client->
dev,
"Failed to register interrupt\n");
188 error = input_register_device(input_dev);
192 i2c_set_clientdata(client, data);
198 input_free_device(input_dev);
210 input_unregister_device(data->
input_dev);
216 static void mcs_touchkey_shutdown(
struct i2c_client *client)
224 #ifdef CONFIG_PM_SLEEP
225 static int mcs_touchkey_suspend(
struct device *
dev)
240 static int mcs_touchkey_resume(
struct device *dev)
257 mcs_touchkey_suspend, mcs_touchkey_resume);
266 static struct i2c_driver mcs_touchkey_driver = {
268 .name =
"mcs_touchkey",
270 .pm = &mcs_touchkey_pm_ops,
272 .probe = mcs_touchkey_probe,
274 .shutdown = mcs_touchkey_shutdown,
275 .id_table = mcs_touchkey_id,