From patchwork Wed Aug 24 08:44:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Johnny.Chuang" X-Patchwork-Id: 9297207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE136607EE for ; Wed, 24 Aug 2016 08:58:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEED528EA4 for ; Wed, 24 Aug 2016 08:58:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3C2128EA7; Wed, 24 Aug 2016 08:58:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6681628EA4 for ; Wed, 24 Aug 2016 08:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755068AbcHXI6a (ORCPT ); Wed, 24 Aug 2016 04:58:30 -0400 Received: from emcscan.emc.com.tw ([192.72.220.5]:5286 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755054AbcHXI62 (ORCPT ); Wed, 24 Aug 2016 04:58:28 -0400 X-Greylist: delayed 816 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Aug 2016 04:58:24 EDT Received: from unknown (HELO emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 24 Aug 2016 16:45:00 +0800 Received: from localhost.localdomain ([192.168.55.122]) by emc.com.tw (8.13.7+Sun/8.13.7) with ESMTP id u7O8ismC006222; Wed, 24 Aug 2016 16:44:54 +0800 (CST) From: Johnny Chuang To: Dmitry Torokhov , Daniel Kurtz , Jennifer Tsai , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Cc: James Chen , Paul Liang , Jeff Chuang , Johnny Chuang Subject: [PATCH] Input: elants_i2c - get product id on recovery mode for FW update Date: Wed, 24 Aug 2016 16:44:25 +0800 Message-Id: <1472028265-5018-1-git-send-email-johnny.chuang@emc.com.tw> X-Mailer: git-send-email 1.8.3.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This CL takes the responsibility for getting product/hardware id on recovery mode. It will fix firmware update script could not find correspond firmware file name on recovery mode. BTW, firmware must need to support reading product/hardware id on boot code. Signed-off-by: Johnny Chuang --- drivers/input/touchscreen/elants_i2c.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index ac09855..24662c3 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -298,7 +298,7 @@ static u16 elants_i2c_parse_version(u8 *buf) return get_unaligned_be32(buf) >> 4; } -static int elants_i2c_query_fw_id(struct elants_data *ts) +static int elants_i2c_query_hw_version(struct elants_data *ts) { struct i2c_client *client = ts->client; int error, retry_cnt; @@ -318,8 +318,13 @@ static int elants_i2c_query_fw_id(struct elants_data *ts) error, (int)sizeof(resp), resp); } - dev_err(&client->dev, - "Failed to read fw id or fw id is invalid\n"); + if (error) { + dev_err(&clent->dev, + "Failed to read fw id: %d\n", error); + return error; + } + + dev_err(&clent->dev, "Invalid fw id: %#04x\n", ts->hw_version); return -EINVAL; } @@ -508,7 +513,7 @@ static int elants_i2c_fastboot(struct i2c_client *client) static int elants_i2c_initialize(struct elants_data *ts) { struct i2c_client *client = ts->client; - int error, retry_cnt; + int error, error2, retry_cnt; const u8 hello_packet[] = { 0x55, 0x55, 0x55, 0x55 }; const u8 recov_packet[] = { 0x55, 0x55, 0x80, 0x80 }; u8 buf[HEADER_SIZE]; @@ -553,18 +558,21 @@ static int elants_i2c_initialize(struct elants_data *ts) } } + /* hw version is available even if device in recovery state */ + error2 = elants_i2c_query_hw_version(ts); if (!error) - error = elants_i2c_query_fw_id(ts); + error = error2; if (!error) error = elants_i2c_query_fw_version(ts); + if (!error) + error = elants_i2c_query_test_version(ts); + if (!error) + error = elants_i2c_query_bc_version(ts); + if (!error) + error = elants_i2c_query_ts_info(ts); - if (error) { + if (error) ts->iap_mode = ELAN_IAP_RECOVERY; - } else { - elants_i2c_query_test_version(ts); - elants_i2c_query_bc_version(ts); - elants_i2c_query_ts_info(ts); - } return 0; }