Skip to content

Commit 13c23cd

Browse files
fcoopertidtor
authored andcommitted
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>
1 parent c5c18a0 commit 13c23cd

File tree

3 files changed

+40
-96
lines changed

3 files changed

+40
-96
lines changed

Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Example:
5050
pinctrl-0 = <&edt_ft5x06_pins>;
5151
interrupt-parent = <&gpio2>;
5252
interrupts = <5 0>;
53-
reset-gpios = <&gpio2 6 1>;
54-
wake-gpios = <&gpio4 9 0>;
53+
reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
54+
wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
5555
};

drivers/input/touchscreen/edt-ft5x06.c

Lines changed: 38 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
#include <linux/delay.h>
3535
#include <linux/debugfs.h>
3636
#include <linux/slab.h>
37-
#include <linux/gpio.h>
38-
#include <linux/of_gpio.h>
37+
#include <linux/gpio/consumer.h>
3938
#include <linux/input/mt.h>
4039
#include <linux/input/touchscreen.h>
4140
#include <linux/input/edt-ft5x06.h>
@@ -91,9 +90,9 @@ struct edt_ft5x06_ts_data {
9190
u16 num_x;
9291
u16 num_y;
9392

94-
int reset_pin;
95-
int irq_pin;
96-
int wake_pin;
93+
struct gpio_desc *reset_gpio;
94+
struct gpio_desc *wake_gpio;
95+
struct gpio_desc *irq_gpio;
9796

9897
#if defined(CONFIG_DEBUG_FS)
9998
struct dentry *debug_dir;
@@ -752,45 +751,6 @@ edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
752751

753752
#endif /* CONFIG_DEBUGFS */
754753

755-
static 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-
794754
static int edt_ft5x06_ts_identify(struct i2c_client *client,
795755
struct edt_ft5x06_ts_data *tsdata,
796756
char *fw_version)
@@ -931,30 +891,6 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
931891
}
932892
}
933893

934-
#ifdef CONFIG_OF
935-
static 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
951-
static 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-
958894
static int edt_ft5x06_ts_probe(struct i2c_client *client,
959895
const struct i2c_device_id *id)
960896
{
@@ -973,32 +909,42 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
973909
return -ENOMEM;
974910
}
975911

976-
if (!pdata) {
977-
error = edt_ft5x06_i2c_ts_probe_dt(&client->dev, tsdata);
978-
if (error) {
979-
dev_err(&client->dev,
980-
"DT probe failed and no platform data present\n");
981-
return error;
982-
}
983-
} else {
984-
tsdata->reset_pin = pdata->reset_pin;
985-
tsdata->irq_pin = pdata->irq_pin;
986-
tsdata->wake_pin = -EINVAL;
912+
tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev,
913+
"reset", GPIOD_OUT_HIGH);
914+
if (IS_ERR(tsdata->reset_gpio)) {
915+
error = PTR_ERR(tsdata->reset_gpio);
916+
dev_err(&client->dev,
917+
"Failed to request GPIO reset pin, error %d\n", error);
918+
return error;
987919
}
988920

989-
error = edt_ft5x06_ts_reset(client, tsdata);
990-
if (error)
921+
tsdata->wake_gpio = devm_gpiod_get_optional(&client->dev,
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);
991927
return error;
928+
}
992929

993-
if (gpio_is_valid(tsdata->irq_pin)) {
994-
error = devm_gpio_request_one(&client->dev, tsdata->irq_pin,
995-
GPIOF_IN, "edt-ft5x06 irq");
996-
if (error) {
997-
dev_err(&client->dev,
998-
"Failed to request GPIO %d, error %d\n",
999-
tsdata->irq_pin, error);
1000-
return error;
1001-
}
930+
tsdata->irq_gpio = devm_gpiod_get_optional(&client->dev,
931+
"irq", GPIOD_IN);
932+
if (IS_ERR(tsdata->irq_gpio)) {
933+
error = PTR_ERR(tsdata->irq_gpio);
934+
dev_err(&client->dev,
935+
"Failed to request GPIO irq pin, error %d\n", error);
936+
return error;
937+
}
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);
1002948
}
1003949

1004950
input = devm_input_allocate_device(&client->dev);
@@ -1074,7 +1020,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
10741020

10751021
dev_dbg(&client->dev,
10761022
"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));
10781025

10791026
return 0;
10801027

include/linux/input/edt-ft5x06.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111

1212
struct edt_ft5x06_platform_data {
13-
int irq_pin;
14-
int reset_pin;
15-
1613
/* startup defaults for operational parameters */
1714
bool use_parameters;
1815
u8 gain;

0 commit comments

Comments
 (0)