From patchwork Fri Dec 5 08:08:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harini Katakam X-Patchwork-Id: 5442631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 835FBBEEA8 for ; Fri, 5 Dec 2014 08:11:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A708C2035D for ; Fri, 5 Dec 2014 08:11:11 +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 D64942035C for ; Fri, 5 Dec 2014 08:11:10 +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 1Xwnwz-0003DJ-1P; Fri, 05 Dec 2014 08:09:17 +0000 Received: from mail-ie0-x230.google.com ([2607:f8b0:4001:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xwnwu-000370-1E for linux-arm-kernel@lists.infradead.org; Fri, 05 Dec 2014 08:09:12 +0000 Received: by mail-ie0-f176.google.com with SMTP id tr6so268302ieb.21 for ; Fri, 05 Dec 2014 00:08:54 -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=muosgw+Nkm0FlKHTan4d9QwrkyqR5iaHmEnw7+z2qmU=; b=KgQnMgOFiRy3EK3qTzhlLaxJIQpd+Z9G4T/+4RX64rdZo36x9/d0IdJ934TQf5vUws qPMEK+VBZPBBqbhYDoBCXBYcypKnPwrJs31dtl4TqSpWnuYVtCY/H/A2ebL78gQOmVxY GTLzglAbrv9LMNajL7nMnc0zV6Bbdi1TR3DDe4QzkBl8ma1QPgVwQ0CYt7ghSjFYNtmf agcGtrueTCHAF4MVbSH3jM/fp9RMZ0vSBpWvQnbC1Xf0S/j3S13kigyJLveZzOjP/f9T gs87br3b5jDFvaThD04CRiGDzVOFpoiEzoEHf8FKJP0NncL9QGHbLSSreXBTDAtnDV6k TV5g== X-Received: by 10.107.9.65 with SMTP id j62mr13833472ioi.57.1417766934781; Fri, 05 Dec 2014 00:08:54 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id cy6sm522744igc.21.2014.12.05.00.08.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 05 Dec 2014 00:08:53 -0800 (PST) From: Harini Katakam To: wsa@the-dreams.de, mark.rutland@arm.com Subject: [PATCH v3 2/2] i2c: cadence: Check for errata condition involving master receive Date: Fri, 5 Dec 2014 13:38:04 +0530 Message-Id: <1417766884-8383-3-git-send-email-harinik@xilinx.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1417766884-8383-1-git-send-email-harinik@xilinx.com> References: <1417766884-8383-1-git-send-email-harinik@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141205_000912_138957_F8D9ED80 X-CRM114-Status: GOOD ( 13.67 ) 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 Reviewed-by: Rajeev Kumar --- 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 5f5d4fa..3ea3b7a 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -541,6 +541,21 @@ 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\t"); + dev_warn(adap->dev.parent, + "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;