From patchwork Wed Dec 10 11:44:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harini Katakam X-Patchwork-Id: 5468131 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 5966C9F2E8 for ; Wed, 10 Dec 2014 11:48:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EF3520121 for ; Wed, 10 Dec 2014 11:48:06 +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 B889120114 for ; Wed, 10 Dec 2014 11:48:05 +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 1XyfiW-0003MT-9T; Wed, 10 Dec 2014 11:46:04 +0000 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyfiT-0003HH-Mb for linux-arm-kernel@lists.infradead.org; Wed, 10 Dec 2014 11:46:02 +0000 Received: by mail-ob0-f177.google.com with SMTP id va2so1974697obc.8 for ; Wed, 10 Dec 2014 03:45:39 -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=SItwZfYluyqz40iAoD1VCblrMdUx/B8kZqoYmJEF1DQ=; b=SEgYlhJOWBKySdL9RLfTce924agD1/CGqnOn3WpuyRzED5CVE8o4GCI1v4CavPBpcM YPyxi1PXUUFiqYkrfFWbzhLZngGPM8jSI9OfAKMF+F6VBrbLnztuidoNwXxtZuWb3XqX 5XhNuZyNfLFIuEcaGtg7j0js+6osmf6LCSVyq8M2zNedlP76Ovm0ie7904Ip9WvblDUP BwuKTkbRgbLQaQYSyyB2RYmWJUUFKnGkieDhONkaG3E0Db0JbfF0HZpXbtN52MGagiEN XoW7kCTUZeFlw0XeEC6r7BM3QRXHYYSe8V31wJQy5VOsYU3Q3oCrUfkzCcovWsinbBbF de8Q== X-Received: by 10.202.76.216 with SMTP id z207mr2035910oia.101.1418211939313; Wed, 10 Dec 2014 03:45:39 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id n8sm1865911obz.9.2014.12.10.03.45.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 10 Dec 2014 03:45:38 -0800 (PST) From: Harini Katakam To: wsa@the-dreams.de, mark.rutland@arm.com Subject: [PATCH v4 2/2] i2c: cadence: Check for errata condition involving master receive Date: Wed, 10 Dec 2014 17:14:44 +0530 Message-Id: <1418211884-5329-3-git-send-email-harinik@xilinx.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418211884-5329-1-git-send-email-harinik@xilinx.com> References: <1418211884-5329-1-git-send-email-harinik@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141210_034601_787795_61CE4558 X-CRM114-Status: GOOD ( 13.84 ) 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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, 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 --- 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 5f5d4fa..f9269a6 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -541,6 +541,20 @@ 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;