q2spi-gsi.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __SPI_Q2SPI_GPI_H_
  6. #define __SPI_Q2SPI_GPI_H_
  7. /* Q2SPI Config0 TRE */
  8. #define MSM_GPI_Q2SPI_CONFIG0_TRE_DWORD0(tsn, pack, tdn, cs_mode, intr_pol, word_size) \
  9. (((tsn) << 27) | ((pack) << 24) | \
  10. ((tdn) << 14) | ((cs_mode) << 6) | ((intr_pol) << 5) | (word_size))
  11. #define MSM_GPI_Q2SPI_CONFIG0_TRE_DWORD1(tan, cs_clk_del, ssn) \
  12. ((tan) | ((cs_clk_del) << 8) | ((ssn) << 16))
  13. #define MSM_GPI_Q2SPI_CONFIG0_TRE_DWORD2(cn_delay, clk_src, clk_div) (((cn_delay) << 20) | \
  14. ((clk_src) << 16) | (clk_div))
  15. #define MSM_GPI_Q2SPI_CONFIG0_TRE_DWORD3(link_rx, bei, ieot, ieob, ch) \
  16. ((0x2 << 20) | (0x2 << 16) | ((link_rx) << 11) | ((bei) << 10) | \
  17. ((ieot) << 9) | ((ieob) << 8) | (ch))
  18. /* Q2SPI Go TRE */
  19. #define MSM_GPI_Q2SPI_GO_TRE_DWORD0(flags, cs, cmd) (((flags) << 17) | \
  20. ((cs) << 8) | (cmd))
  21. #define MSM_GPI_Q2SPI_GO_TRE_DWORD1 (0)
  22. #define MSM_GPI_Q2SPI_GO_TRE_DWORD2(rx_len) (rx_len)
  23. #define MSM_GPI_Q2SPI_GO_TRE_DWORD3(link_rx, bei, ieot, ieob, ch) ((0x2 << 20) | \
  24. (0x0 << 16) | ((link_rx) << 11) | ((bei) << 10) | ((ieot) << 9) | \
  25. ((ieob) << 8) | (ch))
  26. /**
  27. * struct q2spi_gsi - structure to store gsi information for q2spi driver
  28. *
  29. * @tx_c: TX DMA channel
  30. * @rx_c: RX DMA channel
  31. * @config0_tre: stores config0 tre info
  32. * @go_tre: stores go tre info
  33. * @tx_dma_tre: stores DMA TX tre info
  34. * @rx_dma_tre: stores DMA RX tre info
  35. * @tx_ev: control structure to config gpi dma engine via dmaengine_slave_config() for tx.
  36. * @rx_ev: control structure to config gpi dma engine via dmaengine_slave_config() for rx.
  37. * @tx_desc: async transaction descriptor for tx
  38. * @rx_desc: async transaction descriptor for rx
  39. * @tx_cb_param: gpi specific callback parameters to pass between gpi client and gpi engine for TX.
  40. * @rx_cb_param: gpi specific callback parameters to pass between gpi client and gpi engine for RX.
  41. * @chan_setup: flag to mark channel setup completion.
  42. * @tx_sg: sg table for TX transfers
  43. * @rx_sg: sg table for RX transfers
  44. * tx_cookie: Represents dma tx cookie
  45. * rx_cookie: Represents dma rx cookie
  46. * num_tx_eot: Represents number of TX End of Transfers
  47. * num_rx_eot: Represents number of RX End of Transfers
  48. * qup_gsi_err: flag to represent gsi error if any
  49. */
  50. struct q2spi_gsi {
  51. struct dma_chan *tx_c;
  52. struct dma_chan *rx_c;
  53. struct msm_gpi_tre config0_tre;
  54. struct msm_gpi_tre go_tre;
  55. struct msm_gpi_tre tx_dma_tre;
  56. struct msm_gpi_tre rx_dma_tre;
  57. struct msm_gpi_ctrl tx_ev;
  58. struct msm_gpi_ctrl rx_ev;
  59. struct dma_async_tx_descriptor *tx_desc;
  60. struct dma_async_tx_descriptor *rx_desc;
  61. struct dma_async_tx_descriptor *db_rx_desc;
  62. struct msm_gpi_dma_async_tx_cb_param tx_cb_param;
  63. struct msm_gpi_dma_async_tx_cb_param rx_cb_param;
  64. struct msm_gpi_dma_async_tx_cb_param db_rx_cb_param;
  65. bool chan_setup;
  66. struct scatterlist tx_sg[3];
  67. struct scatterlist rx_sg[3];
  68. dma_cookie_t tx_cookie;
  69. dma_cookie_t rx_cookie;
  70. int num_tx_eot;
  71. int num_rx_eot;
  72. bool qup_gsi_err;
  73. };
  74. #endif /* __SPI_Q2SPI_GPI_H_ */