Skip to content

Commit a2d141f

Browse files
committed
Input: atmel_mxt_ts - combine bootloader version query with probe
This removes some complexity from the bootloader state machine, and means that we always output some debug about the version as soon as we start talking to the bootloader. Signed-off-by: Nick Dyer <[email protected]>
1 parent bedd706 commit a2d141f

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

drivers/input/touchscreen/atmel_mxt_ts.c

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -489,47 +489,31 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address)
489489
{
490490
struct device *dev = &data->client->dev;
491491
int error;
492-
u8 val;
493-
bool crc_failure;
492+
u8 buf[3];
493+
bool crc_failure, extended_id;
494494

495495
error = mxt_lookup_bootloader_address(data, alt_address);
496496
if (error)
497497
return error;
498498

499-
error = mxt_bootloader_read(data, &val, 1);
499+
/* Check bootloader status and version information */
500+
error = mxt_bootloader_read(data, buf, sizeof(buf));
500501
if (error)
501502
return error;
502503

503-
/* Check app crc fail mode */
504-
crc_failure = (val & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL;
504+
crc_failure = (buf[0] & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL;
505+
extended_id = buf[0] & MXT_BOOT_EXTENDED_ID;
505506

506-
dev_err(dev, "Detected bootloader, status:%02X%s\n",
507-
val, crc_failure ? ", APP_CRC_FAIL" : "");
507+
dev_info(dev, "Found bootloader addr:%02x ID:%u%s%u%s\n",
508+
data->bootloader_addr,
509+
extended_id ? (buf[1] & MXT_BOOT_ID_MASK) : buf[0],
510+
extended_id ? " version:" : "",
511+
extended_id ? buf[2] : 0,
512+
crc_failure ? ", APP_CRC_FAIL" : "");
508513

509514
return 0;
510515
}
511516

512-
static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val)
513-
{
514-
struct device *dev = &data->client->dev;
515-
u8 buf[3];
516-
517-
if (val & MXT_BOOT_EXTENDED_ID) {
518-
if (mxt_bootloader_read(data, &buf[0], 3) != 0) {
519-
dev_err(dev, "%s: i2c failure\n", __func__);
520-
return val;
521-
}
522-
523-
dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]);
524-
525-
return buf[0];
526-
} else {
527-
dev_dbg(dev, "Bootloader ID:%d\n", val & MXT_BOOT_ID_MASK);
528-
529-
return val;
530-
}
531-
}
532-
533517
static int mxt_check_bootloader(struct mxt_data *data, unsigned int state,
534518
bool wait)
535519
{
@@ -563,9 +547,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state,
563547
if (ret)
564548
return ret;
565549

566-
if (state == MXT_WAITING_BOOTLOAD_CMD)
567-
val = mxt_get_bootloader_version(data, val);
568-
569550
switch (state) {
570551
case MXT_WAITING_BOOTLOAD_CMD:
571552
case MXT_WAITING_FRAME_DATA:
@@ -2749,7 +2730,7 @@ static int mxt_enter_bootloader(struct mxt_data *data)
27492730
msleep(MXT_RESET_TIME);
27502731

27512732
/* Do not need to scan since we know family ID */
2752-
ret = mxt_lookup_bootloader_address(data, 0);
2733+
ret = mxt_probe_bootloader(data, 0);
27532734
if (ret)
27542735
return ret;
27552736

0 commit comments

Comments
 (0)