From patchwork Wed Jul 6 12:12:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iiro Valkonen X-Patchwork-Id: 949512 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p66CD7Lp029704 for ; Wed, 6 Jul 2011 12:13:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753401Ab1GFMNG (ORCPT ); Wed, 6 Jul 2011 08:13:06 -0400 Received: from newsmtp5.atmel.com ([204.2.163.5]:62916 "EHLO sjogate2.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753316Ab1GFMNG (ORCPT ); Wed, 6 Jul 2011 08:13:06 -0400 Received: from csomb01.corp.atmel.com ([10.95.30.150]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id p66C9UlZ020781; Wed, 6 Jul 2011 05:09:43 -0700 (PDT) Received: from hammb01.corp.atmel.com ([10.142.130.20]) by csomb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 6 Jul 2011 06:12:43 -0600 Received: from [10.191.100.69] ([10.191.100.69]) by hammb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 6 Jul 2011 13:12:41 +0100 Message-ID: <4E145128.9060404@atmel.com> Date: Wed, 06 Jul 2011 15:12:24 +0300 From: Iiro Valkonen User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Dmitry Torokhov , Joonyoung Shim CC: linux-input@vger.kernel.org Subject: [PATCH 1/3 v3] Input: atmel_mxt_ts - Make wait-after-reset period compatible with all chips X-OriginalArrivalTime: 06 Jul 2011 12:12:41.0839 (UTC) FILETIME=[015687F0:01CC3BD6] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 06 Jul 2011 12:13:08 +0000 (UTC) The delay before the chip can be accessed after reset varies between different chips in maXTouch family. Waiting for 200ms and then monitoring the CHG (chip is ready when the line is low) is guaranteed to work with all chips. v3: Add a check for NULL read_chg() function, and add the read_chg() to platform files using this driver (currently only mach-goni.c) v2: At Dmitry's suggestion, add a timeout so we are not stuck looping endlessly in case the CHG is not going low. Signed-off-by: Iiro Valkonen --- arch/arm/mach-s5pv210/mach-goni.c | 6 ++++++ drivers/input/touchscreen/atmel_mxt_ts.c | 14 +++++++++++++- include/linux/i2c/atmel_mxt_ts.h | 1 + 3 files changed, 20 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c index 31d5aa7..196e92c 100644 --- a/arch/arm/mach-s5pv210/mach-goni.c +++ b/arch/arm/mach-s5pv210/mach-goni.c @@ -225,6 +225,11 @@ static void __init goni_radio_init(void) gpio_direction_output(gpio, 1); } +static u8 read_chg(void) +{ + return gpio_get_value(S5PV210_GPJ0(5)); +} + /* TSP */ static struct mxt_platform_data qt602240_platform_data = { .x_line = 17, @@ -236,6 +241,7 @@ static struct mxt_platform_data qt602240_platform_data = { .voltage = 2800000, /* 2.8V */ .orient = MXT_DIAGONAL, .irqflags = IRQF_TRIGGER_FALLING, + .read_chg = &read_chg, }; static struct s3c2410_platform_i2c i2c2_data __initdata = { diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 1e61387..99df3b7 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -170,7 +170,8 @@ #define MXT_BOOT_VALUE 0xa5 #define MXT_BACKUP_VALUE 0x55 #define MXT_BACKUP_TIME 25 /* msec */ -#define MXT_RESET_TIME 65 /* msec */ +#define MXT_RESET_TIME 200 /* msec */ +#define MXT_RESET_NOCHGREAD 400 /* msec */ #define MXT_FWRESET_TIME 175 /* msec */ @@ -792,6 +793,7 @@ static int mxt_initialize(struct mxt_data *data) struct i2c_client *client = data->client; struct mxt_info *info = &data->info; int error; + int reset_timeout = 0; u8 val; error = mxt_get_info(data); @@ -828,6 +830,16 @@ static int mxt_initialize(struct mxt_data *data) mxt_write_object(data, MXT_GEN_COMMAND, MXT_COMMAND_RESET, 1); msleep(MXT_RESET_TIME); + if (data->pdata->read_chg == NULL) { + msleep(MXT_RESET_NOCHGREAD); + } else { + while ((reset_timeout++ <= 100) && data->pdata->read_chg()) + msleep(2); + if (reset_timeout >= 100) { + dev_err(&client->dev, "No response after reset!\n"); + return -EIO; + } + } /* Update matrix size at info struct */ error = mxt_read_reg(client, MXT_MATRIX_X_SIZE, &val); diff --git a/include/linux/i2c/atmel_mxt_ts.h b/include/linux/i2c/atmel_mxt_ts.h index f027f7a..ef59c22 100644 --- a/include/linux/i2c/atmel_mxt_ts.h +++ b/include/linux/i2c/atmel_mxt_ts.h @@ -39,6 +39,7 @@ struct mxt_platform_data { unsigned int voltage; unsigned char orient; unsigned long irqflags; + u8(*read_chg) (void); }; #endif /* __LINUX_ATMEL_MXT_TS_H */