All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data
@ 2022-09-14 14:14 Dmitry Torokhov
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 14:14 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

Currently there are no users of auo_pixcir_ts_platdata in the mainline, and
having it (with legacy gpio numbers) prevents us from converting the driver
to gpiod API, so let's drop it.

If, in the future, someone wants to use this driver on non-device tree,
non-ACPI system, they should use static device properties instead of
platform data.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 118 ++++++++++------------
 include/linux/input/auo-pixcir-ts.h       |  44 --------
 2 files changed, 56 insertions(+), 106 deletions(-)
 delete mode 100644 include/linux/input/auo-pixcir-ts.h

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index c33e63ca6142..a51d66ebff2b 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -20,7 +20,6 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
-#include <linux/input/auo-pixcir-ts.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 
@@ -69,6 +68,16 @@
 #define AUO_PIXCIR_INT_RELEASE		(1 << 4)
 #define AUO_PIXCIR_INT_ENABLE		(1 << 3)
 #define AUO_PIXCIR_INT_POL_HIGH		(1 << 2)
+
+/*
+ * Interrupt modes:
+ * periodical:		interrupt is asserted periodicaly
+ * compare coordinates:	interrupt is asserted when coordinates change
+ * indicate touch:	interrupt is asserted during touch
+ */
+#define AUO_PIXCIR_INT_PERIODICAL	0x00
+#define AUO_PIXCIR_INT_COMP_COORD	0x01
+#define AUO_PIXCIR_INT_TOUCH_IND	0x02
 #define AUO_PIXCIR_INT_MODE_MASK	0x03
 
 /*
@@ -103,10 +112,14 @@
 struct auo_pixcir_ts {
 	struct i2c_client	*client;
 	struct input_dev	*input;
-	const struct auo_pixcir_ts_platdata *pdata;
+	int			gpio_int;
+	int			gpio_rst;
 	char			phys[32];
 
-	/* special handling for touch_indicate interupt mode */
+	unsigned int		x_max;
+	unsigned int		y_max;
+
+	/* special handling for touch_indicate interrupt mode */
 	bool			touch_ind_mode;
 
 	wait_queue_head_t	wait;
@@ -125,7 +138,6 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
 				   struct auo_point_t *point)
 {
 	struct i2c_client *client = ts->client;
-	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
 	uint8_t raw_coord[8];
 	uint8_t raw_area[4];
 	int i, ret;
@@ -152,8 +164,8 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
 		point[i].coord_y =
 			raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2];
 
-		if (point[i].coord_x > pdata->x_max ||
-		    point[i].coord_y > pdata->y_max) {
+		if (point[i].coord_x > ts->x_max ||
+		    point[i].coord_y > ts->y_max) {
 			dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
 				point[i].coord_x, point[i].coord_y);
 			point[i].coord_x = point[i].coord_y = 0;
@@ -171,7 +183,6 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
 static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
 {
 	struct auo_pixcir_ts *ts = dev_id;
-	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
 	struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS];
 	int i;
 	int ret;
@@ -182,7 +193,7 @@ static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
 
 		/* check for up event in touch touch_ind_mode */
 		if (ts->touch_ind_mode) {
-			if (gpio_get_value(pdata->gpio_int) == 0) {
+			if (gpio_get_value(ts->gpio_int) == 0) {
 				input_mt_sync(ts->input);
 				input_report_key(ts->input, BTN_TOUCH, 0);
 				input_sync(ts->input);
@@ -278,11 +289,9 @@ static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode)
 	return 0;
 }
 
-static int auo_pixcir_int_config(struct auo_pixcir_ts *ts,
-					   int int_setting)
+static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting)
 {
 	struct i2c_client *client = ts->client;
-	const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
 	int ret;
 
 	ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING);
@@ -304,7 +313,7 @@ static int auo_pixcir_int_config(struct auo_pixcir_ts *ts,
 		return ret;
 	}
 
-	ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND;
+	ts->touch_ind_mode = int_setting == AUO_PIXCIR_INT_TOUCH_IND;
 
 	return 0;
 }
@@ -466,49 +475,41 @@ static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
 			 auo_pixcir_suspend, auo_pixcir_resume);
 
 #ifdef CONFIG_OF
-static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
+static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts)
 {
-	struct auo_pixcir_ts_platdata *pdata;
 	struct device_node *np = dev->of_node;
 
 	if (!np)
-		return ERR_PTR(-ENOENT);
+		return -ENOENT;
 
-	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata)
-		return ERR_PTR(-ENOMEM);
-
-	pdata->gpio_int = of_get_gpio(np, 0);
-	if (!gpio_is_valid(pdata->gpio_int)) {
+	ts->gpio_int = of_get_gpio(np, 0);
+	if (!gpio_is_valid(ts->gpio_int)) {
 		dev_err(dev, "failed to get interrupt gpio\n");
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 
-	pdata->gpio_rst = of_get_gpio(np, 1);
-	if (!gpio_is_valid(pdata->gpio_rst)) {
+	ts->gpio_rst = of_get_gpio(np, 1);
+	if (!gpio_is_valid(ts->gpio_rst)) {
 		dev_err(dev, "failed to get reset gpio\n");
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 
-	if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
+	if (of_property_read_u32(np, "x-size", &ts->x_max)) {
 		dev_err(dev, "failed to get x-size property\n");
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 
-	if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
+	if (of_property_read_u32(np, "y-size", &ts->y_max)) {
 		dev_err(dev, "failed to get y-size property\n");
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 
-	/* default to asserting the interrupt when the screen is touched */
-	pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND;
-
-	return pdata;
+	return 0;
 }
 #else
-static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev)
+static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts)
 {
-	return ERR_PTR(-EINVAL);
+	return -EINVAL;
 }
 #endif
 
@@ -516,27 +517,18 @@ static void auo_pixcir_reset(void *data)
 {
 	struct auo_pixcir_ts *ts = data;
 
-	gpio_set_value(ts->pdata->gpio_rst, 0);
+	gpio_set_value(ts->gpio_rst, 0);
 }
 
 static int auo_pixcir_probe(struct i2c_client *client,
 			    const struct i2c_device_id *id)
 {
-	const struct auo_pixcir_ts_platdata *pdata;
 	struct auo_pixcir_ts *ts;
 	struct input_dev *input_dev;
 	int version;
 	int error;
 
-	pdata = dev_get_platdata(&client->dev);
-	if (!pdata) {
-		pdata = auo_pixcir_parse_dt(&client->dev);
-		if (IS_ERR(pdata))
-			return PTR_ERR(pdata);
-	}
-
-	ts = devm_kzalloc(&client->dev,
-			  sizeof(struct auo_pixcir_ts), GFP_KERNEL);
+	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
 	if (!ts)
 		return -ENOMEM;
 
@@ -546,7 +538,6 @@ static int auo_pixcir_probe(struct i2c_client *client,
 		return -ENOMEM;
 	}
 
-	ts->pdata = pdata;
 	ts->client = client;
 	ts->input = input_dev;
 	ts->touch_ind_mode = 0;
@@ -556,6 +547,10 @@ static int auo_pixcir_probe(struct i2c_client *client,
 	snprintf(ts->phys, sizeof(ts->phys),
 		 "%s/input0", dev_name(&client->dev));
 
+	error = auo_pixcir_parse_dt(&client->dev, ts);
+	if (error)
+		return error;
+
 	input_dev->name = "AUO-Pixcir touchscreen";
 	input_dev->phys = ts->phys;
 	input_dev->id.bustype = BUS_I2C;
@@ -569,36 +564,34 @@ static int auo_pixcir_probe(struct i2c_client *client,
 	__set_bit(BTN_TOUCH, input_dev->keybit);
 
 	/* For single touch */
-	input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0);
+	input_set_abs_params(input_dev, ABS_X, 0, ts->x_max, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0);
 
 	/* For multi touch */
-	input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
-			     pdata->x_max, 0, 0);
-	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
-			     pdata->y_max, 0, 0);
-	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
-			     AUO_PIXCIR_MAX_AREA, 0, 0);
-	input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,
-			     AUO_PIXCIR_MAX_AREA, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
+			     0, AUO_PIXCIR_MAX_AREA, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
+			     0, AUO_PIXCIR_MAX_AREA, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
 
 	input_set_drvdata(ts->input, ts);
 
-	error = devm_gpio_request_one(&client->dev, pdata->gpio_int,
+	error = devm_gpio_request_one(&client->dev, ts->gpio_int,
 				      GPIOF_DIR_IN, "auo_pixcir_ts_int");
 	if (error) {
 		dev_err(&client->dev, "request of gpio %d failed, %d\n",
-			pdata->gpio_int, error);
+			ts->gpio_int, error);
 		return error;
 	}
 
-	error = devm_gpio_request_one(&client->dev, pdata->gpio_rst,
+	error = devm_gpio_request_one(&client->dev, ts->gpio_rst,
 				      GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
 				      "auo_pixcir_ts_rst");
 	if (error) {
 		dev_err(&client->dev, "request of gpio %d failed, %d\n",
-			pdata->gpio_rst, error);
+			ts->gpio_rst, error);
 		return error;
 	}
 
@@ -619,7 +612,8 @@ static int auo_pixcir_probe(struct i2c_client *client,
 
 	dev_info(&client->dev, "firmware version 0x%X\n", version);
 
-	error = auo_pixcir_int_config(ts, pdata->int_setting);
+	/* default to asserting the interrupt when the screen is touched */
+	error = auo_pixcir_int_config(ts, AUO_PIXCIR_INT_TOUCH_IND);
 	if (error)
 		return error;
 
diff --git a/include/linux/input/auo-pixcir-ts.h b/include/linux/input/auo-pixcir-ts.h
deleted file mode 100644
index ed0776997a7a..000000000000
--- a/include/linux/input/auo-pixcir-ts.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Driver for AUO in-cell touchscreens
- *
- * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de>
- *
- * based on auo_touch.h from Dell Streak kernel
- *
- * Copyright (c) 2008 QUALCOMM Incorporated.
- * Copyright (c) 2008 QUALCOMM USA, INC.
- */
-
-#ifndef __AUO_PIXCIR_TS_H__
-#define __AUO_PIXCIR_TS_H__
-
-/*
- * Interrupt modes:
- * periodical:		interrupt is asserted periodicaly
- * compare coordinates:	interrupt is asserted when coordinates change
- * indicate touch:	interrupt is asserted during touch
- */
-#define AUO_PIXCIR_INT_PERIODICAL	0x00
-#define AUO_PIXCIR_INT_COMP_COORD	0x01
-#define AUO_PIXCIR_INT_TOUCH_IND	0x02
-
-/*
- * @gpio_int		interrupt gpio
- * @int_setting		one of AUO_PIXCIR_INT_*
- * @init_hw		hardwarespecific init
- * @exit_hw		hardwarespecific shutdown
- * @x_max		x-resolution
- * @y_max		y-resolution
- */
-struct auo_pixcir_ts_platdata {
-	int gpio_int;
-	int gpio_rst;
-
-	int int_setting;
-
-	unsigned int x_max;
-	unsigned int y_max;
-};
-
-#endif
-- 
2.37.2.789.g6183377224-goog


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

* [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API
  2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
@ 2022-09-14 14:14 ` Dmitry Torokhov
  2022-09-14 15:04   ` Heiko Stuebner
                     ` (2 more replies)
  2022-09-14 14:14 ` [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger Dmitry Torokhov
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 14:14 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

This switches the driver to gpiod API and drops uses of of_get_gpio() API.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index a51d66ebff2b..c3bce9fb2c94 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -10,6 +10,7 @@
  * Copyright (c) 2008 QUALCOMM USA, INC.
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -19,9 +20,8 @@
 #include <linux/i2c.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 
 /*
  * Coordinate calculation:
@@ -112,8 +112,8 @@
 struct auo_pixcir_ts {
 	struct i2c_client	*client;
 	struct input_dev	*input;
-	int			gpio_int;
-	int			gpio_rst;
+	struct gpio_desc	*gpio_int;
+	struct gpio_desc	*gpio_rst;
 	char			phys[32];
 
 	unsigned int		x_max;
@@ -193,7 +193,7 @@ static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
 
 		/* check for up event in touch touch_ind_mode */
 		if (ts->touch_ind_mode) {
-			if (gpio_get_value(ts->gpio_int) == 0) {
+			if (gpiod_get_value_cansleep(ts->gpio_int) == 0) {
 				input_mt_sync(ts->input);
 				input_report_key(ts->input, BTN_TOUCH, 0);
 				input_sync(ts->input);
@@ -482,18 +482,6 @@ static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts)
 	if (!np)
 		return -ENOENT;
 
-	ts->gpio_int = of_get_gpio(np, 0);
-	if (!gpio_is_valid(ts->gpio_int)) {
-		dev_err(dev, "failed to get interrupt gpio\n");
-		return -EINVAL;
-	}
-
-	ts->gpio_rst = of_get_gpio(np, 1);
-	if (!gpio_is_valid(ts->gpio_rst)) {
-		dev_err(dev, "failed to get reset gpio\n");
-		return -EINVAL;
-	}
-
 	if (of_property_read_u32(np, "x-size", &ts->x_max)) {
 		dev_err(dev, "failed to get x-size property\n");
 		return -EINVAL;
@@ -517,7 +505,7 @@ static void auo_pixcir_reset(void *data)
 {
 	struct auo_pixcir_ts *ts = data;
 
-	gpio_set_value(ts->gpio_rst, 0);
+	gpiod_set_value_cansleep(ts->gpio_rst, 1);
 }
 
 static int auo_pixcir_probe(struct i2c_client *client,
@@ -578,23 +566,28 @@ static int auo_pixcir_probe(struct i2c_client *client,
 
 	input_set_drvdata(ts->input, ts);
 
-	error = devm_gpio_request_one(&client->dev, ts->gpio_int,
-				      GPIOF_DIR_IN, "auo_pixcir_ts_int");
+	ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);
+	error = PTR_ERR_OR_ZERO(ts->gpio_int);
 	if (error) {
-		dev_err(&client->dev, "request of gpio %d failed, %d\n",
-			ts->gpio_int, error);
+		dev_err(&client->dev,
+			"request of int gpio failed: %d\n", error);
 		return error;
 	}
 
-	error = devm_gpio_request_one(&client->dev, ts->gpio_rst,
-				      GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
-				      "auo_pixcir_ts_rst");
+	gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int");
+
+	/* Take the chip out of reset */
+	ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1,
+					    GPIOD_OUT_LOW);
+	error = PTR_ERR_OR_ZERO(ts->gpio_rst);
 	if (error) {
-		dev_err(&client->dev, "request of gpio %d failed, %d\n",
-			ts->gpio_rst, error);
+		dev_err(&client->dev,
+			"request of reset gpio failed: %d\n", error);
 		return error;
 	}
 
+	gpiod_set_consumer_name(ts->gpio_rst, "auo_pixcir_ts_rst");
+
 	error = devm_add_action_or_reset(&client->dev, auo_pixcir_reset, ts);
 	if (error) {
 		dev_err(&client->dev, "failed to register reset action, %d\n",
-- 
2.37.2.789.g6183377224-goog


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

* [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger
  2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
@ 2022-09-14 14:14 ` Dmitry Torokhov
  2022-09-14 15:05   ` Heiko Stuebner
  2022-09-14 14:14 ` [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties Dmitry Torokhov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 14:14 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

Instead of hard-coding rising edge as the interrupt trigger, let's rely on
the platform (ACPI, DT) to configure the interrupt properly.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index c3bce9fb2c94..4960a50f59ea 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -612,7 +612,7 @@ static int auo_pixcir_probe(struct i2c_client *client,
 
 	error = devm_request_threaded_irq(&client->dev, client->irq,
 					  NULL, auo_pixcir_interrupt,
-					  IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+					  IRQF_ONESHOT,
 					  input_dev->name, ts);
 	if (error) {
 		dev_err(&client->dev, "irq %d requested failed, %d\n",
-- 
2.37.2.789.g6183377224-goog


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

* [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties
  2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
  2022-09-14 14:14 ` [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger Dmitry Torokhov
@ 2022-09-14 14:14 ` Dmitry Torokhov
  2022-09-14 15:06   ` Heiko Stuebner
  2022-09-14 14:14 ` [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties Dmitry Torokhov
  2022-09-14 14:40 ` [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Heiko Stuebner
  4 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 14:14 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

Let's use generic device properties API instead of OF-specific one.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/auo-pixcir-ts.c | 40 ++++++-----------------
 1 file changed, 10 insertions(+), 30 deletions(-)

diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index 4960a50f59ea..2deae5a6823a 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of.h>
+#include <linux/property.h>
 
 /*
  * Coordinate calculation:
@@ -474,33 +475,6 @@ static int __maybe_unused auo_pixcir_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
 			 auo_pixcir_suspend, auo_pixcir_resume);
 
-#ifdef CONFIG_OF
-static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts)
-{
-	struct device_node *np = dev->of_node;
-
-	if (!np)
-		return -ENOENT;
-
-	if (of_property_read_u32(np, "x-size", &ts->x_max)) {
-		dev_err(dev, "failed to get x-size property\n");
-		return -EINVAL;
-	}
-
-	if (of_property_read_u32(np, "y-size", &ts->y_max)) {
-		dev_err(dev, "failed to get y-size property\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-#else
-static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts)
-{
-	return -EINVAL;
-}
-#endif
-
 static void auo_pixcir_reset(void *data)
 {
 	struct auo_pixcir_ts *ts = data;
@@ -535,9 +509,15 @@ static int auo_pixcir_probe(struct i2c_client *client,
 	snprintf(ts->phys, sizeof(ts->phys),
 		 "%s/input0", dev_name(&client->dev));
 
-	error = auo_pixcir_parse_dt(&client->dev, ts);
-	if (error)
-		return error;
+	if (device_property_read_u32(&client->dev, "x-size", &ts->x_max)) {
+		dev_err(&client->dev, "failed to get x-size property\n");
+		return -EINVAL;
+	}
+
+	if (device_property_read_u32(&client->dev, "y-size", &ts->y_max)) {
+		dev_err(&client->dev, "failed to get y-size property\n");
+		return -EINVAL;
+	}
 
 	input_dev->name = "AUO-Pixcir touchscreen";
 	input_dev->phys = ts->phys;
-- 
2.37.2.789.g6183377224-goog


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

* [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties
  2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2022-09-14 14:14 ` [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties Dmitry Torokhov
@ 2022-09-14 14:14 ` Dmitry Torokhov
  2022-09-14 15:07   ` Heiko Stuebner
  2022-09-14 14:40 ` [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Heiko Stuebner
  4 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 14:14 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

Add proper interrupt trigger and gpio polarity data to the binding example.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 .../devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
index f40f21c642b9..b8db975e9f77 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt
@@ -17,10 +17,10 @@ Example:
 		auo_pixcir_ts@5c {
 			compatible = "auo,auo_pixcir_ts";
 			reg = <0x5c>;
-			interrupts = <2 0>;
+			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
 
-			gpios = <&gpf 2 0 2>, /* INT */
-				<&gpf 5 1 0>; /* RST */
+			gpios = <&gpf 2 0 GPIO_LEVEL_HIGH>, /* INT */
+				<&gpf 5 1 GPIO_LEVEL_LOW>; /* RST */
 
 			x-size = <800>;
 			y-size = <600>;
-- 
2.37.2.789.g6183377224-goog


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

* Re: [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data
  2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2022-09-14 14:14 ` [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties Dmitry Torokhov
@ 2022-09-14 14:40 ` Heiko Stuebner
  4 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-14 14:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:24 CEST schrieb Dmitry Torokhov:
> Currently there are no users of auo_pixcir_ts_platdata in the mainline, and
> having it (with legacy gpio numbers) prevents us from converting the driver
> to gpiod API, so let's drop it.
> 
> If, in the future, someone wants to use this driver on non-device tree,
> non-ACPI system, they should use static device properties instead of
> platform data.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
@ 2022-09-14 15:04   ` Heiko Stuebner
  2022-09-14 15:15     ` Dmitry Torokhov
  2022-09-15 13:08   ` Heiko Stuebner
  2022-09-18 14:40   ` Linus Walleij
  2 siblings, 1 reply; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-14 15:04 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:25 CEST schrieb Dmitry Torokhov:
> This switches the driver to gpiod API and drops uses of of_get_gpio() API.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
>  1 file changed, 20 insertions(+), 27 deletions(-)

[...]

> @@ -578,23 +566,28 @@ static int auo_pixcir_probe(struct i2c_client *client,
>  
>  	input_set_drvdata(ts->input, ts);
>  
> -	error = devm_gpio_request_one(&client->dev, ts->gpio_int,
> -				      GPIOF_DIR_IN, "auo_pixcir_ts_int");
> +	ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);
> +	error = PTR_ERR_OR_ZERO(ts->gpio_int);
>  	if (error) {
> -		dev_err(&client->dev, "request of gpio %d failed, %d\n",
> -			ts->gpio_int, error);
> +		dev_err(&client->dev,
> +			"request of int gpio failed: %d\n", error);
>  		return error;
>  	}
>  
> -	error = devm_gpio_request_one(&client->dev, ts->gpio_rst,
> -				      GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
> -				      "auo_pixcir_ts_rst");
> +	gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int");
> +
> +	/* Take the chip out of reset */
> +	ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1,
> +					    GPIOD_OUT_LOW);

hmm, is this really equivalent? It looks like above we're startig
with GPIOF_INIT_HIGH, while here it is LOW?

Looking at the old datasheet, yes gpio-high is the setting to
put the device into the usable state.

Interestingly there is no regulator support in the driver, the datahsheet
specifies 0.5ms for rst-low to rst-high after vdd_tp is turned on.

Heiko

Heiko



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

* Re: [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger
  2022-09-14 14:14 ` [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger Dmitry Torokhov
@ 2022-09-14 15:05   ` Heiko Stuebner
  0 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-14 15:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:26 CEST schrieb Dmitry Torokhov:
> Instead of hard-coding rising edge as the interrupt trigger, let's rely on
> the platform (ACPI, DT) to configure the interrupt properly.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties
  2022-09-14 14:14 ` [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties Dmitry Torokhov
@ 2022-09-14 15:06   ` Heiko Stuebner
  0 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-14 15:06 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:27 CEST schrieb Dmitry Torokhov:
> Let's use generic device properties API instead of OF-specific one.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties
  2022-09-14 14:14 ` [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties Dmitry Torokhov
@ 2022-09-14 15:07   ` Heiko Stuebner
  0 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-14 15:07 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:28 CEST schrieb Dmitry Torokhov:
> Add proper interrupt trigger and gpio polarity data to the binding example.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API
  2022-09-14 15:04   ` Heiko Stuebner
@ 2022-09-14 15:15     ` Dmitry Torokhov
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Torokhov @ 2022-09-14 15:15 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: Linus Walleij, linux-input, linux-kernel

On Wed, Sep 14, 2022 at 05:04:14PM +0200, Heiko Stuebner wrote:
> Am Mittwoch, 14. September 2022, 16:14:25 CEST schrieb Dmitry Torokhov:
> > This switches the driver to gpiod API and drops uses of of_get_gpio() API.
> > 
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
> >  1 file changed, 20 insertions(+), 27 deletions(-)
> 
> [...]
> 
> > @@ -578,23 +566,28 @@ static int auo_pixcir_probe(struct i2c_client *client,
> >  
> >  	input_set_drvdata(ts->input, ts);
> >  
> > -	error = devm_gpio_request_one(&client->dev, ts->gpio_int,
> > -				      GPIOF_DIR_IN, "auo_pixcir_ts_int");
> > +	ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN);
> > +	error = PTR_ERR_OR_ZERO(ts->gpio_int);
> >  	if (error) {
> > -		dev_err(&client->dev, "request of gpio %d failed, %d\n",
> > -			ts->gpio_int, error);
> > +		dev_err(&client->dev,
> > +			"request of int gpio failed: %d\n", error);
> >  		return error;
> >  	}
> >  
> > -	error = devm_gpio_request_one(&client->dev, ts->gpio_rst,
> > -				      GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
> > -				      "auo_pixcir_ts_rst");
> > +	gpiod_set_consumer_name(ts->gpio_int, "auo_pixcir_ts_int");
> > +
> > +	/* Take the chip out of reset */
> > +	ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1,
> > +					    GPIOD_OUT_LOW);
> 
> hmm, is this really equivalent? It looks like above we're startig
> with GPIOF_INIT_HIGH, while here it is LOW?

Yes, I believe the behavior will not change. You need to remember that
legacy gpio API operates on raw line states, whereas gpiod API is
normally logical state that gets converted to raw state (and the
conversion takes into account the polarity).

Here we are dealing with ACTIVE_LOW gpio, so setting it into logical
"low" (== inactive) means that the raw state is "high", as it was with
gpio_request_oneio_request_one(...GPIOF_DIR_OUT | GPIOF_INIT_HIGH, ...);

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
  2022-09-14 15:04   ` Heiko Stuebner
@ 2022-09-15 13:08   ` Heiko Stuebner
  2022-09-18 14:40   ` Linus Walleij
  2 siblings, 0 replies; 13+ messages in thread
From: Heiko Stuebner @ 2022-09-15 13:08 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Linus Walleij, linux-input, linux-kernel

Am Mittwoch, 14. September 2022, 16:14:25 CEST schrieb Dmitry Torokhov:
> This switches the driver to gpiod API and drops uses of of_get_gpio() API.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API
  2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
  2022-09-14 15:04   ` Heiko Stuebner
  2022-09-15 13:08   ` Heiko Stuebner
@ 2022-09-18 14:40   ` Linus Walleij
  2 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2022-09-18 14:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Heiko Stuebner, linux-input, linux-kernel

On Wed, Sep 14, 2022 at 4:14 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> This switches the driver to gpiod API and drops uses of of_get_gpio() API.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2022-09-18 14:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 14:14 [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Dmitry Torokhov
2022-09-14 14:14 ` [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API Dmitry Torokhov
2022-09-14 15:04   ` Heiko Stuebner
2022-09-14 15:15     ` Dmitry Torokhov
2022-09-15 13:08   ` Heiko Stuebner
2022-09-18 14:40   ` Linus Walleij
2022-09-14 14:14 ` [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger Dmitry Torokhov
2022-09-14 15:05   ` Heiko Stuebner
2022-09-14 14:14 ` [PATCH 4/5] Input: auo-pixcir-ts - switch to using generic device properties Dmitry Torokhov
2022-09-14 15:06   ` Heiko Stuebner
2022-09-14 14:14 ` [PATCH 5/5] dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties Dmitry Torokhov
2022-09-14 15:07   ` Heiko Stuebner
2022-09-14 14:40 ` [PATCH 1/5] Input: auo-pixcir-ts - drop support for platform data Heiko Stuebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.