aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranklin S Cooper Jr <fcooper@ti.com>2015-09-11 20:30:34 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-09-27 20:33:58 -0400
commit13c23cd18bd12ddbf00beddd136e3cd33b4f2dfa (patch)
treeee8fb29e6b3d24054b9010f908880e0e4af0de42
parentc5c18a06af753eab1162fcdfb1cf03581e70b3f4 (diff)
Input: edt-ft5x06 - switch to newer gpio framework
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>
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt4
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c129
-rw-r--r--include/linux/input/edt-ft5x06.h3
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 76db96704a60..9330d4d34cb9 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt
@@ -50,6 +50,6 @@ Example:
50 pinctrl-0 = <&edt_ft5x06_pins>; 50 pinctrl-0 = <&edt_ft5x06_pins>;
51 interrupt-parent = <&gpio2>; 51 interrupt-parent = <&gpio2>;
52 interrupts = <5 0>; 52 interrupts = <5 0>;
53 reset-gpios = <&gpio2 6 1>; 53 reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
54 wake-gpios = <&gpio4 9 0>; 54 wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
55 }; 55 };
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 48de1e8b3c93..5738722873bb 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -34,8 +34,7 @@
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/debugfs.h> 35#include <linux/debugfs.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/gpio.h> 37#include <linux/gpio/consumer.h>
38#include <linux/of_gpio.h>
39#include <linux/input/mt.h> 38#include <linux/input/mt.h>
40#include <linux/input/touchscreen.h> 39#include <linux/input/touchscreen.h>
41#include <linux/input/edt-ft5x06.h> 40#include <linux/input/edt-ft5x06.h>
@@ -91,9 +90,9 @@ struct edt_ft5x06_ts_data {
91 u16 num_x; 90 u16 num_x;
92 u16 num_y; 91 u16 num_y;
93 92
94 int reset_pin; 93 struct gpio_desc *reset_gpio;
95 int irq_pin; 94 struct gpio_desc *wake_gpio;
96 int wake_pin; 95 struct gpio_desc *irq_gpio;
97 96
98#if defined(CONFIG_DEBUG_FS) 97#if defined(CONFIG_DEBUG_FS)
99 struct dentry *debug_dir; 98 struct dentry *debug_dir;
@@ -752,45 +751,6 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
752 751
753#endif /* CONFIG_DEBUGFS */ 752#endif /* CONFIG_DEBUGFS */
754 753
755static int edt_ft5x06_ts_reset(struct i2c_client *client,
756 struct edt_ft5x06_ts_data *tsdata)
757{
758 int error;
759
760 if (gpio_is_valid(tsdata->wake_pin)) {
761 error = devm_gpio_request_one(&client->dev,
762 tsdata->wake_pin, GPIOF_OUT_INIT_LOW,
763 "edt-ft5x06 wake");
764 if (error) {
765 dev_err(&client->dev,
766 "Failed to request GPIO %d as wake pin, error %d\n",
767 tsdata->wake_pin, error);
768 return error;
769 }
770
771 msleep(5);
772 gpio_set_value(tsdata->wake_pin, 1);
773 }
774 if (gpio_is_valid(tsdata->reset_pin)) {
775 /* this pulls reset down, enabling the low active reset */
776 error = devm_gpio_request_one(&client->dev,
777 tsdata->reset_pin, GPIOF_OUT_INIT_LOW,
778 "edt-ft5x06 reset");
779 if (error) {
780 dev_err(&client->dev,
781 "Failed to request GPIO %d as reset pin, error %d\n",
782 tsdata->reset_pin, error);
783 return error;
784 }
785
786 msleep(5);
787 gpio_set_value(tsdata->reset_pin, 1);
788 msleep(300);
789 }
790
791 return 0;
792}
793
794static int edt_ft5x06_ts_identify(struct i2c_client *client, 754static int edt_ft5x06_ts_identify(struct i2c_client *client,
795 struct edt_ft5x06_ts_data *tsdata, 755 struct edt_ft5x06_ts_data *tsdata,
796 char *fw_version) 756 char *fw_version)
@@ -931,30 +891,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
931 } 891 }
932} 892}
933 893
934#ifdef CONFIG_OF
935static int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
936 struct edt_ft5x06_ts_data *tsdata)
937{
938 struct device_node *np = dev->of_node;
939
940 /*
941 * irq_pin is not needed for DT setup.
942 * irq is associated via 'interrupts' property in DT
943 */
944 tsdata->irq_pin = -EINVAL;
945 tsdata->reset_pin = of_get_named_gpio(np, "reset-gpios", 0);
946 tsdata->wake_pin = of_get_named_gpio(np, "wake-gpios", 0);
947
948 return 0;
949}
950#else
951static inline int edt_ft5x06_i2c_ts_probe_dt(struct device *dev,
952 struct edt_ft5x06_ts_data *tsdata)
953{
954 return -ENODEV;
955}
956#endif
957
958static int edt_ft5x06_ts_probe(struct i2c_client *client, 894static int edt_ft5x06_ts_probe(struct i2c_client *client,
959 const struct i2c_device_id *id) 895 const struct i2c_device_id *id)
960{ 896{
@@ -973,32 +909,42 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
973 return -ENOMEM; 909 return -ENOMEM;
974 } 910 }
975 911
976 if (!pdata) { 912 tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
977 error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata); 913 "reset", GPIOD_OUT_HIGH);
978 if (error) { 914 if (IS_ERR(tsdata->reset_gpio)) {
979 dev_err(&client->dev, 915 error = PTR_ERR(tsdata->reset_gpio);
980 "DT probe failed and no platform data present\n"); 916 dev_err(&client->dev,
981 return error; 917 "Failed to request GPIO reset pin, error %d\n", error);
982 } 918 return error;
983 } else {
984 tsdata->reset_pin = pdata->reset_pin;
985 tsdata->irq_pin = pdata->irq_pin;
986 tsdata->wake_pin = -EINVAL;
987 } 919 }
988 920
989 error = edt_ft5x06_ts_reset(client, tsdata); 921 tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
990 if (error) 922 "wake", GPIOD_OUT_LOW);
923 if (IS_ERR(tsdata->wake_gpio)) {
924 error = PTR_ERR(tsdata->wake_gpio);
925 dev_err(&client->dev,
926 "Failed to request GPIO wake pin, error %d\n", error);
991 return error; 927 return error;
928 }
992 929
993 if (gpio_is_valid(tsdata->irq_pin)) { 930 tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
994 error = devm_gpio_request_one(&client->dev, tsdata->irq_pin, 931 "irq", GPIOD_IN);
995 GPIOF_IN, "edt-ft5x06 irq"); 932 if (IS_ERR(tsdata->irq_gpio)) {
996 if (error) { 933 error = PTR_ERR(tsdata->irq_gpio);
997 dev_err(&client->dev, 934 dev_err(&client->dev,
998 "Failed to request GPIO %d, error %d\n", 935 "Failed to request GPIO irq pin, error %d\n", error);
999 tsdata->irq_pin, error); 936 return error;
1000 return error; 937 }
1001 } 938
939 if (tsdata->wake_gpio) {
940 usleep_range(5000, 6000);
941 gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
942 }
943
944 if (tsdata->reset_gpio) {
945 usleep_range(5000, 6000);
946 gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
947 msleep(300);
1002 } 948 }
1003 949
1004 input = devm_input_allocate_device(&client->dev); 950 input = devm_input_allocate_device(&client->dev);
@@ -1074,7 +1020,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
1074 1020
1075 dev_dbg(&client->dev, 1021 dev_dbg(&client->dev,
1076 "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n", 1022 "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
1077 client->irq, tsdata->wake_pin, tsdata->reset_pin); 1023 client->irq, desc_to_gpio(tsdata->wake_gpio),
1024 desc_to_gpio(tsdata->reset_gpio));
1078 1025
1079 return 0; 1026 return 0;
1080 1027
diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
index 8a1e0d1a0124..5ca5b4cc308c 100644
--- a/include/linux/input/edt-ft5x06.h
+++ b/include/linux/input/edt-ft5x06.h
@@ -10,9 +10,6 @@
10 */ 10 */
11 11
12struct edt_ft5x06_platform_data { 12struct edt_ft5x06_platform_data {
13 int irq_pin;
14 int reset_pin;
15
16 /* startup defaults for operational parameters */ 13 /* startup defaults for operational parameters */
17 bool use_parameters; 14 bool use_parameters;
18 u8 gain; 15 u8 gain;