Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4316155ybc; Fri, 22 Nov 2019 00:29:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyYjqzAIH5iOkvSIW1I4H7QFU1S+jGG1bX0htfTREq6bEVbdmSM6DaMqbOuhPHrfkffN7F+ X-Received: by 2002:a17:906:4910:: with SMTP id b16mr20466478ejq.133.1574411382236; Fri, 22 Nov 2019 00:29:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574411382; cv=none; d=google.com; s=arc-20160816; b=vJcGo1QEFLiGwHRGWliv1iJtDVAy5bUrotW+9e1JyjYKG95pubVpmbldXCzEykhelz /anXKwLhlVzxxSQyqdae0IXSHLlgM8x12EQJ7Hwu/buhGOzr3SBTXThYrnY2gAaJHj7Q HsifEGWGGpMCbYpYDT08r9L1uTCynBbLIK2JGkWMkSJIkfAcYkkwYRO5YO2lV3DGNirJ n2nitWoQAWmMIo7trBV3nzqNNWbovh73njI0fN2K7n+wJlu0eRy09Og8R6AqEFa90KDf 8AV99FbtMXcEGbHIQ/Eo1SE6tbWSVLmlbuxslTOrGADmTyaoLW7X8RdhBkOWJCJfjPt8 TPqQ== 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=tkuPdYr4TFluK2I9iwtThFr3EZrYi3DKtfn6Y3ENpow=; b=JrZ+C8DdwZc++BRgLydk8uM0w4amJED9sCfu60v1v1RygCb0Chln6G9tGjErCBfP88 OdVhsPh1Cet4UT/eFsRqV53DSzDof/J/AauAKytAxRJ6qStzlW60ON2MigwTNYF5H9ex CVW+RxGQ/qZWQp/6UinarusFB5vAXuLKaToktyOJ/DuS5W1WwFeS7EvzNyz2/c5jI7rw 1IeMzhM0ZTKYn9O+qbW3IblE+dDc823O/dTC+P56vcxF9KBu9ExlW0xuer3Kj3LBqXb8 MAYGDhoUpFGaKRoAyQG+PRr1MnBl57U1FD4uGwkLjAVOBZCM/fDXqXpPJ+5WvfwPlvmM T86w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si4066114edp.264.2019.11.22.00.29.18; Fri, 22 Nov 2019 00:29:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbfKVIZ1 (ORCPT + 99 others); Fri, 22 Nov 2019 03:25:27 -0500 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:52499 "EHLO esa2.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbfKVIZX (ORCPT ); Fri, 22 Nov 2019 03:25:23 -0500 IronPort-SDR: oWmG1OcHbjPK7HCR/H+anRdGgLSQCzMiDK/B6Z7xLRS1n+h93hoKGeUN2NgnPihjtFIhuEN3Dm UcH/27zxTZXj8Zb2sT6zv56F07NHwQjnQILyGSlnVd4LGNfi43ff0Dl1ZOjvY+IV8aRPQR8MNH OsyDfa4to7hMKhXssfyLbQS472Q4H/Bl3m0Ydv56bkq9KILzAA93cJmUjj1uRfrg4kzGdUINke 18mP5nYOtGPRSZgcza+a4WUtDJlWAP8NdwPCPVycfEJkUWZcneb6HVXmt0+h3YC6zDdi1shZh5 pxs= X-IronPort-AV: E=Sophos;i="5.69,229,1571731200"; d="scan'208";a="43358926" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 22 Nov 2019 00:25:23 -0800 IronPort-SDR: XHDpIymJMyYDdAjqR0Y1jJHBxOaFPThvO/K2HKvRV3E2/McOUcR1S9QNKErPtfD9KM/6soLhij wivM2lJQyN8qR9HYtrdivBlUTmuELPvcAOba7CjSkMtWd49w9bp9PviTDXsofdPBtjegGiYQ57 wIWUowCWXxGe4/TUAl1KtAkl3nzAEGR4PF/wrsNa5PSU6bFPDgd+UwJX/m7FkMfZocGHRsO+1z +Bm6B8dtJTuFhMU11o+HIx6GbGBsnO+ybq2It9nSSMm1rYU7VNerzH+dLu/3H3r2Weg9Fsv38D 43E= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v6 21/48] Input: atmel_mxt_ts - combine bootloader version query with probe Date: Fri, 22 Nov 2019 17:23:35 +0900 Message-ID: <20191122082402.18173-22-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191122082402.18173-1-jiada_wang@mentor.com> References: <20191122082402.18173-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 04627db23ad2..d38ae9525e35 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -558,47 +558,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) { @@ -632,9 +616,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: @@ -3283,7 +3264,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