From patchwork Sat Nov 22 22:52:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Cvek X-Patchwork-Id: 5360091 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 84F5DC11AC for ; Sat, 22 Nov 2014 23:04:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B66820154 for ; Sat, 22 Nov 2014 23:04:33 +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 1F39F20145 for ; Sat, 22 Nov 2014 23:04:32 +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 1XsJfy-0000U4-PT; Sat, 22 Nov 2014 23:01:10 +0000 Received: from bubo.tul.cz ([2001:718:1c01:16::aa]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XsJfv-0000Rk-NK for linux-arm-kernel@lists.infradead.org; Sat, 22 Nov 2014 23:01:08 +0000 Received: from [78.80.185.17] (78-80-185-17.tmcz.cz [78.80.185.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by bubo.tul.cz (Postfix) with ESMTPSA id 545761F000A; Sat, 22 Nov 2014 23:51:05 +0100 (CET) Message-ID: <54711397.9060601@tul.cz> Date: Sat, 22 Nov 2014 23:52:07 +0100 From: Petr Cvek User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131204 Thunderbird/17.0.11 MIME-Version: 1.0 To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] Add support for SCCB devices into PXA27x I2C controller X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141122_150107_931558_AA2BDC6B X-CRM114-Status: GOOD ( 14.20 ) X-Spam-Score: -0.0 (/) Cc: 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: , 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, 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 Add support for SCCB devices into PXA27x I2C controller. Fix generated START but no STOP for message without I2C_M_NOSTART flag. Add support for I2C_M_IGNORE_NAK flag. Signed-off-by: Petr Cvek --- drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) /* @@ -919,12 +926,15 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) icr |= ICR_ALDIE | ICR_TB; /* - * If this is the last byte of the last message, send - * a STOP. + * If this is the last byte of the last message or last byte + * or any message without I2C_M_NOSTART, send a STOP. */ - if (i2c->msg_ptr == i2c->msg->len && - i2c->msg_idx == i2c->msg_num - 1) - icr |= ICR_STOP; + if (((i2c->msg_ptr == i2c->msg->len) && + (!(i2c->msg->flags & I2C_M_NOSTART))) || + ((i2c->msg_ptr == i2c->msg->len) && + (i2c->msg_idx == i2c->msg_num - 1))) + icr |= ICR_STOP; + } else if (i2c->msg_idx < i2c->msg_num - 1) { /* * Next segment of the message. diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index be671f7..adad044 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) return; /* ignore */ } - if (isr & ISR_BED) { + /* + * Ignore NAK when flag I2C_M_IGNORE_NAK is present, + * this enables use of SCCB devices + */ + if ((isr & ISR_BED) && + (!((i2c->msg->flags & I2C_M_IGNORE_NAK) && + (isr & ISR_ACKNAK)))) { + int ret = BUS_ERROR;