Commit 999c39a45f115a17f6b894e3a9cd894c598fb2e0

Authored by Michal Simek
Committed by Jagannadha Sutradharudu Teki
1 parent 22a240c32c

spi: xilinx: Move timeout calculation out of the loop

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>
Reviewed-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>

Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff

drivers/spi/xilinx_spi.c
... ... @@ -149,6 +149,7 @@
149 149 const unsigned char *txp = dout;
150 150 unsigned char *rxp = din;
151 151 unsigned rxecount = 17; /* max. 16 elements in FIFO, leftover 1 */
  152 + unsigned global_timeout;
152 153  
153 154 debug("%s: bus:%i cs:%i bitlen:%i bytes:%i flags:%lx\n", __func__,
154 155 slave->bus, slave->cs, bitlen, bytes, flags);
155 156  
... ... @@ -176,11 +177,12 @@
176 177 if (flags & SPI_XFER_BEGIN)
177 178 spi_cs_activate(slave);
178 179  
179   - while (bytes--) {
180   - unsigned timeout = /* at least 1usec or greater, leftover 1 */
181   - xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
  180 + /* at least 1usec or greater, leftover 1 */
  181 + global_timeout = xilspi->freq > XILSPI_MAX_XFER_BITS * 1000000 ? 2 :
182 182 (XILSPI_MAX_XFER_BITS * 1000000 / xilspi->freq) + 1;
183 183  
  184 + while (bytes--) {
  185 + unsigned timeout = global_timeout;
184 186 /* get Tx element from data out buffer and count up */
185 187 unsigned char d = txp ? *txp++ : CONFIG_XILINX_SPI_IDLE_VAL;
186 188 debug("%s: tx:%x ", __func__, d);