Commit 882597af authored by Dmitry Torokhov's avatar Dmitry Torokhov

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.
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20220914141428.2201784-1-dmitry.torokhov@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 60a884da
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/input/auo-pixcir-ts.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
...@@ -69,6 +68,16 @@ ...@@ -69,6 +68,16 @@
#define AUO_PIXCIR_INT_RELEASE (1 << 4) #define AUO_PIXCIR_INT_RELEASE (1 << 4)
#define AUO_PIXCIR_INT_ENABLE (1 << 3) #define AUO_PIXCIR_INT_ENABLE (1 << 3)
#define AUO_PIXCIR_INT_POL_HIGH (1 << 2) #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 #define AUO_PIXCIR_INT_MODE_MASK 0x03
/* /*
...@@ -103,10 +112,14 @@ ...@@ -103,10 +112,14 @@
struct auo_pixcir_ts { struct auo_pixcir_ts {
struct i2c_client *client; struct i2c_client *client;
struct input_dev *input; struct input_dev *input;
const struct auo_pixcir_ts_platdata *pdata; int gpio_int;
int gpio_rst;
char phys[32]; 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; bool touch_ind_mode;
wait_queue_head_t wait; wait_queue_head_t wait;
...@@ -125,7 +138,6 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, ...@@ -125,7 +138,6 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
struct auo_point_t *point) struct auo_point_t *point)
{ {
struct i2c_client *client = ts->client; struct i2c_client *client = ts->client;
const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
uint8_t raw_coord[8]; uint8_t raw_coord[8];
uint8_t raw_area[4]; uint8_t raw_area[4];
int i, ret; int i, ret;
...@@ -152,8 +164,8 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, ...@@ -152,8 +164,8 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts,
point[i].coord_y = point[i].coord_y =
raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2];
if (point[i].coord_x > pdata->x_max || if (point[i].coord_x > ts->x_max ||
point[i].coord_y > pdata->y_max) { point[i].coord_y > ts->y_max) {
dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", 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);
point[i].coord_x = point[i].coord_y = 0; point[i].coord_x = point[i].coord_y = 0;
...@@ -171,7 +183,6 @@ static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, ...@@ -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) static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
{ {
struct auo_pixcir_ts *ts = 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]; struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS];
int i; int i;
int ret; int ret;
...@@ -182,7 +193,7 @@ static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) ...@@ -182,7 +193,7 @@ static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id)
/* check for up event in touch touch_ind_mode */ /* check for up event in touch touch_ind_mode */
if (ts->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_mt_sync(ts->input);
input_report_key(ts->input, BTN_TOUCH, 0); input_report_key(ts->input, BTN_TOUCH, 0);
input_sync(ts->input); input_sync(ts->input);
...@@ -278,11 +289,9 @@ static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode) ...@@ -278,11 +289,9 @@ static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode)
return 0; return 0;
} }
static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting)
int int_setting)
{ {
struct i2c_client *client = ts->client; struct i2c_client *client = ts->client;
const struct auo_pixcir_ts_platdata *pdata = ts->pdata;
int ret; int ret;
ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); 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, ...@@ -304,7 +313,7 @@ static int auo_pixcir_int_config(struct auo_pixcir_ts *ts,
return ret; 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; return 0;
} }
...@@ -466,49 +475,41 @@ static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, ...@@ -466,49 +475,41 @@ static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops,
auo_pixcir_suspend, auo_pixcir_resume); auo_pixcir_suspend, auo_pixcir_resume);
#ifdef CONFIG_OF #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; struct device_node *np = dev->of_node;
if (!np) if (!np)
return ERR_PTR(-ENOENT); return -ENOENT;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); ts->gpio_int = of_get_gpio(np, 0);
if (!pdata) if (!gpio_is_valid(ts->gpio_int)) {
return ERR_PTR(-ENOMEM);
pdata->gpio_int = of_get_gpio(np, 0);
if (!gpio_is_valid(pdata->gpio_int)) {
dev_err(dev, "failed to get interrupt gpio\n"); dev_err(dev, "failed to get interrupt gpio\n");
return ERR_PTR(-EINVAL); return -EINVAL;
} }
pdata->gpio_rst = of_get_gpio(np, 1); ts->gpio_rst = of_get_gpio(np, 1);
if (!gpio_is_valid(pdata->gpio_rst)) { if (!gpio_is_valid(ts->gpio_rst)) {
dev_err(dev, "failed to get reset gpio\n"); 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"); 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"); 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 */ return 0;
pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND;
return pdata;
} }
#else #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 #endif
...@@ -516,27 +517,18 @@ static void auo_pixcir_reset(void *data) ...@@ -516,27 +517,18 @@ static void auo_pixcir_reset(void *data)
{ {
struct auo_pixcir_ts *ts = 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, static int auo_pixcir_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
const struct auo_pixcir_ts_platdata *pdata;
struct auo_pixcir_ts *ts; struct auo_pixcir_ts *ts;
struct input_dev *input_dev; struct input_dev *input_dev;
int version; int version;
int error; int error;
pdata = dev_get_platdata(&client->dev); ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
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);
if (!ts) if (!ts)
return -ENOMEM; return -ENOMEM;
...@@ -546,7 +538,6 @@ static int auo_pixcir_probe(struct i2c_client *client, ...@@ -546,7 +538,6 @@ static int auo_pixcir_probe(struct i2c_client *client,
return -ENOMEM; return -ENOMEM;
} }
ts->pdata = pdata;
ts->client = client; ts->client = client;
ts->input = input_dev; ts->input = input_dev;
ts->touch_ind_mode = 0; ts->touch_ind_mode = 0;
...@@ -556,6 +547,10 @@ static int auo_pixcir_probe(struct i2c_client *client, ...@@ -556,6 +547,10 @@ static int auo_pixcir_probe(struct i2c_client *client,
snprintf(ts->phys, sizeof(ts->phys), snprintf(ts->phys, sizeof(ts->phys),
"%s/input0", dev_name(&client->dev)); "%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->name = "AUO-Pixcir touchscreen";
input_dev->phys = ts->phys; input_dev->phys = ts->phys;
input_dev->id.bustype = BUS_I2C; input_dev->id.bustype = BUS_I2C;
...@@ -569,36 +564,34 @@ static int auo_pixcir_probe(struct i2c_client *client, ...@@ -569,36 +564,34 @@ static int auo_pixcir_probe(struct i2c_client *client,
__set_bit(BTN_TOUCH, input_dev->keybit); __set_bit(BTN_TOUCH, input_dev->keybit);
/* For single touch */ /* For single touch */
input_set_abs_params(input_dev, ABS_X, 0, pdata->x_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, pdata->y_max, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0);
/* For multi touch */ /* For multi touch */
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
pdata->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_POSITION_Y, 0, input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
pdata->y_max, 0, 0); 0, AUO_PIXCIR_MAX_AREA, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
AUO_PIXCIR_MAX_AREA, 0, 0); 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_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
input_set_drvdata(ts->input, ts); 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"); GPIOF_DIR_IN, "auo_pixcir_ts_int");
if (error) { if (error) {
dev_err(&client->dev, "request of gpio %d failed, %d\n", dev_err(&client->dev, "request of gpio %d failed, %d\n",
pdata->gpio_int, error); ts->gpio_int, error);
return 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, GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
"auo_pixcir_ts_rst"); "auo_pixcir_ts_rst");
if (error) { if (error) {
dev_err(&client->dev, "request of gpio %d failed, %d\n", dev_err(&client->dev, "request of gpio %d failed, %d\n",
pdata->gpio_rst, error); ts->gpio_rst, error);
return error; return error;
} }
...@@ -619,7 +612,8 @@ static int auo_pixcir_probe(struct i2c_client *client, ...@@ -619,7 +612,8 @@ static int auo_pixcir_probe(struct i2c_client *client,
dev_info(&client->dev, "firmware version 0x%X\n", version); 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) if (error)
return error; return error;
......
/* 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment