public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom <Tom.Rix@windriver.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] SPI: Fix 32 bit transfers in mxc_spi.c
Date: Sun, 07 Feb 2010 12:43:40 -0600	[thread overview]
Message-ID: <4B6F09DC.4020100@windriver.com> (raw)
In-Reply-To: <1263726375-4929-1-git-send-email-lilja.magnus@gmail.com>

Magnus Lilja wrote:
> Commit f9b6a1575d9f1ca192e4cb60e547aa66f08baa3f,  "i.MX31: fix SPI
> driver for shorter than 32 bit" broke 32 bit transfers. This patch
> makes single 32 bit transfer work again.
> 
> Transfer lengths that are known not to work will abort and print
> an error message.
> 
> Tested on i.MX31 Litekit and i.MX31 PDK using 32 bit transfers to
> the MC13783/ATLAS chip (using the 'date' command).
> 
> Signed-off-by: Magnus Lilja <lilja.magnus@gmail.com>
> ---
> 
> As discussed on the mailing list, Guennadi Liakhovetski thinks that
> all transfers > 16 bits are broken. This patch fixes the 32 bit case
> and makes sure the user is notified if a broken bitlength is used.
> 
>  drivers/spi/mxc_spi.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
> index fad9840..93c2bd7 100644
> --- a/drivers/spi/mxc_spi.c
> +++ b/drivers/spi/mxc_spi.c
> @@ -131,6 +131,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>  		return 1;
>  	}
>  
> +	/* This driver is currently partly broken, alert the user */
> +	if (bitlen > 16 && bitlen != 32) {

I believe this check can be improved
The transfer loops over 32 bit blks.
so bitlen that are multiples of 32 should work.
so

bitlen != 32

can change to

(bitlen % 32)

Tom

> +		printf("Error: SPI transfer with bitlen=%d is broken.\n",
> +		       bitlen);
> +		return 1;
> +	}
> +
>  	for (i = 0, in_l = (u32 *)din, out_l = (u32 *)dout;
>  	     i < n_blks;
>  	     i++, in_l++, out_l++, bitlen -= 32) {
> @@ -142,6 +149,8 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>  				*(u8 *)din = data;
>  			else if (bitlen < 17)
>  				*(u16 *)din = data;
> +			else
> +				*in_l = data;
>  		}
>  	}
>  

  parent reply	other threads:[~2010-02-07 18:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-17 11:06 [U-Boot] [PATCH v2] SPI: Fix 32 bit transfers in mxc_spi.c Magnus Lilja
2010-01-17 23:02 ` Wolfgang Denk
2010-01-23 17:08   ` Magnus Lilja
2010-02-07 18:43 ` Tom [this message]
2010-02-08 20:06   ` Magnus Lilja

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=4B6F09DC.4020100@windriver.com \
    --to=tom.rix@windriver.com \
    --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