21 #include <linux/module.h>
23 #include <linux/slab.h>
24 #include <linux/i2c.h>
25 #include <linux/input.h>
38 u8 rdbuf[10], wrbuf[1] = { 0 };
43 if (ret !=
sizeof(wrbuf)) {
45 "%s: i2c_master_send failed(), ret=%d\n",
51 if (ret !=
sizeof(rdbuf)) {
53 "%s: i2c_master_recv failed(), ret=%d\n",
60 u16 posx1 = (rdbuf[3] << 8) | rdbuf[2];
61 u16 posy1 = (rdbuf[5] << 8) | rdbuf[4];
62 u16 posx2 = (rdbuf[7] << 8) | rdbuf[6];
63 u16 posy2 = (rdbuf[9] << 8) | rdbuf[8];
71 input_mt_sync(tsdata->
input);
74 input_report_abs(tsdata->
input,
76 input_report_abs(tsdata->
input,
78 input_mt_sync(tsdata->
input);
84 input_sync(tsdata->
input);
92 pixcir_ts_poscheck(tsdata);
94 if (tsdata->
chip->attb_read_val())
103 #ifdef CONFIG_PM_SLEEP
104 static int pixcir_i2c_ts_suspend(
struct device *
dev)
108 if (device_may_wakeup(&client->
dev))
109 enable_irq_wake(client->
irq);
114 static int pixcir_i2c_ts_resume(
struct device *dev)
118 if (device_may_wakeup(&client->
dev))
119 disable_irq_wake(client->
irq);
126 pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume);
133 struct input_dev *
input;
137 dev_err(&client->
dev,
"platform data not defined\n");
141 tsdata = kzalloc(
sizeof(*tsdata),
GFP_KERNEL);
142 input = input_allocate_device();
143 if (!tsdata || !input) {
144 dev_err(&client->
dev,
"Failed to allocate driver data!\n");
153 input->name = client->
name;
155 input->dev.parent = &client->
dev;
160 input_set_abs_params(input,
ABS_X, 0, pdata->
x_max, 0, 0);
161 input_set_abs_params(input,
ABS_Y, 0, pdata->
y_max, 0, 0);
165 input_set_drvdata(input, tsdata);
169 client->
name, tsdata);
171 dev_err(&client->
dev,
"Unable to request touchscreen IRQ.\n");
175 error = input_register_device(input);
179 i2c_set_clientdata(client, tsdata);
187 input_free_device(input);
202 input_unregister_device(tsdata->
input);
214 static struct i2c_driver pixcir_i2c_ts_driver = {
218 .pm = &pixcir_dev_pm_ops,
220 .probe = pixcir_i2c_ts_probe,
222 .id_table = pixcir_i2c_ts_id,