From patchwork Fri Dec 12 04:18:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harini Katakam X-Patchwork-Id: 5478901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B97939F30B for ; Fri, 12 Dec 2014 04:22:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8CF3201EF for ; Fri, 12 Dec 2014 04:22:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 270DE201B9 for ; Fri, 12 Dec 2014 04:22:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XzHhZ-0006we-Su; Fri, 12 Dec 2014 04:19:37 +0000 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XzHhX-0006fp-1s for linux-arm-kernel@lists.infradead.org; Fri, 12 Dec 2014 04:19:35 +0000 Received: by mail-wg0-f46.google.com with SMTP id x13so8207042wgg.33 for ; Thu, 11 Dec 2014 20:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=phMtsqfb1KwCOQ/TsRwFffnzJsSZB6qVGFFPUY6GcQw=; b=KsINw+Q/YaVJFeC1XA2KJiEDiD4OKqryypDhx+LHe5YFLe3UcuA1AgbEEFeUwsic8A 1+ylh6KanD5+s6uT0+30Z+vbYNsr7ohirnP1w810M2ax2xQvqBf3pu2awAnvSEvdEDGQ QRK/TLwsyG+UJH6deyMVD9ASj4kkYC+sNgh0CvLf3k6tn4XJjB1aSyjBwtkMRuVqoPCu 3wgUOkc9hvqENrBeVqqvpzdMFIcAoOEUGij7XkTxW5OML5hYlR3vUJeW6ohPbUqV2zfV l8xqOrOkBO+fXux4PeXfy8kF+rHSn1X381BtS9t/fXsW/Pek0mN8fyjLejUfa4ByVtYY CtAQ== X-Received: by 10.194.79.199 with SMTP id l7mr23403094wjx.136.1418357953004; Thu, 11 Dec 2014 20:19:13 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id js5sm367661wid.11.2014.12.11.20.19.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Dec 2014 20:19:12 -0800 (PST) From: Harini Katakam To: wsa@the-dreams.de, mark.rutland@arm.com Subject: [PATCH v5 2/2] i2c: cadence: Check for errata condition involving master receive Date: Fri, 12 Dec 2014 09:48:27 +0530 Message-Id: <1418357907-4215-3-git-send-email-harinik@xilinx.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418357907-4215-1-git-send-email-harinik@xilinx.com> References: <1418357907-4215-1-git-send-email-harinik@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141211_201935_243214_3BE2B2BF X-CRM114-Status: GOOD ( 12.94 ) X-Spam-Score: -0.7 (/) Cc: harinik@xilinx.com, Vishnu Motghare , linux-kernel@vger.kernel.org, harinikatakamlinux@gmail.com, michal.simek@xilinx.com, soren.brinkmann@xilinx.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cadence I2C controller has the following bugs: - completion indication is not given to the driver at the end of a read/receive transfer with HOLD bit set. - Invalid read transaction are generated on the bus when HW timeout condition occurs with HOLD bit set. As a result of the above, if a set of messages to be transferred with repeated start includes any transfer following a read transfer, completion is never indicated and timeout occurs. Hence a check is implemented to return -EOPNOTSUPP for such sequences. Signed-off-by: Harini Katakam Signed-off-by: Vishnu Motghare --- v5: Make warning grepable in driver. v4: Use single dev_warn and make message grep-able. v3: Add warning in case of unsupported transfer. v2: Dont defeteature repeated start. Just check for unsupported conditions in the driver and return error. --- drivers/i2c/busses/i2c-cadence.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 5f5d4fa..6538c6c 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -541,6 +541,18 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, * processed with a repeated start. */ if (num > 1) { + /* + * This controller does not give completion interrupt after a + * master receive transfer if HOLD bit is set (repeated start), + * resulting in SW timeout. Hence, if a receive transfer is + * followed by any other transfer, an error is returned + * indicating that this sequence is not supported. + */ + for (count = 0; count < num-1; count++) { + if (msgs[count].flags & I2C_M_RD) + dev_warn(adap->dev.parent, "No support for repeated start when receive is followed by a transfer\n"); + return -EOPNOTSUPP; + } id->bus_hold_flag = 1; reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); reg |= CDNS_I2C_CR_HOLD;