linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Input: pixcir_i2c_ts - move platform data
@ 2015-07-07  0:30 Dmitry Torokhov
  2015-07-07  0:30 ` [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod Dmitry Torokhov
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

Let's move driver's platform data definitions from include/linux/input/
into include/linux/platform_data/ so that it stays with the rest of
platform data definitions.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c   |  2 +-
 include/linux/input/pixcir_ts.h             | 64 -----------------------------
 include/linux/platform_data/pixcir_i2c_ts.h | 64 +++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 65 deletions(-)
 delete mode 100644 include/linux/input/pixcir_ts.h
 create mode 100644 include/linux/platform_data/pixcir_i2c_ts.h

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 8f3e243..ccafa75 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -24,11 +24,11 @@
 #include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/input/mt.h>
-#include <linux/input/pixcir_ts.h>
 #include <linux/gpio.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/platform_data/pixcir_i2c_ts.h>
 
 #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h
deleted file mode 100644
index 7bae83b..0000000
--- a/include/linux/input/pixcir_ts.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef	_PIXCIR_I2C_TS_H
-#define	_PIXCIR_I2C_TS_H
-
-/*
- * Register map
- */
-#define PIXCIR_REG_POWER_MODE	51
-#define PIXCIR_REG_INT_MODE	52
-
-/*
- * Power modes:
- * active: max scan speed
- * idle: lower scan speed with automatic transition to active on touch
- * halt: datasheet says sleep but this is more like halt as the chip
- *       clocks are cut and it can only be brought out of this mode
- *	 using the RESET pin.
- */
-enum pixcir_power_mode {
-	PIXCIR_POWER_ACTIVE,
-	PIXCIR_POWER_IDLE,
-	PIXCIR_POWER_HALT,
-};
-
-#define PIXCIR_POWER_MODE_MASK	0x03
-#define PIXCIR_POWER_ALLOW_IDLE (1UL << 2)
-
-/*
- * Interrupt modes:
- * periodical: interrupt is asserted periodicaly
- * diff coordinates: interrupt is asserted when coordinates change
- * level on touch: interrupt level asserted during touch
- * pulse on touch: interrupt pulse asserted druing touch
- *
- */
-enum pixcir_int_mode {
-	PIXCIR_INT_PERIODICAL,
-	PIXCIR_INT_DIFF_COORD,
-	PIXCIR_INT_LEVEL_TOUCH,
-	PIXCIR_INT_PULSE_TOUCH,
-};
-
-#define PIXCIR_INT_MODE_MASK	0x03
-#define PIXCIR_INT_ENABLE	(1UL << 3)
-#define PIXCIR_INT_POL_HIGH	(1UL << 2)
-
-/**
- * struct pixcir_irc_chip_data - chip related data
- * @max_fingers:	Max number of fingers reported simultaneously by h/w
- * @has_hw_ids:		Hardware supports finger tracking IDs
- *
- */
-struct pixcir_i2c_chip_data {
-	u8 max_fingers;
-	bool has_hw_ids;
-};
-
-struct pixcir_ts_platform_data {
-	int x_max;
-	int y_max;
-	int gpio_attb;		/* GPIO connected to ATTB line */
-	struct pixcir_i2c_chip_data chip;
-};
-
-#endif
diff --git a/include/linux/platform_data/pixcir_i2c_ts.h b/include/linux/platform_data/pixcir_i2c_ts.h
new file mode 100644
index 0000000..7bae83b
--- /dev/null
+++ b/include/linux/platform_data/pixcir_i2c_ts.h
@@ -0,0 +1,64 @@
+#ifndef	_PIXCIR_I2C_TS_H
+#define	_PIXCIR_I2C_TS_H
+
+/*
+ * Register map
+ */
+#define PIXCIR_REG_POWER_MODE	51
+#define PIXCIR_REG_INT_MODE	52
+
+/*
+ * Power modes:
+ * active: max scan speed
+ * idle: lower scan speed with automatic transition to active on touch
+ * halt: datasheet says sleep but this is more like halt as the chip
+ *       clocks are cut and it can only be brought out of this mode
+ *	 using the RESET pin.
+ */
+enum pixcir_power_mode {
+	PIXCIR_POWER_ACTIVE,
+	PIXCIR_POWER_IDLE,
+	PIXCIR_POWER_HALT,
+};
+
+#define PIXCIR_POWER_MODE_MASK	0x03
+#define PIXCIR_POWER_ALLOW_IDLE (1UL << 2)
+
+/*
+ * Interrupt modes:
+ * periodical: interrupt is asserted periodicaly
+ * diff coordinates: interrupt is asserted when coordinates change
+ * level on touch: interrupt level asserted during touch
+ * pulse on touch: interrupt pulse asserted druing touch
+ *
+ */
+enum pixcir_int_mode {
+	PIXCIR_INT_PERIODICAL,
+	PIXCIR_INT_DIFF_COORD,
+	PIXCIR_INT_LEVEL_TOUCH,
+	PIXCIR_INT_PULSE_TOUCH,
+};
+
+#define PIXCIR_INT_MODE_MASK	0x03
+#define PIXCIR_INT_ENABLE	(1UL << 3)
+#define PIXCIR_INT_POL_HIGH	(1UL << 2)
+
+/**
+ * struct pixcir_irc_chip_data - chip related data
+ * @max_fingers:	Max number of fingers reported simultaneously by h/w
+ * @has_hw_ids:		Hardware supports finger tracking IDs
+ *
+ */
+struct pixcir_i2c_chip_data {
+	u8 max_fingers;
+	bool has_hw_ids;
+};
+
+struct pixcir_ts_platform_data {
+	int x_max;
+	int y_max;
+	int gpio_attb;		/* GPIO connected to ATTB line */
+	struct pixcir_i2c_chip_data chip;
+};
+
+#endif
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
@ 2015-07-07  0:30 ` Dmitry Torokhov
  2015-07-07 10:55   ` Roger Quadros
  2015-07-07  0:30 ` [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders Dmitry Torokhov
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

This allows uniform parsing on legacy, DT and ACPI systems.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c   | 26 +++++++++-----------------
 include/linux/platform_data/pixcir_i2c_ts.h |  1 -
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index ccafa75..9093aa9 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -25,8 +25,8 @@
 #include <linux/input.h>
 #include <linux/input/mt.h>
 #include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/of_device.h>
 #include <linux/platform_data/pixcir_i2c_ts.h>
 
@@ -35,6 +35,7 @@
 struct pixcir_i2c_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
+	struct gpio_desc *gpio_attb;
 	const struct pixcir_ts_platform_data *pdata;
 	bool running;
 	int max_fingers;	/* Max fingers supported in this instance */
@@ -161,7 +162,6 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
 static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 {
 	struct pixcir_i2c_ts_data *tsdata = dev_id;
-	const struct pixcir_ts_platform_data *pdata = tsdata->pdata;
 	struct pixcir_report_data report;
 
 	while (tsdata->running) {
@@ -171,7 +171,7 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 		/* report it */
 		pixcir_ts_report(tsdata, &report);
 
-		if (gpio_get_value(pdata->gpio_attb)) {
+		if (gpiod_get_value(tsdata->gpio_attb)) {
 			if (report.num_touches) {
 				/*
 				 * Last report with no finger up?
@@ -427,9 +427,6 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
 
 	pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
 
-	pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0);
-	/* gpio_attb validity is checked in probe */
-
 	if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) {
 		dev_err(dev, "Failed to get touchscreen-size-x property\n");
 		return ERR_PTR(-EINVAL);
@@ -442,8 +439,8 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
 	}
 	pdata->y_max -= 1;
 
-	dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
-		pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
+	dev_dbg(dev, "%s: x %d, y %d\n", __func__,
+		pdata->x_max + 1, pdata->y_max + 1);
 
 	return pdata;
 }
@@ -476,11 +473,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	if (!gpio_is_valid(pdata->gpio_attb)) {
-		dev_err(dev, "Invalid gpio_attb in pdata\n");
-		return -EINVAL;
-	}
-
 	if (!pdata->chip.max_fingers) {
 		dev_err(dev, "Invalid max_fingers in pdata\n");
 		return -EINVAL;
@@ -530,10 +522,10 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 	input_set_drvdata(input, tsdata);
 
-	error = devm_gpio_request_one(dev, pdata->gpio_attb,
-				      GPIOF_DIR_IN, "pixcir_i2c_attb");
-	if (error) {
-		dev_err(dev, "Failed to request ATTB gpio\n");
+	tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN);
+	if (IS_ERR(tsdata->gpio_attb)) {
+		error = PTR_ERR(tsdata->gpio_attb);
+		dev_err(dev, "Failed to request ATTB gpio: %d\n", error);
 		return error;
 	}
 
diff --git a/include/linux/platform_data/pixcir_i2c_ts.h b/include/linux/platform_data/pixcir_i2c_ts.h
index 7bae83b..646af6f 100644
--- a/include/linux/platform_data/pixcir_i2c_ts.h
+++ b/include/linux/platform_data/pixcir_i2c_ts.h
@@ -57,7 +57,6 @@ struct pixcir_i2c_chip_data {
 struct pixcir_ts_platform_data {
 	int x_max;
 	int y_max;
-	int gpio_attb;		/* GPIO connected to ATTB line */
 	struct pixcir_i2c_chip_data chip;
 };
 
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
  2015-07-07  0:30 ` [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod Dmitry Torokhov
@ 2015-07-07  0:30 ` Dmitry Torokhov
  2015-07-07 10:55   ` Roger Quadros
  2015-07-07  0:30 ` [PATCH 4/6] Input: pixcir_i2c_ts - add RESET gpio Dmitry Torokhov
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

We are using threaded interrupt handler and thus are allowed to sleep.
Let's switch over to gpiod_get_value_cansleep() so that we do not get
ugly warnings in case GPIO controller might sleep when accessing GPIO.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 9093aa9..8965d7c 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -171,7 +171,7 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 		/* report it */
 		pixcir_ts_report(tsdata, &report);
 
-		if (gpiod_get_value(tsdata->gpio_attb)) {
+		if (gpiod_get_value_cansleep(tsdata->gpio_attb)) {
 			if (report.num_touches) {
 				/*
 				 * Last report with no finger up?
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] Input: pixcir_i2c_ts - add RESET gpio
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
  2015-07-07  0:30 ` [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod Dmitry Torokhov
  2015-07-07  0:30 ` [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders Dmitry Torokhov
@ 2015-07-07  0:30 ` Dmitry Torokhov
  2015-07-07  0:30 ` [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization Dmitry Torokhov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

From: Roger Quadros <rogerq@ti.com>

The controller has a RESET pin which is usually controlled over
a GPIO line. If such a GPIO is provided, perform a RESET
during probe.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  3 +++
 drivers/input/touchscreen/pixcir_i2c_ts.c          | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
index 6e55109..8eb240a 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
@@ -8,6 +8,9 @@ Required properties:
 - touchscreen-size-x: horizontal resolution of touchscreen (in pixels)
 - touchscreen-size-y: vertical resolution of touchscreen (in pixels)
 
+Optional properties:
+- reset-gpio: GPIO connected to the RESET line of the chip
+
 Example:
 
 	i2c@00000000 {
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 8965d7c..9d9ac08 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -36,6 +36,7 @@ struct pixcir_i2c_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
 	struct gpio_desc *gpio_attb;
+	struct gpio_desc *gpio_reset;
 	const struct pixcir_ts_platform_data *pdata;
 	bool running;
 	int max_fingers;	/* Max fingers supported in this instance */
@@ -189,6 +190,17 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static void pixcir_reset(struct pixcir_i2c_ts_data *tsdata)
+{
+	if (!IS_ERR_OR_NULL(tsdata->gpio_reset)) {
+		gpiod_set_value_cansleep(tsdata->gpio_reset, 1);
+		ndelay(100);	/* datasheet section 1.2.3 says 80ns min. */
+		gpiod_set_value_cansleep(tsdata->gpio_reset, 0);
+		/* wait for controller ready. 100ms guess. */
+		msleep(100);
+	}
+}
+
 static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
 				 enum pixcir_power_mode mode)
 {
@@ -529,6 +541,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
+	tsdata->gpio_reset = devm_gpiod_get_optional(dev, "reset",
+						     GPIOD_OUT_LOW);
+	if (IS_ERR(tsdata->gpio_reset)) {
+		error = PTR_ERR(tsdata->gpio_reset);
+		dev_err(dev, "Failed to request RESET gpio: %d\n", error);
+		return error;
+	}
+
 	error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
 					  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 					  client->name, tsdata);
@@ -537,6 +557,8 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
+	pixcir_reset(tsdata);
+
 	/* Always be in IDLE mode to save power, device supports auto wake */
 	error = pixcir_set_power_mode(tsdata, PIXCIR_POWER_IDLE);
 	if (error) {
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2015-07-07  0:30 ` [PATCH 4/6] Input: pixcir_i2c_ts - add RESET gpio Dmitry Torokhov
@ 2015-07-07  0:30 ` Dmitry Torokhov
  2015-07-07 11:39   ` Roger Quadros
  2015-07-07  0:30 ` [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code Dmitry Torokhov
  2015-07-07 10:46 ` [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Roger Quadros
  5 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

input_mt_init_slots() will perform necessary settings for performing
multi-touch to single-touch emulation, we do not need to do that ourselves.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 9d9ac08..043d219 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -510,11 +510,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	input->close = pixcir_input_close;
 	input->dev.parent = &client->dev;
 
-	__set_bit(EV_KEY, input->evbit);
-	__set_bit(EV_ABS, input->evbit);
-	__set_bit(BTN_TOUCH, input->keybit);
-	input_set_abs_params(input, ABS_X, 0, pdata->x_max, 0, 0);
-	input_set_abs_params(input, ABS_Y, 0, pdata->y_max, 0, 0);
 	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
 	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
 
-- 
2.4.3.573.g4eafbef

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2015-07-07  0:30 ` [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization Dmitry Torokhov
@ 2015-07-07  0:30 ` Dmitry Torokhov
  2015-07-07 11:47   ` Roger Quadros
  2015-07-07 10:46 ` [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Roger Quadros
  5 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2015-07-07  0:30 UTC (permalink / raw)
  To: linux-input, Roger Quadros; +Cc: Jianchun Bian, linux-kernel

Let's switch to using standard touchscreen device properties parsing module
instead of doing it by hand in the driver.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 95 ++++++++++++++-----------------
 1 file changed, 44 insertions(+), 51 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 043d219..31f1c7d 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -24,9 +24,10 @@
 #include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
-#include <linux/of.h>
+/*#include <linux/of.h>*/
 #include <linux/of_device.h>
 #include <linux/platform_data/pixcir_i2c_ts.h>
 
@@ -37,9 +38,9 @@ struct pixcir_i2c_ts_data {
 	struct input_dev *input;
 	struct gpio_desc *gpio_attb;
 	struct gpio_desc *gpio_reset;
-	const struct pixcir_ts_platform_data *pdata;
-	bool running;
+	const struct pixcir_i2c_chip_data *chip;
 	int max_fingers;	/* Max fingers supported in this instance */
+	bool running;
 };
 
 struct pixcir_touch {
@@ -62,7 +63,7 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
 	u8 touch;
 	int ret, i;
 	int readsize;
-	const struct pixcir_i2c_chip_data *chip = &tsdata->pdata->chip;
+	const struct pixcir_i2c_chip_data *chip = tsdata->chip;
 
 	memset(report, 0, sizeof(struct pixcir_report_data));
 
@@ -115,13 +116,13 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
 	struct pixcir_touch *touch;
 	int n, i, slot;
 	struct device *dev = &ts->client->dev;
-	const struct pixcir_i2c_chip_data *chip = &ts->pdata->chip;
+	const struct pixcir_i2c_chip_data *chip = ts->chip;
 
 	n = report->num_touches;
 	if (n > PIXCIR_MAX_SLOTS)
 		n = PIXCIR_MAX_SLOTS;
 
-	if (!chip->has_hw_ids) {
+	if (!ts->chip->has_hw_ids) {
 		for (i = 0; i < n; i++) {
 			touch = &report->touches[i];
 			pos[i].x = touch->x;
@@ -423,77 +424,59 @@ static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
 #ifdef CONFIG_OF
 static const struct of_device_id pixcir_of_match[];
 
-static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
+static int pixcir_parse_dt(struct device *dev,
+			   struct pixcir_i2c_ts_data *tsdata)
 {
-	struct pixcir_ts_platform_data *pdata;
-	struct device_node *np = dev->of_node;
 	const struct of_device_id *match;
 
 	match = of_match_device(of_match_ptr(pixcir_of_match), dev);
 	if (!match)
-		return ERR_PTR(-EINVAL);
-
-	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return ERR_PTR(-ENOMEM);
-
-	pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
-
-	if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) {
-		dev_err(dev, "Failed to get touchscreen-size-x property\n");
-		return ERR_PTR(-EINVAL);
-	}
-	pdata->x_max -= 1;
-
-	if (of_property_read_u32(np, "touchscreen-size-y", &pdata->y_max)) {
-		dev_err(dev, "Failed to get touchscreen-size-y property\n");
-		return ERR_PTR(-EINVAL);
-	}
-	pdata->y_max -= 1;
+		return -EINVAL;
 
-	dev_dbg(dev, "%s: x %d, y %d\n", __func__,
-		pdata->x_max + 1, pdata->y_max + 1);
+	tsdata->chip = (const struct pixcir_i2c_chip_data *)match->data;
+	if (!tsdata->chip)
+		return -EINVAL;
 
-	return pdata;
+	return 0;
 }
 #else
-static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
+static int pixcir_parse_dt(struct device *dev,
+			   struct pixcir_i2c_ts_data *tsdata)
 {
-	return ERR_PTR(-EINVAL);
+	return -EINVAL;
 }
 #endif
 
 static int pixcir_i2c_ts_probe(struct i2c_client *client,
-					 const struct i2c_device_id *id)
+			       const struct i2c_device_id *id)
 {
 	const struct pixcir_ts_platform_data *pdata =
 			dev_get_platdata(&client->dev);
 	struct device *dev = &client->dev;
-	struct device_node *np = dev->of_node;
 	struct pixcir_i2c_ts_data *tsdata;
 	struct input_dev *input;
 	int error;
 
-	if (np && !pdata) {
-		pdata = pixcir_parse_dt(dev);
-		if (IS_ERR(pdata))
-			return PTR_ERR(pdata);
-	}
+	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
+	if (!tsdata)
+		return -ENOMEM;
 
-	if (!pdata) {
+	if (pdata) {
+		tsdata->chip = &pdata->chip;
+	} else if (dev->of_node) {
+		error = pixcir_parse_dt(dev, tsdata);
+		if (error)
+			return error;
+	} else {
 		dev_err(&client->dev, "platform data not defined\n");
 		return -EINVAL;
 	}
 
-	if (!pdata->chip.max_fingers) {
-		dev_err(dev, "Invalid max_fingers in pdata\n");
+	if (!tsdata->chip->max_fingers) {
+		dev_err(dev, "Invalid max_fingers in chip data\n");
 		return -EINVAL;
 	}
 
-	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
-	if (!tsdata)
-		return -ENOMEM;
-
 	input = devm_input_allocate_device(dev);
 	if (!input) {
 		dev_err(dev, "Failed to allocate input device\n");
@@ -502,7 +485,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 	tsdata->client = client;
 	tsdata->input = input;
-	tsdata->pdata = pdata;
 
 	input->name = client->name;
 	input->id.bustype = BUS_I2C;
@@ -510,10 +492,21 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	input->close = pixcir_input_close;
 	input->dev.parent = &client->dev;
 
-	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
-	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
+	if (pdata) {
+		input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
+		input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
+	} else {
+		input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
+		input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
+		touchscreen_parse_properties(input, true);
+		if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
+		    !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
+			dev_err(dev, "Touchscreen size is not specified\n");
+			return -EINVAL;
+		}
+	}
 
-	tsdata->max_fingers = tsdata->pdata->chip.max_fingers;
+	tsdata->max_fingers = tsdata->chip->max_fingers;
 	if (tsdata->max_fingers > PIXCIR_MAX_SLOTS) {
 		tsdata->max_fingers = PIXCIR_MAX_SLOTS;
 		dev_info(dev, "Limiting maximum fingers to %d\n",
-- 
2.4.3.573.g4eafbef


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/6] Input: pixcir_i2c_ts - move platform data
  2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2015-07-07  0:30 ` [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code Dmitry Torokhov
@ 2015-07-07 10:46 ` Roger Quadros
  5 siblings, 0 replies; 11+ messages in thread
From: Roger Quadros @ 2015-07-07 10:46 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: Jianchun Bian, linux-kernel

On 07/07/15 03:30, Dmitry Torokhov wrote:
> Let's move driver's platform data definitions from include/linux/input/
> into include/linux/platform_data/ so that it stays with the rest of
> platform data definitions.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>   drivers/input/touchscreen/pixcir_i2c_ts.c   |  2 +-
>   include/linux/input/pixcir_ts.h             | 64 -----------------------------
>   include/linux/platform_data/pixcir_i2c_ts.h | 64 +++++++++++++++++++++++++++++
>   3 files changed, 65 insertions(+), 65 deletions(-)
>   delete mode 100644 include/linux/input/pixcir_ts.h
>   create mode 100644 include/linux/platform_data/pixcir_i2c_ts.h
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 8f3e243..ccafa75 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -24,11 +24,11 @@
>   #include <linux/i2c.h>
>   #include <linux/input.h>
>   #include <linux/input/mt.h>
> -#include <linux/input/pixcir_ts.h>
>   #include <linux/gpio.h>
>   #include <linux/of.h>
>   #include <linux/of_gpio.h>
>   #include <linux/of_device.h>
> +#include <linux/platform_data/pixcir_i2c_ts.h>
>
>   #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
>
> diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h
> deleted file mode 100644
> index 7bae83b..0000000
> --- a/include/linux/input/pixcir_ts.h
> +++ /dev/null
> @@ -1,64 +0,0 @@
> -#ifndef	_PIXCIR_I2C_TS_H
> -#define	_PIXCIR_I2C_TS_H
> -
> -/*
> - * Register map
> - */
> -#define PIXCIR_REG_POWER_MODE	51
> -#define PIXCIR_REG_INT_MODE	52
> -
> -/*
> - * Power modes:
> - * active: max scan speed
> - * idle: lower scan speed with automatic transition to active on touch
> - * halt: datasheet says sleep but this is more like halt as the chip
> - *       clocks are cut and it can only be brought out of this mode
> - *	 using the RESET pin.
> - */
> -enum pixcir_power_mode {
> -	PIXCIR_POWER_ACTIVE,
> -	PIXCIR_POWER_IDLE,
> -	PIXCIR_POWER_HALT,
> -};
> -
> -#define PIXCIR_POWER_MODE_MASK	0x03
> -#define PIXCIR_POWER_ALLOW_IDLE (1UL << 2)
> -
> -/*
> - * Interrupt modes:
> - * periodical: interrupt is asserted periodicaly
> - * diff coordinates: interrupt is asserted when coordinates change
> - * level on touch: interrupt level asserted during touch
> - * pulse on touch: interrupt pulse asserted druing touch
> - *
> - */
> -enum pixcir_int_mode {
> -	PIXCIR_INT_PERIODICAL,
> -	PIXCIR_INT_DIFF_COORD,
> -	PIXCIR_INT_LEVEL_TOUCH,
> -	PIXCIR_INT_PULSE_TOUCH,
> -};
> -
> -#define PIXCIR_INT_MODE_MASK	0x03
> -#define PIXCIR_INT_ENABLE	(1UL << 3)
> -#define PIXCIR_INT_POL_HIGH	(1UL << 2)
> -
> -/**
> - * struct pixcir_irc_chip_data - chip related data
> - * @max_fingers:	Max number of fingers reported simultaneously by h/w
> - * @has_hw_ids:		Hardware supports finger tracking IDs
> - *
> - */
> -struct pixcir_i2c_chip_data {
> -	u8 max_fingers;
> -	bool has_hw_ids;
> -};
> -
> -struct pixcir_ts_platform_data {
> -	int x_max;
> -	int y_max;
> -	int gpio_attb;		/* GPIO connected to ATTB line */
> -	struct pixcir_i2c_chip_data chip;
> -};
> -
> -#endif
> diff --git a/include/linux/platform_data/pixcir_i2c_ts.h b/include/linux/platform_data/pixcir_i2c_ts.h
> new file mode 100644
> index 0000000..7bae83b
> --- /dev/null
> +++ b/include/linux/platform_data/pixcir_i2c_ts.h
> @@ -0,0 +1,64 @@
> +#ifndef	_PIXCIR_I2C_TS_H
> +#define	_PIXCIR_I2C_TS_H
> +
> +/*
> + * Register map
> + */
> +#define PIXCIR_REG_POWER_MODE	51
> +#define PIXCIR_REG_INT_MODE	52
> +
> +/*
> + * Power modes:
> + * active: max scan speed
> + * idle: lower scan speed with automatic transition to active on touch
> + * halt: datasheet says sleep but this is more like halt as the chip
> + *       clocks are cut and it can only be brought out of this mode
> + *	 using the RESET pin.
> + */
> +enum pixcir_power_mode {
> +	PIXCIR_POWER_ACTIVE,
> +	PIXCIR_POWER_IDLE,
> +	PIXCIR_POWER_HALT,
> +};
> +
> +#define PIXCIR_POWER_MODE_MASK	0x03
> +#define PIXCIR_POWER_ALLOW_IDLE (1UL << 2)
> +
> +/*
> + * Interrupt modes:
> + * periodical: interrupt is asserted periodicaly
> + * diff coordinates: interrupt is asserted when coordinates change
> + * level on touch: interrupt level asserted during touch
> + * pulse on touch: interrupt pulse asserted druing touch
> + *
> + */
> +enum pixcir_int_mode {
> +	PIXCIR_INT_PERIODICAL,
> +	PIXCIR_INT_DIFF_COORD,
> +	PIXCIR_INT_LEVEL_TOUCH,
> +	PIXCIR_INT_PULSE_TOUCH,
> +};
> +
> +#define PIXCIR_INT_MODE_MASK	0x03
> +#define PIXCIR_INT_ENABLE	(1UL << 3)
> +#define PIXCIR_INT_POL_HIGH	(1UL << 2)
> +
> +/**
> + * struct pixcir_irc_chip_data - chip related data
> + * @max_fingers:	Max number of fingers reported simultaneously by h/w
> + * @has_hw_ids:		Hardware supports finger tracking IDs
> + *
> + */
> +struct pixcir_i2c_chip_data {
> +	u8 max_fingers;
> +	bool has_hw_ids;
> +};
> +
> +struct pixcir_ts_platform_data {
> +	int x_max;
> +	int y_max;
> +	int gpio_attb;		/* GPIO connected to ATTB line */
> +	struct pixcir_i2c_chip_data chip;
> +};
> +
> +#endif
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod
  2015-07-07  0:30 ` [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod Dmitry Torokhov
@ 2015-07-07 10:55   ` Roger Quadros
  0 siblings, 0 replies; 11+ messages in thread
From: Roger Quadros @ 2015-07-07 10:55 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: Jianchun Bian, linux-kernel

On 07/07/15 03:30, Dmitry Torokhov wrote:
> This allows uniform parsing on legacy, DT and ACPI systems.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>   drivers/input/touchscreen/pixcir_i2c_ts.c   | 26 +++++++++-----------------
>   include/linux/platform_data/pixcir_i2c_ts.h |  1 -
>   2 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index ccafa75..9093aa9 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -25,8 +25,8 @@
>   #include <linux/input.h>
>   #include <linux/input/mt.h>
>   #include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
>   #include <linux/of.h>
> -#include <linux/of_gpio.h>
>   #include <linux/of_device.h>
>   #include <linux/platform_data/pixcir_i2c_ts.h>
>
> @@ -35,6 +35,7 @@
>   struct pixcir_i2c_ts_data {
>   	struct i2c_client *client;
>   	struct input_dev *input;
> +	struct gpio_desc *gpio_attb;
>   	const struct pixcir_ts_platform_data *pdata;
>   	bool running;
>   	int max_fingers;	/* Max fingers supported in this instance */
> @@ -161,7 +162,6 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
>   static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
>   {
>   	struct pixcir_i2c_ts_data *tsdata = dev_id;
> -	const struct pixcir_ts_platform_data *pdata = tsdata->pdata;
>   	struct pixcir_report_data report;
>
>   	while (tsdata->running) {
> @@ -171,7 +171,7 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
>   		/* report it */
>   		pixcir_ts_report(tsdata, &report);
>
> -		if (gpio_get_value(pdata->gpio_attb)) {
> +		if (gpiod_get_value(tsdata->gpio_attb)) {
>   			if (report.num_touches) {
>   				/*
>   				 * Last report with no finger up?
> @@ -427,9 +427,6 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
>
>   	pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
>
> -	pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0);
> -	/* gpio_attb validity is checked in probe */
> -
>   	if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) {
>   		dev_err(dev, "Failed to get touchscreen-size-x property\n");
>   		return ERR_PTR(-EINVAL);
> @@ -442,8 +439,8 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
>   	}
>   	pdata->y_max -= 1;
>
> -	dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
> -		pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
> +	dev_dbg(dev, "%s: x %d, y %d\n", __func__,
> +		pdata->x_max + 1, pdata->y_max + 1);
>
>   	return pdata;
>   }
> @@ -476,11 +473,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   		return -EINVAL;
>   	}
>
> -	if (!gpio_is_valid(pdata->gpio_attb)) {
> -		dev_err(dev, "Invalid gpio_attb in pdata\n");
> -		return -EINVAL;
> -	}
> -
>   	if (!pdata->chip.max_fingers) {
>   		dev_err(dev, "Invalid max_fingers in pdata\n");
>   		return -EINVAL;
> @@ -530,10 +522,10 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>
>   	input_set_drvdata(input, tsdata);
>
> -	error = devm_gpio_request_one(dev, pdata->gpio_attb,
> -				      GPIOF_DIR_IN, "pixcir_i2c_attb");
> -	if (error) {
> -		dev_err(dev, "Failed to request ATTB gpio\n");
> +	tsdata->gpio_attb = devm_gpiod_get(dev, "attb", GPIOD_IN);
> +	if (IS_ERR(tsdata->gpio_attb)) {
> +		error = PTR_ERR(tsdata->gpio_attb);
> +		dev_err(dev, "Failed to request ATTB gpio: %d\n", error);
>   		return error;
>   	}
>
> diff --git a/include/linux/platform_data/pixcir_i2c_ts.h b/include/linux/platform_data/pixcir_i2c_ts.h
> index 7bae83b..646af6f 100644
> --- a/include/linux/platform_data/pixcir_i2c_ts.h
> +++ b/include/linux/platform_data/pixcir_i2c_ts.h
> @@ -57,7 +57,6 @@ struct pixcir_i2c_chip_data {
>   struct pixcir_ts_platform_data {
>   	int x_max;
>   	int y_max;
> -	int gpio_attb;		/* GPIO connected to ATTB line */
>   	struct pixcir_i2c_chip_data chip;
>   };
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders
  2015-07-07  0:30 ` [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders Dmitry Torokhov
@ 2015-07-07 10:55   ` Roger Quadros
  0 siblings, 0 replies; 11+ messages in thread
From: Roger Quadros @ 2015-07-07 10:55 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: linux-kernel

On 07/07/15 03:30, Dmitry Torokhov wrote:
> We are using threaded interrupt handler and thus are allowed to sleep.
> Let's switch over to gpiod_get_value_cansleep() so that we do not get
> ugly warnings in case GPIO controller might sleep when accessing GPIO.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>   drivers/input/touchscreen/pixcir_i2c_ts.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 9093aa9..8965d7c 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -171,7 +171,7 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
>   		/* report it */
>   		pixcir_ts_report(tsdata, &report);
>
> -		if (gpiod_get_value(tsdata->gpio_attb)) {
> +		if (gpiod_get_value_cansleep(tsdata->gpio_attb)) {
>   			if (report.num_touches) {
>   				/*
>   				 * Last report with no finger up?
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization
  2015-07-07  0:30 ` [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization Dmitry Torokhov
@ 2015-07-07 11:39   ` Roger Quadros
  0 siblings, 0 replies; 11+ messages in thread
From: Roger Quadros @ 2015-07-07 11:39 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: Jianchun Bian, linux-kernel


On 07/07/15 03:30, Dmitry Torokhov wrote:
> input_mt_init_slots() will perform necessary settings for performing
> multi-touch to single-touch emulation, we do not need to do that ourselves.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>   drivers/input/touchscreen/pixcir_i2c_ts.c | 5 -----
>   1 file changed, 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 9d9ac08..043d219 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -510,11 +510,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   	input->close = pixcir_input_close;
>   	input->dev.parent = &client->dev;
>
> -	__set_bit(EV_KEY, input->evbit);
> -	__set_bit(EV_ABS, input->evbit);
> -	__set_bit(BTN_TOUCH, input->keybit);
> -	input_set_abs_params(input, ABS_X, 0, pdata->x_max, 0, 0);
> -	input_set_abs_params(input, ABS_Y, 0, pdata->y_max, 0, 0);
>   	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
>   	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code
  2015-07-07  0:30 ` [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code Dmitry Torokhov
@ 2015-07-07 11:47   ` Roger Quadros
  0 siblings, 0 replies; 11+ messages in thread
From: Roger Quadros @ 2015-07-07 11:47 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: linux-kernel

On 07/07/15 03:30, Dmitry Torokhov wrote:
> Let's switch to using standard touchscreen device properties parsing module
> instead of doing it by hand in the driver.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>   drivers/input/touchscreen/pixcir_i2c_ts.c | 95 ++++++++++++++-----------------
>   1 file changed, 44 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 043d219..31f1c7d 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -24,9 +24,10 @@
>   #include <linux/i2c.h>
>   #include <linux/input.h>
>   #include <linux/input/mt.h>
> +#include <linux/input/touchscreen.h>
>   #include <linux/gpio.h>
>   #include <linux/gpio/consumer.h>
> -#include <linux/of.h>
> +/*#include <linux/of.h>*/
>   #include <linux/of_device.h>
>   #include <linux/platform_data/pixcir_i2c_ts.h>
>
> @@ -37,9 +38,9 @@ struct pixcir_i2c_ts_data {
>   	struct input_dev *input;
>   	struct gpio_desc *gpio_attb;
>   	struct gpio_desc *gpio_reset;
> -	const struct pixcir_ts_platform_data *pdata;
> -	bool running;
> +	const struct pixcir_i2c_chip_data *chip;
>   	int max_fingers;	/* Max fingers supported in this instance */
> +	bool running;
>   };
>
>   struct pixcir_touch {
> @@ -62,7 +63,7 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
>   	u8 touch;
>   	int ret, i;
>   	int readsize;
> -	const struct pixcir_i2c_chip_data *chip = &tsdata->pdata->chip;
> +	const struct pixcir_i2c_chip_data *chip = tsdata->chip;
>
>   	memset(report, 0, sizeof(struct pixcir_report_data));
>
> @@ -115,13 +116,13 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
>   	struct pixcir_touch *touch;
>   	int n, i, slot;
>   	struct device *dev = &ts->client->dev;
> -	const struct pixcir_i2c_chip_data *chip = &ts->pdata->chip;
> +	const struct pixcir_i2c_chip_data *chip = ts->chip;
>
>   	n = report->num_touches;
>   	if (n > PIXCIR_MAX_SLOTS)
>   		n = PIXCIR_MAX_SLOTS;
>
> -	if (!chip->has_hw_ids) {
> +	if (!ts->chip->has_hw_ids) {
>   		for (i = 0; i < n; i++) {
>   			touch = &report->touches[i];
>   			pos[i].x = touch->x;
> @@ -423,77 +424,59 @@ static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
>   #ifdef CONFIG_OF
>   static const struct of_device_id pixcir_of_match[];
>
> -static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
> +static int pixcir_parse_dt(struct device *dev,
> +			   struct pixcir_i2c_ts_data *tsdata)
>   {
> -	struct pixcir_ts_platform_data *pdata;
> -	struct device_node *np = dev->of_node;
>   	const struct of_device_id *match;
>
>   	match = of_match_device(of_match_ptr(pixcir_of_match), dev);
>   	if (!match)
> -		return ERR_PTR(-EINVAL);
> -
> -	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> -	if (!pdata)
> -		return ERR_PTR(-ENOMEM);
> -
> -	pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
> -
> -	if (of_property_read_u32(np, "touchscreen-size-x", &pdata->x_max)) {
> -		dev_err(dev, "Failed to get touchscreen-size-x property\n");
> -		return ERR_PTR(-EINVAL);
> -	}
> -	pdata->x_max -= 1;
> -
> -	if (of_property_read_u32(np, "touchscreen-size-y", &pdata->y_max)) {
> -		dev_err(dev, "Failed to get touchscreen-size-y property\n");
> -		return ERR_PTR(-EINVAL);
> -	}
> -	pdata->y_max -= 1;
> +		return -EINVAL;
>
> -	dev_dbg(dev, "%s: x %d, y %d\n", __func__,
> -		pdata->x_max + 1, pdata->y_max + 1);
> +	tsdata->chip = (const struct pixcir_i2c_chip_data *)match->data;
> +	if (!tsdata->chip)
> +		return -EINVAL;
>
> -	return pdata;
> +	return 0;
>   }
>   #else
> -static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
> +static int pixcir_parse_dt(struct device *dev,
> +			   struct pixcir_i2c_ts_data *tsdata)
>   {
> -	return ERR_PTR(-EINVAL);
> +	return -EINVAL;
>   }
>   #endif
>
>   static int pixcir_i2c_ts_probe(struct i2c_client *client,
> -					 const struct i2c_device_id *id)
> +			       const struct i2c_device_id *id)
>   {
>   	const struct pixcir_ts_platform_data *pdata =
>   			dev_get_platdata(&client->dev);
>   	struct device *dev = &client->dev;
> -	struct device_node *np = dev->of_node;
>   	struct pixcir_i2c_ts_data *tsdata;
>   	struct input_dev *input;
>   	int error;
>
> -	if (np && !pdata) {
> -		pdata = pixcir_parse_dt(dev);
> -		if (IS_ERR(pdata))
> -			return PTR_ERR(pdata);
> -	}
> +	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
> +	if (!tsdata)
> +		return -ENOMEM;
>
> -	if (!pdata) {
> +	if (pdata) {
> +		tsdata->chip = &pdata->chip;
> +	} else if (dev->of_node) {
> +		error = pixcir_parse_dt(dev, tsdata);
> +		if (error)
> +			return error;
> +	} else {
>   		dev_err(&client->dev, "platform data not defined\n");
>   		return -EINVAL;
>   	}
>
> -	if (!pdata->chip.max_fingers) {
> -		dev_err(dev, "Invalid max_fingers in pdata\n");
> +	if (!tsdata->chip->max_fingers) {
> +		dev_err(dev, "Invalid max_fingers in chip data\n");
>   		return -EINVAL;
>   	}
>
> -	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
> -	if (!tsdata)
> -		return -ENOMEM;
> -
>   	input = devm_input_allocate_device(dev);
>   	if (!input) {
>   		dev_err(dev, "Failed to allocate input device\n");
> @@ -502,7 +485,6 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>
>   	tsdata->client = client;
>   	tsdata->input = input;
> -	tsdata->pdata = pdata;
>
>   	input->name = client->name;
>   	input->id.bustype = BUS_I2C;
> @@ -510,10 +492,21 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   	input->close = pixcir_input_close;
>   	input->dev.parent = &client->dev;
>
> -	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
> -	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
> +	if (pdata) {
> +		input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
> +		input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
> +	} else {
> +		input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
> +		input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
> +		touchscreen_parse_properties(input, true);
> +		if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
> +		    !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
> +			dev_err(dev, "Touchscreen size is not specified\n");
> +			return -EINVAL;
> +		}
> +	}
>
> -	tsdata->max_fingers = tsdata->pdata->chip.max_fingers;
> +	tsdata->max_fingers = tsdata->chip->max_fingers;
>   	if (tsdata->max_fingers > PIXCIR_MAX_SLOTS) {
>   		tsdata->max_fingers = PIXCIR_MAX_SLOTS;
>   		dev_info(dev, "Limiting maximum fingers to %d\n",
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-07-07 11:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07  0:30 [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Dmitry Torokhov
2015-07-07  0:30 ` [PATCH 2/6] Input: pixcir_i2c_ts - switch the device over to gpiod Dmitry Torokhov
2015-07-07 10:55   ` Roger Quadros
2015-07-07  0:30 ` [PATCH 3/6] Input: pixcir_i2c_ts - allow using with GPIO expanders Dmitry Torokhov
2015-07-07 10:55   ` Roger Quadros
2015-07-07  0:30 ` [PATCH 4/6] Input: pixcir_i2c_ts - add RESET gpio Dmitry Torokhov
2015-07-07  0:30 ` [PATCH 5/6] Input: pixcir_i2c_ts - simplify input device initialization Dmitry Torokhov
2015-07-07 11:39   ` Roger Quadros
2015-07-07  0:30 ` [PATCH 6/6] Input: pixcir_i2c_ts - use standard OF touchscreen parsing code Dmitry Torokhov
2015-07-07 11:47   ` Roger Quadros
2015-07-07 10:46 ` [PATCH 1/6] Input: pixcir_i2c_ts - move platform data Roger Quadros

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).