]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spi: zynqmp_qspi: Perform timeout irrespective of processor speed
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Wed, 5 Oct 2016 11:10:16 +0000 (16:40 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 26 Oct 2016 07:13:58 +0000 (09:13 +0200)
Perform QSPI timeout irrespective of processor speed. With this
the timeout is set to 100 seconds. This solves issue of timeout
on some boards with different processor speeds

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/spi/zynqmp_qspi.c

index 8e7c745389bb3dd7734bbcf7215200d5bde97a28..7caf67b6592a2c05f8176e5cd7fb76c2ee2ce001 100644 (file)
@@ -87,6 +87,8 @@
 #define ZYNQMP_QSPI_DMA_ALIGN  0x4
 #define ZYNQMP_QSPI_MAX_BAUD_RATE_VAL  7
 
+#define ZYNQMP_QSPI_TIMEOUT    100000000
+
 /* QSPI register offsets */
 struct zynqmp_qspi_regs {
        u32 confr;      /* 0x00 */
@@ -388,7 +390,7 @@ static int zynqmp_qspi_set_mode(struct udevice *bus, uint mode)
 static int zynqmp_qspi_fill_tx_fifo(struct zynqmp_qspi_priv *priv, u32 size)
 {
        u32 data;
-       u32 timeout = 10000000;
+       u32 timeout = ZYNQMP_QSPI_TIMEOUT;
        struct zynqmp_qspi_regs *regs = priv->regs;
        u32 *buf = (u32 *)priv->tx_buf;
        u32 len = size;
@@ -427,11 +429,12 @@ static int zynqmp_qspi_fill_tx_fifo(struct zynqmp_qspi_priv *priv, u32 size)
                                size = 0;
                        }
                } else {
+                       udelay(1);
                        timeout--;
                }
        }
        if (!timeout) {
-               debug("zynqmp_qspi_fill_tx_fifo: Timeout\n");
+               printf("zynqmp_qspi_fill_tx_fifo: Timeout\n");
                return -1;
        }
 
@@ -535,7 +538,7 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv,
 {
        u32 addr;
        u32 size, len;
-       u32 timeout = 10000000;
+       u32 timeout = ZYNQMP_QSPI_TIMEOUT;
        u32 actuallen = priv->len;
        struct zynqmp_qspi_dma_regs *dma_regs = priv->dma_regs;
 
@@ -565,6 +568,7 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv,
                               &dma_regs->dmaisr);
                        break;
                }
+               udelay(1);
                timeout--;
        }
 
@@ -572,7 +576,7 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv,
              (unsigned long)buf, (unsigned long)priv->rx_buf, *buf,
              actuallen);
        if (!timeout) {
-               debug("DMA Timeout:0x%x\n", readl(&dma_regs->dmaisr));
+               printf("DMA Timeout:0x%x\n", readl(&dma_regs->dmaisr));
                return -1;
        }