From patchwork Fri Nov 9 17:23:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 1721431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 35ADFDF264 for ; Fri, 9 Nov 2012 17:25:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TWsIk-0000IS-Ig; Fri, 09 Nov 2012 17:23:30 +0000 Received: from eusmtp01.atmel.com ([212.144.249.242]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TWsIg-0000Hk-Si for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2012 17:23:27 +0000 Received: from ibiza.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server id 14.2.318.1; Fri, 9 Nov 2012 18:22:54 +0100 From: To: , Subject: [PATCH] i2c: at91: fix SMBus quick command Date: Fri, 9 Nov 2012 18:23:17 +0100 Message-ID: <1352481797-3520-1-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121109_122327_206972_F136E156 X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: plagnioj@jcrosoft.com, N.Voss@weinmann.de, nicolas.ferre@atmel.com, Ludovic Desroches X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Ludovic Desroches SMBus command was not performed. This patch fixes this issue. The timeout log priority has been decreased to not make console dirty uselessly. Signed-off-by: Ludovic Desroches --- Hi Wolfram, It would be great if this patch could be included into 3.7. The driver was claiming that it supports SMBus quick command but it was not true. Moreover, with some IP versions, it could cause data corruption. I tested it with i2cdetect as you suggested. EEPROMs were detected but not other devices (lm75 and ds1337). I have exactly the same behavior by using i2c-gpio driver so I think there is no major issue on a driver point of view. Thanks. Regards. Ludovic drivers/i2c/busses/i2c-at91.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index aa59a25..a6670eb 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c @@ -39,6 +39,7 @@ #define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */ #define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */ #define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */ +#define AT91_TWI_QUICK 0x0040 /* SMBus quick command */ #define AT91_TWI_SWRST 0x0080 /* Software Reset */ #define AT91_TWI_MMR 0x0004 /* Master Mode Register */ @@ -212,7 +213,10 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev) INIT_COMPLETION(dev->cmd_complete); dev->transfer_status = 0; - if (dev->msg->flags & I2C_M_RD) { + + if (!dev->buf_len) { + at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK); + } else if (dev->msg->flags & I2C_M_RD) { unsigned start_flags = AT91_TWI_START; if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) { @@ -235,7 +239,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev) ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, dev->adapter.timeout); if (ret == 0) { - dev_err(dev->dev, "controller timed out\n"); + dev_dbg(dev->dev, "controller timed out\n"); at91_init_twi_bus(dev); return -ETIMEDOUT; }