From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] MX28: SPI: Fix CTRL0 not being written at end of DMA transfer
Date: Sat, 1 Sep 2012 03:31:15 +0200 [thread overview]
Message-ID: <201209010331.15889.marex@denx.de> (raw)
In-Reply-To: <1346273254-24326-1-git-send-email-marex@denx.de>
> The final DMA descriptor doesn't properly write CTRL0 register
> during the DMA transfer. Properly write CTRL0 to make sure the
> transmission is complete.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Otavio Salvador <otavio@ossystems.com.br>
> Cc: Stefano Babic <sbabic@denx.de>
!!
Please discard
> ---
> drivers/spi/mxs_spi.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
> index 168dbe4..5ee0ea1 100644
> --- a/drivers/spi/mxs_spi.c
> +++ b/drivers/spi/mxs_spi.c
> @@ -226,6 +226,7 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave
> *slave, uint32_t cache_data_count;
> int dmach;
> int tl;
> + int ret = 0;
>
> ALLOC_CACHE_ALIGN_BUFFER(struct mxs_dma_desc, desc, desc_count);
>
> @@ -302,12 +303,25 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave
> *slave, MXS_DMA_DESC_IRQ | MXS_DMA_DESC_DEC_SEM;
> if (flags & SPI_XFER_END) {
> ctrl0 &= ~SSP_CTRL0_LOCK_CS;
> - dp->cmd.pio_words[0] = ctrl0 | SSP_CTRL0_IGNORE_CRC;
> + ctrl0 |= SSP_CTRL0_IGNORE_CRC;
> + dp->cmd.pio_words[0] = ctrl0;
> }
> mxs_dma_desc_append(dmach, dp);
>
> if (mxs_dma_go(dmach))
> - return -EINVAL;
> + ret = -EINVAL;
> +
> + /*
> + * The DMA contains further hidden gems, like the last transfer
> + * not writing the CTRL0 PIO word properly. Write the PIO word
> + * directly here for proper operation. This issue was detected
> + * on S25FL064P chip by issuing:
> + *
> + * sf probe 2:0 ; sf read 0x42000000 0 0x800000 ; sf probe 2:0
> + *
> + * This resulted in garbled subsequent probe.
> + */
> + writel(ctrl0, &ssp_regs->hw_ssp_ctrl0_reg);
>
> /* The data arrived into DRAM, invalidate cache over them */
> if (!write) {
> @@ -315,7 +329,7 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave
> *slave, (uint32_t)(data + cache_data_count));
> }
>
> - return 0;
> + return ret;
> }
>
> int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
Best regards,
Marek Vasut
next prev parent reply other threads:[~2012-09-01 1:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-29 20:47 [U-Boot] [PATCH] MX28: SPI: Fix CTRL0 not being written at end of DMA transfer Marek Vasut
2012-09-01 1:31 ` Marek Vasut [this message]
2012-09-01 7:10 ` 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=201209010331.15889.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 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.