summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/egalax_ts.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/egalax_ts.c')
-rw-r--r--drivers/input/touchscreen/egalax_ts.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 83ac8c128192..742d47a75ac1 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -14,17 +14,17 @@
- auto idle mode support
*/
+#include <linux/err.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/irq.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/input/mt.h>
-#include <linux/of_gpio.h>
/*
* Mouse Mode: some panel may configure the controller to mouse mode,
@@ -119,32 +119,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
- struct device_node *np = client->dev.of_node;
- int gpio;
+ struct gpio_desc *gpio;
int ret;
- if (!np)
- return -ENODEV;
-
- gpio = of_get_named_gpio(np, "wakeup-gpios", 0);
- if (!gpio_is_valid(gpio))
- return -ENODEV;
-
- ret = gpio_request(gpio, "egalax_irq");
- if (ret < 0) {
- dev_err(&client->dev,
- "request gpio failed, cannot wake up controller: %d\n",
- ret);
+ /* wake up controller via an falling edge on IRQ gpio. */
+ gpio = gpiod_get(&client->dev, "wakeup", GPIOD_OUT_HIGH);
+ ret = PTR_ERR_OR_ZERO(gpio);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(&client->dev,
+ "failed to request wakeup gpio, cannot wake up controller: %d\n",
+ ret);
return ret;
}
- /* wake up controller via an falling edge on IRQ gpio. */
- gpio_direction_output(gpio, 0);
- gpio_set_value(gpio, 1);
+ /* release the line */
+ gpiod_set_value_cansleep(gpio, 0);
- /* controller should be waken up, return irq. */
- gpio_direction_input(gpio);
- gpio_free(gpio);
+ /* controller should be woken up, return irq. */
+ gpiod_direction_input(gpio);
+ gpiod_put(gpio);
return 0;
}
@@ -161,8 +155,7 @@ static int egalax_firmware_version(struct i2c_client *client)
return 0;
}
-static int egalax_ts_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int egalax_ts_probe(struct i2c_client *client)
{
struct egalax_ts *ts;
struct input_dev *input_dev;
@@ -185,10 +178,8 @@ static int egalax_ts_probe(struct i2c_client *client,
/* controller may be in sleep, wake it up. */
error = egalax_wake_up_device(client);
- if (error) {
- dev_err(&client->dev, "Failed to wake up the controller\n");
+ if (error)
return error;
- }
error = egalax_firmware_version(client);
if (error < 0) {
@@ -211,10 +202,9 @@ static int egalax_ts_probe(struct i2c_client *client,
ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0);
input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0);
- error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
- egalax_ts_interrupt,
- IRQF_TRIGGER_LOW | IRQF_ONESHOT,
- "egalax_ts", ts);
+ error = devm_request_threaded_irq(&client->dev, client->irq,
+ NULL, egalax_ts_interrupt,
+ IRQF_ONESHOT, "egalax_ts", ts);
if (error < 0) {
dev_err(&client->dev, "Failed to register interrupt\n");
return error;
@@ -273,7 +263,7 @@ static struct i2c_driver egalax_ts_driver = {
.of_match_table = egalax_ts_dt_ids,
},
.id_table = egalax_ts_id,
- .probe = egalax_ts_probe,
+ .probe_new = egalax_ts_probe,
};
module_i2c_driver(egalax_ts_driver);