linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework
@ 2015-09-12 17:45 Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

From: Franklin S Cooper Jr <fcooper@ti.com>

The current/old gpio framework used doesn't properly listen to
ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
account these flags when setting gpio values.

Since the values being output were based on voltage and not logic they
change to reflect this difference. Also use gpiod_set_value_cansleep since
wake and reset pins can be provided by bus based io expanders.

Switch from msleep(5) to udelay_range(5000,6000) to avoid check patch
warning.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 .../bindings/input/touchscreen/edt-ft5x06.txt      |   4 +-
 drivers/input/touchscreen/edt-ft5x06.c             | 129 ++++++---------------
 include/linux/input/edt-ft5x06.h                   |   3 -
 3 files changed, 40 insertions(+), 96 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
index 76db967..9330d4d 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
@@ -50,6 +50,6 @@ Example:
 		pinctrl-0 = <&edt_ft5x06_pins>;
 		interrupt-parent = <&gpio2>;
 		interrupts = <5 0>;
-		reset-gpios = <&gpio2 6 1>;
-		wake-gpios = <&gpio4 9 0>;
+		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
+		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
 	};
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 48de1e8..5738722 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -34,8 +34,7 @@
 #include <linux/delay.h>
 #include <linux/debugfs.h>
 #include <linux/slab.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/input/mt.h>
 #include <linux/input/touchscreen.h>
 #include <linux/input/edt-ft5x06.h>
@@ -91,9 +90,9 @@ struct edt_ft5x06_ts_data {
 	u16 num_x;
 	u16 num_y;
 
-	int reset_pin;
-	int irq_pin;
-	int wake_pin;
+	struct gpio_desc *reset_gpio;
+	struct gpio_desc *wake_gpio;
+	struct gpio_desc *irq_gpio;
 
 #if defined(CONFIG_DEBUG_FS)
 	struct dentry *debug_dir;
@@ -752,45 +751,6 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
 
 #endif /* CONFIG_DEBUGFS */
 
-static int edt_ft5x06_ts_reset(struct i2c_client *client,
-			struct edt_ft5x06_ts_data *tsdata)
-{
-	int error;
-
-	if (gpio_is_valid(tsdata->wake_pin)) {
-		error = devm_gpio_request_one(&client->dev,
-					tsdata->wake_pin, GPIOF_OUT_INIT_LOW,
-					"edt-ft5x06 wake");
-		if (error) {
-			dev_err(&client->dev,
-				"Failed to request GPIO %d as wake pin, error %d\n",
-				tsdata->wake_pin, error);
-			return error;
-		}
-
-		msleep(5);
-		gpio_set_value(tsdata->wake_pin, 1);
-	}
-	if (gpio_is_valid(tsdata->reset_pin)) {
-		/* this pulls reset down, enabling the low active reset */
-		error = devm_gpio_request_one(&client->dev,
-					tsdata->reset_pin, GPIOF_OUT_INIT_LOW,
-					"edt-ft5x06 reset");
-		if (error) {
-			dev_err(&client->dev,
-				"Failed to request GPIO %d as reset pin, error %d\n",
-				tsdata->reset_pin, error);
-			return error;
-		}
-
-		msleep(5);
-		gpio_set_value(tsdata->reset_pin, 1);
-		msleep(300);
-	}
-
-	return 0;
-}
-
 static int edt_ft5x06_ts_identify(struct i2c_client *client,
 					struct edt_ft5x06_ts_data *tsdata,
 					char *fw_version)
@@ -931,30 +891,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
 	}
 }
 
-#ifdef CONFIG_OF
-static int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
-				struct edt_ft5x06_ts_data *tsdata)
-{
-	struct device_node *np = dev->of_node;
-
-	/*
-	 * irq_pin is not needed for DT setup.
-	 * irq is associated via 'interrupts' property in DT
-	 */
-	tsdata->irq_pin = -EINVAL;
-	tsdata->reset_pin = of_get_named_gpio(np, "reset-gpios", 0);
-	tsdata->wake_pin = of_get_named_gpio(np, "wake-gpios", 0);
-
-	return 0;
-}
-#else
-static inline int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
-					struct edt_ft5x06_ts_data *tsdata)
-{
-	return -ENODEV;
-}
-#endif
-
 static int edt_ft5x06_ts_probe(struct i2c_client *client,
 					 const struct i2c_device_id *id)
 {
@@ -973,32 +909,42 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 		return -ENOMEM;
 	}
 
-	if (!pdata) {
-		error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata);
-		if (error) {
-			dev_err(&client->dev,
-				"DT probe failed and no platform data present\n");
-			return error;
-		}
-	} else {
-		tsdata->reset_pin = pdata->reset_pin;
-		tsdata->irq_pin = pdata->irq_pin;
-		tsdata->wake_pin = -EINVAL;
+	tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
+						     "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(tsdata->reset_gpio)) {
+		error = PTR_ERR(tsdata->reset_gpio);
+		dev_err(&client->dev,
+			"Failed to request GPIO reset pin, error %d\n", error);
+		return error;
 	}
 
-	error = edt_ft5x06_ts_reset(client, tsdata);
-	if (error)
+	tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
+						    "wake", GPIOD_OUT_LOW);
+	if (IS_ERR(tsdata->wake_gpio)) {
+		error = PTR_ERR(tsdata->wake_gpio);
+		dev_err(&client->dev,
+			"Failed to request GPIO wake pin, error %d\n", error);
 		return error;
+	}
 
-	if (gpio_is_valid(tsdata->irq_pin)) {
-		error = devm_gpio_request_one(&client->dev, tsdata->irq_pin,
-					GPIOF_IN, "edt-ft5x06 irq");
-		if (error) {
-			dev_err(&client->dev,
-				"Failed to request GPIO %d, error %d\n",
-				tsdata->irq_pin, error);
-			return error;
-		}
+	tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
+						   "irq", GPIOD_IN);
+	if (IS_ERR(tsdata->irq_gpio)) {
+		error = PTR_ERR(tsdata->irq_gpio);
+		dev_err(&client->dev,
+			"Failed to request GPIO irq pin, error %d\n", error);
+		return error;
+	}
+
+	if (tsdata->wake_gpio) {
+		usleep_range(5000, 6000);
+		gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
+	}
+
+	if (tsdata->reset_gpio) {
+		usleep_range(5000, 6000);
+		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
+		msleep(300);
 	}
 
 	input = devm_input_allocate_device(&client->dev);
@@ -1074,7 +1020,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 
 	dev_dbg(&client->dev,
 		"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
-		client->irq, tsdata->wake_pin, tsdata->reset_pin);
+		client->irq, desc_to_gpio(tsdata->wake_gpio),
+		desc_to_gpio(tsdata->reset_gpio));
 
 	return 0;
 
diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
index 8a1e0d1..5ca5b4c 100644
--- a/include/linux/input/edt-ft5x06.h
+++ b/include/linux/input/edt-ft5x06.h
@@ -10,9 +10,6 @@
  */
 
 struct edt_ft5x06_platform_data {
-	int irq_pin;
-	int reset_pin;
-
 	/* startup defaults for operational parameters */
 	bool use_parameters;
 	u8 gain;
-- 
2.6.0.rc0.131.gf624c3d


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

* [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
@ 2015-09-12 17:45 ` Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data Dmitry Torokhov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

The driver does not use irq gpio as gpio, but rather relies on I2C core or
board code to set up client's structure IRQ line, so let's stop trying to
locate the resource and parse it.

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

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 5738722..df76f19 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -92,7 +92,6 @@ struct edt_ft5x06_ts_data {
 
 	struct gpio_desc *reset_gpio;
 	struct gpio_desc *wake_gpio;
-	struct gpio_desc *irq_gpio;
 
 #if defined(CONFIG_DEBUG_FS)
 	struct dentry *debug_dir;
@@ -927,15 +926,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
-	tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
-						   "irq", GPIOD_IN);
-	if (IS_ERR(tsdata->irq_gpio)) {
-		error = PTR_ERR(tsdata->irq_gpio);
-		dev_err(&client->dev,
-			"Failed to request GPIO irq pin, error %d\n", error);
-		return error;
-	}
-
 	if (tsdata->wake_gpio) {
 		usleep_range(5000, 6000);
 		gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
-- 
2.6.0.rc0.131.gf624c3d


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

* [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov
@ 2015-09-12 17:45 ` Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 4/6] Input: edt-ft5x06 - use generic properties API Dmitry Torokhov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

We do not have any users of platform data in the tree and all newer
platforms are either DT or ACPI, so let's drop handling of platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 41 ++++------------------------------
 include/linux/input/edt-ft5x06.h       | 21 -----------------
 2 files changed, 4 insertions(+), 58 deletions(-)
 delete mode 100644 include/linux/input/edt-ft5x06.h

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index df76f19..134c66c 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -37,7 +37,6 @@
 #include <linux/gpio/consumer.h>
 #include <linux/input/mt.h>
 #include <linux/input/touchscreen.h>
-#include <linux/input/edt-ft5x06.h>
 
 #define MAX_SUPPORT_POINTS		5
 
@@ -809,21 +808,14 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
 	return 0;
 }
 
-#define EDT_ATTR_CHECKSET(name, reg) \
-do {								\
-	if (pdata->name >= edt_ft5x06_attr_##name.limit_low &&		\
-	    pdata->name <= edt_ft5x06_attr_##name.limit_high)		\
-		edt_ft5x06_register_write(tsdata, reg, pdata->name);	\
-} while (0)
-
 #define EDT_GET_PROP(name, reg) {				\
 	u32 val;						\
 	if (of_property_read_u32(np, #name, &val) == 0)		\
 		edt_ft5x06_register_write(tsdata, reg, val);	\
 }
 
-static void edt_ft5x06_ts_get_dt_defaults(struct device_node *np,
-					struct edt_ft5x06_ts_data *tsdata)
+static void edt_ft5x06_ts_get_defaults(struct device_node *np,
+				       struct edt_ft5x06_ts_data *tsdata)
 {
 	struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
 
@@ -833,23 +825,6 @@ static void edt_ft5x06_ts_get_dt_defaults(struct device_node *np,
 }
 
 static void
-edt_ft5x06_ts_get_defaults(struct edt_ft5x06_ts_data *tsdata,
-			   const struct edt_ft5x06_platform_data *pdata)
-{
-	struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
-
-	if (!pdata->use_parameters)
-		return;
-
-	/* pick up defaults from the platform data */
-	EDT_ATTR_CHECKSET(threshold, reg_addr->reg_threshold);
-	EDT_ATTR_CHECKSET(gain, reg_addr->reg_gain);
-	EDT_ATTR_CHECKSET(offset, reg_addr->reg_offset);
-	if (reg_addr->reg_report_rate != NO_REGISTER)
-		EDT_ATTR_CHECKSET(report_rate, reg_addr->reg_report_rate);
-}
-
-static void
 edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
 {
 	struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
@@ -893,8 +868,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
 static int edt_ft5x06_ts_probe(struct i2c_client *client,
 					 const struct i2c_device_id *id)
 {
-	const struct edt_ft5x06_platform_data *pdata =
-						dev_get_platdata(&client->dev);
 	struct edt_ft5x06_ts_data *tsdata;
 	struct input_dev *input;
 	int error;
@@ -955,12 +928,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	}
 
 	edt_ft5x06_ts_set_regs(tsdata);
-
-	if (!pdata)
-		edt_ft5x06_ts_get_dt_defaults(client->dev.of_node, tsdata);
-	else
-		edt_ft5x06_ts_get_defaults(tsdata, pdata);
-
+	edt_ft5x06_ts_get_defaults(client->dev.of_node, tsdata);
 	edt_ft5x06_ts_get_parameters(tsdata);
 
 	dev_dbg(&client->dev,
@@ -976,8 +944,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	input_set_abs_params(input, ABS_MT_POSITION_Y,
 			     0, tsdata->num_y * 64 - 1, 0, 0);
 
-	if (!pdata)
-		touchscreen_parse_properties(input, true);
+	touchscreen_parse_properties(input, true);
 
 	error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT);
 	if (error) {
diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
deleted file mode 100644
index 5ca5b4c..0000000
--- a/include/linux/input/edt-ft5x06.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef _EDT_FT5X06_H
-#define _EDT_FT5X06_H
-
-/*
- * Copyright (c) 2012 Simon Budig, <simon.budig@kernelconcepts.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-struct edt_ft5x06_platform_data {
-	/* startup defaults for operational parameters */
-	bool use_parameters;
-	u8 gain;
-	u8 threshold;
-	u8 offset;
-	u8 report_rate;
-};
-
-#endif /* _EDT_FT5X06_H */
-- 
2.6.0.rc0.131.gf624c3d


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

* [PATCH 4/6] Input: edt-ft5x06 - use generic properties API
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data Dmitry Torokhov
@ 2015-09-12 17:45 ` Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 5/6] Input: edt-ft5x06 - do not hardcode interrupt trigger type Dmitry Torokhov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

Instead of only parsing device tree properties let's switch to using
generic properties API so that the driver can also work on other platforms.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 134c66c..ef8a7cd 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -808,20 +808,24 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
 	return 0;
 }
 
-#define EDT_GET_PROP(name, reg) {				\
-	u32 val;						\
-	if (of_property_read_u32(np, #name, &val) == 0)		\
-		edt_ft5x06_register_write(tsdata, reg, val);	\
-}
-
-static void edt_ft5x06_ts_get_defaults(struct device_node *np,
+static void edt_ft5x06_ts_get_defaults(struct device *dev,
 				       struct edt_ft5x06_ts_data *tsdata)
 {
 	struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
+	u32 val;
+	int error;
+
+	error = device_property_read_u32(dev, "threshold", &val);
+	if (!error)
+		reg_addr->reg_threshold = val;
+
+	error = device_property_read_u32(dev, "gain", &val);
+	if (!error)
+		reg_addr->reg_gain = val;
 
-	EDT_GET_PROP(threshold, reg_addr->reg_threshold);
-	EDT_GET_PROP(gain, reg_addr->reg_gain);
-	EDT_GET_PROP(offset, reg_addr->reg_offset);
+	error = device_property_read_u32(dev, "offset", &val);
+	if (!error)
+		reg_addr->reg_offset = val;
 }
 
 static void
@@ -928,7 +932,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	}
 
 	edt_ft5x06_ts_set_regs(tsdata);
-	edt_ft5x06_ts_get_defaults(client->dev.of_node, tsdata);
+	edt_ft5x06_ts_get_defaults(&client->dev, tsdata);
 	edt_ft5x06_ts_get_parameters(tsdata);
 
 	dev_dbg(&client->dev,
-- 
2.6.0.rc0.131.gf624c3d


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

* [PATCH 5/6] Input: edt-ft5x06 - do not hardcode interrupt trigger type
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2015-09-12 17:45 ` [PATCH 4/6] Input: edt-ft5x06 - use generic properties API Dmitry Torokhov
@ 2015-09-12 17:45 ` Dmitry Torokhov
  2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
  2015-09-21 22:55 ` [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
  5 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

Instead of hardcoding IRQ trigger type to IRQF_TRIGGER_FALLING, let's
respect settings specified in device tree. To be compatible with older
DTSes, if trigger type is not set up in DTS we'll set it to default
(falling edge).

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 .../devicetree/bindings/input/touchscreen/edt-ft5x06.txt     |  2 +-
 drivers/input/touchscreen/edt-ft5x06.c                       | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
index 9330d4d..bedd7dd 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
@@ -49,7 +49,7 @@ Example:
 		pinctrl-names = "default";
 		pinctrl-0 = <&edt_ft5x06_pins>;
 		interrupt-parent = <&gpio2>;
-		interrupts = <5 0>;
+		interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
 	};
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index ef8a7cd..7239c31 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -27,6 +27,7 @@
 
 #include <linux/module.h>
 #include <linux/ratelimit.h>
+#include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/i2c.h>
@@ -874,6 +875,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 {
 	struct edt_ft5x06_ts_data *tsdata;
 	struct input_dev *input;
+	unsigned long irq_flags;
 	int error;
 	char fw_version[EDT_NAME_LEN];
 
@@ -959,9 +961,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 	input_set_drvdata(input, tsdata);
 	i2c_set_clientdata(client, tsdata);
 
-	error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
-					edt_ft5x06_ts_isr,
-					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+	irq_flags = irq_get_trigger_type(client->irq);
+	if (irq_flags == IRQF_TRIGGER_NONE)
+		irq_flags = IRQF_TRIGGER_FALLING;
+	irq_flags |= IRQF_ONESHOT;
+
+	error = devm_request_threaded_irq(&client->dev, client->irq,
+					NULL, edt_ft5x06_ts_isr, irq_flags,
 					client->name, tsdata);
 	if (error) {
 		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
-- 
2.6.0.rc0.131.gf624c3d


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

* [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2015-09-12 17:45 ` [PATCH 5/6] Input: edt-ft5x06 - do not hardcode interrupt trigger type Dmitry Torokhov
@ 2015-09-12 17:45 ` Dmitry Torokhov
  2015-09-14 21:24   ` Felipe Balbi
  2015-09-23 12:16   ` Shawn Guo
  2015-09-21 22:55 ` [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
  5 siblings, 2 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-12 17:45 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard,
	Lothar Waßmann, Tony Lindgren, Rob Herring, Pawel Moll,
	Shawn Guo, Sascha Hauer, devicetree, linux-arm-kernel

Now that the driver respects IRQ trigger settings from device tree, let's
fix them up in individual DTSes (note that the driver is still compatible
with older DTSes).

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/boot/dts/am437x-sk-evm.dts   | 2 +-
 arch/arm/boot/dts/imx28-tx28.dts      | 3 ++-
 arch/arm/boot/dts/imx53-tx53-x03x.dts | 3 ++-
 arch/arm/boot/dts/imx6qdl-tx6.dtsi    | 3 ++-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
index c17097d..d83fdcd 100644
--- a/arch/arm/boot/dts/am437x-sk-evm.dts
+++ b/arch/arm/boot/dts/am437x-sk-evm.dts
@@ -471,7 +471,7 @@
 
 		reg = <0x38>;
 		interrupt-parent = <&gpio0>;
-		interrupts = <31 0>;
+		interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
 
 		reset-gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
 
diff --git a/arch/arm/boot/dts/imx28-tx28.dts b/arch/arm/boot/dts/imx28-tx28.dts
index a5b27c8..4ea8934 100644
--- a/arch/arm/boot/dts/imx28-tx28.dts
+++ b/arch/arm/boot/dts/imx28-tx28.dts
@@ -13,6 +13,7 @@
 /dts-v1/;
 #include "imx28.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 
 / {
 	model = "Ka-Ro electronics TX28 module";
@@ -324,7 +325,7 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&tx28_edt_ft5x06_pins>;
 		interrupt-parent = <&gpio2>;
-		interrupts = <5 0>;
+		interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
 	};
diff --git a/arch/arm/boot/dts/imx53-tx53-x03x.dts b/arch/arm/boot/dts/imx53-tx53-x03x.dts
index 3b73e81..13e842b 100644
--- a/arch/arm/boot/dts/imx53-tx53-x03x.dts
+++ b/arch/arm/boot/dts/imx53-tx53-x03x.dts
@@ -12,6 +12,7 @@
 /dts-v1/;
 #include "imx53-tx53.dtsi"
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pwm/pwm.h>
 
 / {
@@ -216,7 +217,7 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_edt_ft5x06_1>;
 		interrupt-parent = <&gpio6>;
-		interrupts = <15 0>;
+		interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
 	};
diff --git a/arch/arm/boot/dts/imx6qdl-tx6.dtsi b/arch/arm/boot/dts/imx6qdl-tx6.dtsi
index da08de3..13cb7cc 100644
--- a/arch/arm/boot/dts/imx6qdl-tx6.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-tx6.dtsi
@@ -11,6 +11,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pwm/pwm.h>
 
 / {
@@ -272,7 +273,7 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_edt_ft5x06>;
 		interrupt-parent = <&gpio6>;
-		interrupts = <15 0>;
+		interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
 		reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
 		wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
 		linux,wakeup;
-- 
2.6.0.rc0.131.gf624c3d


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

* Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
  2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
@ 2015-09-14 21:24   ` Felipe Balbi
  2015-09-15 15:40     ` Tony Lindgren
  2015-09-23 12:16   ` Shawn Guo
  1 sibling, 1 reply; 11+ messages in thread
From: Felipe Balbi @ 2015-09-14 21:24 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Franklin S Cooper Jr, Maxime Ripard,
	Lothar Waßmann, Tony Lindgren, Rob Herring, Pawel Moll,
	Shawn Guo, Sascha Hauer, devicetree, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]

On Sat, Sep 12, 2015 at 10:45:51AM -0700, Dmitry Torokhov wrote:
> Now that the driver respects IRQ trigger settings from device tree, let's
> fix them up in individual DTSes (note that the driver is still compatible
> with older DTSes).
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  arch/arm/boot/dts/am437x-sk-evm.dts   | 2 +-
>  arch/arm/boot/dts/imx28-tx28.dts      | 3 ++-
>  arch/arm/boot/dts/imx53-tx53-x03x.dts | 3 ++-
>  arch/arm/boot/dts/imx6qdl-tx6.dtsi    | 3 ++-
>  4 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
> index c17097d..d83fdcd 100644
> --- a/arch/arm/boot/dts/am437x-sk-evm.dts
> +++ b/arch/arm/boot/dts/am437x-sk-evm.dts
> @@ -471,7 +471,7 @@
>  
>  		reg = <0x38>;
>  		interrupt-parent = <&gpio0>;
> -		interrupts = <31 0>;
> +		interrupts = <31 IRQ_TYPE_EDGE_FALLING>;

for AM437x SK:

Acked-by: Felipe Balbi <balbi@ti.com>

Seems like there are no changes considering driver was always using
IRQF_TRIGGER_FALLING.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
  2015-09-14 21:24   ` Felipe Balbi
@ 2015-09-15 15:40     ` Tony Lindgren
  0 siblings, 0 replies; 11+ messages in thread
From: Tony Lindgren @ 2015-09-15 15:40 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Franklin S Cooper Jr,
	Maxime Ripard, Lothar Waßmann, Rob Herring, Pawel Moll,
	Shawn Guo, Sascha Hauer, devicetree, linux-arm-kernel

* Felipe Balbi <balbi@ti.com> [150914 14:28]:
> On Sat, Sep 12, 2015 at 10:45:51AM -0700, Dmitry Torokhov wrote:
> > Now that the driver respects IRQ trigger settings from device tree, let's
> > fix them up in individual DTSes (note that the driver is still compatible
> > with older DTSes).
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  arch/arm/boot/dts/am437x-sk-evm.dts   | 2 +-
> >  arch/arm/boot/dts/imx28-tx28.dts      | 3 ++-
> >  arch/arm/boot/dts/imx53-tx53-x03x.dts | 3 ++-
> >  arch/arm/boot/dts/imx6qdl-tx6.dtsi    | 3 ++-
> >  4 files changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
> > index c17097d..d83fdcd 100644
> > --- a/arch/arm/boot/dts/am437x-sk-evm.dts
> > +++ b/arch/arm/boot/dts/am437x-sk-evm.dts
> > @@ -471,7 +471,7 @@
> >  
> >  		reg = <0x38>;
> >  		interrupt-parent = <&gpio0>;
> > -		interrupts = <31 0>;
> > +		interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
> 
> for AM437x SK:
> 
> Acked-by: Felipe Balbi <balbi@ti.com>
> 
> Seems like there are no changes considering driver was always using
> IRQF_TRIGGER_FALLING.

Should not cause merge conflicts AFAIK:

Acked-by: Tony Lindgren <tony@atomide.com>

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

* Re: [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework
  2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
@ 2015-09-21 22:55 ` Dmitry Torokhov
  2015-09-22 22:00   ` Franklin S Cooper Jr.
  5 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2015-09-21 22:55 UTC (permalink / raw)
  To: linux-input
  Cc: linux-kernel, Franklin S Cooper Jr, Maxime Ripard, Lothar Waßmann

On Sat, Sep 12, 2015 at 10:45:46AM -0700, Dmitry Torokhov wrote:
> From: Franklin S Cooper Jr <fcooper@ti.com>
> 
> The current/old gpio framework used doesn't properly listen to
> ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
> account these flags when setting gpio values.
> 
> Since the values being output were based on voltage and not logic they
> change to reflect this difference. Also use gpiod_set_value_cansleep since
> wake and reset pins can be provided by bus based io expanders.
> 
> Switch from msleep(5) to udelay_range(5000,6000) to avoid check patch
> warning.
> 
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Franklin, could you please give this series a spin so I can queue it for
the next merge window?

Thanks!

> ---
>  .../bindings/input/touchscreen/edt-ft5x06.txt      |   4 +-
>  drivers/input/touchscreen/edt-ft5x06.c             | 129 ++++++---------------
>  include/linux/input/edt-ft5x06.h                   |   3 -
>  3 files changed, 40 insertions(+), 96 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> index 76db967..9330d4d 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> @@ -50,6 +50,6 @@ Example:
>  		pinctrl-0 = <&edt_ft5x06_pins>;
>  		interrupt-parent = <&gpio2>;
>  		interrupts = <5 0>;
> -		reset-gpios = <&gpio2 6 1>;
> -		wake-gpios = <&gpio4 9 0>;
> +		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> +		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
>  	};
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index 48de1e8..5738722 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -34,8 +34,7 @@
>  #include <linux/delay.h>
>  #include <linux/debugfs.h>
>  #include <linux/slab.h>
> -#include <linux/gpio.h>
> -#include <linux/of_gpio.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/input/mt.h>
>  #include <linux/input/touchscreen.h>
>  #include <linux/input/edt-ft5x06.h>
> @@ -91,9 +90,9 @@ struct edt_ft5x06_ts_data {
>  	u16 num_x;
>  	u16 num_y;
>  
> -	int reset_pin;
> -	int irq_pin;
> -	int wake_pin;
> +	struct gpio_desc *reset_gpio;
> +	struct gpio_desc *wake_gpio;
> +	struct gpio_desc *irq_gpio;
>  
>  #if defined(CONFIG_DEBUG_FS)
>  	struct dentry *debug_dir;
> @@ -752,45 +751,6 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
>  
>  #endif /* CONFIG_DEBUGFS */
>  
> -static int edt_ft5x06_ts_reset(struct i2c_client *client,
> -			struct edt_ft5x06_ts_data *tsdata)
> -{
> -	int error;
> -
> -	if (gpio_is_valid(tsdata->wake_pin)) {
> -		error = devm_gpio_request_one(&client->dev,
> -					tsdata->wake_pin, GPIOF_OUT_INIT_LOW,
> -					"edt-ft5x06 wake");
> -		if (error) {
> -			dev_err(&client->dev,
> -				"Failed to request GPIO %d as wake pin, error %d\n",
> -				tsdata->wake_pin, error);
> -			return error;
> -		}
> -
> -		msleep(5);
> -		gpio_set_value(tsdata->wake_pin, 1);
> -	}
> -	if (gpio_is_valid(tsdata->reset_pin)) {
> -		/* this pulls reset down, enabling the low active reset */
> -		error = devm_gpio_request_one(&client->dev,
> -					tsdata->reset_pin, GPIOF_OUT_INIT_LOW,
> -					"edt-ft5x06 reset");
> -		if (error) {
> -			dev_err(&client->dev,
> -				"Failed to request GPIO %d as reset pin, error %d\n",
> -				tsdata->reset_pin, error);
> -			return error;
> -		}
> -
> -		msleep(5);
> -		gpio_set_value(tsdata->reset_pin, 1);
> -		msleep(300);
> -	}
> -
> -	return 0;
> -}
> -
>  static int edt_ft5x06_ts_identify(struct i2c_client *client,
>  					struct edt_ft5x06_ts_data *tsdata,
>  					char *fw_version)
> @@ -931,30 +891,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
>  	}
>  }
>  
> -#ifdef CONFIG_OF
> -static int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
> -				struct edt_ft5x06_ts_data *tsdata)
> -{
> -	struct device_node *np = dev->of_node;
> -
> -	/*
> -	 * irq_pin is not needed for DT setup.
> -	 * irq is associated via 'interrupts' property in DT
> -	 */
> -	tsdata->irq_pin = -EINVAL;
> -	tsdata->reset_pin = of_get_named_gpio(np, "reset-gpios", 0);
> -	tsdata->wake_pin = of_get_named_gpio(np, "wake-gpios", 0);
> -
> -	return 0;
> -}
> -#else
> -static inline int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
> -					struct edt_ft5x06_ts_data *tsdata)
> -{
> -	return -ENODEV;
> -}
> -#endif
> -
>  static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  					 const struct i2c_device_id *id)
>  {
> @@ -973,32 +909,42 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  		return -ENOMEM;
>  	}
>  
> -	if (!pdata) {
> -		error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata);
> -		if (error) {
> -			dev_err(&client->dev,
> -				"DT probe failed and no platform data present\n");
> -			return error;
> -		}
> -	} else {
> -		tsdata->reset_pin = pdata->reset_pin;
> -		tsdata->irq_pin = pdata->irq_pin;
> -		tsdata->wake_pin = -EINVAL;
> +	tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
> +						     "reset", GPIOD_OUT_HIGH);
> +	if (IS_ERR(tsdata->reset_gpio)) {
> +		error = PTR_ERR(tsdata->reset_gpio);
> +		dev_err(&client->dev,
> +			"Failed to request GPIO reset pin, error %d\n", error);
> +		return error;
>  	}
>  
> -	error = edt_ft5x06_ts_reset(client, tsdata);
> -	if (error)
> +	tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
> +						    "wake", GPIOD_OUT_LOW);
> +	if (IS_ERR(tsdata->wake_gpio)) {
> +		error = PTR_ERR(tsdata->wake_gpio);
> +		dev_err(&client->dev,
> +			"Failed to request GPIO wake pin, error %d\n", error);
>  		return error;
> +	}
>  
> -	if (gpio_is_valid(tsdata->irq_pin)) {
> -		error = devm_gpio_request_one(&client->dev, tsdata->irq_pin,
> -					GPIOF_IN, "edt-ft5x06 irq");
> -		if (error) {
> -			dev_err(&client->dev,
> -				"Failed to request GPIO %d, error %d\n",
> -				tsdata->irq_pin, error);
> -			return error;
> -		}
> +	tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
> +						   "irq", GPIOD_IN);
> +	if (IS_ERR(tsdata->irq_gpio)) {
> +		error = PTR_ERR(tsdata->irq_gpio);
> +		dev_err(&client->dev,
> +			"Failed to request GPIO irq pin, error %d\n", error);
> +		return error;
> +	}
> +
> +	if (tsdata->wake_gpio) {
> +		usleep_range(5000, 6000);
> +		gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
> +	}
> +
> +	if (tsdata->reset_gpio) {
> +		usleep_range(5000, 6000);
> +		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
> +		msleep(300);
>  	}
>  
>  	input = devm_input_allocate_device(&client->dev);
> @@ -1074,7 +1020,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  
>  	dev_dbg(&client->dev,
>  		"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
> -		client->irq, tsdata->wake_pin, tsdata->reset_pin);
> +		client->irq, desc_to_gpio(tsdata->wake_gpio),
> +		desc_to_gpio(tsdata->reset_gpio));
>  
>  	return 0;
>  
> diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
> index 8a1e0d1..5ca5b4c 100644
> --- a/include/linux/input/edt-ft5x06.h
> +++ b/include/linux/input/edt-ft5x06.h
> @@ -10,9 +10,6 @@
>   */
>  
>  struct edt_ft5x06_platform_data {
> -	int irq_pin;
> -	int reset_pin;
> -
>  	/* startup defaults for operational parameters */
>  	bool use_parameters;
>  	u8 gain;
> -- 
> 2.6.0.rc0.131.gf624c3d
> 

-- 
Dmitry

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

* Re: [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework
  2015-09-21 22:55 ` [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
@ 2015-09-22 22:00   ` Franklin S Cooper Jr.
  0 siblings, 0 replies; 11+ messages in thread
From: Franklin S Cooper Jr. @ 2015-09-22 22:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Maxime Ripard, Lothar Waßmann

On Mon, Sep 21, 2015 at 03:55:33PM -0700, Dmitry Torokhov wrote:
> On Sat, Sep 12, 2015 at 10:45:46AM -0700, Dmitry Torokhov wrote:
> > From: Franklin S Cooper Jr <fcooper@ti.com>
> > 
> > The current/old gpio framework used doesn't properly listen to
> > ACTIVE_LOW and ACTIVE_HIGH flags. The newer gpio framework takes into
> > account these flags when setting gpio values.
> > 
> > Since the values being output were based on voltage and not logic they
> > change to reflect this difference. Also use gpiod_set_value_cansleep since
> > wake and reset pins can be provided by bus based io expanders.
> > 
> > Switch from msleep(5) to udelay_range(5000,6000) to avoid check patch
> > warning.
> > 
> > Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> Franklin, could you please give this series a spin so I can queue it for
> the next merge window?
> 
> Thanks!
>
Sorry. Patch set worked fine for me.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> 
> > ---
> >  .../bindings/input/touchscreen/edt-ft5x06.txt      |   4 +-
> >  drivers/input/touchscreen/edt-ft5x06.c             | 129 ++++++---------------
> >  include/linux/input/edt-ft5x06.h                   |   3 -
> >  3 files changed, 40 insertions(+), 96 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> > index 76db967..9330d4d 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
> > @@ -50,6 +50,6 @@ Example:
> >  		pinctrl-0 = <&edt_ft5x06_pins>;
> >  		interrupt-parent = <&gpio2>;
> >  		interrupts = <5 0>;
> > -		reset-gpios = <&gpio2 6 1>;
> > -		wake-gpios = <&gpio4 9 0>;
> > +		reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> > +		wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
> >  	};
> > diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> > index 48de1e8..5738722 100644
> > --- a/drivers/input/touchscreen/edt-ft5x06.c
> > +++ b/drivers/input/touchscreen/edt-ft5x06.c
> > @@ -34,8 +34,7 @@
> >  #include <linux/delay.h>
> >  #include <linux/debugfs.h>
> >  #include <linux/slab.h>
> > -#include <linux/gpio.h>
> > -#include <linux/of_gpio.h>
> > +#include <linux/gpio/consumer.h>
> >  #include <linux/input/mt.h>
> >  #include <linux/input/touchscreen.h>
> >  #include <linux/input/edt-ft5x06.h>
> > @@ -91,9 +90,9 @@ struct edt_ft5x06_ts_data {
> >  	u16 num_x;
> >  	u16 num_y;
> >  
> > -	int reset_pin;
> > -	int irq_pin;
> > -	int wake_pin;
> > +	struct gpio_desc *reset_gpio;
> > +	struct gpio_desc *wake_gpio;
> > +	struct gpio_desc *irq_gpio;
> >  
> >  #if defined(CONFIG_DEBUG_FS)
> >  	struct dentry *debug_dir;
> > @@ -752,45 +751,6 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
> >  
> >  #endif /* CONFIG_DEBUGFS */
> >  
> > -static int edt_ft5x06_ts_reset(struct i2c_client *client,
> > -			struct edt_ft5x06_ts_data *tsdata)
> > -{
> > -	int error;
> > -
> > -	if (gpio_is_valid(tsdata->wake_pin)) {
> > -		error = devm_gpio_request_one(&client->dev,
> > -					tsdata->wake_pin, GPIOF_OUT_INIT_LOW,
> > -					"edt-ft5x06 wake");
> > -		if (error) {
> > -			dev_err(&client->dev,
> > -				"Failed to request GPIO %d as wake pin, error %d\n",
> > -				tsdata->wake_pin, error);
> > -			return error;
> > -		}
> > -
> > -		msleep(5);
> > -		gpio_set_value(tsdata->wake_pin, 1);
> > -	}
> > -	if (gpio_is_valid(tsdata->reset_pin)) {
> > -		/* this pulls reset down, enabling the low active reset */
> > -		error = devm_gpio_request_one(&client->dev,
> > -					tsdata->reset_pin, GPIOF_OUT_INIT_LOW,
> > -					"edt-ft5x06 reset");
> > -		if (error) {
> > -			dev_err(&client->dev,
> > -				"Failed to request GPIO %d as reset pin, error %d\n",
> > -				tsdata->reset_pin, error);
> > -			return error;
> > -		}
> > -
> > -		msleep(5);
> > -		gpio_set_value(tsdata->reset_pin, 1);
> > -		msleep(300);
> > -	}
> > -
> > -	return 0;
> > -}
> > -
> >  static int edt_ft5x06_ts_identify(struct i2c_client *client,
> >  					struct edt_ft5x06_ts_data *tsdata,
> >  					char *fw_version)
> > @@ -931,30 +891,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
> >  	}
> >  }
> >  
> > -#ifdef CONFIG_OF
> > -static int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
> > -				struct edt_ft5x06_ts_data *tsdata)
> > -{
> > -	struct device_node *np = dev->of_node;
> > -
> > -	/*
> > -	 * irq_pin is not needed for DT setup.
> > -	 * irq is associated via 'interrupts' property in DT
> > -	 */
> > -	tsdata->irq_pin = -EINVAL;
> > -	tsdata->reset_pin = of_get_named_gpio(np, "reset-gpios", 0);
> > -	tsdata->wake_pin = of_get_named_gpio(np, "wake-gpios", 0);
> > -
> > -	return 0;
> > -}
> > -#else
> > -static inline int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
> > -					struct edt_ft5x06_ts_data *tsdata)
> > -{
> > -	return -ENODEV;
> > -}
> > -#endif
> > -
> >  static int edt_ft5x06_ts_probe(struct i2c_client *client,
> >  					 const struct i2c_device_id *id)
> >  {
> > @@ -973,32 +909,42 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> >  		return -ENOMEM;
> >  	}
> >  
> > -	if (!pdata) {
> > -		error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata);
> > -		if (error) {
> > -			dev_err(&client->dev,
> > -				"DT probe failed and no platform data present\n");
> > -			return error;
> > -		}
> > -	} else {
> > -		tsdata->reset_pin = pdata->reset_pin;
> > -		tsdata->irq_pin = pdata->irq_pin;
> > -		tsdata->wake_pin = -EINVAL;
> > +	tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
> > +						     "reset", GPIOD_OUT_HIGH);
> > +	if (IS_ERR(tsdata->reset_gpio)) {
> > +		error = PTR_ERR(tsdata->reset_gpio);
> > +		dev_err(&client->dev,
> > +			"Failed to request GPIO reset pin, error %d\n", error);
> > +		return error;
> >  	}
> >  
> > -	error = edt_ft5x06_ts_reset(client, tsdata);
> > -	if (error)
> > +	tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
> > +						    "wake", GPIOD_OUT_LOW);
> > +	if (IS_ERR(tsdata->wake_gpio)) {
> > +		error = PTR_ERR(tsdata->wake_gpio);
> > +		dev_err(&client->dev,
> > +			"Failed to request GPIO wake pin, error %d\n", error);
> >  		return error;
> > +	}
> >  
> > -	if (gpio_is_valid(tsdata->irq_pin)) {
> > -		error = devm_gpio_request_one(&client->dev, tsdata->irq_pin,
> > -					GPIOF_IN, "edt-ft5x06 irq");
> > -		if (error) {
> > -			dev_err(&client->dev,
> > -				"Failed to request GPIO %d, error %d\n",
> > -				tsdata->irq_pin, error);
> > -			return error;
> > -		}
> > +	tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
> > +						   "irq", GPIOD_IN);
> > +	if (IS_ERR(tsdata->irq_gpio)) {
> > +		error = PTR_ERR(tsdata->irq_gpio);
> > +		dev_err(&client->dev,
> > +			"Failed to request GPIO irq pin, error %d\n", error);
> > +		return error;
> > +	}
> > +
> > +	if (tsdata->wake_gpio) {
> > +		usleep_range(5000, 6000);
> > +		gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
> > +	}
> > +
> > +	if (tsdata->reset_gpio) {
> > +		usleep_range(5000, 6000);
> > +		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
> > +		msleep(300);
> >  	}
> >  
> >  	input = devm_input_allocate_device(&client->dev);
> > @@ -1074,7 +1020,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> >  
> >  	dev_dbg(&client->dev,
> >  		"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
> > -		client->irq, tsdata->wake_pin, tsdata->reset_pin);
> > +		client->irq, desc_to_gpio(tsdata->wake_gpio),
> > +		desc_to_gpio(tsdata->reset_gpio));
> >  
> >  	return 0;
> >  
> > diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
> > index 8a1e0d1..5ca5b4c 100644
> > --- a/include/linux/input/edt-ft5x06.h
> > +++ b/include/linux/input/edt-ft5x06.h
> > @@ -10,9 +10,6 @@
> >   */
> >  
> >  struct edt_ft5x06_platform_data {
> > -	int irq_pin;
> > -	int reset_pin;
> > -
> >  	/* startup defaults for operational parameters */
> >  	bool use_parameters;
> >  	u8 gain;
> > -- 
> > 2.6.0.rc0.131.gf624c3d
> > 
> 
> -- 
> Dmitry

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

* Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
  2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
  2015-09-14 21:24   ` Felipe Balbi
@ 2015-09-23 12:16   ` Shawn Guo
  1 sibling, 0 replies; 11+ messages in thread
From: Shawn Guo @ 2015-09-23 12:16 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Franklin S Cooper Jr, Maxime Ripard,
	Lothar Waßmann, Tony Lindgren, Rob Herring, Pawel Moll,
	Sascha Hauer, devicetree, linux-arm-kernel

On Sat, Sep 12, 2015 at 10:45:51AM -0700, Dmitry Torokhov wrote:
> Now that the driver respects IRQ trigger settings from device tree, let's
> fix them up in individual DTSes (note that the driver is still compatible
> with older DTSes).
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
...
>  arch/arm/boot/dts/imx28-tx28.dts      | 3 ++-
>  arch/arm/boot/dts/imx53-tx53-x03x.dts | 3 ++-
>  arch/arm/boot/dts/imx6qdl-tx6.dtsi    | 3 ++-

Acked-by: Shawn Guo <shawnguo@kernel.org>

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

end of thread, other threads:[~2015-09-23 12:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-12 17:45 [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 4/6] Input: edt-ft5x06 - use generic properties API Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 5/6] Input: edt-ft5x06 - do not hardcode interrupt trigger type Dmitry Torokhov
2015-09-12 17:45 ` [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov
2015-09-14 21:24   ` Felipe Balbi
2015-09-15 15:40     ` Tony Lindgren
2015-09-23 12:16   ` Shawn Guo
2015-09-21 22:55 ` [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov
2015-09-22 22:00   ` Franklin S Cooper Jr.

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).