huangcm
2024-10-12 1f4dc0fe687f74148f03d6ac2ead47c9b45b9463
longan/kernel/linux-4.9/drivers/input/touchscreen/gt9xx/gt9xx.c
....@@ -240,10 +240,10 @@
240240 msleep(ms);
241241
242242 gtp_set_int_value(0);
243
- msleep(2);
243
+ msleep(50);
244244
245245 ctp_wakeup(1, 0);
246
- msleep(6);
246
+ msleep(60);
247247
248248
249249 #if GTP_ESD_PROTECT
....@@ -289,7 +289,7 @@
289289 }
290290
291291 if(retries >= 2) {
292
- printk("%s:I2C retry timeout, reset chip.", __func__);
292
+ printk("%s:I2C retry timeout, reset chip. \n", __func__);
293293 }
294294 return ret;
295295 }
....@@ -659,7 +659,7 @@
659659 }
660660
661661
662
-
662
+static s32 gtp_init_panel(struct goodix_ts_data *ts);
663663
664664 /*******************************************************
665665 Function:
....@@ -708,13 +708,14 @@
708708 *******************************************************/
709709 static s8 gtp_wakeup_sleep(struct goodix_ts_data * ts)
710710 {
711
- u8 retry = 0;
712
- s8 ret = -1;
713
-
711
+ //u8 retry = 0;
712
+ s8 ret = 0;
713
+ printk("hcm gtp_wakeup_sleep !\n");
714714 gtp_io_init(20);
715715 gtp_set_io_int();
716716
717
-#if GTP_POWER_CTRL_SLEEP
717
+//#if GTP_POWER_CTRL_SLEEP
718
+#if 0
718719 while(retry++ < 5)
719720 {
720721 ret = gtp_send_cfg(ts->client);
....@@ -726,9 +727,31 @@
726727 }
727728
728729 printk("GTP wakeup sleep failed.");
729
- return ret;
730
+
731
+#endif
732
+
733
+ ret = gtp_i2c_test(ts->client);
734
+ if (ret < 0){
735
+ printk("hcm I2C communication ERROR!\n");
736
+ msleep(50);
737
+ gtp_set_io_int();
738
+ ret = gtp_i2c_test(ts->client);
739
+ if (ret < 0){
740
+ printk("I2C communication ERROR 2!\n");
741
+ }
742
+ }
743
+
744
+ ret = gtp_init_panel(ts);
745
+ if (ret < 0) {
746
+ printk("GTP init panel failed.\n");
747
+ }
748
+
749
+
750
+#if GTP_CREATE_WR_NODE
751
+ init_wr_node(ts->client);
730752 #endif
731753
754
+ return ret;
732755 }
733756
734757
....@@ -978,7 +1001,7 @@
9781001 if (ret > 0) {
9791002 return ret;
9801003 }
981
- printk("GTP i2c test failed time %d.",retry);
1004
+ printk("GTP i2c test failed time %d. \n",retry);
9821005 msleep(10);
9831006 }
9841007 return ret;
....@@ -1060,6 +1083,37 @@
10601083 return 0;
10611084 }
10621085
1086
+static int goodix_ts_suspend(struct device *dev);
1087
+static int goodix_ts_resume(struct device *dev);
1088
+extern void gt9xx_resume_extern(void);
1089
+extern void gt9xx_suspend_extern(void);
1090
+struct goodix_ts_data *cur_ts;
1091
+
1092
+void gt9xx_suspend_extern(void)
1093
+{
1094
+ // goodix_ts_suspend(config_info.dev);
1095
+
1096
+ gtp_irq_disable(cur_ts);
1097
+ cancel_work_sync(&goodix_resume_work);
1098
+ flush_workqueue(goodix_resume_wq);
1099
+ cancel_work_sync(&cur_ts->work);
1100
+ flush_workqueue(goodix_wq);
1101
+
1102
+}
1103
+EXPORT_SYMBOL(gt9xx_suspend_extern);
1104
+
1105
+void gt9xx_resume_extern(void)
1106
+{
1107
+ // goodix_ts_resume(config_info.dev);
1108
+ printk("%s goodix_ts_resume v1\n", goodix_ts_name);
1109
+ __gpio_set_value(config_info.wakeup_gpio.gpio, 1);
1110
+ input_set_power_enable(&(config_info.input_type), 1);
1111
+ msleep(10);
1112
+ // goodix_resume_events
1113
+ queue_work(goodix_resume_wq, &goodix_resume_work);//gandy
1114
+
1115
+}
1116
+EXPORT_SYMBOL(gt9xx_resume_extern);
10631117
10641118 /*******************************************************
10651119 Function:
....@@ -1102,8 +1156,16 @@
11021156
11031157
11041158 ret = gtp_i2c_test(client);
1105
- if (ret < 0){
1106
- printk("I2C communication ERROR!\n");
1159
+ if (ret < 0 && client->addr == 0x5d){
1160
+ printk("I2C communication ERROR! reset chip and retry \n");
1161
+ gtp_set_io_int();
1162
+ ret = gtp_i2c_test(client);
1163
+ if (ret < 0){
1164
+ printk("I2C communication ERROR 2!\n");
1165
+ goto exit_device_detect;
1166
+ }
1167
+ } else if (ret < 0) {
1168
+ printk("I2C communication ERROR %02x !\n", client->addr);
11071169 goto exit_device_detect;
11081170 }
11091171
....@@ -1165,6 +1227,9 @@
11651227 queue_delayed_work(gtp_esd_check_workqueue, &gtp_esd_check_work, GTP_ESD_CHECK_CIRCLE);
11661228 #endif
11671229 dprintk(DEBUG_INIT, "gt9xx probe success!\n");
1230
+
1231
+ cur_ts = ts;
1232
+
11681233 return 0;
11691234 exit_device_detect:
11701235 i2c_set_clientdata(client, NULL);
....@@ -1221,7 +1286,7 @@
12211286 {
12221287 int ret;
12231288 struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client);
1224
-
1289
+ printk("goodix_resume_events \n");
12251290 ret = gtp_wakeup_sleep(ts);
12261291 if (ret < 0)
12271292 printk("resume power on failed\n");
....@@ -1438,11 +1503,11 @@
14381503 .driver = {
14391504 .name = CTP_NAME,
14401505 .owner = THIS_MODULE,
1441
-#ifndef CONFIG_HAS_EARLYSUSPEND
1442
-#ifdef CONFIG_PM
1443
- .pm = GT9XX_PM_OPS,
1444
-#endif
1445
-#endif
1506
+// #ifndef CONFIG_HAS_EARLYSUSPEND
1507
+// #ifdef CONFIG_PM
1508
+// .pm = GT9XX_PM_OPS,
1509
+// #endif
1510
+// #endif
14461511 },
14471512 .address_list = normal_i2c,
14481513 };
....@@ -1521,6 +1586,7 @@
15211586 //of_property_read_u32(np, "ctp_exchange_x_y_flag", &exchange_x_y_flag);
15221587 #endif
15231588 sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name);
1589
+ pr_err("gt %s, line:%d irq_pin_name = %s \n",__FUNCTION__, __LINE__, irq_pin_name);
15241590 gtp_io_init(20);
15251591
15261592 goodix_wq = create_singlethread_workqueue("goodix_wq");