aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-10-30 03:20:56 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-10-30 03:20:56 -0400
commit53279f36dccffc26ff536003fd6bb97cc21c3b82 (patch)
tree9d16e497c0e4158c7c054c479bd0e9ff0388d7bb /drivers/input/touchscreen
parenta6e8c0a25377e27958b11b20e1927885ae7c9857 (diff)
parent8f0d8163b50e01f398b14bcd4dc039ac5ab18d64 (diff)
Merge tag 'v3.7-rc3' into next to sync up with recent USB and MFD changes
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/88pm860x-ts.c127
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c11
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c2
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c40
-rw-r--r--drivers/input/touchscreen/wm831x-ts.c2
5 files changed, 160 insertions, 22 deletions
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index 05f30b73c3c3..326218dbd6e6 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/of.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/i2c.h> 15#include <linux/i2c.h>
15#include <linux/input.h> 16#include <linux/input.h>
@@ -113,14 +114,69 @@ static void pm860x_touch_close(struct input_dev *dev)
113 pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); 114 pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
114} 115}
115 116
117#ifdef CONFIG_OF
118static int __devinit pm860x_touch_dt_init(struct platform_device *pdev,
119 struct pm860x_chip *chip,
120 int *res_x)
121{
122 struct device_node *np = pdev->dev.parent->of_node;
123 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \
124 : chip->companion;
125 int data, n, ret;
126 if (!np)
127 return -ENODEV;
128 np = of_find_node_by_name(np, "touch");
129 if (!np) {
130 dev_err(&pdev->dev, "Can't find touch node\n");
131 return -EINVAL;
132 }
133 /* set GPADC MISC1 register */
134 data = 0;
135 if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-prebias", &n))
136 data |= (n << 1) & PM8607_GPADC_PREBIAS_MASK;
137 if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-slot-cycle", &n))
138 data |= (n << 3) & PM8607_GPADC_SLOT_CYCLE_MASK;
139 if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-off-scale", &n))
140 data |= (n << 5) & PM8607_GPADC_OFF_SCALE_MASK;
141 if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-sw-cal", &n))
142 data |= (n << 7) & PM8607_GPADC_SW_CAL_MASK;
143 if (data) {
144 ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data);
145 if (ret < 0)
146 return -EINVAL;
147 }
148 /* set tsi prebias time */
149 if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) {
150 ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data);
151 if (ret < 0)
152 return -EINVAL;
153 }
154 /* set prebias & prechg time of pen detect */
155 data = 0;
156 if (!of_property_read_u32(np, "marvell,88pm860x-pen-prebias", &n))
157 data |= n & PM8607_PD_PREBIAS_MASK;
158 if (!of_property_read_u32(np, "marvell,88pm860x-pen-prechg", &n))
159 data |= n & PM8607_PD_PRECHG_MASK;
160 if (data) {
161 ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data);
162 if (ret < 0)
163 return -EINVAL;
164 }
165 of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x);
166 return 0;
167}
168#else
169#define pm860x_touch_dt_init(x, y, z) (-1)
170#endif
171
116static int __devinit pm860x_touch_probe(struct platform_device *pdev) 172static int __devinit pm860x_touch_probe(struct platform_device *pdev)
117{ 173{
118 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 174 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
119 struct pm860x_platform_data *pm860x_pdata = \ 175 struct pm860x_touch_pdata *pdata = pdev->dev.platform_data;
120 pdev->dev.parent->platform_data;
121 struct pm860x_touch_pdata *pdata = NULL;
122 struct pm860x_touch *touch; 176 struct pm860x_touch *touch;
123 int irq, ret; 177 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \
178 : chip->companion;
179 int irq, ret, res_x = 0, data = 0;
124 180
125 irq = platform_get_irq(pdev, 0); 181 irq = platform_get_irq(pdev, 0);
126 if (irq < 0) { 182 if (irq < 0) {
@@ -128,16 +184,55 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
128 return -EINVAL; 184 return -EINVAL;
129 } 185 }
130 186
131 if (!pm860x_pdata) { 187 if (pm860x_touch_dt_init(pdev, chip, &res_x)) {
132 dev_err(&pdev->dev, "platform data is missing\n"); 188 if (pdata) {
133 return -EINVAL; 189 /* set GPADC MISC1 register */
134 } 190 data = 0;
135 191 data |= (pdata->gpadc_prebias << 1)
136 pdata = pm860x_pdata->touch; 192 & PM8607_GPADC_PREBIAS_MASK;
137 if (!pdata) { 193 data |= (pdata->slot_cycle << 3)
138 dev_err(&pdev->dev, "touchscreen data is missing\n"); 194 & PM8607_GPADC_SLOT_CYCLE_MASK;
139 return -EINVAL; 195 data |= (pdata->off_scale << 5)
196 & PM8607_GPADC_OFF_SCALE_MASK;
197 data |= (pdata->sw_cal << 7)
198 & PM8607_GPADC_SW_CAL_MASK;
199 if (data) {
200 ret = pm860x_reg_write(i2c,
201 PM8607_GPADC_MISC1, data);
202 if (ret < 0)
203 return -EINVAL;
204 }
205 /* set tsi prebias time */
206 if (pdata->tsi_prebias) {
207 data = pdata->tsi_prebias;
208 ret = pm860x_reg_write(i2c,
209 PM8607_TSI_PREBIAS, data);
210 if (ret < 0)
211 return -EINVAL;
212 }
213 /* set prebias & prechg time of pen detect */
214 data = 0;
215 data |= pdata->pen_prebias
216 & PM8607_PD_PREBIAS_MASK;
217 data |= (pdata->pen_prechg << 5)
218 & PM8607_PD_PRECHG_MASK;
219 if (data) {
220 ret = pm860x_reg_write(i2c,
221 PM8607_PD_PREBIAS, data);
222 if (ret < 0)
223 return -EINVAL;
224 }
225 res_x = pdata->res_x;
226 } else {
227 dev_err(&pdev->dev, "failed to get platform data\n");
228 return -EINVAL;
229 }
140 } 230 }
231 /* enable GPADC */
232 ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, PM8607_GPADC_EN,
233 PM8607_GPADC_EN);
234 if (ret)
235 return ret;
141 236
142 touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); 237 touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL);
143 if (touch == NULL) 238 if (touch == NULL)
@@ -158,9 +253,9 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev)
158 touch->idev->open = pm860x_touch_open; 253 touch->idev->open = pm860x_touch_open;
159 touch->idev->close = pm860x_touch_close; 254 touch->idev->close = pm860x_touch_close;
160 touch->chip = chip; 255 touch->chip = chip;
161 touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; 256 touch->i2c = i2c;
162 touch->irq = irq + chip->irq_base; 257 touch->irq = irq;
163 touch->res_x = pdata->res_x; 258 touch->res_x = res_x;
164 input_set_drvdata(touch->idev, touch); 259 input_set_drvdata(touch->idev, touch);
165 260
166 ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, 261 ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler,
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index bcaea7a5e02b..d9c6007e445f 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -558,9 +558,12 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
558 } 558 }
559 559
560 read = min_t(size_t, count, tsdata->raw_bufsize - *off); 560 read = min_t(size_t, count, tsdata->raw_bufsize - *off);
561 error = copy_to_user(buf, tsdata->raw_buffer + *off, read); 561 if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
562 if (!error) 562 error = -EFAULT;
563 *off += read; 563 goto out;
564 }
565
566 *off += read;
564out: 567out:
565 mutex_unlock(&tsdata->mutex); 568 mutex_unlock(&tsdata->mutex);
566 return error ?: read; 569 return error ?: read;
@@ -594,6 +597,7 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
594{ 597{
595 if (tsdata->debug_dir) 598 if (tsdata->debug_dir)
596 debugfs_remove_recursive(tsdata->debug_dir); 599 debugfs_remove_recursive(tsdata->debug_dir);
600 kfree(tsdata->raw_buffer);
597} 601}
598 602
599#else 603#else
@@ -835,7 +839,6 @@ static int __devexit edt_ft5x06_ts_remove(struct i2c_client *client)
835 if (gpio_is_valid(pdata->reset_pin)) 839 if (gpio_is_valid(pdata->reset_pin))
836 gpio_free(pdata->reset_pin); 840 gpio_free(pdata->reset_pin);
837 841
838 kfree(tsdata->raw_buffer);
839 kfree(tsdata); 842 kfree(tsdata);
840 843
841 return 0; 844 return 0;
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index b3c66d4d02f6..549fa29548f8 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -37,7 +37,7 @@
37 37
38#include <plat/adc.h> 38#include <plat/adc.h>
39#include <plat/regs-adc.h> 39#include <plat/regs-adc.h>
40#include <plat/ts.h> 40#include <linux/platform_data/touchscreen-s3c2410.h>
41 41
42#define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0)) 42#define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0))
43 43
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index e32709e0dd65..721fdb3597ca 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -304,6 +304,45 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
304#define EGALAX_PKT_TYPE_REPT 0x80 304#define EGALAX_PKT_TYPE_REPT 0x80
305#define EGALAX_PKT_TYPE_DIAG 0x0A 305#define EGALAX_PKT_TYPE_DIAG 0x0A
306 306
307static int egalax_init(struct usbtouch_usb *usbtouch)
308{
309 int ret, i;
310 unsigned char *buf;
311 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
312
313 /*
314 * An eGalax diagnostic packet kicks the device into using the right
315 * protocol. We send a "check active" packet. The response will be
316 * read later and ignored.
317 */
318
319 buf = kmalloc(3, GFP_KERNEL);
320 if (!buf)
321 return -ENOMEM;
322
323 buf[0] = EGALAX_PKT_TYPE_DIAG;
324 buf[1] = 1; /* length */
325 buf[2] = 'A'; /* command - check active */
326
327 for (i = 0; i < 3; i++) {
328 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
329 0,
330 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
331 0, 0, buf, 3,
332 USB_CTRL_SET_TIMEOUT);
333 if (ret >= 0) {
334 ret = 0;
335 break;
336 }
337 if (ret != -EPIPE)
338 break;
339 }
340
341 kfree(buf);
342
343 return ret;
344}
345
307static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 346static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
308{ 347{
309 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) 348 if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
@@ -1056,6 +1095,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
1056 .process_pkt = usbtouch_process_multi, 1095 .process_pkt = usbtouch_process_multi,
1057 .get_pkt_len = egalax_get_pkt_len, 1096 .get_pkt_len = egalax_get_pkt_len,
1058 .read_data = egalax_read_data, 1097 .read_data = egalax_read_data,
1098 .init = egalax_init,
1059 }, 1099 },
1060#endif 1100#endif
1061 1101
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
index 362f78d4507f..c7eee56d0087 100644
--- a/drivers/input/touchscreen/wm831x-ts.c
+++ b/drivers/input/touchscreen/wm831x-ts.c
@@ -221,7 +221,7 @@ static void wm831x_ts_input_close(struct input_dev *idev)
221 synchronize_irq(wm831x_ts->pd_irq); 221 synchronize_irq(wm831x_ts->pd_irq);
222 222
223 /* Make sure the IRQ completion work is quiesced */ 223 /* Make sure the IRQ completion work is quiesced */
224 flush_work_sync(&wm831x_ts->pd_data_work); 224 flush_work(&wm831x_ts->pd_data_work);
225 225
226 /* If we ended up with the pen down then make sure we revert back 226 /* If we ended up with the pen down then make sure we revert back
227 * to pen detection state for the next time we start up. 227 * to pen detection state for the next time we start up.