From patchwork Thu May 26 23:25:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: York Sun X-Patchwork-Id: 97636 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DF4B5B6F89 for ; Fri, 27 May 2011 09:26:11 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C301A2813F; Fri, 27 May 2011 01:26:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VO82yYrD0uAy; Fri, 27 May 2011 01:26:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D76A128142; Fri, 27 May 2011 01:26:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2E4C92813F for ; Fri, 27 May 2011 01:26:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o-y+UM1i-HwL for ; Fri, 27 May 2011 01:26:04 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from AM1EHSOBE005.bigfish.com (am1ehsobe005.messaging.microsoft.com [213.199.154.208]) by theia.denx.de (Postfix) with ESMTPS id 063462813D for ; Fri, 27 May 2011 01:26:02 +0200 (CEST) Received: from mail70-am1-R.bigfish.com (10.3.201.243) by AM1EHSOBE005.bigfish.com (10.3.204.25) with Microsoft SMTP Server id 14.1.225.22; Thu, 26 May 2011 23:26:01 +0000 Received: from mail70-am1 (localhost.localdomain [127.0.0.1]) by mail70-am1-R.bigfish.com (Postfix) with ESMTP id BC879134041B for ; Thu, 26 May 2011 23:26:01 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail70-am1 (localhost.localdomain [127.0.0.1]) by mail70-am1 (MessageSwitch) id 1306452361644742_29638; Thu, 26 May 2011 23:26:01 +0000 (UTC) Received: from AM1EHSMHS002.bigfish.com (unknown [10.3.201.243]) by mail70-am1.bigfish.com (Postfix) with ESMTP id 92D97F4804B for ; Thu, 26 May 2011 23:26:01 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS002.bigfish.com (10.3.207.102) with Microsoft SMTP Server (TLS) id 14.1.225.22; Thu, 26 May 2011 23:26:01 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.270.2; Thu, 26 May 2011 18:25:59 -0500 Received: from localhost.localdomain (vpn-10-214-200-8.ap.freescale.net [10.214.200.8]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p4QNPv9m000699; Thu, 26 May 2011 18:25:58 -0500 (CDT) From: York Sun To: Date: Fri, 27 May 2011 07:25:47 +0800 Message-ID: <1306452353-11611-1-git-send-email-yorksun@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH 1/7] powerpc/i2c: introduce CONFIG_I2C_TWR for setting tWR value X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: york EEPROM requires tWR for write cycle time. Since there is no other way to poll if the internal programming ends, wait for 5ms which is the max timing for AT24C01/02/04/08/16 by default. It can be overridden by defining CONFIG_I2C_TWR in configuration file if the slowest device has different write cycle time. Signed-off-by: York Sun --- README | 7 +++++++ drivers/i2c/fsl_i2c.c | 9 +++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/README b/README index 8bb9c8d..83a316c 100644 --- a/README +++ b/README @@ -1717,6 +1717,13 @@ The following options need to be configured: devices can use either method, but some require one or the other. + CONFIG_I2C_TWR + + defining this will override the default write cycle time + 5ms which is the default for AT24C01/02/4/08/16. If the + slowest I2C device has different write cycle time, this + option should be defined. The unit is microsecond. + - SPI Support: CONFIG_SPI Enables SPI driver (so far only tested with diff --git a/drivers/i2c/fsl_i2c.c b/drivers/i2c/fsl_i2c.c index cb13dee..d192b2a 100644 --- a/drivers/i2c/fsl_i2c.c +++ b/drivers/i2c/fsl_i2c.c @@ -42,6 +42,14 @@ #define CONFIG_I2C_TIMEOUT 10000 #endif +/* + * tWR is the write cycle time for EEPROM device + * in microseconds + */ +#ifndef CONFIG_I2C_TWR +#define CONFIG_I2C_TWR 5000 +#endif + #define I2C_READ_BIT 1 #define I2C_WRITE_BIT 0 @@ -416,6 +424,7 @@ i2c_write(u8 dev, uint addr, int alen, u8 *data, int length) if (i2c_wait4bus()) /* Wait until STOP */ debug("i2c_write: wait4bus timed out\n"); + udelay(CONFIG_I2C_TWR); if (i == length) return 0;