Skip to contentSkip to conversation

Input: auo-pixcir-ts - drop support for platform data

PATCH In review Dmitry Torokhov 3 participants 13 messages Sep 14, 2022 – Sep 18, 2022

Subsystems (3)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/5 Input: auo-pixcir-ts - drop support for platform data

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.

---
 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
drivers/input/touchscreen/auo-pixcir-ts.c +56 -62
index c33e63ca6142..a51d66ebff2b 100644
@@ -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;
 
include/linux/input/auo-pixcir-ts.h deleted +0 -44

44 lines not on this page · raw message

Signature · 1 line
2.37.2.789.g6183377224-goog
author maintainer
#1 lore raw

PATCH 2/5 Input: auo-pixcir-ts - switch to using gpiod API

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

---
 drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
 1 file changed, 20 insertions(+), 27 deletions(-)
drivers/input/touchscreen/auo-pixcir-ts.c +20 -27
index a51d66ebff2b..c3bce9fb2c94 100644
@@ -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",
Signature · 1 line
2.37.2.789.g6183377224-goog
#2 lore raw

Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API

Am Mittwoch, 14. September 2022, 16:14:25 CEST schrieb Dmitry Torokhov:

Quoted 6 lines

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

---
 drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
 1 file changed, 20 insertions(+), 27 deletions(-)

[...]

Quoted 14 lines
drivers/input/touchscreen/auo-pixcir-ts.c +4 -4
@@ -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;

drivers/input/touchscreen/auo-pixcir-ts.c static int auo_pixcir_probe(struct i2c_client *client, · line 581

Quoted 10 lines
drivers/input/touchscreen/auo-pixcir-ts.c +5 -3
 	}
 
-	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

author maintainer
#3 lore raw

Re: [PATCH 2/5] Input: auo-pixcir-ts - switch to using gpiod API

Quoted 26 lines · Heiko Stuebner

Am Mittwoch, 14. September 2022, 16:14:25 CEST schrieb Dmitry Torokhov:

Quoted 6 lines

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

---
 drivers/input/touchscreen/auo-pixcir-ts.c | 47 ++++++++++-------------
 1 file changed, 20 insertions(+), 27 deletions(-)

[...]

Quoted 16 lines
drivers/input/touchscreen/auo-pixcir-ts.c +4 -4
@@ -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;
 	}
 
Quoted 11 lines

drivers/input/touchscreen/auo-pixcir-ts.c static int auo_pixcir_probe(struct i2c_client *client, · line 581

Quoted 8 lines
drivers/input/touchscreen/auo-pixcir-ts.c +5 -3
-	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.

Signature · 1 line
Dmitry
author maintainer
#6 lore raw

PATCH 3/5 Input: auo-pixcir-ts - do not force rising edge interrupt trigger

In reply to 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.

---
 drivers/input/touchscreen/auo-pixcir-ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/auo-pixcir-ts.c +1 -1
index c3bce9fb2c94..4960a50f59ea 100644
@@ -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",
Signature · 1 line
2.37.2.789.g6183377224-goog
Reviewed-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] Input: auo-pixcir-ts - do not force rising edge interrupt trigger

Am Mittwoch, 14. September 2022, 16:14:26 CEST schrieb Dmitry Torokhov:

Quoted 4 lines

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

author maintainer
#8 lore raw

PATCH 4/5 Input: auo-pixcir-ts - switch to using generic device properties

In reply to Dmitry Torokhov

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

---
 drivers/input/touchscreen/auo-pixcir-ts.c | 40 ++++++-----------------
 1 file changed, 10 insertions(+), 30 deletions(-)
drivers/input/touchscreen/auo-pixcir-ts.c +10 -30
index 4960a50f59ea..2deae5a6823a 100644
@@ -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;
Signature · 1 line
2.37.2.789.g6183377224-goog
author maintainer
#10 lore raw

PATCH 5/5 dt-bindings: input: auo-pixcir-ts: fix gpio and interrupt properties

In reply to Dmitry Torokhov

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

---
 .../devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/input/touchscreen/auo_pixcir_ts.txt +3 -3
index f40f21c642b9..b8db975e9f77 100644
@@ -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>;
Signature · 1 line
2.37.2.789.g6183377224-goog
Reviewed-by on v1 1/5
#12 lore raw
In reply to Dmitry Torokhov

Am Mittwoch, 14. September 2022, 16:14:24 CEST schrieb Dmitry Torokhov:

Quoted 9 lines

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.