All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Felipe Balbi <balbi@ti.com>
Cc: linux-i2c@vger.kernel.org, Wolfram Sang <w.sang@pengutronix.de>,
	"Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
	Jean Delvare <khali@linux-fr.org>,
	dirk.brandewie@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] i2c-designware: always set the STOP bit after last byte
Date: Thu, 17 Jan 2013 12:42:47 +0200	[thread overview]
Message-ID: <20130117104247.GU2239@intel.com> (raw)
In-Reply-To: <20130117103248.GL10814@arwen.pp.htv.fi>

On Thu, Jan 17, 2013 at 12:32:48PM +0200, Felipe Balbi wrote:
> Hi,
> 
> On Thu, Jan 17, 2013 at 12:31:05PM +0200, Mika Westerberg wrote:
> > If IC_EMPTYFIFO_HOLD_MASTER_EN is set to one, the DesignWare I2C controller
> > doesn't generate STOP on the bus when the FIFO is empty. This violates the
> > rules of Linux I2C stack as it requires that the STOP is issued once the
> > i2c_transfer() is finished.
> > 
> > However, there is no way to detect this from the hardware registers, so we
> > must make sure that the STOP bit is always set once the last byte of the
> > last message is transferred.
> > 
> > This patch is based on the work of Dirk Brandewie.
> > 
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > ---
> >  drivers/i2c/busses/i2c-designware-core.c |   16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
> > index f5258c2..94fd818 100644
> > --- a/drivers/i2c/busses/i2c-designware-core.c
> > +++ b/drivers/i2c/busses/i2c-designware-core.c
> > @@ -413,11 +413,23 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
> >  		rx_limit = dev->rx_fifo_depth - dw_readl(dev, DW_IC_RXFLR);
> >  
> >  		while (buf_len > 0 && tx_limit > 0 && rx_limit > 0) {
> > +			u32 cmd = 0;
> > +
> > +			/*
> > +			 * If IC_EMPTYFIFO_HOLD_MASTER_EN is set we must
> > +			 * manually set the stop bit. However, it cannot be
> > +			 * detected from the registers so we set it always
> > +			 * when writing/reading the last byte.
> > +			 */
> > +			if (dev->msg_write_idx == dev->msgs_num - 1 &&
> > +			    buf_len == 1)
> > +				cmd |= BIT(9);
> > +
> >  			if (msgs[dev->msg_write_idx].flags & I2C_M_RD) {
> > -				dw_writel(dev, 0x100, DW_IC_DATA_CMD);
> > +				dw_writel(dev, cmd | 0x100, DW_IC_DATA_CMD);
> >  				rx_limit--;
> >  			} else
> > -				dw_writel(dev, *buf++, DW_IC_DATA_CMD);
> > +				dw_writel(dev, cmd | *buf++, DW_IC_DATA_CMD);
> 
> also need to send STP bit if I2C_M_STOP is set.

True but only if the driver exposes I2C_FUNC_PROTOCOL_MANGLING, which is
not done in this driver.

  reply	other threads:[~2013-01-17 10:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 10:31 [PATCH 0/4] i2c-designware: add Intel Lynxpoint support Mika Westerberg
2013-01-17 10:31 ` Mika Westerberg
2013-01-17 10:31 ` [PATCH 2/4] i2c-designware: always set the STOP bit after last byte Mika Westerberg
2013-01-17 10:32   ` Felipe Balbi
2013-01-17 10:32     ` Felipe Balbi
2013-01-17 10:42     ` Mika Westerberg [this message]
     [not found]       ` <20130117104247.GU2239-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-01-17 10:43         ` Felipe Balbi
2013-01-17 10:43           ` Felipe Balbi
2013-01-17 10:31 ` [PATCH 3/4] i2c-designware: add minimal support for runtime PM Mika Westerberg
2013-01-17 10:31 ` [PATCH 4/4] i2c-designware: add support for Intel Lynxpoint Mika Westerberg
     [not found] ` <1358418667-4533-1-git-send-email-mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2013-01-17 10:31   ` [PATCH 1/4] i2c-designware: add missing MODULE_LICENSE Mika Westerberg
2013-01-17 10:31     ` Mika Westerberg
2013-01-24  7:28   ` [PATCH 0/4] i2c-designware: add Intel Lynxpoint support Wolfram Sang
2013-01-24  7:28     ` Wolfram Sang
     [not found]     ` <20130124072846.GO8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org>
2013-01-24  9:18       ` Mika Westerberg
2013-01-24  9:18         ` Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130117104247.GU2239@intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=balbi@ti.com \
    --cc=ben-linux@fluff.org \
    --cc=dirk.brandewie@gmail.com \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w.sang@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.