From patchwork Tue Jan 13 18:34:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harini Katakam X-Patchwork-Id: 5623461 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10B01C058D for ; Tue, 13 Jan 2015 18:38:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EA192020F for ; Tue, 13 Jan 2015 18:38:45 +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 61B7F20131 for ; Tue, 13 Jan 2015 18:38:44 +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 1YB6Jj-00014m-My; Tue, 13 Jan 2015 18:35:51 +0000 Received: from mail-ob0-x232.google.com ([2607:f8b0:4003:c01::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YB6JV-0000mE-O4 for linux-arm-kernel@lists.infradead.org; Tue, 13 Jan 2015 18:35:38 +0000 Received: by mail-ob0-f178.google.com with SMTP id gq1so4017360obb.9 for ; Tue, 13 Jan 2015 10:35:15 -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; bh=/uA24QQHs8Elb9ITp3efqEcSn1UHAYgsydhBrsDJn50=; b=oLjg/NcrrC0Mn6+wY/XNkqTZmptSPG0unc0nv0+sOILR/RAE20miRjdttRxc3CiTtd 2fX/fgej8Kpc7hWzL/4BTZF4hkObZ5naKft9vqqUUhPWTmZOk7uT7Ff/AG2NSdOo+Nxc tRsunB2SA8oO/DDxUYiMJJXNFsXVTrwC+NQqnN9vJfIX6mGvFfhNdd7m2CqFe+inquaI scaqKPX7pEM1WkumJ/oGuUVrk93SPRdiVQBu3cG3leh9uwX+U49T4DvojgA8gKo67A5E aL7pEu+OcBzxnES2HXxn+9wM6cb/Pm8MYF5E28NwCjHMg0I8N4EZJ2tHO9cT9vngcp5p hbdA== X-Received: by 10.182.120.230 with SMTP id lf6mr21768150obb.39.1421174115417; Tue, 13 Jan 2015 10:35:15 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id g2sm2531973oem.11.2015.01.13.10.35.12 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 10:35:14 -0800 (PST) From: Harini Katakam To: wsa@the-dreams.de, mark.rutland@arm.com Subject: [PATCH v6] i2c: cadence: Check for errata condition involving master receive Date: Wed, 14 Jan 2015 00:04:59 +0530 Message-Id: <1421174099-19839-1-git-send-email-harinik@xilinx.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150113_103537_888141_9EF8A973 X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -0.7 (/) Cc: harinik@xilinx.com, 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 message following a read message, 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 --- v6: - Correct if condition - add braces to include both statements. - Modify comments and warning message. 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 5f5d4fa..c7be4fb 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -541,6 +541,19 @@ 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 message if HOLD bit is set (repeated start), + * resulting in SW timeout. Hence, if a receive message is + * followed by any other message, 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, "Can't do repeated start after a receive message\n"); + return -EOPNOTSUPP; + } + } id->bus_hold_flag = 1; reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); reg |= CDNS_I2C_CR_HOLD;