Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1368074ybj; Thu, 7 May 2020 23:01:22 -0700 (PDT) X-Google-Smtp-Source: APiQypJ7U3X3ovVavOVADAAoEkSNApqKdHLfFMxyP6Qmisx4uKFBnQUOMYChtrrrM9CKbI9Ok+eo X-Received: by 2002:a17:907:2170:: with SMTP id rl16mr523498ejb.238.1588917681910; Thu, 07 May 2020 23:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917681; cv=none; d=google.com; s=arc-20160816; b=gbbdIxYEulO6BgZIjgggllLlkZA5q3yACHMEvktZXk7rYfwK7SPvt+pldhUmfe8HaN 2r87EBwKCNrwU+PPOHtPPClF/pnP65fqJxbREh1e7Aqa2Q2X6A0BuAsE+Bpu9IE9D9Cf Q9WUkOmjizXCLWOK4r9GsFwBd/+DVOIGEzDoaqj1sQkw5DCSMn82yb8KfR1z855sQnwd rZJ5Vt8drOidQeQng8EiEfYROR8a146tGneJslOd0WFqC3hBZu9ywj5rNGlgrChOmbFl 3BdPQmEpzqmH7IHRnMeXVxwNH6Q5j8Udksw0uJDIhKXB/gZ5Gh5njp9sOeeWUfdiKoSX CB4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=ZahbieDKw5IJunP2oWJMF/gWHUJBwWr9ldjRJhSjFio=; b=GyJFkv3vGMC8BGPBjzE3ug2EukrWQEkyMU/gWbF2fcXNq0IweUuJpwd1vajHI5cPcz Vz4quSuMu5HKkQ9bcvMGb6YH/1VfcjE7A3uwKoq0fOnmtMlIChYfjDCO36eP8lgyQHSe R7+UtBdX0vTqTxrjkfITv8i8wKJaD+yF4KiE5AD7AMfFNv6Iv7vTW99/PZUGHJo30/jj og9dmlXnGkQRUlGyObyj7r/65yY9CnHNzqaIS9yp7G5gXXaQYbfk68oIKyg899D+1E/a NV7Eb/lzy8LOyOCKYH7whotwcmGWIdV62SQJ4thr6yOcqCnMT1qUW9zmpQfcRVucZ4tO hsLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j6si319471edd.521.2020.05.07.23.00.58; Thu, 07 May 2020 23:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbgEHF6x (ORCPT + 99 others); Fri, 8 May 2020 01:58:53 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:45906 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgEHF6w (ORCPT ); Fri, 8 May 2020 01:58:52 -0400 IronPort-SDR: JHsLNhFGi8MNXYsrMJd73Wy/XwoktPaR/vaB7zBQfSZm0haCNSOp2cUGLwhalESKNy7L0/ujx7 MA/8L6i/G6Js0K3R5WzxwsUN1+yC35XgtQeh1xV1BXjC6FvVIXInsU6Ak+2zQQFSlea7rSSZ3q 2P9PutKDLQ4noKr0OWMofFeShvGQX/Yy6KWP8/1in+Ar1+FuCtpczrSa5fGbzuTRXZCt8RZMMi j8j3uQjxsIxaKSDUxv0/IqXuj5GIfNBR7nKc/6q9sMEquxdi9pMfxH1ZxC0NMWiwF03I/8s0Rr dIA= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="48710628" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:51 -0800 IronPort-SDR: Ykvrv/U4JQnt7VN16jBlVZVrYcobX2V/+g1n8xKJOq/jcicayp3vrUM9eRfVdMdg3n6t/eL5Ed zEnV6C4vsEulq4NdOAmfoJbEYCGE72aS0Aa1rNayWNdQOta+RAn8GxGDlhc5xy2kxSKb7C5qjG WeV4KEOMoo/l6St1GsS0DbRrw5ong1hsBHMyWZ0dK93XL3zVqlYI7TPe+pN/nlU3ECa2zVX354 uor4A6uXPPIqf7yI+Tc2o13wcyCqmiUdGIMtCi3JEDr2rpwmX/FlHqh0w95jhp8J577YwSLYVG AFg= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 29/56] Input: atmel_mxt_ts - combine bootloader version query with probe Date: Thu, 7 May 2020 22:56:29 -0700 Message-ID: <20200508055656.96389-30-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Dyer 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 (cherry picked from ndyer/linux/for-upstream commit a2d141f170c80fea6663af98aab0be32abc0ddb0) Signed-off-by: George G. Davis Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 45 +++++++----------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 674763dddcd3..e2538c2dd3f7 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -559,47 +559,31 @@ static int mxt_probe_bootloader(struct mxt_data *data, bool alt_address) { struct device *dev = &data->client->dev; int error; - u8 val; - bool crc_failure; + u8 buf[3]; + bool crc_failure, extended_id; error = mxt_lookup_bootloader_address(data, alt_address); if (error) return error; - error = mxt_bootloader_read(data, &val, 1); + /* Check bootloader status and version information */ + error = mxt_bootloader_read(data, buf, sizeof(buf)); if (error) return error; - /* Check app crc fail mode */ - crc_failure = (val & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + crc_failure = (buf[0] & ~MXT_BOOT_STATUS_MASK) == MXT_APP_CRC_FAIL; + extended_id = buf[0] & MXT_BOOT_EXTENDED_ID; - dev_err(dev, "Detected bootloader, status:%02X%s\n", - val, crc_failure ? ", APP_CRC_FAIL" : ""); + dev_info(dev, "Found bootloader addr:%02x ID:%u%s%u%s\n", + data->bootloader_addr, + extended_id ? (buf[1] & MXT_BOOT_ID_MASK) : buf[0], + extended_id ? " version:" : "", + extended_id ? buf[2] : 0, + crc_failure ? ", APP_CRC_FAIL" : ""); return 0; } -static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val) -{ - struct device *dev = &data->client->dev; - u8 buf[3]; - - if (val & MXT_BOOT_EXTENDED_ID) { - if (mxt_bootloader_read(data, &buf[0], 3) != 0) { - dev_err(dev, "%s: i2c failure\n", __func__); - return val; - } - - dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]); - - return buf[0]; - } else { - dev_dbg(dev, "Bootloader ID:%d\n", val & MXT_BOOT_ID_MASK); - - return val; - } -} - static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, bool wait) { @@ -633,9 +617,6 @@ static int mxt_check_bootloader(struct mxt_data *data, unsigned int state, if (ret) return ret; - if (state == MXT_WAITING_BOOTLOAD_CMD) - val = mxt_get_bootloader_version(data, val); - switch (state) { case MXT_WAITING_BOOTLOAD_CMD: case MXT_WAITING_FRAME_DATA: @@ -3279,7 +3260,7 @@ static int mxt_enter_bootloader(struct mxt_data *data) msleep(MXT_RESET_TIME); /* Do not need to scan since we know family ID */ - ret = mxt_lookup_bootloader_address(data, 0); + ret = mxt_probe_bootloader(data, 0); if (ret) return ret; -- 2.17.1