Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1223439 > unrolled thread

[PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2015-09-12 19:50 +0200
Last post2015-09-23 00:10 +0200
Articles 10 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-12 19:50 +0200
    [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-12 19:50 +0200
      Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06  interrupts Felipe Balbi <balbi@ti.com> - 2015-09-14 23:30 +0200
        Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06  interrupts Tony Lindgren <tony@atomide.com> - 2015-09-15 17:50 +0200
      Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06  interrupts Shawn Guo <shawnguo@kernel.org> - 2015-09-23 14:20 +0200
    [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-12 19:50 +0200
    [PATCH 4/6] Input: edt-ft5x06 - use generic properties API Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-12 19:50 +0200
    [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-12 19:50 +0200
    Re: [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-09-22 01:00 +0200
      Re: [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework "Franklin S Cooper Jr." <fcooper@ti.com> - 2015-09-23 00:10 +0200

#1223439 — [PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-12 19:50 +0200
Subject[PATCH 1/6] Input: edt-ft5x06 - switch to newer gpio framework
Message-ID<q7X61-7w7-5@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1223442 — [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-12 19:50 +0200
Subject[PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
Message-ID<q7X62-7w7-15@gated-at.bofh.it>
In reply to#1223439
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1224460 — Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts

FromFelipe Balbi <balbi@ti.com>
Date2015-09-14 23:30 +0200
SubjectRe: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
Message-ID<q8Ju1-1pD-7@gated-at.bofh.it>
In reply to#1223442

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [next] | [standalone]


#1225355 — Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts

FromTony Lindgren <tony@atomide.com>
Date2015-09-15 17:50 +0200
SubjectRe: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
Message-ID<q90EA-Jd-69@gated-at.bofh.it>
In reply to#1224460
* 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>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231404 — Re: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts

FromShawn Guo <shawnguo@kernel.org>
Date2015-09-23 14:20 +0200
SubjectRe: [PATCH 6/6] ARM: dts: set up trigger type for edt-ft5x06 interrupts
Message-ID<qbRbI-3Sd-5@gated-at.bofh.it>
In reply to#1223442
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>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1223443 — [PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-12 19:50 +0200
Subject[PATCH 2/6] Input: edt-ft5x06 - drop parsing of irq gpio
Message-ID<q7X62-7w7-17@gated-at.bofh.it>
In reply to#1223439
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1223444 — [PATCH 4/6] Input: edt-ft5x06 - use generic properties API

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-12 19:50 +0200
Subject[PATCH 4/6] Input: edt-ft5x06 - use generic properties API
Message-ID<q7X62-7w7-19@gated-at.bofh.it>
In reply to#1223439
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1223445 — [PATCH 3/6] Input: edt-ft5x06 - remove support for platform data

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-12 19:50 +0200
Subject[PATCH 3/6] Input: edt-ft5x06 - remove support for platform data
Message-ID<q7X62-7w7-21@gated-at.bofh.it>
In reply to#1223439
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1229809

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-09-22 01:00 +0200
Message-ID<qbidY-3MW-1@gated-at.bofh.it>
In reply to#1223439
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231001

From"Franklin S Cooper Jr." <fcooper@ti.com>
Date2015-09-23 00:10 +0200
Message-ID<qbDV8-1yU-13@gated-at.bofh.it>
In reply to#1229809
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web