mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marc Reilly <marc@cpdesign.com.au>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] i2c-imx: sync with kernel's driver
Date: Fri, 14 Jan 2011 10:06:01 +0100	[thread overview]
Message-ID: <20110114090601.GC24373@pengutronix.de> (raw)
In-Reply-To: <201101141045.18241.marc@cpdesign.com.au>

On Fri, Jan 14, 2011 at 10:45:18AM +1100, Marc Reilly wrote:
> On Thursday, January 13, 2011 02:21:37 am Eric Bénard wrote:
> > strange behaviour was observed with actual driver : bus lock, probe of
> > absent adresses, wrong data read.
> > This patch sync the driver with linux's one and after a few tests, we
> > don't see anymore strange behaviour (tested on i.MX27).
> > 
> > Signed-off-by: Eric Bénard <eric@eukrea.com>
> 
> FWIW, This patch doesn't seem to break anything for me, but I also wasn't 
> seeing any problems (that I was aware of!).

I'll interpret this as an Acked-by.

Sascha

> 
> Cheers,
> Marc
> 
> > ---
> >  drivers/i2c/busses/i2c-imx.c |   35 ++++++++---------------------------
> >  1 files changed, 8 insertions(+), 27 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > index 266cb52..93e978e 100644
> > --- a/drivers/i2c/busses/i2c-imx.c
> > +++ b/drivers/i2c/busses/i2c-imx.c
> > @@ -151,7 +151,7 @@ static int i2c_imx_bus_busy(struct i2c_adapter
> > *adapter, int for_busy) break;
> >  		if (!for_busy && !(temp & I2SR_IBB))
> >  			break;
> > -		if (is_timeout(start, MSECOND)) {
> > +		if (is_timeout(start, 500 * MSECOND)) {
> >  			dev_err(adapter->dev,
> >  				 "<%s> timeout waiting for I2C bus %s\n",
> >  				 __func__,for_busy ? "busy" : "not busy");
> > @@ -170,34 +170,15 @@ static int i2c_imx_trx_complete(struct i2c_adapter
> > *adapter) start = get_time_ns();
> >  	while (1) {
> >  		unsigned int reg = readb(base + IMX_I2C_I2SR);
> > -		if (reg & I2SR_ICF)
> > -			break;
> > -
> > -		if (is_timeout(start, 100 * MSECOND)) {
> > -			dev_err(adapter->dev, "<%s> TXR timeout\n", __func__);
> > -			return -EIO;
> > -		}
> > -	}
> > -
> > -	return 0;
> > -}
> > -
> > -static int i2c_imx_wait_iif(struct i2c_adapter *adapter)
> > -{
> > -	unsigned long base = adapter->dev->map_base;
> > -	uint64_t start;
> > -
> > -	start = get_time_ns();
> > -	while (1) {
> > -		unsigned int reg = readb(base + IMX_I2C_I2SR);
> >  		if (reg & I2SR_IIF)
> >  			break;
> > 
> >  		if (is_timeout(start, 100 * MSECOND)) {
> > -			dev_err(adapter->dev, "<%s> IIF timeout\n", __func__);
> > +			dev_err(adapter->dev, "<%s> TXR timeout\n", __func__);
> >  			return -EIO;
> >  		}
> >  	}
> > +	writeb(0, base + IMX_I2C_I2SR);
> > 
> >  	return 0;
> >  }
> > @@ -277,9 +258,13 @@ static void i2c_imx_stop(struct i2c_adapter *adapter)
> >  		udelay(i2c_imx->disable_delay);
> >  	}
> > 
> > +	if (!i2c_imx->stopped) {
> > +		i2c_imx_bus_busy(adapter, 0);
> > +		i2c_imx->stopped = 1;
> > +	}
> > +
> >  	/* Disable I2C controller, and force our state to stopped */
> >  	writeb(0, base + IMX_I2C_I2CR);
> > -	i2c_imx->stopped = 1;
> >  }
> > 
> >  static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
> > @@ -379,10 +364,6 @@ static int i2c_imx_read(struct i2c_adapter *adapter,
> > struct i2c_msg *msgs) if (result)
> >  		return result;
> > 
> > -	result = i2c_imx_wait_iif(adapter);
> > -	if (result)
> > -		return result;
> > -
> >  	/* setup bus to read data */
> >  	temp = readb(base + IMX_I2C_I2CR);
> >  	temp &= ~I2CR_MTX;
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2011-01-14  9:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-12 15:21 Eric Bénard
2011-01-13 23:45 ` Marc Reilly
2011-01-14  9:06   ` Sascha Hauer [this message]

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=20110114090601.GC24373@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=marc@cpdesign.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox