From patchwork Tue Jul 21 15:15:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sonasath, Moiz" X-Patchwork-Id: 36551 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6LFFOfZ027559 for ; Tue, 21 Jul 2009 15:15:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755278AbZGUPPU (ORCPT ); Tue, 21 Jul 2009 11:15:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755277AbZGUPPU (ORCPT ); Tue, 21 Jul 2009 11:15:20 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:39407 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755273AbZGUPPT convert rfc822-to-8bit (ORCPT ); Tue, 21 Jul 2009 11:15:19 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n6LFFEMV022960; Tue, 21 Jul 2009 10:15:19 -0500 Received: from dlep20.itg.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n6LFFE5W026718; Tue, 21 Jul 2009 10:15:14 -0500 (CDT) Received: from dlee74.ent.ti.com (localhost [127.0.0.1]) by dlep20.itg.ti.com (8.12.11/8.12.11) with ESMTP id n6LFFDvs018743; Tue, 21 Jul 2009 10:15:13 -0500 (CDT) Received: from dlee06.ent.ti.com ([157.170.170.11]) by dlee74.ent.ti.com ([157.170.170.8]) with mapi; Tue, 21 Jul 2009 10:15:13 -0500 From: "Sonasath, Moiz" To: "linux-i2c@vger.kernel.org" CC: "linux-omap@vger.kernel.org" Date: Tue, 21 Jul 2009 10:15:12 -0500 Subject: [PATCH 3/3] [OMAP:I2C]OMAP3430 Silicon Errata 1.153 Thread-Topic: [PATCH 3/3] [OMAP:I2C]OMAP3430 Silicon Errata 1.153 Thread-Index: AcoKFYK3qccrv5q6S/2x6FaJkBeJlgAAHe7Q Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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. Do a Busy-wait for XUDF, before writing data to DATA_REG. While waiting if there is NACK | AL, set the appropriate error flags, ack the pending interrupts and return from the ISR. Signed-off-by: Moiz Sonasath Signed-off-by: Vikram pandita --- drivers/i2c/busses/i2c-omap.c | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 05b5e4c..8deaf87 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -672,9 +672,10 @@ omap_i2c_isr(int this_irq, void *dev_id) break; } + err = 0; +complete: omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); - err = 0; if (stat & OMAP_I2C_STAT_NACK) { err |= OMAP_I2C_STAT_NACK; omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, @@ -764,6 +765,27 @@ omap_i2c_isr(int this_irq, void *dev_id) "data to send\n"); 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 (cpu_is_omap34xx()) { + 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); + } + } + omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); } omap_i2c_ack_stat(dev,