public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop
@ 2014-01-22  8:48 Michal Simek
  2014-02-04 15:51 ` Michal Simek
  2014-02-04 17:16 ` Jagan Teki
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Simek @ 2014-01-22  8:48 UTC (permalink / raw)
  To: u-boot

Timeout calculation should be out of the data loop.
This patch increase spi bandwidth for 30%.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/spi/xilinx_spi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 5ac0184..56d99d1 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -149,6 +149,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	const unsigned char *txp = dout;
 	unsigned char *rxp = din;
 	unsigned rxecount = 17;	/* max. 16 elements in FIFO, leftover 1 */
+	unsigned global_timeout;

 	debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
 		slave->bus, slave->cs, bitlen, bytes, flags);
@@ -176,11 +177,12 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	if (flags & SPI_XFER_BEGIN)
 		spi_cs_activate(slave);

-	while (bytes--) {
-		unsigned timeout = /* at least 1usec or greater, leftover 1 */
-			xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
+	/* at least 1usec or greater, leftover 1 */
+	global_timeout = xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
 			(XILSPI_MAX_XFER_BITS * 1000000 / xilspi->freq) + 1;

+	while (bytes--) {
+		unsigned timeout = global_timeout;
 		/* get Tx element from data out buffer and count up */
 		unsigned char d = txp ? *txp++ : CONFIG_XILINX_SPI_IDLE_VAL;
 		debug("%s: tx:%x ", __func__, d);
--
1.8.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140122/8727475f/attachment.pgp>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop
  2014-01-22  8:48 [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop Michal Simek
@ 2014-02-04 15:51 ` Michal Simek
  2014-02-04 17:16 ` Jagan Teki
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Simek @ 2014-02-04 15:51 UTC (permalink / raw)
  To: u-boot

On 01/22/2014 09:48 AM, Michal Simek wrote:
> Timeout calculation should be out of the data loop.
> This patch increase spi bandwidth for 30%.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  drivers/spi/xilinx_spi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Jagan: Can you please add this patch to your custodian tree?

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140204/b5dc2367/attachment.pgp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop
  2014-01-22  8:48 [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop Michal Simek
  2014-02-04 15:51 ` Michal Simek
@ 2014-02-04 17:16 ` Jagan Teki
  1 sibling, 0 replies; 3+ messages in thread
From: Jagan Teki @ 2014-02-04 17:16 UTC (permalink / raw)
  To: u-boot

On Wed, Jan 22, 2014 at 2:18 PM, Michal Simek <michal.simek@xilinx.com> wrote:
> Timeout calculation should be out of the data loop.
> This patch increase spi bandwidth for 30%.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  drivers/spi/xilinx_spi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
> index 5ac0184..56d99d1 100644
> --- a/drivers/spi/xilinx_spi.c
> +++ b/drivers/spi/xilinx_spi.c
> @@ -149,6 +149,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>         const unsigned char *txp = dout;
>         unsigned char *rxp = din;
>         unsigned rxecount = 17; /* max. 16 elements in FIFO, leftover 1 */
> +       unsigned global_timeout;
>
>         debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
>                 slave->bus, slave->cs, bitlen, bytes, flags);
> @@ -176,11 +177,12 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
>         if (flags & SPI_XFER_BEGIN)
>                 spi_cs_activate(slave);
>
> -       while (bytes--) {
> -               unsigned timeout = /* at least 1usec or greater, leftover 1 */
> -                       xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
> +       /* at least 1usec or greater, leftover 1 */
> +       global_timeout = xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
>                         (XILSPI_MAX_XFER_BITS * 1000000 / xilspi->freq) + 1;
>
> +       while (bytes--) {
> +               unsigned timeout = global_timeout;
>                 /* get Tx element from data out buffer and count up */
>                 unsigned char d = txp ? *txp++ : CONFIG_XILINX_SPI_IDLE_VAL;
>                 debug("%s: tx:%x ", __func__, d);
> --
> 1.8.2.3
>

Applied to u-boot-spi/master

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-04 17:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22  8:48 [U-Boot] [PATCH] xilinx_spi: Move timeout calculation out of the loop Michal Simek
2014-02-04 15:51 ` Michal Simek
2014-02-04 17:16 ` Jagan Teki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox