@@ -67,6 +67,8 @@ struct ili210x {
67
67
u8 version_proto [2 ];
68
68
u8 ic_mode [2 ];
69
69
bool stop ;
70
+ struct timer_list poll_timer ;
71
+ struct work_struct poll_work ;
70
72
};
71
73
72
74
static int ili210x_read_reg (struct i2c_client * client ,
@@ -360,6 +362,34 @@ static irqreturn_t ili210x_irq(int irq, void *irq_data)
360
362
return IRQ_HANDLED ;
361
363
}
362
364
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
+
363
393
static int ili251x_firmware_update_resolution (struct device * dev )
364
394
{
365
395
struct i2c_client * client = to_i2c_client (dev );
@@ -945,11 +975,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
945
975
return - ENODEV ;
946
976
}
947
977
948
- if (client -> irq <= 0 ) {
949
- dev_err (dev , "No IRQ!\n" );
950
- return - EINVAL ;
951
- }
952
-
953
978
reset_gpio = devm_gpiod_get_optional (dev , "reset" , GPIOD_OUT_HIGH );
954
979
if (IS_ERR (reset_gpio ))
955
980
return PTR_ERR (reset_gpio );
@@ -1001,12 +1026,17 @@ static int ili210x_i2c_probe(struct i2c_client *client)
1001
1026
return error ;
1002
1027
}
1003
1028
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 );
1010
1040
}
1011
1041
1012
1042
error = devm_add_action_or_reset (dev , ili210x_stop , priv );
@@ -1029,6 +1059,16 @@ static int ili210x_i2c_probe(struct i2c_client *client)
1029
1059
return 0 ;
1030
1060
}
1031
1061
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
+
1032
1072
static const struct i2c_device_id ili210x_i2c_id [] = {
1033
1073
{ "ili210x" , (long )& ili210x_chip },
1034
1074
{ "ili2117" , (long )& ili211x_chip },
@@ -1054,6 +1094,7 @@ static struct i2c_driver ili210x_ts_driver = {
1054
1094
},
1055
1095
.id_table = ili210x_i2c_id ,
1056
1096
.probe = ili210x_i2c_probe ,
1097
+ .remove = ili210x_i2c_remove ,
1057
1098
};
1058
1099
1059
1100
module_i2c_driver (ili210x_ts_driver );
0 commit comments