aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenkateswara Rao Mandela2017-05-08 05:11:03 -0500
committerVishal Mahaveer2017-05-08 10:51:15 -0500
commit5d6f2e55cea31158a3ec79dc569722b0b44049ac (patch)
treef403b05223af0dd95da105fed8f6d04b1ef44e0c
parentd99e36011a802b83f5dec004d4b718dbe40148d0 (diff)
downloadkernel-omap-5d6f2e55cea31158a3ec79dc569722b0b44049ac.tar.gz
kernel-omap-5d6f2e55cea31158a3ec79dc569722b0b44049ac.tar.xz
kernel-omap-5d6f2e55cea31158a3ec79dc569722b0b44049ac.zip
dra71x: lcard: Touch screen functional6AM.1.3-lcard
Enable goodix touchscreen with polling mode. Change-Id: I0a23d2cb3a185e3c2d2ff142eb37be738c10c557 Signed-off-by: Venkateswara Rao Mandela <venkat.mandela@ti.com> Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
-rw-r--r--drivers/input/touchscreen/Kconfig1
-rw-r--r--drivers/input/touchscreen/goodix.c97
2 files changed, 86 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 8364d84fd696..97f1eacdda0e 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -325,6 +325,7 @@ config TOUCHSCREEN_GOODIX
325 tristate "Goodix I2C touchscreen" 325 tristate "Goodix I2C touchscreen"
326 depends on I2C 326 depends on I2C
327 depends on GPIOLIB 327 depends on GPIOLIB
328 select INPUT_POLLDEV
328 help 329 help
329 Say Y here if you have the Goodix touchscreen (such as one 330 Say Y here if you have the Goodix touchscreen (such as one
330 installed in Onda v975w tablets) connected to your 331 installed in Onda v975w tablets) connected to your
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index a27f0d7107af..f553bea645d7 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/input/mt.h> 24#include <linux/input/mt.h>
25#include <linux/input-polldev.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
27#include <linux/irq.h> 28#include <linux/irq.h>
@@ -34,6 +35,7 @@
34struct goodix_ts_data { 35struct goodix_ts_data {
35 struct i2c_client *client; 36 struct i2c_client *client;
36 struct input_dev *input_dev; 37 struct input_dev *input_dev;
38 struct input_polled_dev *poll_dev;
37 int abs_x_max; 39 int abs_x_max;
38 int abs_y_max; 40 int abs_y_max;
39 bool swapped_x_y; 41 bool swapped_x_y;
@@ -77,6 +79,8 @@ struct goodix_ts_data {
77#define MAX_CONTACTS_LOC 5 79#define MAX_CONTACTS_LOC 5
78#define TRIGGER_LOC 6 80#define TRIGGER_LOC 6
79 81
82#define TSC_DEFAULT_POLL_PERIOD 30 /* ms */
83
80static const unsigned long goodix_irq_flags[] = { 84static const unsigned long goodix_irq_flags[] = {
81 IRQ_TYPE_EDGE_RISING, 85 IRQ_TYPE_EDGE_RISING,
82 IRQ_TYPE_EDGE_FALLING, 86 IRQ_TYPE_EDGE_FALLING,
@@ -281,6 +285,19 @@ static void goodix_process_events(struct goodix_ts_data *ts)
281 input_sync(ts->input_dev); 285 input_sync(ts->input_dev);
282} 286}
283 287
288static void _goodix_process_events(struct goodix_ts_data *ts)
289{
290 goodix_process_events(ts);
291
292 if (goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0) < 0)
293 dev_err(&ts->client->dev, "I2C write end_cmd error\n");
294
295}
296static void goodix_poll(struct input_polled_dev *poll_dev)
297{
298 struct goodix_ts_data *ts = poll_dev->private;
299 _goodix_process_events(ts);
300}
284/** 301/**
285 * goodix_ts_irq_handler - The IRQ handler 302 * goodix_ts_irq_handler - The IRQ handler
286 * 303 *
@@ -291,10 +308,7 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
291{ 308{
292 struct goodix_ts_data *ts = dev_id; 309 struct goodix_ts_data *ts = dev_id;
293 310
294 goodix_process_events(ts); 311 _goodix_process_events(ts);
295
296 if (goodix_i2c_write_u8(ts->client, GOODIX_READ_COOR_ADDR, 0) < 0)
297 dev_err(&ts->client->dev, "I2C write end_cmd error\n");
298 312
299 return IRQ_HANDLED; 313 return IRQ_HANDLED;
300} 314}
@@ -614,6 +628,58 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
614 return 0; 628 return 0;
615} 629}
616 630
631static int goodix_request_input_polled_dev(struct goodix_ts_data *ts)
632{
633 int error;
634 struct input_polled_dev *poll_dev;
635
636 dev_err(&ts->client->dev, "Setting up polling.\n");
637 poll_dev = input_allocate_polled_device();
638 if (!poll_dev) {
639 dev_err(&ts->client->dev, "Failed to allocate polled input device.\n");
640 error = -ENOMEM;
641 return error;
642 }
643
644 ts->poll_dev = poll_dev;
645
646 poll_dev->private = ts;
647 poll_dev->poll = goodix_poll;
648 poll_dev->poll_interval = TSC_DEFAULT_POLL_PERIOD;
649
650 ts->input_dev = poll_dev->input;
651 if (!ts->input_dev) {
652 dev_err(&ts->client->dev, "Failed to allocate input device.");
653 return -ENOMEM;
654 }
655
656 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X,
657 0, ts->abs_x_max, 0, 0);
658 input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y,
659 0, ts->abs_y_max, 0, 0);
660 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
661 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
662
663 input_mt_init_slots(ts->input_dev, ts->max_touch_num,
664 INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
665
666 ts->input_dev->name = "Goodix Capacitive TouchScreen";
667 ts->input_dev->phys = "input/ts";
668 ts->input_dev->id.bustype = BUS_I2C;
669 ts->input_dev->id.vendor = 0x0416;
670 ts->input_dev->id.product = ts->id;
671 ts->input_dev->id.version = ts->version;
672
673 error = input_register_polled_device(poll_dev);
674 if (error) {
675 dev_err(&ts->client->dev,
676 "Failed to register input device: %d", error);
677 return error;
678 }
679
680 return 0;
681}
682
617/** 683/**
618 * goodix_configure_dev - Finish device initialization 684 * goodix_configure_dev - Finish device initialization
619 * 685 *
@@ -637,15 +703,22 @@ static int goodix_configure_dev(struct goodix_ts_data *ts)
637 703
638 goodix_read_config(ts); 704 goodix_read_config(ts);
639 705
640 error = goodix_request_input_dev(ts);
641 if (error)
642 return error;
643 706
644 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT; 707 if (ts->client->irq) {
645 error = goodix_request_irq(ts); 708 error = goodix_request_input_dev(ts);
646 if (error) { 709 if (error)
647 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error); 710 return error;
648 return error; 711 ts->irq_flags = goodix_irq_flags[ts->int_trigger_type] | IRQF_ONESHOT;
712 error = goodix_request_irq(ts);
713 if (error) {
714 dev_err(&ts->client->dev, "request IRQ failed: %d\n", error);
715 return error;
716 }
717 } else {
718 /* setup polling if IRQ is not defined */
719
720 error = goodix_request_input_polled_dev(ts);
721
649 } 722 }
650 723
651 return 0; 724 return 0;