From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2] spi: exynos: Minimise access to SPI FIFO level
Date: Thu, 13 Jun 2013 01:29:10 +0530 [thread overview]
Message-ID: <51B8D30E.7080008@gmail.com> (raw)
In-Reply-To: <1369891651-28419-1-git-send-email-rajeshwari.s@samsung.com>
On 30-05-2013 10:57, Rajeshwari Shinde wrote:
> Accessing SPI registers is slow, but access to the FIFO level register
> in particular seems to be extraordinarily expensive (I measure up to
> 600ns). Perhaps it is required to synchronise with the SPI byte output
> logic which might run at 1/8th of the 40MHz SPI speed (just a guess).
>
> Reduce access to this register by filling up and emptying FIFOs
> more completely, rather than just one word each time around the inner
> loop.
>
> Since the rxfifo value will now likely be much greater that what we read
> before we fill the txfifo, we only fill the txfifo halfway. This is
> because if the txfifo is empty, but the rxfifo has data in it, then writing
> too much data to the txfifo may overflow the rxfifo as data arrives.
>
> This speeds up SPI flash reading from about 1MB/s to about 2MB/s on snow.
>
> Based on "[PATCH 0/2 V3] exynos: Support a delay after deactivate for SPI"
Please use the format i suggested on earlier patch
http://patchwork.ozlabs.org/patch/247451/
Thanks,
Jagan.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> ---
> Changes in V2:
> - Rebased on "[PATCH 0/2 V5] spi: Enable SPI_PREAMBLE Mode"
> drivers/spi/exynos_spi.c | 27 +++++++++++++++------------
> 1 files changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
> index deb32bd..bcca3d6 100644
> --- a/drivers/spi/exynos_spi.c
> +++ b/drivers/spi/exynos_spi.c
> @@ -259,24 +259,27 @@ static int spi_rx_tx(struct exynos_spi_slave *spi_slave, int todo,
>
> /* Keep the fifos full/empty. */
> spi_get_fifo_levels(regs, &rx_lvl, &tx_lvl);
> - if (tx_lvl < spi_slave->fifo_size && out_bytes) {
> + while (tx_lvl < spi_slave->fifo_size/2 && out_bytes) {
> temp = txp ? *txp++ : 0xff;
> writel(temp, ®s->tx_data);
> out_bytes--;
> + tx_lvl++;
> }
> if (rx_lvl > 0) {
> - temp = readl(®s->rx_data);
> - if (spi_slave->skip_preamble) {
> - if (temp == SPI_PREAMBLE_END_BYTE) {
> - spi_slave->skip_preamble = 0;
> - stopping = 0;
> + while (rx_lvl > 0) {
> + temp = readl(®s->rx_data);
> + if (spi_slave->skip_preamble) {
> + if (temp == SPI_PREAMBLE_END_BYTE) {
> + spi_slave->skip_preamble = 0;
> + stopping = 0;
> + }
> + } else {
> + if (rxp || stopping)
> + *rxp++ = temp;
> + in_bytes--;
> }
> - } else {
> - if (rxp || stopping)
> - *rxp++ = temp;
> - in_bytes--;
> - }
> - toread--;
> + toread--;
> + rx_lvl--;
> } else if (!toread) {
> /*
> * We have run out of input data, but haven't read
>
next prev parent reply other threads:[~2013-06-12 19:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 5:27 [U-Boot] [PATCH V2] spi: exynos: Minimise access to SPI FIFO level Rajeshwari Shinde
2013-06-12 19:59 ` Jagan Teki [this message]
2013-08-08 13:48 ` Jagan Teki
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=51B8D30E.7080008@gmail.com \
--to=jagannadh.teki@gmail.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 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.