Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3365627ybb; Tue, 31 Mar 2020 03:53:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsFXIP/lVxc4wq4wB/DqifKISmHAdcGT8R7U0AIciYSP46hDP1TTjy1r+ZUnu4sq/l7kxK7 X-Received: by 2002:a4a:2c55:: with SMTP id o82mr13023439ooo.33.1585652016780; Tue, 31 Mar 2020 03:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585652016; cv=none; d=google.com; s=arc-20160816; b=J0XY1iKK1k3KEuo9CUWhF6g64J22BMUOs1/kOynpxavnyP3g4Fih6/7ky0k5O1FVgA kglhiTw4ZIhXpinN/O9EKMg1LnyEPX6SWFnTHejI59bKTPsTDEzAeUvyUqMJeulyItZm QB6pDmUP91JPVEJGlF041vZ6G/+OEDOFSPiDLwN4ZYAcb5PiwPN0v8Lwp/2MRojIblz2 3vqeO0JgRYoSfME0HLLQkLlgcpBU4fQUElVkdRnIYbe/uMlQn7nhvicDe4Blu62dqxti 6Kek1GQAuQXW6Mq5frjYZHVuX3mQDQHXqVGNAXqQ/hthnZRfJksg5xifB5ihPuudxSg+ 8+Vw== 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=qym+acGayrVEilL4B9bt8zCRuJW7uhlpp4ZybLLeAns=; b=NjdhxuZ/UdRCCGPrDXXV027WKoYqp+/5N9Sz29oN3EaMDMZTpyyPJ7mx//RuFjJ9hg v/GDsskzOQuOrxju9Fv48k7rpHQwNxKLBaUcvh8HpEZFGawdFwbil/UVXMxcS2lxWneG AVEwn5SR3qWUHecGIg08yU7zvGPCEYSO4cvG1fOOfhyX6kcGX6SfuHz7lRWPJWTtKIwB Ud0nGhm8vqvB3RCK2d6+RS4Yo2QwAo0CkVoXkDYgBR+ZlakFDTgBmSkRSyaS4/iekqAn SBqf/zvEuXM6vCnTeDnAh6WlUi3f0fScd3+1KfnUAY/z5wOGd7jynV5lo4ZgNHG3cg3A 7HEg== 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 x189si7200529oia.270.2020.03.31.03.53.24; Tue, 31 Mar 2020 03:53:36 -0700 (PDT) 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 S1730561AbgCaKwo (ORCPT + 99 others); Tue, 31 Mar 2020 06:52:44 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:43593 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730739AbgCaKwm (ORCPT ); Tue, 31 Mar 2020 06:52:42 -0400 IronPort-SDR: H0FMrk3rZITyUbkekZtFY6TVq0gtVnDNvvr8fPBijDEh0fOMjNK/oCSfRREImRB5FpqijCOZwx gRKqzd9biEZ8AugEIqv6e/Ub6x4eNpZ+fpaAMrQaTr8WddePCFJCUUT4JTkOrHpt+2zF+FkipX IY9ldvFxSH2ccG2Fnfnt0NKZKfkJM1mwifh/Xrb0zxPsvm3bRz1i9SS30u6fS/HZRNWsCNIqTs HGCfaDC5YPOU+nVvMkgnTIETFOjZ9PC+PXCkKVi559HgBOHzPmcJa1lDzZfZraCwzNLH6OcBTf KZM= X-IronPort-AV: E=Sophos;i="5.72,327,1580803200"; d="scan'208";a="47330790" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 31 Mar 2020 02:52:38 -0800 IronPort-SDR: E7PXX0zs2PIMiFs4wsNLxmGnJ+JBPB8DfvY7UIHBfcPLRcLHDQ8cVFsamDB3IHsmq/Vqwk7Z4P OH0ycQspC7uE25wwUalK3BDewt3iTmDi4fkjLdpBOzRl+HJu2yaVs4eVtqUCFnIVslxiIppoNB QEt/GWU85m5i/m6S2s11Xi7rYbSovS25+qdzOBFzZrO507ayUMKuq3Mmz3vvh8Bxorei7Xr+1w Ft+9rNJfVNSBPq2B2xmtu+E2w73Ch03A3bwixcZXvSyuEMTnya+FGbKGq1f4u6CiFXoN2FwNsr 4Cs= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v10 27/55] Input: atmel_mxt_ts - combine bootloader version query with probe Date: Tue, 31 Mar 2020 03:50:23 -0700 Message-ID: <20200331105051.58896-28-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331105051.58896-1-jiada_wang@mentor.com> References: <20200331105051.58896-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 11b2f133e6be..71d5781d3539 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