Skip to content

Commit 9763892

Browse files
eng33pelwell
authored andcommitted
drivers:input:touchscreen: Add support for no irq to ili210x driver
Signed-off-by: eng33 <[email protected]>
1 parent 02dee26 commit 9763892

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

drivers/input/touchscreen/ili210x.c

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct ili210x {
6767
u8 version_proto[2];
6868
u8 ic_mode[2];
6969
bool stop;
70+
struct timer_list poll_timer;
71+
struct work_struct poll_work;
7072
};
7173

7274
static int ili210x_read_reg(struct i2c_client *client,
@@ -360,6 +362,34 @@ static irqreturn_t ili210x_irq(int irq, void *irq_data)
360362
return IRQ_HANDLED;
361363
}
362364

365+
static void ili210x_poll_work(struct work_struct *work)
366+
{
367+
struct ili210x *priv = container_of(work, struct ili210x, poll_work);
368+
struct i2c_client *client = priv->client;
369+
const struct ili2xxx_chip *chip = priv->chip;
370+
u8 touchdata[ILI210X_DATA_SIZE] = { 0 };
371+
bool touch;
372+
int error;
373+
374+
error = chip->get_touch_data(client, touchdata);
375+
if (error) {
376+
dev_err(&client->dev, "Unable to get touch data: %d\n", error);
377+
return;
378+
}
379+
380+
touch = ili210x_report_events(priv, touchdata);
381+
}
382+
383+
static void ili210x_poll_timer_callback(struct timer_list *t)
384+
{
385+
struct ili210x *priv = from_timer(priv, t, poll_timer);
386+
387+
schedule_work(&priv->poll_work);
388+
389+
if (!priv->stop)
390+
mod_timer(&priv->poll_timer, jiffies + msecs_to_jiffies(ILI2XXX_POLL_PERIOD));
391+
}
392+
363393
static int ili251x_firmware_update_resolution(struct device *dev)
364394
{
365395
struct i2c_client *client = to_i2c_client(dev);
@@ -945,11 +975,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
945975
return -ENODEV;
946976
}
947977

948-
if (client->irq <= 0) {
949-
dev_err(dev, "No IRQ!\n");
950-
return -EINVAL;
951-
}
952-
953978
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
954979
if (IS_ERR(reset_gpio))
955980
return PTR_ERR(reset_gpio);
@@ -1001,12 +1026,17 @@ static int ili210x_i2c_probe(struct i2c_client *client)
10011026
return error;
10021027
}
10031028

1004-
error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
1005-
IRQF_ONESHOT, client->name, priv);
1006-
if (error) {
1007-
dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n",
1008-
error);
1009-
return error;
1029+
if (client->irq) {
1030+
error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
1031+
IRQF_ONESHOT, client->name, priv);
1032+
if (error) {
1033+
dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", error);
1034+
return error;
1035+
}
1036+
} else {
1037+
timer_setup(&priv->poll_timer, ili210x_poll_timer_callback, 0);
1038+
mod_timer(&priv->poll_timer, jiffies + msecs_to_jiffies(ILI2XXX_POLL_PERIOD));
1039+
INIT_WORK(&priv->poll_work, ili210x_poll_work);
10101040
}
10111041

10121042
error = devm_add_action_or_reset(dev, ili210x_stop, priv);
@@ -1029,6 +1059,16 @@ static int ili210x_i2c_probe(struct i2c_client *client)
10291059
return 0;
10301060
}
10311061

1062+
static void ili210x_i2c_remove(struct i2c_client *client)
1063+
{
1064+
struct ili210x *tsdata = i2c_get_clientdata(client);
1065+
1066+
if (!client->irq) {
1067+
del_timer(&tsdata->poll_timer);
1068+
cancel_work_sync(&tsdata->poll_work);
1069+
}
1070+
}
1071+
10321072
static const struct i2c_device_id ili210x_i2c_id[] = {
10331073
{ "ili210x", (long)&ili210x_chip },
10341074
{ "ili2117", (long)&ili211x_chip },
@@ -1054,6 +1094,7 @@ static struct i2c_driver ili210x_ts_driver = {
10541094
},
10551095
.id_table = ili210x_i2c_id,
10561096
.probe = ili210x_i2c_probe,
1097+
.remove = ili210x_i2c_remove,
10571098
};
10581099

10591100
module_i2c_driver(ili210x_ts_driver);

0 commit comments

Comments
 (0)