linux下GT911触摸屏驱动优化记录
背景
由于最近要做linux内核启动速度优化,所以就对着驱动一点一点优化,加上QT应用程序的初始化,总共的启动时间要做到4S以内。目前先调试GT911驱动程序。
平台
- 芯片:全志A33
- 内核:linux-3.4
- 优化驱动:GT911
优化步骤
原始驱动加载信息
[ 47.327870] ***CTP***GTP driver init
[ 47.335887] =====ctp_fetch_sysconfig_para=====.
[ 47.353187] ctp_fetch_sysconfig_para: ctp_power_io script_get_item err.
[ 47.365240] ctp_irq gpio number is 37
[ 47.371302] axp22_ldoio1: Failed to create debugfs directory
[ 47.370921] CPU1: Booted secondary processor
[ 47.383971] ***CTP***GTP driver gesture wakeup is used!
[ 47.410038] ***CTP***info.ctp_used:1
[ 47.414094] ***CTP***info.twi_id:0
[ 47.418038] ***CTP***info.screen_max_x:1024
[ 47.422781] ***CTP***info.screen_max_y:600
[ 47.427413] ***CTP***info.revert_x_flag:0
[ 47.432053] ***CTP***info.revert_y_flag:0
[ 47.436591] ***CTP***info.exchange_x_y_flag:0
[ 47.441606] ***CTP***info.irq_gpio_number:37
[ 47.446430] ***CTP***info.wakeup_gpio_number:360
[ 47.451661] ***CTP******CTP*** ctp_wakeup:status:0,ms = 0
[ 47.520025] ***CTP******CTP*** ctp_wakeup:status:1,ms = 0
[ 47.620873] the adapter number is 0
[ 47.625075] ctp_detect: addr = 5d
[ 47.629115] detect ret 2
[ 47.632780] ======detect ok !=====
[ 47.638369] ***CTP***GTP Driver Version: V2.2<2014/01/14>***CTP***GTP Driver Built@09:35:50, Dec 31 2019***CTP***GTP I2C Address: 0x5d<<-GTP-INFO->> IC Version: 911_1060
[ 47.659088] ***CTP***Config Groups Lengths: 186, 186, 186, 186, 186, 186, 186
[ 47.668453] ***CTP***CTP name : gt911_1024x600
[ 47.675321] ***CTP***gt9xx:sensor_id = 6
[ 47.679800] ***CTP***Sensor_ID: 6***CTP***CTP_CONFIG_GROUP7 used, config length: 186
[ 47.689203] ***CTP***CFG_GROUP7 Config Version: 66, 0x42; IC Config Version: 65, 0x41
[ 47.698040] <<-GTP-INFO->> Driver send config.
[ 47.709369] <<-GTP-INFO->> X_MAX: 1024, Y_MAX: 600, TRIGGER: 0x00
[ 47.730077] <<-GTP-INFO->> create proc entry gt9xx_config success
[ 47.737015] <<-GTP-INFO->> Ready to run update thread.
[ 47.743022] <<-GTP-INFO->> Update by default firmware array
[ 47.751617] <<-GTP-INFO->> GTP works in interrupt mode.
[ 47.757607] <<-GTP-INFO->> Applied memory size:2562.
[ 47.763463] <<-GTP-INFO->> I2C function: without pre and end cmd!
[ 47.770612] <<-GTP-INFO->> Create proc entry success!
[ 47.776678] the adapter number is 1
[ 47.782579] <<-GTP-INFO->> FILE HARDWARE INFO:00016000
[ 47.780962] CPU2: Booted secondary processor
[ 47.793334] <<-GTP-INFO->> FILE PID:9271
[ 47.797777] <<-GTP-INFO->> FILE VID:1040
[ 47.802322] <<-GTP-INFO->> IC HARDWARE INFO:00900600
[ 47.807920] <<-GTP-INFO->> IC PID:911
[ 47.812081] <<-GTP-INFO->> IC VID:1060
[ 47.816416] <<-GTP-INFO->> Firmware length:90112(88K)
[ 47.822130] <<-GTP-ERROR->> File PID != Ic PID, update aborted!
[ 47.828871] <<-GTP-ERROR->> [update_proc]Check *.bin file fail.
由上图可以得知整个驱动的加载时间等于:47.8288-47.3278 = 500ms
对于一个tp驱动来说,一个初始化代码居然要500ms,不能忍。这个驱动是有很大的优化空间的,目标是第一阶段先优化到100ms以内。具体的操作步骤如下:
1、关闭自动更新(-200ms)
2、优化tp的上电复位时序(-100ms)
3、屏蔽多余的打印信息(-100ms)
更改记录
-------------------------- drivers/input/init-input.c --------------------------
index edfc4e1..0355baa 100755
@@ -37,7 +37,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)struct ctp_config_info *data = container_of(ctp_type,struct ctp_config_info, input_type);- pr_info("=====%s=====. \n", __func__);
+// pr_info("=====%s=====. \n", __func__);type = script_get_item("ctp_para", "ctp_used", &val);if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
@@ -79,7 +79,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)data->ctp_power_vol = val.val;type = script_get_item("ctp_para", "ctp_power_io", &val);if(SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
- pr_err("%s: ctp_power_io script_get_item err. \n",__func__ );
+// pr_err("%s: ctp_power_io script_get_item err. \n",__func__ );}elsedata->ctp_power_io = val.gpio;
@@ -136,7 +136,7 @@ static int ctp_fetch_sysconfig_para(enum input_sensor_type *ctp_type)}data->irq_gpio = val.gpio;data->int_number = val.gpio.gpio;
- pr_err("ctp_irq gpio number is %d\n", data->int_number);
+// pr_err("ctp_irq gpio number is %d\n", data->int_number);#ifdef TOUCH_KEY_LIGHT_SUPPORT type = script_get_item("ctp_para", "ctp_light", &val);------------------ drivers/input/touchscreen/gt9xxnew/gt9xx.c ------------------
index 0a16c94..dbb317b 100755
@@ -170,8 +170,9 @@ enum{DEBUG_WAKEUP_INFO = 1U << 5,DEBUG_OTHERS_INFO = 1U << 6,};
-#define dprintk(level_mask,fmt,arg...) if(unlikely(debug_mask & level_mask)) \
- printk("***CTP***"fmt, ## arg)
+#define dprintk(level_mask,fmt,arg...)
+//#define dprintk(level_mask,fmt,arg...) if(unlikely(debug_mask & level_mask)) \
+// printk("***CTP***"fmt, ## arg)module_param_named(debug_mask,debug_mask,int,S_IRUGO | S_IWUSR | S_IWGRP);static const unsigned short normal_i2c[2] = {0x5d, I2C_CLIENT_END};struct ctp_config_info config_info = {
@@ -190,7 +191,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info){struct i2c_adapter *adapter = client->adapter;int ret = -1;
- printk("the adapter number is %d\n", adapter->nr);if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)){printk("======return=====\n");
@@ -198,7 +198,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info)}if(twi_id == adapter->nr){
- printk("%s: addr = %x\n", __func__, client->addr);ret = gtp_i2c_test(client);printk("detect ret %d\n",ret);if(!ret){
@@ -206,7 +205,6 @@ static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info)return -ENODEV;}else{ strlcpy(info->type, CTP_NAME, I2C_NAME_SIZE);
- printk("======detect ok !=====\n");return 0; }}else{
@@ -239,31 +237,10 @@ void ctp_print_info(struct ctp_config_info info,int debug_level)* ctp_wakeup - function**/
-int ctp_wakeup(int status,int ms)
+int ctp_wakeup(int status){
- dprintk(DEBUG_INIT,"***CTP*** %s:status:%d,ms = %d\n",__func__,status,ms);
-
- if (status == 0) {
-
- if(ms == 0) {
- __gpio_set_value(config_info.wakeup_gpio.gpio, 0);
- }else {
- __gpio_set_value(config_info.wakeup_gpio.gpio, 0);
- msleep(ms);
- __gpio_set_value(config_info.wakeup_gpio.gpio, 1);
- }
- }
- if (status == 1) {
- if(ms == 0) {
- __gpio_set_value(config_info.wakeup_gpio.gpio, 1);
- }else {
- __gpio_set_value(config_info.wakeup_gpio.gpio, 1);
- msleep(ms);
- __gpio_set_value(config_info.wakeup_gpio.gpio, 0);
- }
- }
- msleep(5);
-
+ dprintk(DEBUG_INIT,"***CTP*** %s:status:%d\n",__func__,status);
+ __gpio_set_value(config_info.wakeup_gpio.gpio, status);return 0;}@@ -295,19 +272,15 @@ void gtp_set_io_int(void)}-void gtp_io_init(int ms)
-{
-
- ctp_wakeup(0, 0);
- msleep(ms);
-
- gtp_set_int_value(0);
- msleep(2);
-
- ctp_wakeup(1, 0);
- msleep(6);
- gpio_direction_output(config_info.wakeup_gpio.gpio,1);
- gtp_int_sync(50);
+void gtp_io_init()
+{
+ input_set_power_enable(&(config_info.input_type), 1);
+ gtp_set_int_value(0);
+ ctp_wakeup(0);
+ msleep(4);
+ ctp_wakeup(1);
+ msleep(28);
+ gtp_set_io_int();}/*******************************************************************************/static ssize_t gtp_gesture_enable_store(struct device *dev,struct device_attribute *attr,const char *buf, size_t count)
@@ -1357,7 +1330,6 @@ Output:*******************************************************/void gtp_int_sync(s32 ms){
- gtp_set_int_value(0);msleep(ms);gtp_set_io_int();}
@@ -2713,11 +2685,11 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id}#endif- ret = gtp_i2c_test(client);
- if (ret < 0)
- {
- printk("I2C communication ERROR!");
- }
+// ret = gtp_i2c_test(client);
+// if (ret < 0)
+// {
+// printk("I2C communication ERROR!");
+// }ret = gtp_read_version(client, &version_info);if (ret < 0)
@@ -3249,10 +3221,10 @@ Output:********************************************************/static int __devinit goodix_ts_init(void){
+ printk("dzh-->GTP driver init\n");s32 ret = -1;script_item_u val;script_item_value_type_e type;
- dprintk(DEBUG_INIT,"GTP driver init\n");if (input_fetch_sysconfig_para(&(config_info.input_type))) {printk("%s: ctp_fetch_sysconfig_para err.\n", __func__);return 0;
@@ -3282,8 +3254,6 @@ static int __devinit goodix_ts_init(void)if(!gtp_gesture_wakeup)gtp_power_ctrl_sleep = 1; - input_set_power_enable(&(config_info.input_type), 1);
- msleep(10);if(!ctp_get_system_config()){printk("%s:read config fail!\n",__func__);
@@ -3292,7 +3262,7 @@ static int __devinit goodix_ts_init(void)sunxi_gpio_to_name(CTP_IRQ_NUMBER,irq_pin_name);
- gtp_io_init(20);
+ gtp_io_init();goodix_wq = create_singlethread_workqueue("goodix_wq");if (!goodix_wq)
@@ -3304,9 +3274,10 @@ static int __devinit goodix_ts_init(void)INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func);gtp_esd_check_workqueue = create_workqueue("gtp_esd_check");#endif
- goodix_ts_driver.detect = ctp_detect;
+ goodix_ts_driver.detect = ctp_detect;ret = i2c_add_driver(&goodix_ts_driver);
- return ret;
+ printk("dzh-->GTP driver init done\n");
+ return ret;}/******************************************************* ------------------ drivers/input/touchscreen/gt9xxnew/gt9xx.h ------------------
index c43f741..42384d9 100755
@@ -49,7 +49,7 @@#define GTP_HAVE_TOUCH_KEY 0#define GTP_ICS_SLOT_REPORT 0-#define GTP_AUTO_UPDATE 1 // auto update fw by .bin file as default
+#define GTP_AUTO_UPDATE 0 // auto update fw by .bin file as default#define GTP_HEADER_FW_UPDATE 1 // auto update fw by gtp_default_FW in gt9xx_firmware.h, function together with GTP_AUTO_UPDATE#define GTP_AUTO_UPDATE_CFG 0 // auto update config by .cfg file, function together with GTP_AUTO_UPDATE@@ -437,7 +437,8 @@ enum{printk("***CTP***"fmt, ## arg)***************************************************************************/-#define GTP_INFO(fmt,arg...) printk("<<-GTP-INFO->> "fmt"\n",##arg)
+#define GTP_INFO(fmt,arg...)
+//#define GTP_INFO(fmt,arg...) printk("<<-GTP-INFO->> "fmt"\n",##arg)#define GTP_ERROR(fmt,arg...) printk("<<-GTP-ERROR->> "fmt"\n",##arg)#define GTP_DEBUG(fmt,arg...) do{\if(GTP_DEBUG_ON)\