003-spi-qup-Ensure-done-detection.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 4faba89e3ffbb1c5f6232651375b9b3212b50f02 Mon Sep 17 00:00:00 2001
  2. From: Andy Gross <agross@codeaurora.org>
  3. Date: Thu, 15 Jan 2015 17:56:02 -0800
  4. Subject: [PATCH] spi: qup: Ensure done detection
  5. This patch fixes an issue where a SPI transaction has completed, but the done
  6. condition is missed. This occurs because at the time of interrupt the
  7. MAX_INPUT_DONE_FLAG is not asserted. However, in the process of reading blocks
  8. of data from the FIFO, the last portion of data comes in.
  9. The opflags read at the beginning of the irq handler no longer matches the
  10. current opflag state. To get around this condition, the block read function
  11. should update the opflags so that done detection is correct after the return.
  12. Change-Id: If109e0eeb432f96000d765c4b34dbb2269f8093f
  13. Signed-off-by: Andy Gross <agross@codeaurora.org>
  14. ---
  15. drivers/spi/spi-qup.c | 12 +++++++-----
  16. 1 file changed, 7 insertions(+), 5 deletions(-)
  17. --- a/drivers/spi/spi-qup.c
  18. +++ b/drivers/spi/spi-qup.c
  19. @@ -298,7 +298,7 @@ static void spi_qup_fifo_write(struct sp
  20. }
  21. static void spi_qup_block_read(struct spi_qup *controller,
  22. - struct spi_transfer *xfer)
  23. + struct spi_transfer *xfer, u32 *opflags)
  24. {
  25. u32 data;
  26. u32 reads_per_blk = controller->in_blk_sz >> 2;
  27. @@ -327,10 +327,12 @@ static void spi_qup_block_read(struct sp
  28. /*
  29. * Due to extra stickiness of the QUP_OP_IN_SERVICE_FLAG during block
  30. - * reads, it has to be cleared again at the very end
  31. + * reads, it has to be cleared again at the very end. However, be sure
  32. + * to refresh opflags value because MAX_INPUT_DONE_FLAG may now be
  33. + * present and this is used to determine if transaction is complete
  34. */
  35. - if (readl_relaxed(controller->base + QUP_OPERATIONAL) &
  36. - QUP_OP_MAX_INPUT_DONE_FLAG)
  37. + *opflags = readl_relaxed(controller->base + QUP_OPERATIONAL);
  38. + if (*opflags & QUP_OP_MAX_INPUT_DONE_FLAG)
  39. writel_relaxed(QUP_OP_IN_SERVICE_FLAG,
  40. controller->base + QUP_OPERATIONAL);
  41. @@ -633,7 +635,7 @@ static irqreturn_t spi_qup_qup_irq(int i
  42. if (!controller->use_dma) {
  43. if (opflags & QUP_OP_IN_SERVICE_FLAG) {
  44. if (opflags & QUP_OP_IN_BLOCK_READ_REQ)
  45. - spi_qup_block_read(controller, xfer);
  46. + spi_qup_block_read(controller, xfer, &opflags);
  47. else
  48. spi_qup_fifo_read(controller, xfer);
  49. }