aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJohnny Chuang <johnny.chuang@emc.com.tw>2016-08-25 12:26:53 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-08-25 13:11:31 -0400
commitbc1d57fe5ff7574e6cf1d53bd88edbd87e127420 (patch)
tree7708056bfba6ea2dc09e9ef0dcc0bea61eeaa229 /drivers/input
parentc9a3a7cf95d8429c5db0fc98758c21f8fefb38fa (diff)
Input: elants_i2c - get product id on recovery mode for FW update
We use hw version to construct name of file holding touchscreen firmware, so let's try reading it even if touchscreen initialization fails (the firmware supports reading product/hardware id even when device is in recovery/boot mode). Signed-off-by: Johnny Chuang <johnny.chuang@emc.com.tw> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/elants_i2c.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index ac09855fa435..02aec284deca 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -298,7 +298,7 @@ static u16 elants_i2c_parse_version(u8 *buf)
298 return get_unaligned_be32(buf) >> 4; 298 return get_unaligned_be32(buf) >> 4;
299} 299}
300 300
301static int elants_i2c_query_fw_id(struct elants_data *ts) 301static int elants_i2c_query_hw_version(struct elants_data *ts)
302{ 302{
303 struct i2c_client *client = ts->client; 303 struct i2c_client *client = ts->client;
304 int error, retry_cnt; 304 int error, retry_cnt;
@@ -318,8 +318,13 @@ static int elants_i2c_query_fw_id(struct elants_data *ts)
318 error, (int)sizeof(resp), resp); 318 error, (int)sizeof(resp), resp);
319 } 319 }
320 320
321 dev_err(&client->dev, 321 if (error) {
322 "Failed to read fw id or fw id is invalid\n"); 322 dev_err(&client->dev,
323 "Failed to read fw id: %d\n", error);
324 return error;
325 }
326
327 dev_err(&client->dev, "Invalid fw id: %#04x\n", ts->hw_version);
323 328
324 return -EINVAL; 329 return -EINVAL;
325} 330}
@@ -508,7 +513,7 @@ static int elants_i2c_fastboot(struct i2c_client *client)
508static int elants_i2c_initialize(struct elants_data *ts) 513static int elants_i2c_initialize(struct elants_data *ts)
509{ 514{
510 struct i2c_client *client = ts->client; 515 struct i2c_client *client = ts->client;
511 int error, retry_cnt; 516 int error, error2, retry_cnt;
512 const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 }; 517 const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 };
513 const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 }; 518 const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 };
514 u8 buf[HEADER_SIZE]; 519 u8 buf[HEADER_SIZE];
@@ -553,18 +558,22 @@ static int elants_i2c_initialize(struct elants_data *ts)
553 } 558 }
554 } 559 }
555 560
561 /* hw version is available even if device in recovery state */
562 error2 = elants_i2c_query_hw_version(ts);
556 if (!error) 563 if (!error)
557 error = elants_i2c_query_fw_id(ts); 564 error = error2;
565
558 if (!error) 566 if (!error)
559 error = elants_i2c_query_fw_version(ts); 567 error = elants_i2c_query_fw_version(ts);
568 if (!error)
569 error = elants_i2c_query_test_version(ts);
570 if (!error)
571 error = elants_i2c_query_bc_version(ts);
572 if (!error)
573 error = elants_i2c_query_ts_info(ts);
560 574
561 if (error) { 575 if (error)
562 ts->iap_mode = ELAN_IAP_RECOVERY; 576 ts->iap_mode = ELAN_IAP_RECOVERY;
563 } else {
564 elants_i2c_query_test_version(ts);
565 elants_i2c_query_bc_version(ts);
566 elants_i2c_query_ts_info(ts);
567 }
568 577
569 return 0; 578 return 0;
570} 579}