@@ -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 );
@@ -947,11 +977,6 @@ static int ili210x_i2c_probe(struct i2c_client *client)
947
977
return - ENODEV ;
948
978
}
949
979
950
- if (client -> irq <= 0 ) {
951
- dev_err (dev , "No IRQ!\n" );
952
- return - EINVAL ;
953
- }
954
-
955
980
reset_gpio = devm_gpiod_get_optional (dev , "reset" , GPIOD_OUT_HIGH );
956
981
if (IS_ERR (reset_gpio ))
957
982
return PTR_ERR (reset_gpio );
@@ -1003,12 +1028,17 @@ static int ili210x_i2c_probe(struct i2c_client *client)
1003
1028
return error ;
1004
1029
}
1005
1030
1006
- error = devm_request_threaded_irq (dev , client -> irq , NULL , ili210x_irq ,
1007
- IRQF_ONESHOT , client -> name , priv );
1008
- if (error ) {
1009
- dev_err (dev , "Unable to request touchscreen IRQ, err: %d\n" ,
1010
- error );
1011
- return error ;
1031
+ if (client -> irq ) {
1032
+ error = devm_request_threaded_irq (dev , client -> irq , NULL , ili210x_irq ,
1033
+ IRQF_ONESHOT , client -> name , priv );
1034
+ if (error ) {
1035
+ dev_err (dev , "Unable to request touchscreen IRQ, err: %d\n" , error );
1036
+ return error ;
1037
+ }
1038
+ } else {
1039
+ timer_setup (& priv -> poll_timer , ili210x_poll_timer_callback , 0 );
1040
+ mod_timer (& priv -> poll_timer , jiffies + msecs_to_jiffies (ILI2XXX_POLL_PERIOD ));
1041
+ INIT_WORK (& priv -> poll_work , ili210x_poll_work );
1012
1042
}
1013
1043
1014
1044
error = devm_add_action_or_reset (dev , ili210x_stop , priv );
@@ -1024,6 +1054,16 @@ static int ili210x_i2c_probe(struct i2c_client *client)
1024
1054
return 0 ;
1025
1055
}
1026
1056
1057
+ static void ili210x_i2c_remove (struct i2c_client * client )
1058
+ {
1059
+ struct ili210x * tsdata = i2c_get_clientdata (client );
1060
+
1061
+ if (!client -> irq ) {
1062
+ del_timer (& tsdata -> poll_timer );
1063
+ cancel_work_sync (& tsdata -> poll_work );
1064
+ }
1065
+ }
1066
+
1027
1067
static const struct i2c_device_id ili210x_i2c_id [] = {
1028
1068
{ "ili210x" , (long )& ili210x_chip },
1029
1069
{ "ili2117" , (long )& ili211x_chip },
@@ -1050,6 +1090,7 @@ static struct i2c_driver ili210x_ts_driver = {
1050
1090
},
1051
1091
.id_table = ili210x_i2c_id ,
1052
1092
.probe = ili210x_i2c_probe ,
1093
+ .remove = ili210x_i2c_remove ,
1053
1094
};
1054
1095
1055
1096
module_i2c_driver (ili210x_ts_driver );
0 commit comments