From patchwork Wed Dec 16 13:43:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 68362 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBI4ixoC005715 for ; Fri, 18 Dec 2009 04:46:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756030AbZLPNol (ORCPT ); Wed, 16 Dec 2009 08:44:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755931AbZLPNok (ORCPT ); Wed, 16 Dec 2009 08:44:40 -0500 Received: from smtp.nokia.com ([192.100.122.233]:22502 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753650AbZLPNoj (ORCPT ); Wed, 16 Dec 2009 08:44:39 -0500 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBGDiC7X030223; Wed, 16 Dec 2009 15:44:20 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Dec 2009 15:43:53 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 16 Dec 2009 15:43:52 +0200 Received: from esdhcp04087 (esdhcp041145.research.nokia.com [172.21.41.145]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBGDhmgn032734 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 16 Dec 2009 15:43:50 +0200 Received: from ash by esdhcp04087 with local (Exim 4.69) (envelope-from ) id 1NKuAN-0007GO-VV; Wed, 16 Dec 2009 15:43:47 +0200 From: Alexander Shishkin To: ben-linux@fluff.org Cc: linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, Alexander Shishkin Subject: [PATCH 1/2] omap i2c: make errata 1.153 workaround a separate function Date: Wed, 16 Dec 2009 15:43:04 +0200 Message-Id: <1260970986-26613-3-git-send-email-virtuoso@slind.org> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1260970986-26613-2-git-send-email-virtuoso@slind.org> References: <1260970986-26613-1-git-send-email-virtuoso@slind.org> <1260970986-26613-2-git-send-email-virtuoso@slind.org> X-OriginalArrivalTime: 16 Dec 2009 13:43:53.0097 (UTC) FILETIME=[CE3DFF90:01CA7E55] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 75bf3ad..ad8242a 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -671,6 +671,27 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id) #define omap_i2c_rev1_isr NULL #endif +/* + * OMAP3430 Errata 1.153: When an XRDY/XDR is hit, wait for XUDF before writing + * data to DATA_REG. Otherwise some data bytes can be lost while transferring + * them from the memory to the I2C interface. + */ +static int omap3430_workaround(struct omap_i2c_dev *dev, u16 *stat, int *err) +{ + while (!(*stat & OMAP_I2C_STAT_XUDF)) { + if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { + omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | + OMAP_I2C_STAT_XDR)); + *err |= OMAP_I2C_STAT_XUDF; + return -1; + } + cpu_relax(); + *stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); + } + + return 0; +} + static irqreturn_t omap_i2c_isr(int this_irq, void *dev_id) { @@ -794,25 +815,9 @@ complete: break; } - /* - * OMAP3430 Errata 1.153: When an XRDY/XDR - * is hit, wait for XUDF before writing data - * to DATA_REG. Otherwise some data bytes can - * be lost while transferring them from the - * memory to the I2C interface. - */ - - if (dev->rev <= OMAP_I2C_REV_ON_3430) { - while (!(stat & OMAP_I2C_STAT_XUDF)) { - if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { - omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); - err |= OMAP_I2C_STAT_XUDF; - goto complete; - } - cpu_relax(); - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); - } - } + if (dev->rev <= OMAP_I2C_REV_ON_3430 && + omap3430_workaround(dev, &stat, &err)) + goto complete; omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); }