public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mxs-i2c: Fix internal address byte order
Date: Tue, 1 May 2012 04:45:32 +0200	[thread overview]
Message-ID: <201205010445.32996.marex@denx.de> (raw)
In-Reply-To: <1334677065-6620-1-git-send-email-to-fleischer@t-online.de>

Dear Torsten Fleischer,

> Large EEPROMs, e.g. 24lc32, need 2 byte to address the internal memory.
> These devices require that the high byte of the internal address has to be
> written first.
> The mxs_i2c driver currently writes the address' low byte first.

Are you sure about it? Are you sure what you're seeing isn't FIFO overrun? 
Basically, how does your problem manifest? How did you test this? We've been 
having similar issues in Linux recently.

> 
> The following patch fixes the byte order of the internal address that
> should be written to the I2C device.
> 
> Signed-off-by: Torsten Fleischer <to-fleischer@t-online.de>
> 
> CC: Marek Vasut <marex@denx.de>
> CC: Stefano Babic <sbabic@denx.de>
> CC: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/i2c/mxs_i2c.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
> index c8fea32..48aaaa6 100644
> --- a/drivers/i2c/mxs_i2c.c
> +++ b/drivers/i2c/mxs_i2c.c
> @@ -97,7 +97,7 @@ void mxs_i2c_write(uchar chip, uint addr, int alen,
> 
>  	for (i = 0; i < alen; i++) {
>  		data >>= 8;
> -		data |= ((char *)&addr)[i] << 24;
> +		data |= ((char *)&addr)[alen - i - 1] << 24;
>  		if ((i & 3) == 2)
>  			writel(data, &i2c_regs->hw_i2c_data);
>  	}

Best regards,
Marek Vasut

  parent reply	other threads:[~2012-05-01  2:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 15:37 [U-Boot] [PATCH] mxs-i2c: Fix internal address byte order Torsten Fleischer
2012-04-17 20:30 ` Marek Vasut
2012-05-01  2:45 ` Marek Vasut [this message]
2012-05-07 14:59   ` Torsten Fleischer
2012-05-07 16:13     ` Marek Vasut
2012-05-09  9:41 ` Stefano Babic

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=201205010445.32996.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox