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: 413335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 006D214003E for ; Sun, 23 Nov 2014 10:00:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbaKVXAp (ORCPT ); Sat, 22 Nov 2014 18:00:45 -0500 Received: from bubo.tul.cz ([147.230.16.1]:51464 "EHLO bubo.tul.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbaKVXAp (ORCPT ); Sat, 22 Nov 2014 18:00:45 -0500 X-Greylist: delayed 574 seconds by postgrey-1.27 at vger.kernel.org; Sat, 22 Nov 2014 18:00:45 EST 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 CC: linux-i2c@vger.kernel.org Subject: [PATCH] Add support for SCCB devices into PXA27x I2C controller Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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;