From patchwork Mon Mar 17 17:26:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Dyer X-Patchwork-Id: 3845221 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A60989F369 for ; Mon, 17 Mar 2014 17:34:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2459201FA for ; Mon, 17 Mar 2014 17:34:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF1F420114 for ; Mon, 17 Mar 2014 17:34:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756892AbaCQRe1 (ORCPT ); Mon, 17 Mar 2014 13:34:27 -0400 Received: from kdh-gw.itdev.co.uk ([89.21.227.133]:19851 "EHLO hermes.kdh.itdev.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756480AbaCQRdc (ORCPT ); Mon, 17 Mar 2014 13:33:32 -0400 Received: from juno.kdh.itdev.co.uk (andromeda.kdh.itdev.co.uk [192.168.1.19]) by hermes.kdh.itdev.co.uk (Postfix) with ESMTP id 85DC1862DE; Mon, 17 Mar 2014 17:27:03 +0000 (GMT) From: Nick Dyer To: Dmitry Torokhov Cc: Yufeng Shen , Daniel Kurtz , Henrik Rydberg , Joonyoung Shim , Alan Bowens , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Meerwald , Benson Leung , Olof Johansson , Nick Dyer Subject: [PATCH 07/22] Input: atmel_mxt_ts - wait for CHG after bootloader resets Date: Mon, 17 Mar 2014 17:26:40 +0000 Message-Id: <1395077215-10922-8-git-send-email-nick.dyer@itdev.co.uk> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395077215-10922-1-git-send-email-nick.dyer@itdev.co.uk> References: <1395077215-10922-1-git-send-email-nick.dyer@itdev.co.uk> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benson Leung Rather than msleep for MXT_RESET_TIME and MXT_FWRESET_TIME during the transition to bootloader mode and the transition back from app, wait for the CHG assert to indicate that the transition is done. This change replaces the msleep with a wait for completion that the mxt_interrupt handler signals. Also add CHG poll after last firmware frame - some bootloader versions will assert the interrupt line after the final frame, in testing this meant that the driver attempts to read the info block too early whilst the chip is still resetting. This improves firmware update time as we no longer wait longer than necessary for each reset. Signed-off-by: Benson Leung Signed-off-by: Daniel Kurtz Signed-off-by: Nick Dyer Acked-by: Yufeng Shen Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7f51d39..d5b3043 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -181,8 +181,8 @@ #define MXT_BACKUP_VALUE 0x55 #define MXT_BACKUP_TIME 50 /* msec */ #define MXT_RESET_TIME 200 /* msec */ - -#define MXT_FWRESET_TIME 175 /* msec */ +#define MXT_FW_RESET_TIME 3000 /* msec */ +#define MXT_FW_CHG_TIMEOUT 300 /* msec */ /* Command to unlock bootloader */ #define MXT_UNLOCK_CMD_MSB 0xaa @@ -375,7 +375,7 @@ recheck: * CHG assertion before reading the status byte. * Once the status byte has been read, the line is deasserted. */ - ret = mxt_wait_for_chg(data, 300); + ret = mxt_wait_for_chg(data, MXT_FW_CHG_TIMEOUT); if (ret) { /* * TODO: handle -ERESTARTSYS better by terminating @@ -1047,6 +1047,18 @@ static int mxt_load_fw(struct device *dev, const char *fn) dev_dbg(dev, "Updated %d bytes / %zd bytes\n", pos, fw->size); } + /* Wait for flash. */ + ret = mxt_wait_for_chg(data, MXT_FW_RESET_TIME); + if (ret) + goto disable_irq; + + /* + * Wait for device to reset. Some bootloader versions do not assert + * the CHG line after bootloading has finished, so ignore potential + * errors. + */ + mxt_wait_for_chg(data, MXT_FW_RESET_TIME); + data->in_bootloader = false; disable_irq: @@ -1075,10 +1087,6 @@ static ssize_t mxt_update_fw_store(struct device *dev, count = error; } else { dev_dbg(dev, "The firmware update succeeded\n"); - - /* Wait for reset */ - msleep(MXT_FWRESET_TIME); - mxt_free_object_table(data); mxt_initialize(data);