950-0883-spi-dw-Handle-combined-tx-and-rx-messages.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 8a9c0607ce0daa91c48faefd70ea73bda54ed0ae Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Tue, 29 Nov 2022 10:09:54 +0000
  4. Subject: [PATCH] spi: dw: Handle combined tx and rx messages
  5. Signed-off-by: Phil Elwell <[email protected]>
  6. ---
  7. drivers/spi/spi-dw-core.c | 12 +++++++++---
  8. drivers/spi/spi-dw-mmio.c | 8 ++++++--
  9. 2 files changed, 15 insertions(+), 5 deletions(-)
  10. --- a/drivers/spi/spi-dw-core.c
  11. +++ b/drivers/spi/spi-dw-core.c
  12. @@ -244,8 +244,11 @@ static irqreturn_t dw_spi_transfer_handl
  13. */
  14. if (irq_status & DW_SPI_INT_TXEI) {
  15. dw_writer(dws);
  16. - if (!dws->tx_len)
  17. + if (!dws->tx_len) {
  18. dw_spi_mask_intr(dws, DW_SPI_INT_TXEI);
  19. + if (!dws->rx_len)
  20. + spi_finalize_current_transfer(dws->master);
  21. + }
  22. }
  23. return IRQ_HANDLED;
  24. @@ -372,8 +375,11 @@ static void dw_spi_irq_setup(struct dw_s
  25. dws->transfer_handler = dw_spi_transfer_handler;
  26. - imask = DW_SPI_INT_TXEI | DW_SPI_INT_TXOI |
  27. - DW_SPI_INT_RXUI | DW_SPI_INT_RXOI | DW_SPI_INT_RXFI;
  28. + imask = 0;
  29. + if (dws->tx_len)
  30. + imask |= DW_SPI_INT_TXEI | DW_SPI_INT_TXOI;
  31. + if (dws->rx_len)
  32. + imask |= DW_SPI_INT_RXUI | DW_SPI_INT_RXOI | DW_SPI_INT_RXFI;
  33. dw_spi_umask_intr(dws, imask);
  34. }
  35. --- a/drivers/spi/spi-dw-mmio.c
  36. +++ b/drivers/spi/spi-dw-mmio.c
  37. @@ -20,6 +20,7 @@
  38. #include <linux/property.h>
  39. #include <linux/regmap.h>
  40. #include <linux/reset.h>
  41. +#include <linux/interrupt.h>
  42. #include "spi-dw.h"
  43. @@ -280,8 +281,11 @@ static int dw_spi_mmio_probe(struct plat
  44. dws->paddr = mem->start;
  45. dws->irq = platform_get_irq(pdev, 0);
  46. - if (dws->irq < 0)
  47. - return dws->irq; /* -ENXIO */
  48. + if (dws->irq < 0) {
  49. + if (dws->irq != -ENXIO)
  50. + return dws->irq; /* -ENXIO */
  51. + dws->irq = IRQ_NOTCONNECTED;
  52. + }
  53. dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
  54. if (IS_ERR(dwsmmio->clk))