Skip to content

Commit bc1d57f

Browse files
ElanJohnnyChuangdtor
authored andcommitted
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>
1 parent c9a3a7c commit bc1d57f

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎drivers/input/touchscreen/elants_i2c.c‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static u16 elants_i2c_parse_version(u8 *buf)
298298
return get_unaligned_be32(buf) >> 4;
299299
}
300300

301-
static int elants_i2c_query_fw_id(struct elants_data *ts)
301+
static int elants_i2c_query_hw_version(struct elants_data *ts)
302302
{
303303
struct i2c_client *client = ts->client;
304304
int error, retry_cnt;
@@ -318,8 +318,13 @@ static int elants_i2c_query_fw_id(struct elants_data *ts)
318318
error, (int)sizeof(resp), resp);
319319
}
320320

321-
dev_err(&client->dev,
322-
"Failed to read fw id or fw id is invalid\n");
321+
if (error) {
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);
323328

324329
return -EINVAL;
325330
}
@@ -508,7 +513,7 @@ static int elants_i2c_fastboot(struct i2c_client *client)
508513
static int elants_i2c_initialize(struct elants_data *ts)
509514
{
510515
struct i2c_client *client = ts->client;
511-
int error, retry_cnt;
516+
int error, error2, retry_cnt;
512517
const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 };
513518
const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 };
514519
u8 buf[HEADER_SIZE];
@@ -553,18 +558,22 @@ static int elants_i2c_initialize(struct elants_data *ts)
553558
}
554559
}
555560

561+
/* hw version is available even if device in recovery state */
562+
error2 = elants_i2c_query_hw_version(ts);
556563
if (!error)
557-
error = elants_i2c_query_fw_id(ts);
564+
error = error2;
565+
558566
if (!error)
559567
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);
560574

561-
if (error) {
575+
if (error)
562576
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-
}
568577

569578
return 0;
570579
}

0 commit comments

Comments
 (0)