调试gt9xx驱动记录

SoC:RK3568

TP-size:GT911

目前MIPI-DSI屏幕上使用的是gt911的驱动芯片,查看芯片手册是基于i2c的

所以首先写设备树,查看芯片手册,七位地址为0x14,另外复位和中断的pin脚要参考SoC端的gpio,max-x与max-y分别代表屏幕的width和height(这里对应不一定对应准确,按照实际测试去看),tp-size为具体的tp芯片型号,此处我使用的是gt911

&i2c1 {
	status = "okay";

	gt9xx: gt9xx@14 {
		compatible = "goodix,gt9xx";
		status = "okay";
		reg = <0x14>;
		pinctrl-names = "default";
		pinctrl-0 = <&touch_gpio>;
		reset-gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>;
		touch-gpio = <&gpio0 RK_PB5 IRQ_TYPE_LEVEL_LOW>;
		max-x = <800>;
		max-y = <1280>;
		tp-size = <911>;
	};
};

rk3568原SDK的gt9xx系列驱动是有问题的,需要打补丁,如果没有git管理只能手动打一下补丁了

From e25a827b434563685f5d037c5901c7aa4e94519a Mon Sep 17 00:00:00 2001
From: Huang zhibao <hzb@rock-chips.com>
Date: Sat, 16 Dec 2023 11:25:02 +0800
Subject: [PATCH] input: touchscreen: fixed gt9xx compile error

Change-Id: Ie02a67a206bb7a83dfbd953880f5b1d744955449
Signed-off-by: Huang zhibao <hzb@rock-chips.com>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
---
 drivers/input/touchscreen/Kconfig             |   9 +
 drivers/input/touchscreen/Makefile            |   1 +
 drivers/input/touchscreen/gt9xx/Makefile      |   2 +-
 drivers/input/touchscreen/gt9xx/gt9xx.c       |  91 ++++----
 drivers/input/touchscreen/gt9xx/gt9xx.h       |  23 +-
 drivers/input/touchscreen/gt9xx/gt9xx_cfg.h   |  16 +-
 .../input/touchscreen/gt9xx/gt9xx_firmware.h  |   4 +-
 .../input/touchscreen/gt9xx/gt9xx_update.c    | 197 +++++++++---------
 8 files changed, 190 insertions(+), 153 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0efc7e75a3dd..fa0010eaf232 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -430,6 +430,15 @@ config TOUCHSCREEN_GSLX680_PAD
 config TOUCHSCREEN_GT1X
 	tristate "GT1X touchscreens support"
 
+config TOUCHSCREEN_GT9XX
+	tristate "Goodix gt9xx support for rockchip platform"
+	depends on I2C && ARCH_ROCKCHIP
+	help
+	  Say Y here if you have a touchscreen interface using the gt9xx
+	  on Rockchip platform, and your board-specific initialization
+	  code includes that in its table of IIC devices.
+	  If unsure, say N.
+
 config TOUCHSCREEN_HIDEEP
 	tristate "HiDeep Touch IC"
 	depends on I2C
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 0b1975b3bf95..21582b592945 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -54,6 +54,7 @@ gsl3673-800x1280-y := gsl3673_800x1280.o gsl_point_id.o
 obj-$(CONFIG_TOUCHSCREEN_GSLX680_PAD)	+= gslx680-pad.o
 gslx680-pad-y := gslx680_pad.o gsl_point_id.o
 obj-$(CONFIG_TOUCHSCREEN_GT1X)		+= gt1x/
+obj-$(CONFIG_TOUCHSCREEN_GT9XX)		+= gt9xx/
 obj-$(CONFIG_TOUCHSCREEN_HIDEEP)	+= hideep.o
 obj-$(CONFIG_TOUCHSCREEN_ILI210X)	+= ili210x.o
 obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC)	+= imx6ul_tsc.o
diff --git a/drivers/input/touchscreen/gt9xx/Makefile b/drivers/input/touchscreen/gt9xx/Makefile
index f63b5f2783a5..cb01c656755c 100644
--- a/drivers/input/touchscreen/gt9xx/Makefile
+++ b/drivers/input/touchscreen/gt9xx/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y	+= goodix_gt9xx.o
+obj-$(CONFIG_TOUCHSCREEN_GT9XX)	+= goodix_gt9xx.o
 
 #goodix_gt9xx-y		+=goodix_tool.o
 goodix_gt9xx-y		+=gt9xx.o
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c
index 67b1b3451dab..f340c047808f 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.c
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.c
@@ -68,8 +68,8 @@ static u8 gtp_y_reverse = TRUE;
 
 static const char *goodix_ts_name = "goodix-ts";
 static struct workqueue_struct *goodix_wq;
-struct i2c_client * i2c_connect_client = NULL; 
-u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH]
+struct i2c_client * gtp_i2c_connect_client = NULL; 
+static u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH]
                 = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff};
 
 #if GTP_HAVE_TOUCH_KEY
@@ -86,12 +86,12 @@ u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH]
 static s8 gtp_i2c_test(struct i2c_client *client);
 void gtp_reset_guitar(struct i2c_client *client, s32 ms);
 s32 gtp_send_cfg(struct i2c_client *client);
-void gtp_int_sync(s32 ms, struct goodix_ts_data *ts);
+static void gtp_int_sync(s32 ms, struct goodix_ts_data *ts);
 
 static ssize_t gt91xx_config_read_proc(struct file *, char __user *, size_t, loff_t *);
 static ssize_t gt91xx_config_write_proc(struct file *, const char __user *, size_t, loff_t *);
 
-static struct proc_dir_entry *gt91xx_config_proc = NULL;
+//static struct proc_dir_entry *gt91xx_config_proc = NULL;
 static const struct file_operations config_proc_ops = {
     .owner = THIS_MODULE,
     .read = gt91xx_config_read_proc,
@@ -117,15 +117,15 @@ void gtp_esd_switch(struct i2c_client *, s32);
 
 //*********** For GT9XXF Start **********//
 #if GTP_COMPATIBLE_MODE
-extern s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
-extern s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
-extern s32 gup_clk_calibration(void);
-extern s32 gup_fw_download_proc(void *dir, u8 dwn_mode);
-extern u8 gup_check_fs_mounted(char *path_name);
+//extern s32 gtp_i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
+//extern s32 gtp_i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
+//extern s32 gtp_gup_clk_calibration(void);
+//extern s32 gtp_gup_fw_download_proc(void *dir, u8 dwn_mode);
+//extern u8 gtp_gup_check_fs_mounted(char *path_name);
 
-void gtp_recovery_reset(struct i2c_client *client);
+static void gtp_recovery_reset(struct i2c_client *client);
 static s32 gtp_esd_recovery(struct i2c_client *client);
-s32 gtp_fw_startup(struct i2c_client *client);
+//s32 gtp_fw_startup(struct i2c_client *client);
 static s32 gtp_main_clk_proc(struct goodix_ts_data *ts);
 static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode);
 
@@ -143,7 +143,7 @@ static DOZE_T doze_status = DOZE_DISABLED;
 static s8 gtp_enter_doze(struct goodix_ts_data *ts);
 #endif
 
-u8 grp_cfg_version = 0;
+static u8 grp_cfg_version = 0;
 
 /*******************************************************
 Function:
@@ -157,7 +157,7 @@ u8 grp_cfg_version = 0;
     numbers of i2c_msgs to transfer: 
       2: succeed, otherwise: failed
 *********************************************************/
-s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
+static s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
 {
     struct i2c_msg msgs[2];
     s32 ret=-1;
@@ -230,7 +230,7 @@ s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
     numbers of i2c_msgs to transfer: 
         1: succeed, otherwise: failed
 *********************************************************/
-s32 gtp_i2c_write(struct i2c_client *client,u8 *buf,s32 len)
+static s32 gtp_i2c_write(struct i2c_client *client,u8 *buf,s32 len)
 {
     struct i2c_msg msg;
     s32 ret = -1;
@@ -523,7 +523,7 @@ static void gtp_pen_init(struct goodix_ts_data *ts)
 
 static void gtp_pen_down(s32 x, s32 y, s32 w, s32 id)
 {
-    struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client);
+    struct goodix_ts_data *ts = i2c_get_clientdata(gtp_i2c_connect_client);
 
 	if (gtp_change_x2y)
 		GTP_SWAP(x, y);
@@ -551,7 +551,7 @@ static void gtp_pen_down(s32 x, s32 y, s32 w, s32 id)
 
 static void gtp_pen_up(s32 id)
 {
-    struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client);
+    struct goodix_ts_data *ts = i2c_get_clientdata(gtp_i2c_connect_client);
     
     input_report_key(ts->pen_dev, BTN_TOOL_PEN, 0);
     
@@ -613,7 +613,7 @@ static void goodix_ts_work_func(struct work_struct *work)
 #if GTP_GESTURE_WAKEUP
     if (DOZE_ENABLED == doze_status)
     {               
-        ret = gtp_i2c_read(i2c_connect_client, doze_buf, 3);
+        ret = gtp_i2c_read(gtp_i2c_connect_client, doze_buf, 3);
         GTP_DEBUG("0x814B = 0x%02X", doze_buf[2]);
         if (ret > 0)
         {     
@@ -640,7 +640,7 @@ static void goodix_ts_work_func(struct work_struct *work)
                 input_sync(ts->input_dev);
                 // clear 0x814B
                 doze_buf[2] = 0x00;
-                gtp_i2c_write(i2c_connect_client, doze_buf, 3);
+                gtp_i2c_write(gtp_i2c_connect_client, doze_buf, 3);
 			}
 			else if ( (doze_buf[2] == 0xAA) || (doze_buf[2] == 0xBB) ||
 				(doze_buf[2] == 0xAB) || (doze_buf[2] == 0xBA) )
@@ -656,7 +656,7 @@ static void goodix_ts_work_func(struct work_struct *work)
                 input_sync(ts->input_dev);
                 // clear 0x814B
                 doze_buf[2] = 0x00;
-                gtp_i2c_write(i2c_connect_client, doze_buf, 3);
+                gtp_i2c_write(gtp_i2c_connect_client, doze_buf, 3);
             }
             else if (0xCC == doze_buf[2])
             {
@@ -668,13 +668,13 @@ static void goodix_ts_work_func(struct work_struct *work)
                 input_sync(ts->input_dev);
                 // clear 0x814B
                 doze_buf[2] = 0x00;
-                gtp_i2c_write(i2c_connect_client, doze_buf, 3);
+                gtp_i2c_write(gtp_i2c_connect_client, doze_buf, 3);
             }
             else
             {
                 // clear 0x814B
                 doze_buf[2] = 0x00;
-                gtp_i2c_write(i2c_connect_client, doze_buf, 3);
+                gtp_i2c_write(gtp_i2c_connect_client, doze_buf, 3);
                 gtp_enter_doze(ts);
             }
         }
@@ -1087,7 +1087,7 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
 Output:
     None.
 *******************************************************/
-void gtp_int_sync(s32 ms, struct goodix_ts_data *ts)
+static void gtp_int_sync(s32 ms, struct goodix_ts_data *ts)
 {
     GTP_GPIO_OUTPUT(ts->irq_pin, 0);
     msleep(ms);
@@ -1706,7 +1706,7 @@ static ssize_t gt91xx_config_read_proc(struct file *file, char __user *page, siz
     ptr += sprintf(ptr, "\n");
 
     ptr += sprintf(ptr, "==== GT9XX config real value====\n");
-    gtp_i2c_read(i2c_connect_client, temp_data, GTP_CONFIG_MAX_LENGTH + 2);
+    gtp_i2c_read(gtp_i2c_connect_client, temp_data, GTP_CONFIG_MAX_LENGTH + 2);
     for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++)
     {
         ptr += sprintf(ptr, "0x%02X ", temp_data[i+2]);
@@ -1734,7 +1734,7 @@ static ssize_t gt91xx_config_write_proc(struct file *filp, const char __user *bu
         return -EFAULT;
     }
 
-    ret = gtp_send_cfg(i2c_connect_client);
+    ret = gtp_send_cfg(gtp_i2c_connect_client);
 
     if (ret < 0)
     {
@@ -2144,7 +2144,7 @@ s32 gtp_fw_startup(struct i2c_client *client)
     struct goodix_ts_data *ts = i2c_get_clientdata(client);
     //init sw WDT
 	opr_buf[0] = 0xAA;
-	ret = i2c_write_bytes(client, 0x8041, opr_buf, 1);
+	ret = gtp_i2c_write_bytes(client, 0x8041, opr_buf, 1);
     if (ret < 0)
     {
         return FAIL;
@@ -2152,7 +2152,7 @@ s32 gtp_fw_startup(struct i2c_client *client)
     
     //release SS51 & DSP
     opr_buf[0] = 0x00;
-    ret = i2c_write_bytes(client, 0x4180, opr_buf, 1);
+    ret = gtp_i2c_write_bytes(client, 0x4180, opr_buf, 1);
     if (ret < 0)
     {
         return FAIL;
@@ -2161,7 +2161,7 @@ s32 gtp_fw_startup(struct i2c_client *client)
     gtp_int_sync(25, ts);  
     
     //check fw run status
-    ret = i2c_read_bytes(client, 0x8041, opr_buf, 1);
+    ret = gtp_i2c_read_bytes(client, 0x8041, opr_buf, 1);
     if (ret < 0)
     {
         return FAIL;
@@ -2175,7 +2175,7 @@ s32 gtp_fw_startup(struct i2c_client *client)
     {
         GTP_INFO("IC works normally, Startup success.");
         opr_buf[0] = 0xAA;
-        i2c_write_bytes(client, 0x8041, opr_buf, 1);
+        gtp_i2c_write_bytes(client, 0x8041, opr_buf, 1);
         return SUCCESS;
     }
 }
@@ -2193,7 +2193,7 @@ static s32 gtp_esd_recovery(struct i2c_client *client)
     GTP_INFO("GT9XXF esd recovery mode");
     for (retry = 0; retry < 5; retry++)
     {
-        ret = gup_fw_download_proc(NULL, GTP_FL_ESD_RECOVERY); 
+        ret = gtp_gup_fw_download_proc(NULL, GTP_FL_ESD_RECOVERY); 
         if (FAIL == ret)
         {
             GTP_ERROR("esd recovery failed %d", retry+1);
@@ -2219,7 +2219,7 @@ static s32 gtp_esd_recovery(struct i2c_client *client)
     return SUCCESS;
 }
 
-void gtp_recovery_reset(struct i2c_client *client)
+static void gtp_recovery_reset(struct i2c_client *client)
 {
 #if GTP_ESD_PROTECT
     gtp_esd_switch(client, SWITCH_OFF);
@@ -2246,7 +2246,7 @@ static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode)
     struct file *ref_filp = NULL;
     u8 *p_bak_ref;
     
-    ret = gup_check_fs_mounted("/data");
+    ret = gtp_gup_check_fs_mounted("/data");
     if (FAIL == ret)
     {
         ts->ref_chk_fs_times++;
@@ -2334,7 +2334,7 @@ static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode)
                 }
             }
         }
-        ret = i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
+        ret = gtp_i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
         if (FAIL == ret)
         {
             GTP_ERROR("failed to send bak_ref because of iic comm error");
@@ -2344,7 +2344,7 @@ static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode)
         
     case GTP_BAK_REF_STORE:
         GTP_INFO("Store backup-reference");
-        ret = i2c_read_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
+        ret = gtp_i2c_read_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
         if (ret < 0)
         {
             GTP_ERROR("failed to read bak_ref info, sending default back-reference");
@@ -2368,7 +2368,7 @@ static s32 gtp_bak_ref_proc(struct goodix_ts_data *ts, u8 mode)
         memset(&p_bak_ref[j * ref_seg_len], 0, ref_seg_len);
         p_bak_ref[j * ref_seg_len + ref_seg_len - 1] = 0x01;  // checksum = 1     
     }
-    ret = i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
+    ret = gtp_i2c_write_bytes(ts->client, GTP_REG_BAK_REF, p_bak_ref, ts->bak_ref_len);
     if (!IS_ERR(ref_filp))
     {
         GTP_INFO("write backup-reference data into %s", GTP_BAK_REF_PATH);
@@ -2450,7 +2450,7 @@ static s32 gtp_main_clk_proc(struct goodix_ts_data *ts)
 		goto update_main_clk;
 	}
 	#else
-    ret = gup_check_fs_mounted("/data");
+    ret = gtp_gup_check_fs_mounted("/data");
     if (FAIL == ret)
     {
         ts->clk_chk_fs_times++;
@@ -2496,7 +2496,7 @@ static s32 gtp_main_clk_proc(struct goodix_ts_data *ts)
 #if GTP_ESD_PROTECT
     gtp_esd_switch(ts->client, SWITCH_OFF);
 #endif
-    ret = gup_clk_calibration();
+    ret = gtp_gup_clk_calibration();
     gtp_esd_recovery(ts->client);
     
 #if GTP_ESD_PROTECT
@@ -2527,7 +2527,7 @@ static s32 gtp_main_clk_proc(struct goodix_ts_data *ts)
     }
     
 update_main_clk:
-    ret = i2c_write_bytes(ts->client, GTP_REG_MAIN_CLK, p_main_clk, 6);
+    ret = gtp_i2c_write_bytes(ts->client, GTP_REG_MAIN_CLK, p_main_clk, 6);
     if (FAIL == ret)
     {
         GTP_ERROR("update main clock failed!");
@@ -2544,11 +2544,11 @@ static s32 gtp_main_clk_proc(struct goodix_ts_data *ts)
 }
 
 
-s32 gtp_gt9xxf_init(struct i2c_client *client)
+static s32 gtp_gt9xxf_init(struct i2c_client *client)
 {
     s32 ret = 0;
     
-    ret = gup_fw_download_proc(NULL, GTP_FL_FW_BURN); 
+    ret = gtp_gup_fw_download_proc(NULL, GTP_FL_FW_BURN); 
     if (FAIL == ret)
     {
         return FAIL;
@@ -2562,7 +2562,7 @@ s32 gtp_gt9xxf_init(struct i2c_client *client)
     return SUCCESS;
 }
 
-void gtp_get_chip_type(struct goodix_ts_data *ts)
+static void gtp_get_chip_type(struct goodix_ts_data *ts)
 {
     u8 opr_buf[10] = {0x00};
     s32 ret = 0;
@@ -2626,7 +2626,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
     GTP_INFO("GTP Driver Version: %s", GTP_DRIVER_VERSION);
     GTP_INFO("GTP I2C Address: 0x%02x", client->addr);
 
-    i2c_connect_client = client;
+    gtp_i2c_connect_client = client;
     
     if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 
     {
@@ -2670,8 +2670,8 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
 	} else if (val == 9110) {
 		m89or101 = FALSE;
 		bgt9110 = TRUE;
-		gtp_change_x2y = TRUE;
-		gtp_x_reverse = TRUE;
+		gtp_change_x2y = FALSE;
+		gtp_x_reverse = FALSE;
 		gtp_y_reverse = FALSE;
 	} else if (val == 9111) {
 		m89or101 = FALSE;
@@ -2804,6 +2804,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
     
     ts->irq_flags = ts->int_trigger_type ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
     // Create proc file system
+#if 0
 	gt91xx_config_proc = proc_create(GT91XX_CONFIG_PROC_FILE, 0664, NULL, &config_proc_ops);
     if (gt91xx_config_proc == NULL)
     {
@@ -2813,6 +2814,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
     {
         GTP_INFO("create proc entry %s success", GT91XX_CONFIG_PROC_FILE);
     }
+#endif
     
 #if GTP_AUTO_UPDATE
     ret = gup_init_update_proc(ts);
@@ -3061,7 +3063,7 @@ static void gtp_esd_check_func(struct work_struct *work)
     
     GTP_DEBUG_FUNC();
    
-    ts = i2c_get_clientdata(i2c_connect_client);
+    ts = i2c_get_clientdata(gtp_i2c_connect_client);
 
     if (ts->gtp_is_suspend)
     {
@@ -3233,3 +3235,4 @@ module_exit(goodix_ts_exit);
 
 MODULE_DESCRIPTION("GTP Series Driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.h b/drivers/input/touchscreen/gt9xx/gt9xx.h
index acc288575691..5f9ae184ddd1 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.h
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.h
@@ -154,8 +154,8 @@ struct goodix_ts_data {
     struct regulator *tp_regulator;
 };
 
-extern u16 show_len;
-extern u16 total_len;
+//extern u16 show_len;
+//extern u16 total_len;
 
 
 //*************************** PART2:TODO define **********************************
@@ -391,7 +391,22 @@ extern u16 total_len;
                                        }while (0)
 
 //*****************************End of Part III********************************
-#define TRUE    1
-#define FALSE   0
+//#define TRUE    1
+//#define FALSE   0
+
+extern struct i2c_client *gtp_i2c_connect_client;
+
+s32 gtp_fw_startup(struct i2c_client *client);
+s32 gtp_i2c_read_dbl_check(struct i2c_client *client, u16 addr, u8 *rxbuf, int len);
+void gtp_irq_disable(struct goodix_ts_data *ts);
+void gtp_irq_enable(struct goodix_ts_data *ts);
+s32 gtp_read_version(struct i2c_client *client, u16 *version);
+void gtp_reset_guitar(struct i2c_client *client, s32 ms);
+s32 gtp_send_cfg(struct i2c_client *client);
+u8 gtp_gup_check_fs_mounted(char *path_name);
+s32 gtp_gup_fw_download_proc(void *dir, u8 dwn_mode);
+s32 gtp_i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
+s32 gtp_i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len);
+s32 gtp_gup_clk_calibration(void);
 
 #endif /* _GOODIX_GT9XX_H_ */
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h b/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
index 2b083c5655f8..584da09e9025 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
+++ b/drivers/input/touchscreen/gt9xx/gt9xx_cfg.h
@@ -19,21 +19,21 @@
 #define _GOODIX_GT9XX_CFG_H_
 
 /* CFG for GT911 */
-u8 gtp_dat_gt11[] = {
+static u8 gtp_dat_gt11[] = {
 	/* <1200, 1920>*/
 	#include "WGJ89006B_GT911_Config_20140625_085816_0X43.cfg"
 };
 
-u8 gtp_dat_gt9110[] = {
+static u8 gtp_dat_gt9110[] = {
 	/* <1200, 1920>*/
 	#include "GT9110P(2020)V71_Config_20201028_170326.cfg"
 };
 
-u8 gtp_dat_gt9111[] = {
+static u8 gtp_dat_gt9111[] = {
 	#include "HLS-0102-1398V1-1060-GT911_Config_20201204_V66.cfg"
 };
 
-u8 gtp_dat_8_9[] = {
+static u8 gtp_dat_8_9[] = {
 	/* TODO:Puts your update firmware data here! */
 	/* <1920, 1200> 8.9 */
 	/* #include "WGJ89006B_GT9271_Config_20140625_085816_0X41.cfg" */
@@ -41,22 +41,22 @@ u8 gtp_dat_8_9[] = {
 	#include "WGJ10162B_GT9271_1060_Config_20140821_1341110X42.cfg"
 };
 
-u8 gtp_dat_8_9_1[] = {
+static u8 gtp_dat_8_9_1[] = {
 	#include "GT9271_Config_20170526.cfg"
 };
 
-u8 gtp_dat_9_7[] = {
+static u8 gtp_dat_9_7[] = {
 	/* <1536, 2048> 9.7 */
 	#include "GT9110P_Config_20160217_1526_2048_97.cfg"
 };
 
-u8 gtp_dat_10_1[] = {
+static u8 gtp_dat_10_1[] = {
 	/* TODO:Puts your update firmware data here! */
 	/* <1200, 1920> 10.1 */
 	#include "WGJ10187_GT9271_Config_20140623_104014_0X41.cfg"
 };
 
-u8 gtp_dat_7[] = {
+static u8 gtp_dat_7[] = {
 	/* TODO:Puts your update firmware data here! */
 	/* <1024, 600> 7.0 */
 	#include "WGJ10187_GT910_Config_20140623_104014_0X41.cfg"
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h b/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h
index 7dce6045b736..8fc22fdd4eee 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h
+++ b/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h
@@ -15,7 +15,7 @@
 #define _GT9XX_FIRMWARE_H_
 
 #if GTP_HEADER_FW_UPDATE
-unsigned char gtp_default_FW[] = {
+static unsigned char gtp_default_FW[] = {
 };
 #endif
 
@@ -26,7 +26,7 @@ unsigned char gtp_default_FW[] = {
  *[GENERATED]2014/01/20 17:37:45
  */
 #if GTP_COMPATIBLE_MODE
-unsigned char gtp_default_FW_fl[] = {
+static unsigned char gtp_default_FW_fl[] = {
 	0x00, 0x90, 0x06, 0x00, 0x39, 0x31, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x80, 0x00,
 	0x55, 0x40, 0xa4, 0x28, 0xb3, 0x26, 0x69, 0xf0, 0x0c, 0xc1, 0x00, 0x62, 0x72, 0xed, 0x88, 0x5c,
 	0x4f, 0x41, 0xf0, 0x90, 0x24, 0xbf, 0x32, 0xe0, 0x1d, 0xc9, 0xdf, 0xf2, 0x53, 0x73, 0x01, 0x20,
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx_update.c b/drivers/input/touchscreen/gt9xx/gt9xx_update.c
index 8affe60c7fae..5590f431ff5d 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx_update.c
+++ b/drivers/input/touchscreen/gt9xx/gt9xx_update.c
@@ -26,7 +26,7 @@
  *          3. add update file cal checksum.
  *                          By Andrew, 2012/12/12
  *      V1.6: 
- *          1. replace guitar_client with i2c_connect_client;
+ *          1. replace guitar_client with gtp_i2c_connect_client;
  *          2. support firmware header array update.
  *                          By Meta, 2013/03/11
  *      V2.2:
@@ -106,21 +106,21 @@ typedef struct
     u32 fw_burned_len;
 }st_update_msg;
 
-st_update_msg update_msg;
-u16 show_len;
-u16 total_len;
-u8 got_file_flag = 0;  
-u8 searching_file = 0;
-
-extern u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH];
-extern void gtp_reset_guitar(struct i2c_client *client, s32 ms);
-extern s32  gtp_send_cfg(struct i2c_client *client);
-extern s32 gtp_read_version(struct i2c_client *, u16* );
-extern struct i2c_client * i2c_connect_client;
-extern void gtp_irq_enable(struct goodix_ts_data *ts);
-extern void gtp_irq_disable(struct goodix_ts_data *ts);
-extern s32 gtp_i2c_read_dbl_check(struct i2c_client *, u16, u8 *, int);
-static u8 gup_burn_fw_gwake_section(struct i2c_client *client, u8 *fw_section, u16 start_addr, u32 len, u8 bank_cmd );
+static st_update_msg update_msg;
+static u16 show_len;
+static u16 total_len;
+//static u8 got_file_flag = 0;  
+static u8 searching_file = 0;
+
+//extern u8 config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH];
+//extern void gtp_reset_guitar(struct i2c_client *client, s32 ms);
+//extern s32  gtp_send_cfg(struct i2c_client *client);
+//extern s32 gtp_read_version(struct i2c_client *, u16* );
+//extern struct i2c_client * gtp_i2c_connect_client;
+//extern void gtp_irq_enable(struct goodix_ts_data *ts);
+//extern void gtp_irq_disable(struct goodix_ts_data *ts);
+//extern s32 gtp_i2c_read_dbl_check(struct i2c_client *, u16, u8 *, int);
+//static u8 gup_burn_fw_gwake_section(struct i2c_client *client, u8 *fw_section, u16 start_addr, u32 len, u8 bank_cmd );
 
 #define _CLOSE_FILE(p_file) if (p_file && !IS_ERR(p_file)) \
                             { \
@@ -132,7 +132,7 @@ extern void gtp_esd_switch(struct i2c_client *, s32);
 #endif
 
 #if GTP_COMPATIBLE_MODE
-s32 gup_fw_download_proc(void *dir, u8 dwn_mode);
+s32 gtp_gup_fw_download_proc(void *dir, u8 dwn_mode);
 #endif
 /*******************************************************
 Function:
@@ -146,7 +146,7 @@ s32 gup_fw_download_proc(void *dir, u8 dwn_mode);
     numbers of i2c_msgs to transfer: 
       2: succeed, otherwise: failed
 *********************************************************/
-s32 gup_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
+static s32 gup_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
 {
     struct i2c_msg msgs[2];
     s32 ret=-1;
@@ -192,7 +192,7 @@ s32 gup_i2c_read(struct i2c_client *client, u8 *buf, s32 len)
     numbers of i2c_msgs to transfer: 
         1: succeed, otherwise: failed
 *********************************************************/
-s32 gup_i2c_write(struct i2c_client *client,u8 *buf,s32 len)
+static s32 gup_i2c_write(struct i2c_client *client,u8 *buf,s32 len)
 {
     struct i2c_msg msg;
     s32 ret=-1;
@@ -218,6 +218,7 @@ s32 gup_i2c_write(struct i2c_client *client,u8 *buf,s32 len)
     return ret;
 }
 
+#if 0
 static s32 gup_init_panel(struct goodix_ts_data *ts)
 {
     s32 ret = 0;
@@ -329,6 +330,7 @@ static s32 gup_init_panel(struct goodix_ts_data *ts)
     msleep(10);
     return 0;
 }
+#endif
 
 
 static u8 gup_get_ic_msg(struct i2c_client *client, u16 addr, u8* msg, s32 len)
@@ -381,6 +383,7 @@ static u8 gup_set_ic_msg(struct i2c_client *client, u16 addr, u8 val)
     return SUCCESS;
 }
 
+#if 0
 static u8 gup_get_ic_fw_msg(struct i2c_client *client)
 {
     s32 ret = -1;
@@ -462,7 +465,7 @@ static u8 gup_get_ic_fw_msg(struct i2c_client *client)
     return SUCCESS;
 }
 
-s32 gup_enter_update_mode(struct i2c_client *client)
+static s32 gup_enter_update_mode(struct i2c_client *client)
 {
     s32 ret = -1;
     s32 retry = 0;
@@ -519,14 +522,14 @@ s32 gup_enter_update_mode(struct i2c_client *client)
     return ret;
 }
 
-void gup_leave_update_mode(struct goodix_ts_data *ts)
+static void gup_leave_update_mode(struct goodix_ts_data *ts)
 {
     gpio_direction_input(ts->irq_pin);
     //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE);
     //s3c_gpio_cfgpin(pin, GTP_INT_CFG);
     
     GTP_DEBUG("[leave_update_mode]reset chip.");
-    gtp_reset_guitar(i2c_connect_client, 20);
+    gtp_reset_guitar(gtp_i2c_connect_client, 20);
 }
 
 // Get the correct nvram data
@@ -646,6 +649,7 @@ static u8 gup_enter_update_judge(st_fw_head *fw_head)
 
     return FAIL;
 }
+#endif
 
 
 
@@ -869,6 +873,7 @@ static void gup_search_file(s32 search_type)
 #endif
 
 
+#if 0
 static u8 gup_check_update_file(struct i2c_client *client, st_fw_head* fw_head, u8* path)
 {
     s32 ret = 0;
@@ -924,7 +929,7 @@ static u8 gup_check_update_file(struct i2c_client *client, st_fw_head* fw_head,
         gup_search_file(AUTO_SEARCH_BIN | AUTO_SEARCH_CFG);
         if (got_file_flag & CFG_FILE_READY)
         {
-            ret = gup_update_config(i2c_connect_client);
+            ret = gup_update_config(gtp_i2c_connect_client);
             if(ret <= 0)
             {
                 GTP_ERROR("Update config failed.");
@@ -2271,7 +2276,7 @@ static u8 gup_burn_fw_finish(struct i2c_client *client)
     }
     return FAIL;
 }
-s32 gup_update_proc(void *dir)
+static s32 gup_update_proc(void *dir)
 {
     s32 ret = 0;
     s32 update_ret = FAIL;
@@ -2281,7 +2286,7 @@ s32 gup_update_proc(void *dir)
     
     GTP_DEBUG("[update_proc]Begin update ......");
     
-    ts = i2c_get_clientdata(i2c_connect_client);
+    ts = i2c_get_clientdata(gtp_i2c_connect_client);
     
 #if GTP_AUTO_UPDATE
     if (searching_file)
@@ -2302,19 +2307,19 @@ s32 gup_update_proc(void *dir)
 #if GTP_COMPATIBLE_MODE
     if (CHIP_TYPE_GT9F == ts->chip_type)
     {
-        return gup_fw_download_proc(dir, GTP_FL_FW_BURN);
+        return gtp_gup_fw_download_proc(dir, GTP_FL_FW_BURN);
     }
 #endif
 
     update_msg.file = NULL;
-    ret = gup_check_update_file(i2c_connect_client, &fw_head, (u8*)dir);     //20121211
+    ret = gup_check_update_file(gtp_i2c_connect_client, &fw_head, (u8*)dir);     //20121211
     if(FAIL == ret)
     {
         GTP_ERROR("[update_proc]check update file fail.");
         goto file_fail;
     }
     
-    ret = gup_get_ic_fw_msg(i2c_connect_client);
+    ret = gup_get_ic_fw_msg(gtp_i2c_connect_client);
     if(FAIL == ret)
     {
         GTP_ERROR("[update_proc]get ic message fail.");
@@ -2333,7 +2338,7 @@ s32 gup_update_proc(void *dir)
 #if GTP_ESD_PROTECT
     gtp_esd_switch(ts->client, SWITCH_OFF);
 #endif
-    ret = gup_enter_update_mode(i2c_connect_client);
+    ret = gup_enter_update_mode(gtp_i2c_connect_client);
     if(FAIL == ret)
     {
          GTP_ERROR("[update_proc]enter update mode fail.");
@@ -2345,7 +2350,7 @@ s32 gup_update_proc(void *dir)
         show_len = 10;
         total_len = 100;
         update_msg.fw_burned_len = 0;
-        ret = gup_burn_dsp_isp(i2c_connect_client);
+        ret = gup_burn_dsp_isp(gtp_i2c_connect_client);
         if(FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn dsp isp fail.");
@@ -2353,7 +2358,7 @@ s32 gup_update_proc(void *dir)
         }
         
         show_len = 20;
-        ret = gup_burn_fw_ss51(i2c_connect_client);
+        ret = gup_burn_fw_ss51(gtp_i2c_connect_client);
         if(FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn ss51 firmware fail.");
@@ -2361,7 +2366,7 @@ s32 gup_update_proc(void *dir)
         }
         
         show_len = 30;
-        ret = gup_burn_fw_dsp(i2c_connect_client);
+        ret = gup_burn_fw_dsp(gtp_i2c_connect_client);
         if(FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn dsp firmware fail.");
@@ -2369,7 +2374,7 @@ s32 gup_update_proc(void *dir)
         }
         
         show_len = 40;
-        ret = gup_burn_fw_boot(i2c_connect_client);
+        ret = gup_burn_fw_boot(gtp_i2c_connect_client);
         if(FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn bootloader firmware fail.");
@@ -2377,7 +2382,7 @@ s32 gup_update_proc(void *dir)
         }
         show_len = 50;
         
-        ret = gup_burn_fw_boot_isp(i2c_connect_client);
+        ret = gup_burn_fw_boot_isp(gtp_i2c_connect_client);
         if (FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn boot_isp firmware fail.");
@@ -2385,7 +2390,7 @@ s32 gup_update_proc(void *dir)
         }
         
         show_len = 60;
-        ret = gup_burn_fw_link(i2c_connect_client);
+        ret = gup_burn_fw_link(gtp_i2c_connect_client);
         if (FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn link firmware fail.");
@@ -2393,7 +2398,7 @@ s32 gup_update_proc(void *dir)
         }
         
         show_len = 70;
-        ret = gup_burn_fw_gwake(i2c_connect_client);
+        ret = gup_burn_fw_gwake(gtp_i2c_connect_client);
         if (FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn app_code firmware fail.");
@@ -2401,7 +2406,7 @@ s32 gup_update_proc(void *dir)
         }       
         show_len = 80;
         
-        ret = gup_burn_fw_finish(i2c_connect_client);
+        ret = gup_burn_fw_finish(gtp_i2c_connect_client);
         if (FAIL == ret)
         {
             GTP_ERROR("[update_proc]burn finish fail.");
@@ -2439,7 +2444,7 @@ s32 gup_update_proc(void *dir)
         else
         {
             GTP_DEBUG("[update_proc]send config.");
-            ret = gtp_send_cfg(i2c_connect_client);
+            ret = gtp_send_cfg(gtp_i2c_connect_client);
             if (ret < 0)
             {
                 GTP_ERROR("[update_proc]send config fail.");
@@ -2472,7 +2477,7 @@ s32 gup_update_proc(void *dir)
         gup_search_file(AUTO_SEARCH_CFG);
         if (got_file_flag & CFG_FILE_READY)
         {
-            ret = gup_update_config(i2c_connect_client);
+            ret = gup_update_config(gtp_i2c_connect_client);
             if(ret <= 0)
             {
                 GTP_ERROR("Update config failed.");
@@ -2495,6 +2500,7 @@ s32 gup_update_proc(void *dir)
         return FAIL;
     }
 }
+#endif
 
 #if GTP_AUTO_UPDATE
 u8 gup_init_update_proc(struct goodix_ts_data *ts)
@@ -2570,16 +2576,16 @@ u8 gup_init_update_proc(struct goodix_ts_data *ts)
 
 #if GTP_COMPATIBLE_MODE
 
-u8 i2c_opr_buf[GTP_ADDR_LENGTH + FL_PACK_SIZE] = {0};
-u8 chk_cmp_buf[FL_PACK_SIZE] = {0};
+static u8 i2c_opr_buf[GTP_ADDR_LENGTH + FL_PACK_SIZE] = {0};
+static u8 chk_cmp_buf[FL_PACK_SIZE] = {0};
 
-extern s32 gtp_fw_startup(struct i2c_client *client);
+//extern s32 gtp_fw_startup(struct i2c_client *client);
 static u8 gup_download_fw_dsp(struct i2c_client *client, u8 dwn_mode);
 static s32 gup_burn_fw_proc(struct i2c_client *client, u16 start_addr, s32 start_index, s32 burn_len);
 static s32 gup_check_and_repair(struct i2c_client *client, u16 start_addr, s32 start_index, s32 chk_len);
 
 
-u8 gup_check_fs_mounted(char *path_name)
+u8 gtp_gup_check_fs_mounted(char *path_name)
 {
     struct path root_path;
     struct path path;
@@ -2617,7 +2623,7 @@ u8 gup_check_fs_mounted(char *path_name)
 #endif
 }
 
-s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
+s32 gtp_i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
 {
     s32 ret = 0;
     s32 write_bytes = 0;
@@ -2658,7 +2664,7 @@ s32 i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
     return 1;
 }
 
-s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
+s32 gtp_i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
 {
     s32 ret = 0;
     s32 read_bytes = 0;
@@ -2705,11 +2711,11 @@ s32 i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *buf, s32 len)
 static void gup_bit_write(s32 addr, s32 bit, s32 val)
 {
     u8 buf;
-    i2c_read_bytes(i2c_connect_client, addr, &buf, 1);
+    gtp_i2c_read_bytes(gtp_i2c_connect_client, addr, &buf, 1);
 
     buf = (buf & (~((u8)1 << bit))) | ((u8)val << bit);
 
-    i2c_write_bytes(i2c_connect_client, addr, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, addr, &buf, 1);
 }
 
 static void gup_clk_count_init(s32 bCh, s32 bCNT)
@@ -2722,13 +2728,13 @@ static void gup_clk_count_init(s32 bCh, s32 bCNT)
     gup_bit_write(_fRW_MISCTL__MEA, 1, 1);
     //_bRW_MISCTL__MEA_MODE = 0; //Pulse mode
     buf = 0;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__MEA_MODE, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__MEA_MODE, &buf, 1);
     //_bRW_MISCTL__MEA_SRCSEL = 8 + bCh; //From GIO1
     buf = 8 + bCh;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__MEA_SRCSEL, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__MEA_SRCSEL, &buf, 1);
     //_wRW_MISCTL__MEA_MAX_NUM = bCNT; //Set the Measure Counts = 1
     buf = bCNT;
-    i2c_write_bytes(i2c_connect_client, _wRW_MISCTL__MEA_MAX_NUM, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _wRW_MISCTL__MEA_MAX_NUM, &buf, 1);
     //_fRW_MISCTL__MEA_CLR = 0; //Frequency measure not clear
     gup_bit_write(_fRW_MISCTL__MEA, 1, 0);
     //_fRW_MISCTL__MEA_EN = 1;
@@ -2743,7 +2749,7 @@ static u32 gup_clk_count_get(void)
 
     while (ready == 0) //Wait for measurement complete
     {
-        i2c_read_bytes(i2c_connect_client, _bRO_MISCTL__MEA_RDY, buf, 1);
+        gtp_i2c_read_bytes(gtp_i2c_connect_client, _bRO_MISCTL__MEA_RDY, buf, 1);
         ready = buf[0];
     }
 
@@ -2751,7 +2757,7 @@ static u32 gup_clk_count_get(void)
 
     //_fRW_MISCTL__MEA_EN = 0;
     gup_bit_write(_fRW_MISCTL__MEA, 0, 0);
-    i2c_read_bytes(i2c_connect_client, _dRO_MISCTL__MEA_VAL, buf, 4);
+    gtp_i2c_read_bytes(gtp_i2c_connect_client, _dRO_MISCTL__MEA_VAL, buf, 4);
     GTP_DEBUG("Clk_count 0: %2X", buf[0]);
     GTP_DEBUG("Clk_count 1: %2X", buf[1]);
     GTP_DEBUG("Clk_count 2: %2X", buf[2]);
@@ -2761,23 +2767,23 @@ static u32 gup_clk_count_get(void)
     GTP_INFO("Clk_count : %d", temp);
     return temp;
 }
-u8 gup_clk_dac_setting(int dac)
+static u8 gup_clk_dac_setting(int dac)
 {
     s8 buf1, buf2;
     
-    i2c_read_bytes(i2c_connect_client, _wRW_MISCTL__RG_DMY, &buf1, 1);
-    i2c_read_bytes(i2c_connect_client, _bRW_MISCTL__RG_OSC_CALIB, &buf2, 1);
+    gtp_i2c_read_bytes(gtp_i2c_connect_client, _wRW_MISCTL__RG_DMY, &buf1, 1);
+    gtp_i2c_read_bytes(gtp_i2c_connect_client, _bRW_MISCTL__RG_OSC_CALIB, &buf2, 1);
 
     buf1 = (buf1 & 0xFFCF) | ((dac & 0x03) << 4);
     buf2 = (dac >> 2) & 0x3f;
 
-    i2c_write_bytes(i2c_connect_client, _wRW_MISCTL__RG_DMY, &buf1, 1);
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__RG_OSC_CALIB, &buf2, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _wRW_MISCTL__RG_DMY, &buf1, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__RG_OSC_CALIB, &buf2, 1);
     
     return 0;
 }
 
-static u8 gup_clk_calibration_pin_select(s32 bCh)
+static u8 gtp_gup_clk_calibration_pin_select(s32 bCh)
 {
     s32 i2c_addr;
 
@@ -2822,6 +2828,9 @@ static u8 gup_clk_calibration_pin_select(s32 bCh)
         case 9:
             i2c_addr = _fRW_MISCTL__GIO9;
             break;
+
+        default:
+            return -1;
     }
 
     gup_bit_write(i2c_addr, 1, 0);
@@ -2829,12 +2838,12 @@ static u8 gup_clk_calibration_pin_select(s32 bCh)
     return 0;
 }
 
-void gup_output_pulse(int t)
+static void gup_output_pulse(int t)
 {
 	unsigned long flags;
 	struct goodix_ts_data *ts;
 
-	ts = i2c_get_clientdata(i2c_connect_client);
+	ts = i2c_get_clientdata(gtp_i2c_connect_client);
 
 	GTP_GPIO_OUTPUT(ts->irq_pin, 0);
 	msleep(10);
@@ -2861,13 +2870,13 @@ static void gup_sys_clk_init(void)
     gup_bit_write(_rRW_MISCTL__ANA_RXADC_B0_, 5, 0);
     //_bRW_MISCTL__RG_LDO_A18_PWD = 0; //DrvMISCTL_A18_PowerON
     buf = 0;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__RG_LDO_A18_PWD, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__RG_LDO_A18_PWD, &buf, 1);
     //_bRW_MISCTL__RG_BG_PWD = 0; //DrvMISCTL_BG_PowerON
     buf = 0;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__RG_BG_PWD, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__RG_BG_PWD, &buf, 1);
     //_bRW_MISCTL__RG_CLKGEN_PWD = 0; //DrvMISCTL_CLKGEN_PowerON
     buf = 0;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__RG_CLKGEN_PWD, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__RG_CLKGEN_PWD, &buf, 1);
     //_fRW_MISCTL__RG_RXADC_PWD = 0; //DrvMISCTL_RX_ADC_PowerON
     gup_bit_write(_rRW_MISCTL__ANA_RXADC_B0_, 0, 0);
     //_fRW_MISCTL__RG_RXADC_REF_PWD = 0; //DrvMISCTL_RX_ADCREF_PowerON
@@ -2875,26 +2884,26 @@ static void gup_sys_clk_init(void)
     //gup_clk_dac_setting(60);
     //_bRW_MISCTL__OSC_CK_SEL = 1;;
     buf = 1;
-    i2c_write_bytes(i2c_connect_client, _bRW_MISCTL__OSC_CK_SEL, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _bRW_MISCTL__OSC_CK_SEL, &buf, 1);
 }
 
-s32 gup_clk_calibration(void)
+s32 gtp_gup_clk_calibration(void)
 {
     u8 buf;
     //u8 trigger;
     s32 i;
-    struct timeval start, end;
+    //struct timeval start, end;
     s32 count;
-    s32 count_ref;
-    s32 sec;
-    s32 usec;
+    //s32 count_ref;
+    //s32 sec;
+    //s32 usec;
     //unsigned long flags;
     struct goodix_ts_data *ts;
 
-	ts = i2c_get_clientdata(i2c_connect_client);
+	ts = i2c_get_clientdata(gtp_i2c_connect_client);
 
     buf = 0x0C; // hold ss51 and dsp
-    i2c_write_bytes(i2c_connect_client, _rRW_MISCTL__SWRST_B0_, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, _rRW_MISCTL__SWRST_B0_, &buf, 1);
 
     //_fRW_MISCTL__CLK_BIAS = 0; //disable clock bias
     gup_bit_write(_rRW_MISCTL_RG_DMY83, 7, 0);
@@ -2906,12 +2915,12 @@ s32 gup_clk_calibration(void)
     gup_bit_write(_rRW_MISCTL__GIO1CTL_B1_, 1, 0);
 
     //buf = 0x00;
-    //i2c_write_bytes(i2c_connect_client, _rRW_MISCTL__SWRST_B0_, &buf, 1);
+    //gtp_i2c_write_bytes(gtp_i2c_connect_client, _rRW_MISCTL__SWRST_B0_, &buf, 1);
     //msleep(1000);
 
     GTP_INFO("CLK calibration GO");
     gup_sys_clk_init();
-    gup_clk_calibration_pin_select(1);//use GIO1 to do the calibration
+    gtp_gup_clk_calibration_pin_select(1);//use GIO1 to do the calibration
 
 	GTP_GPIO_OUTPUT(ts->irq_pin, 0);
  
@@ -2928,7 +2937,7 @@ s32 gup_clk_calibration(void)
         gup_clk_dac_setting(i);
         gup_clk_count_init(1, CLK_AVG_TIME);
 
-    #if 0
+    #if 1
         gup_output_pulse(PULSE_LENGTH);
         count = gup_clk_count_get();
   
@@ -2975,24 +2984,24 @@ s32 gup_clk_calibration(void)
 
     //clk_dac = i;
 
-    gtp_reset_guitar(i2c_connect_client, 20);
+    gtp_reset_guitar(gtp_i2c_connect_client, 20);
 
 #if 0//for debug
     //-- ouput clk to GPIO 4
     buf = 0x00;
-    i2c_write_bytes(i2c_connect_client, 0x41FA, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x41FA, &buf, 1);
     buf = 0x00;
-    i2c_write_bytes(i2c_connect_client, 0x4104, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x4104, &buf, 1);
     buf = 0x00;
-    i2c_write_bytes(i2c_connect_client, 0x4105, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x4105, &buf, 1);
     buf = 0x00;
-    i2c_write_bytes(i2c_connect_client, 0x4106, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x4106, &buf, 1);
     buf = 0x01;
-    i2c_write_bytes(i2c_connect_client, 0x4107, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x4107, &buf, 1);
     buf = 0x06;
-    i2c_write_bytes(i2c_connect_client, 0x41F8, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x41F8, &buf, 1);
     buf = 0x02;
-    i2c_write_bytes(i2c_connect_client, 0x41F9, &buf, 1);
+    gtp_i2c_write_bytes(gtp_i2c_connect_client, 0x41F9, &buf, 1);
 #endif
 
 	/*GTP_GPIO_AS_INT(ts->irq_pin);*/
@@ -3002,7 +3011,7 @@ s32 gup_clk_calibration(void)
 
 
 
-s32 gup_hold_ss51_dsp(struct i2c_client *client)
+static s32 gup_hold_ss51_dsp(struct i2c_client *client)
 {
     s32 ret = -1;
     s32 retry = 0;
@@ -3083,7 +3092,7 @@ s32 gup_hold_ss51_dsp(struct i2c_client *client)
     return SUCCESS;
 }
 
-s32 gup_enter_update_mode_fl(struct i2c_client *client)
+static s32 gup_enter_update_mode_fl(struct i2c_client *client)
 {
     s32 ret = -1;
     //s32 retry = 0;
@@ -3215,7 +3224,7 @@ static s32 gup_burn_fw_proc(struct i2c_client *client, u16 start_addr, s32 start
     
     GTP_DEBUG("burn firmware: 0x%04X, %d bytes, start_index: 0x%04X", start_addr, burn_len, start_index);
     
-    ret = i2c_write_bytes(client, start_addr, (u8*)&gtp_default_FW_fl[FW_HEAD_LENGTH + start_index], burn_len);
+    ret = gtp_i2c_write_bytes(client, start_addr, (u8*)&gtp_default_FW_fl[FW_HEAD_LENGTH + start_index], burn_len);
     if (ret < 0)
     {
         GTP_ERROR("burn 0x%04X, %d bytes failed!", start_addr, burn_len);
@@ -3248,7 +3257,7 @@ static s32 gup_check_and_repair(struct i2c_client *client, u16 start_addr, s32 s
 			GTP_ERROR("Check failed, buffer overflow\n");
 			break;
 		}
-        ret = i2c_read_bytes(client, cmp_addr, chk_cmp_buf, cmp_len);
+        ret = gtp_i2c_read_bytes(client, cmp_addr, chk_cmp_buf, cmp_len);
         if (ret < 0)
         {
             chk_fail = 1;
@@ -3259,7 +3268,7 @@ static s32 gup_check_and_repair(struct i2c_client *client, u16 start_addr, s32 s
             if (chk_cmp_buf[i] != gtp_default_FW_fl[FW_HEAD_LENGTH + start_index +i])
             {
                 chk_fail = 1;
-                i2c_write_bytes(client, cmp_addr+i, &gtp_default_FW_fl[FW_HEAD_LENGTH + start_index + i], cmp_len-i);
+                gtp_i2c_write_bytes(client, cmp_addr+i, &gtp_default_FW_fl[FW_HEAD_LENGTH + start_index + i], cmp_len-i);
                 GTP_ERROR("Check failed index: %d(%d != %d), redownload chuck", i, chk_cmp_buf[i], 
                         gtp_default_FW_fl[FW_HEAD_LENGTH + start_index +i]);
                 break;
@@ -3373,7 +3382,7 @@ static s32 gup_prepare_fl_fw(char *path, st_fw_head *fw_head)
     s32 ret = 0;
     s32 i = 0;
     s32 timeout = 0;
-    struct goodix_ts_data *ts = i2c_get_clientdata(i2c_connect_client);
+    struct goodix_ts_data *ts = i2c_get_clientdata(gtp_i2c_connect_client);
     
     if (!memcmp(path, "update", 6))
     {
@@ -3512,14 +3521,14 @@ static u8 gup_check_update_file_fl(struct i2c_client *client, st_fw_head* fw_hea
     return ret;
 }
 
-s32 gup_fw_download_proc(void *dir, u8 dwn_mode)
+s32 gtp_gup_fw_download_proc(void *dir, u8 dwn_mode)
 {
     s32 ret = 0;
     u8  retry = 0;
     st_fw_head fw_head;
     struct goodix_ts_data *ts;
     
-    ts = i2c_get_clientdata(i2c_connect_client);
+    ts = i2c_get_clientdata(gtp_i2c_connect_client);
     if (NULL == dir)
     {
         if(GTP_FL_FW_BURN == dwn_mode)       // GT9XXF firmware burn mode
@@ -3543,7 +3552,7 @@ s32 gup_fw_download_proc(void *dir, u8 dwn_mode)
     total_len = 100;
     show_len = 0;
     
-    ret = gup_check_update_file_fl(i2c_connect_client, &fw_head, (char *)dir);
+    ret = gup_check_update_file_fl(gtp_i2c_connect_client, &fw_head, (char *)dir);
     show_len = 10;
     
     if (FAIL == ret)
@@ -3570,7 +3579,7 @@ s32 gup_fw_download_proc(void *dir, u8 dwn_mode)
 #endif
     }
     
-    ret = gup_enter_update_mode_fl(i2c_connect_client);
+    ret = gup_enter_update_mode_fl(gtp_i2c_connect_client);
     show_len = 20;
     if (FAIL == ret)
     {
@@ -3580,7 +3589,7 @@ s32 gup_fw_download_proc(void *dir, u8 dwn_mode)
 
     while (retry++ < 5)
     {
-        ret = gup_download_fw_ss51(i2c_connect_client, dwn_mode);
+        ret = gup_download_fw_ss51(gtp_i2c_connect_client, dwn_mode);
         show_len = 60;
         if (FAIL == ret)
         {
@@ -3588,7 +3597,7 @@ s32 gup_fw_download_proc(void *dir, u8 dwn_mode)
             continue;
         }
 
-        ret = gup_download_fw_dsp(i2c_connect_client, dwn_mode);
+        ret = gup_download_fw_dsp(gtp_i2c_connect_client, dwn_mode);
         show_len = 80;
         if (FAIL == ret)
         {
-- 
2.20.1

关于如何打开gt9xx的编译,参考补丁开头对Makefile和Kconfig文件的修改

找到内核的defconfig文件,打开GT9XX的编译

CONFIG_TOUCHSCREEN_GT9XX=y

cfg文件的读取在gt9xx_cfg.h内,将cfg文件放到同级目录下,注意cfg命名

关于cfg文件,要找屏幕厂家获取

/* CFG for GT911 */ 
static u8 gtp_dat_gt11[] = { 
    /*1280 800 */ 
    #include "GT911_Config_20190119_v800x1280.cfg" 
};

编译烧录到板子上测试,如果发现坐标有误,可以使用evtest进行坐标调试,选择2

# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      fe6e0030.pwm
/dev/input/event1:      rk805 pwrkey
/dev/input/event2:      goodix-ts
/dev/input/event3:      rockchip-rk809 Headset
/dev/input/event4:      hdmi_cec_key
Select the device event number [0-4]:

点击屏幕会打印点击处的x,y坐标,可以通过修改驱动进行调节

TP的x、y坐标翻转修改下面的参数,例如此时发现x坐标与手的点击恰好相反,则将gtp_x_reverse 改为FALSE,如果在设备树里定义的max-x与max-y和分辨率对应有问题,则修改gtp_change_x2y

else if (val == 911) {
		m89or101 = FALSE;
		bgt911 = TRUE;
		gtp_change_x2y = TRUE;
		gtp_x_reverse = TRUE;
		gtp_y_reverse = TRUE;

修改后发现不生效,找到判断语句,注释掉if判断,测试修改生效

	//if (!bgt911 && !bgt970) {
		if (gtp_x_reverse)
			x = ts->abs_x_max - x;

		if (gtp_y_reverse)
			y = ts->abs_y_max - y;
	//}

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值