From 17d1d601051059a6dc8c608ab9e8324af7bca57d Mon Sep 17 00:00:00 2001 From: brian Date: Wed, 29 Apr 2020 09:48:40 +0800 Subject: [PATCH 94/97] drivers: gt9xx: modify driver for especial hardware 1.the board has not reset,irq and power gpio 2.the board has not regulator 3.add x2y property for change of X direction and Y direction Sign ed-off-by: brian --- drivers/input/touchscreen/gt9xx/gt9xx.c | 125 ++++++++++++++---------- 1 file changed, 71 insertions(+), 54 deletions(-) diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c index 6db7e395f82b..9804fd11ae4e 100644 --- a/drivers/input/touchscreen/gt9xx/gt9xx.c +++ b/drivers/input/touchscreen/gt9xx/gt9xx.c @@ -1124,7 +1124,8 @@ void gtp_reset_guitar(struct i2c_client *client, s32 ms) } #endif - gtp_int_sync(50, ts); + if(ts->irq_pin > 0) + gtp_int_sync(50, ts); #if GTP_ESD_PROTECT gtp_init_ext_watchdog(client); #endif @@ -1213,8 +1214,8 @@ static s8 gtp_enter_sleep(struct goodix_ts_data * ts) } } #endif - - GTP_GPIO_OUTPUT(ts->irq_pin, 0); + if(ts->irq_pin > 0) + GTP_GPIO_OUTPUT(ts->irq_pin, 0); msleep(5); while(retry++ < 5) @@ -1253,7 +1254,8 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data * ts) { u8 opr_buf[3] = {0x41, 0x80}; - GTP_GPIO_OUTPUT(ts->irq_pin, 1); + if(ts->irq_pin > 0) + GTP_GPIO_OUTPUT(ts->irq_pin, 1); msleep(5); for (retry = 0; retry < 10; ++retry) @@ -1327,7 +1329,8 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data * ts) gtp_irq_enable(ts); #else - GTP_GPIO_OUTPUT(ts->irq_pin, 1); + if(ts->irq_pin > 0) + GTP_GPIO_OUTPUT(ts->irq_pin, 1); msleep(5); #endif @@ -1338,7 +1341,8 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data * ts) #if (!GTP_GESTURE_WAKEUP) { - gtp_int_sync(25, ts); + if(ts->irq_pin > 0) + gtp_int_sync(25, ts); #if GTP_ESD_PROTECT gtp_init_ext_watchdog(ts->client); #endif @@ -1819,36 +1823,41 @@ static s8 gtp_request_io_port(struct goodix_ts_data *ts) gpio_direction_input(ts->tp_select_pin); } */ - ret = GTP_GPIO_REQUEST(ts->rst_pin, "GTP_RST_PORT"); - if (ret < 0) - { - GTP_ERROR("2Failed to request GPIO:%d, ERRNO:%d",(s32)ts->rst_pin, ret); - GTP_GPIO_FREE(ts->rst_pin); - return -ENODEV; + if(ts->rst_pin > 0) { + ret = GTP_GPIO_REQUEST(ts->rst_pin, "GTP_RST_PORT"); + if (ret < 0) + { + GTP_ERROR("2Failed to request GPIO:%d, ERRNO:%d",(s32)ts->rst_pin, ret); + GTP_GPIO_FREE(ts->rst_pin); + return -ENODEV; + } } - ret = GTP_GPIO_REQUEST(ts->irq_pin, "GTP_INT_IRQ"); - if (ret < 0) - { - GTP_ERROR("3Failed to request GPIO:%d, ERRNO:%d", (s32)ts->irq_pin, ret); - GTP_GPIO_FREE(ts->irq_pin); - return -ENODEV; - } - else - { - //GTP_GPIO_AS_INT(GTP_INT_PORT); - gpio_direction_input(ts->irq_pin); - //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); - //s3c_gpio_cfgpin(pin, GTP_INT_CFG); - - //ts->client->irq = ts->irq_pin; + if(ts->irq_pin > 0) { + ret = GTP_GPIO_REQUEST(ts->irq_pin, "GTP_INT_IRQ"); + if (ret < 0) + { + GTP_ERROR("3Failed to request GPIO:%d, ERRNO:%d", (s32)ts->irq_pin, ret); + GTP_GPIO_FREE(ts->irq_pin); + return -ENODEV; + } + else + { + //GTP_GPIO_AS_INT(GTP_INT_PORT); + gpio_direction_input(ts->irq_pin); + //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); + //s3c_gpio_cfgpin(pin, GTP_INT_CFG); + + //ts->client->irq = ts->irq_pin; + } } //GTP_GPIO_AS_INPUT(ts->rst_pin); - gpio_direction_input(ts->rst_pin); + if(ts->rst_pin > 0) + gpio_direction_input(ts->rst_pin); //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); - - gtp_reset_guitar(ts->client, 20); + if((ts->rst_pin > 0) && (ts->irq_pin)) + gtp_reset_guitar(ts->client, 20); return ret; } @@ -1866,9 +1875,13 @@ static s8 gtp_request_irq(struct goodix_ts_data *ts) { s32 ret = -1; + if(ts->irq_pin < 0) { + ret = 1; + goto test_pit; + } GTP_DEBUG_FUNC(); GTP_DEBUG("INT trigger type:%x", ts->int_trigger_type); - + ts->irq=gpio_to_irq(ts->irq_pin); //If not defined in client if (ts->irq) { @@ -1899,11 +1912,12 @@ test_pit: { GTP_ERROR("Request IRQ failed!ERRNO:%d.", ret); //GTP_GPIO_AS_INPUT(GTP_INT_PORT); - gpio_direction_input(ts->irq_pin); - //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); - - GTP_GPIO_FREE(ts->irq_pin); + if(ts->irq_pin > 0) { + gpio_direction_input(ts->irq_pin); + //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); + GTP_GPIO_FREE(ts->irq_pin); + } hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); ts->timer.function = goodix_ts_timer_handler; hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); @@ -2139,7 +2153,8 @@ s32 gtp_fw_startup(struct i2c_client *client) return FAIL; } //int sync - gtp_int_sync(25, ts); + if(ts->irq_pin > 0) + gtp_int_sync(25, ts); //check fw run status ret = i2c_read_bytes(client, 0x8041, opr_buf, 1); @@ -2626,27 +2641,25 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id return -EINVAL; } + gtp_change_x2y = (u8)of_property_read_bool(np, "x2y"); + if (val == 89) { m89or101 = TRUE; - gtp_change_x2y = TRUE; gtp_x_reverse = FALSE; gtp_y_reverse = TRUE; } else if (val == 101) { m89or101 = FALSE; - gtp_change_x2y = TRUE; gtp_x_reverse = TRUE; gtp_y_reverse = FALSE; } else if (val == 911) { m89or101 = FALSE; bgt911 = TRUE; - gtp_change_x2y = TRUE; gtp_x_reverse = FALSE; gtp_y_reverse = TRUE; } else if (val == 970) { m89or101 = FALSE; bgt911 = FALSE; bgt970 = TRUE; - gtp_change_x2y = FALSE; gtp_x_reverse = FALSE; gtp_y_reverse = TRUE; } else if (val == 910) { @@ -2654,21 +2667,22 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id bgt911 = FALSE; bgt970 = FALSE; bgt910 = TRUE; - gtp_change_x2y = TRUE; gtp_x_reverse = FALSE; gtp_y_reverse = TRUE; } - ts->tp_regulator = devm_regulator_get(&client->dev, "tp"); if (IS_ERR(ts->tp_regulator)) { dev_err(&client->dev, "failed to get regulator, %ld\n", PTR_ERR(ts->tp_regulator)); - return PTR_ERR(ts->tp_regulator); +// return PTR_ERR(ts->tp_regulator); } - ret = regulator_enable(ts->tp_regulator); - if (ret < 0) - GTP_ERROR("failed to enable tp regulator\n"); + if (IS_ERR(ts->tp_regulator)) { + ret = regulator_enable(ts->tp_regulator); + if (ret < 0) + GTP_ERROR("failed to enable tp regulator\n"); + } + msleep(20); ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)(&ts->irq_flags)); @@ -2732,7 +2746,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id */ #if GTP_COMPATIBLE_MODE gtp_get_chip_type(ts); - + if (CHIP_TYPE_GT9F == ts->chip_type) { ret = gtp_gt9xxf_init(ts->client); @@ -2798,7 +2812,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id { GTP_INFO("GTP works in interrupt mode."); } - + printk("gt9xx use_irq=%d\n",ts->use_irq); if (ts->use_irq) { gtp_irq_enable(ts); @@ -2816,8 +2830,10 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id probe_init_error: printk(" <%s>_%d prob error !!!!!!!!!!!!!!!\n", __func__, __LINE__); tp_unregister_fb(&ts->tp); - GTP_GPIO_FREE(ts->rst_pin); - GTP_GPIO_FREE(ts->irq_pin); + if(ts->rst_pin > 0) + GTP_GPIO_FREE(ts->rst_pin); + if(ts->irq_pin > 0) + GTP_GPIO_FREE(ts->irq_pin); probe_init_error_requireio: tp_unregister_fb(&ts->tp); kfree(ts); @@ -2854,12 +2870,13 @@ static int goodix_ts_remove(struct i2c_client *client) if (ts->use_irq) { //GTP_GPIO_AS_INPUT(GTP_INT_PORT); - - gpio_direction_input(ts->irq_pin); + if(ts->irq_pin > 0) { + gpio_direction_input(ts->irq_pin); //s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE); - GTP_GPIO_FREE(ts->irq_pin); - free_irq(client->irq, ts); + GTP_GPIO_FREE(ts->irq_pin); + free_irq(client->irq, ts); + } } else { -- 2.25.1