From patchwork Fri Apr 4 16:32:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 3939731 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 D2D649F334 for ; Fri, 4 Apr 2014 16:49:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C67EB20382 for ; Fri, 4 Apr 2014 16:49:24 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 C49DE2022D for ; Fri, 4 Apr 2014 16:49:23 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW73y-0004Rn-TG; Fri, 04 Apr 2014 16:33:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW73G-0000Pa-Ji; Fri, 04 Apr 2014 16:33:10 +0000 Received: from ch1ehsobe002.messaging.microsoft.com ([216.32.181.182] helo=ch1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW73D-0000Ni-KH for linux-arm-kernel@lists.infradead.org; Fri, 04 Apr 2014 16:33:08 +0000 Received: from mail28-ch1-R.bigfish.com (10.43.68.245) by CH1EHSOBE015.bigfish.com (10.43.70.65) with Microsoft SMTP Server id 14.1.225.22; Fri, 4 Apr 2014 16:32:42 +0000 Received: from mail28-ch1 (localhost [127.0.0.1]) by mail28-ch1-R.bigfish.com (Postfix) with ESMTP id 91497200598; Fri, 4 Apr 2014 16:32:41 +0000 (UTC) X-Forefront-Antispam-Report: CIP:149.199.60.83; KIP:(null); UIP:(null); IPV:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI X-SpamScore: -2 X-BigFish: VPS-2(zz98dIc89bh936eI1432I4015Izz1f42h2148h1ee6h1de0h1fdah2149h2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6h208chzz1de098h8275bh1de097hz2fh95h839h93fhc61hd24hf0ah119dh1288h12a5h12a9h12bdh137ah13b6h1441h14ddh1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1b0ah224fh1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1fe8h1ff5h209eh2216h2336h2438h2461h2487h24d7h2516h2545h255eh25f6h2605h268bh26d3h906i2673i1155h) Received-SPF: pass (mail28-ch1: domain of xilinx.com designates 149.199.60.83 as permitted sender) client-ip=149.199.60.83; envelope-from=soren.brinkmann@xilinx.com; helo=xsj-gw1 ; helo=xsj-gw1 ; Received: from mail28-ch1 (localhost.localdomain [127.0.0.1]) by mail28-ch1 (MessageSwitch) id 1396629160355553_2234; Fri, 4 Apr 2014 16:32:40 +0000 (UTC) Received: from CH1EHSMHS005.bigfish.com (snatpool3.int.messaging.microsoft.com [10.43.68.226]) by mail28-ch1.bigfish.com (Postfix) with ESMTP id 47522440053; Fri, 4 Apr 2014 16:32:40 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by CH1EHSMHS005.bigfish.com (10.43.70.5) with Microsoft SMTP Server id 14.16.227.3; Fri, 4 Apr 2014 16:32:39 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1WW72o-0002bg-3z; Fri, 04 Apr 2014 09:32:42 -0700 Date: Fri, 4 Apr 2014 09:32:32 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Wolfram Sang Subject: Re: [PATCH v4 2/3] i2c: Add driver for Cadence I2C controller References: <1396547967-19260-1-git-send-email-soren.brinkmann@xilinx.com> <1396547967-19260-2-git-send-email-soren.brinkmann@xilinx.com> <20140404143847.GA5529@katana> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140404143847.GA5529@katana> User-Agent: Mutt/1.5.21 (2010-09-15) X-RCIS-Action: ALLOW Message-ID: <53e29fb2-2a42-4cbf-9c15-490d81ee0de4@CH1EHSMHS005.ehs.local> X-OriginatorOrg: xilinx.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140404_123307_775287_2D3DA5DD X-CRM114-Status: GOOD ( 20.88 ) X-Spam-Score: -2.6 (--) Cc: Mark Rutland , Harini Katakam , Russell King , Pawel Moll , Ian Campbell , Mike Looijmans , linux-doc@vger.kernel.org, Michal Simek , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , linux-i2c@vger.kernel.org, Rob Landley , Kumar Gala , Grant Likely , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On Fri, 2014-04-04 at 04:38PM +0200, Wolfram Sang wrote: > On Thu, Apr 03, 2014 at 10:59:26AM -0700, Soren Brinkmann wrote: > > Add a driver for the Cadence I2C controller. This controller is for > > example found in Xilinx Zynq. > > > > Signed-off-by: Soren Brinkmann > > Tested-by: Michal Simek > > Reviewed-by: Harini Katakam > > Only minor stuff, but since you resend anyhow because of 400kHz issue... > > > +static void cdns_i2c_mrecv(struct cdns_i2c *id) > > +{ > > + unsigned int ctrl_reg; > > + unsigned int isr_status; > > + > > + id->p_recv_buf = id->p_msg->buf; > > + id->recv_count = id->p_msg->len; > > + > > + /* Put the controller in master receive mode and clear the FIFO */ > > + ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); > > + ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO; > > + > > + if ((id->p_msg->flags & I2C_M_RECV_LEN) == I2C_M_RECV_LEN) > > 'if (id->p_msg->flags & I2C_M_RECV_LEN)' is enough. > > > + /* Report the other error interrupts to application as EIO */ > > + if (id->err_status & (CDNS_I2C_IXR_RX_UNF | > > + CDNS_I2C_IXR_TX_OVF | > > + CDNS_I2C_IXR_RX_OVF | > > + CDNS_I2C_IXR_NACK)) { > > + cdns_i2c_master_reset(adap); > > + return -EIO; > > + } > > NACK is returned as -ENXIO. Check 'Documentation/i2c/fault-codes' for > standard patterns. I'd think the rest is EIO, though. Okay, I'll put this into the next version: Thanks, Sören diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 43af8c351c8b..63f3f03ecc9b 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -311,7 +311,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO; - if ((id->p_msg->flags & I2C_M_RECV_LEN) == I2C_M_RECV_LEN) + if (id->p_msg->flags & I2C_M_RECV_LEN) id->recv_count = I2C_SMBUS_BLOCK_MAX + 1; /* @@ -531,12 +531,13 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, if (ret) return ret; - /* Report the other error interrupts to application as EIO */ - if (id->err_status & (CDNS_I2C_IXR_RX_UNF | - CDNS_I2C_IXR_TX_OVF | - CDNS_I2C_IXR_RX_OVF | - CDNS_I2C_IXR_NACK)) { + /* Report the other error interrupts to application */ + if (id->err_status) { cdns_i2c_master_reset(adap); + + if (id->err_status & CDNS_I2C_IXR_NACK) + return -ENXIO; + return -EIO; } }