From e28e51dabcbd1459120fc182e8734eb8b77f7483 Mon Sep 17 00:00:00 2001 From: Wu Liangqing Date: Thu, 3 Dec 2020 22:15:57 +0800 Subject: [PATCH] driver: input: touchscreen: gslx680_pad add work for fw download Change-Id: I06842c0fc9bd3a7c5b0bdf962e7663b3662ccfbc Signed-off-by: Wu Liangqing --- drivers/input/touchscreen/gslx680_pad.c | 42 +++++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/gslx680_pad.c b/drivers/input/touchscreen/gslx680_pad.c index 462079a59d56..76af925d9ebc 100644 --- a/drivers/input/touchscreen/gslx680_pad.c +++ b/drivers/input/touchscreen/gslx680_pad.c @@ -116,6 +116,8 @@ struct gsl_ts { int screen_max_x; int screen_max_y; struct gsl_touch_chip_info *gsl_chip_info; + struct work_struct download_fw_work; + struct work_struct resume_work; }; #ifdef GSL_DEBUG @@ -255,7 +257,6 @@ static void gsl_load_fw(struct i2c_client *client) ptr_fw = ts->gsl_chip_info->ptr_fw; source_len = ts->gsl_chip_info->ptr_fw_len; - for (source_line = 0; source_line < source_len; source_line++) { /* init page trans, set the page val */ @@ -359,6 +360,8 @@ static void clr_reg(struct i2c_client *client) static void init_chip(struct i2c_client *client) { int rc; + struct gsl_ts *ts = i2c_get_clientdata(client); + gslX680_shutdown_low(); mdelay(20); gslX680_shutdown_high(); @@ -370,12 +373,7 @@ static void init_chip(struct i2c_client *client) dev_err(&client->dev, "------gslX680 test_i2c error------\n"); return; } - clr_reg(client); - reset_chip(client); - gsl_load_fw(client); - startup_chip(client); - reset_chip(client); - startup_chip(client); + queue_work(ts->wq, &ts->download_fw_work); } static void check_mem_data(struct i2c_client *client) @@ -934,6 +932,27 @@ static int gsl_ts_suspend(struct device *dev) static int gsl_ts_resume(struct device *dev) { struct gsl_ts *ts = dev_get_drvdata(dev); + + queue_work(ts->wq, &ts->resume_work); + + return 0; +} + +static void gsl_download_fw_work(struct work_struct *work) +{ + struct gsl_ts *ts = dev_get_drvdata(&gsl_client->dev); + + clr_reg(ts->client); + reset_chip(ts->client); + gsl_load_fw(ts->client); + startup_chip(ts->client); + reset_chip(ts->client); + startup_chip(ts->client); +} + +static void gsl_resume_work(struct work_struct *work) +{ + struct gsl_ts *ts = dev_get_drvdata(&gsl_client->dev); #ifdef SLEEP_CLEAR_POINT #ifdef REPORT_DATA_ANDROID_4_0 int i; @@ -941,8 +960,8 @@ static int gsl_ts_resume(struct device *dev) #endif gslX680_shutdown_high(); msleep(20); - reset_chip(ts->client); - startup_chip(ts->client); + //reset_chip(ts->client); + //startup_chip(ts->client); check_mem_data(ts->client); check_mem_data(ts->client); @@ -960,9 +979,9 @@ static int gsl_ts_resume(struct device *dev) input_sync(ts->input); #endif enable_irq(ts->irq); - return 0; } + static int gsl_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1039,6 +1058,9 @@ static int gsl_ts_probe(struct i2c_client *client, dev_info(&ts->client->dev, "irq pin invalid\n"); } + INIT_WORK(&ts->download_fw_work, gsl_download_fw_work); + INIT_WORK(&ts->resume_work, gsl_resume_work); + gslX680_init(); rc = gslX680_ts_init(client, ts); if (rc < 0) {