From: Sascha Hauer <s.hauer@pengutronix.de>
To: Paul Fertser <fercerpav@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] imx_spi: rework transfer according to the API, fix compatibility with spi_write_then_read()
Date: Mon, 12 Sep 2011 12:20:16 +0200 [thread overview]
Message-ID: <20110912102016.GR31404@pengutronix.de> (raw)
In-Reply-To: <3c14dbb81191e6dcf1ecc7ef799834f52ad5f10a.1314685868.git.fercerpav@gmail.com>
Hi Paul,
On Tue, Aug 30, 2011 at 10:20:23AM +0400, Paul Fertser wrote:
> This code was tested barely with m25p80 driver, reading jedec id and some data
> from the chip worked fine.
>
> Signed-off-by: Paul Fertser <fercerpav@gmail.com>
> ---
> drivers/spi/imx_spi.c | 55 +++++++++++++++++++++++++++++++++++++++---------
> 1 files changed, 44 insertions(+), 11 deletions(-)
Applied to -next.
Thanks
Sascha
>
> diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
> index 6dc41b9..0d21fb3 100644
> --- a/drivers/spi/imx_spi.c
> +++ b/drivers/spi/imx_spi.c
> @@ -310,23 +310,56 @@ static void cspi_2_3_init(struct imx_spi *imx)
> }
> #endif
>
> +static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
> +{
> + struct imx_spi *imx = container_of(spi->master, struct imx_spi, master);
> + unsigned i;
> +
> + if (spi->bits_per_word <= 8) {
> + const u8 *tx_buf = t->tx_buf;
> + u8 *rx_buf = t->rx_buf;
> + u8 rx_val;
> +
> + for (i = 0; i < t->len; i++) {
> + rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
> + if (rx_buf)
> + rx_buf[i] = rx_val;
> + }
> + } else if (spi->bits_per_word <= 16) {
> + const u16 *tx_buf = t->tx_buf;
> + u16 *rx_buf = t->rx_buf;
> + u16 rx_val;
> +
> + for (i = 0; i < t->len >> 1; i++) {
> + rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
> + if (rx_buf)
> + rx_buf[i] = rx_val;
> + }
> + } else if (spi->bits_per_word <= 32) {
> + const u32 *tx_buf = t->tx_buf;
> + u32 *rx_buf = t->rx_buf;
> + u32 rx_val;
> +
> + for (i = 0; i < t->len >> 2; i++) {
> + rx_val = imx->xchg_single(imx, tx_buf ? tx_buf[i] : 0);
> + if (rx_buf)
> + rx_buf[i] = rx_val;
> + }
> + }
> +}
> +
> static int imx_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
> {
> - struct spi_master *master = spi->master;
> - struct imx_spi *imx = container_of(master, struct imx_spi, master);
> - struct spi_transfer *t = NULL;
> + struct imx_spi *imx = container_of(spi->master, struct imx_spi, master);
> + struct spi_transfer *t = NULL;
>
> imx->chipselect(spi, 1);
>
> - list_for_each_entry (t, &mesg->transfers, transfer_list) {
> - const u32 *txbuf = t->tx_buf;
> - u32 *rxbuf = t->rx_buf;
> - int i = 0;
> + mesg->actual_length = 0;
>
> - while(i < t->len >> 2) {
> - rxbuf[i] = imx->xchg_single(imx, txbuf[i]);
> - i++;
> - }
> + list_for_each_entry(t, &mesg->transfers, transfer_list) {
> + imx_spi_do_transfer(spi, t);
> + mesg->actual_length += t->len;
> }
>
> imx->chipselect(spi, 0);
> --
> 1.5.2.2
>
>
> _______________________________________________
> 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
prev parent reply other threads:[~2011-09-12 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-30 6:20 Paul Fertser
2011-08-30 6:30 ` [PATCH 2/2] imx25: imx_spi: support CSPI v0.7 as found on i.MX25 Paul Fertser
2011-09-12 10:21 ` Sascha Hauer
2011-08-30 6:30 ` [PATCH] " Paul Fertser
2011-09-12 10:20 ` 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=20110912102016.GR31404@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=fercerpav@gmail.com \
/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