t7xx_cldma.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* SPDX-License-Identifier: GPL-2.0-only
  2. *
  3. * Copyright (c) 2021, MediaTek Inc.
  4. * Copyright (c) 2021-2022, Intel Corporation.
  5. *
  6. * Authors:
  7. * Haijun Liu <[email protected]>
  8. * Moises Veleta <[email protected]>
  9. * Ricardo Martinez <[email protected]>
  10. *
  11. * Contributors:
  12. * Amir Hanania <[email protected]>
  13. * Andy Shevchenko <[email protected]>
  14. * Sreehari Kancharla <[email protected]>
  15. */
  16. #ifndef __T7XX_CLDMA_H__
  17. #define __T7XX_CLDMA_H__
  18. #include <linux/bits.h>
  19. #include <linux/types.h>
  20. #define CLDMA_TXQ_NUM 8
  21. #define CLDMA_RXQ_NUM 8
  22. #define CLDMA_ALL_Q GENMASK(7, 0)
  23. /* Interrupt status bits */
  24. #define EMPTY_STATUS_BITMASK GENMASK(15, 8)
  25. #define TXRX_STATUS_BITMASK GENMASK(7, 0)
  26. #define EQ_STA_BIT_OFFSET 8
  27. #define L2_INT_BIT_COUNT 16
  28. #define EQ_STA_BIT(index) (BIT((index) + EQ_STA_BIT_OFFSET) & EMPTY_STATUS_BITMASK)
  29. #define TQ_ERR_INT_BITMASK GENMASK(23, 16)
  30. #define TQ_ACTIVE_START_ERR_INT_BITMASK GENMASK(31, 24)
  31. #define RQ_ERR_INT_BITMASK GENMASK(23, 16)
  32. #define RQ_ACTIVE_START_ERR_INT_BITMASK GENMASK(31, 24)
  33. #define CLDMA0_AO_BASE 0x10049000
  34. #define CLDMA0_PD_BASE 0x1021d000
  35. #define CLDMA1_AO_BASE 0x1004b000
  36. #define CLDMA1_PD_BASE 0x1021f000
  37. #define CLDMA_R_AO_BASE 0x10023000
  38. #define CLDMA_R_PD_BASE 0x1023d000
  39. /* CLDMA TX */
  40. #define REG_CLDMA_UL_START_ADDRL_0 0x0004
  41. #define REG_CLDMA_UL_START_ADDRH_0 0x0008
  42. #define REG_CLDMA_UL_CURRENT_ADDRL_0 0x0044
  43. #define REG_CLDMA_UL_CURRENT_ADDRH_0 0x0048
  44. #define REG_CLDMA_UL_STATUS 0x0084
  45. #define REG_CLDMA_UL_START_CMD 0x0088
  46. #define REG_CLDMA_UL_RESUME_CMD 0x008c
  47. #define REG_CLDMA_UL_STOP_CMD 0x0090
  48. #define REG_CLDMA_UL_ERROR 0x0094
  49. #define REG_CLDMA_UL_CFG 0x0098
  50. #define UL_CFG_BIT_MODE_36 BIT(5)
  51. #define UL_CFG_BIT_MODE_40 BIT(6)
  52. #define UL_CFG_BIT_MODE_64 BIT(7)
  53. #define UL_CFG_BIT_MODE_MASK GENMASK(7, 5)
  54. #define REG_CLDMA_UL_MEM 0x009c
  55. #define UL_MEM_CHECK_DIS BIT(0)
  56. /* CLDMA RX */
  57. #define REG_CLDMA_DL_START_CMD 0x05bc
  58. #define REG_CLDMA_DL_RESUME_CMD 0x05c0
  59. #define REG_CLDMA_DL_STOP_CMD 0x05c4
  60. #define REG_CLDMA_DL_MEM 0x0508
  61. #define DL_MEM_CHECK_DIS BIT(0)
  62. #define REG_CLDMA_DL_CFG 0x0404
  63. #define DL_CFG_UP_HW_LAST BIT(2)
  64. #define DL_CFG_BIT_MODE_36 BIT(10)
  65. #define DL_CFG_BIT_MODE_40 BIT(11)
  66. #define DL_CFG_BIT_MODE_64 BIT(12)
  67. #define DL_CFG_BIT_MODE_MASK GENMASK(12, 10)
  68. #define REG_CLDMA_DL_START_ADDRL_0 0x0478
  69. #define REG_CLDMA_DL_START_ADDRH_0 0x047c
  70. #define REG_CLDMA_DL_CURRENT_ADDRL_0 0x04b8
  71. #define REG_CLDMA_DL_CURRENT_ADDRH_0 0x04bc
  72. #define REG_CLDMA_DL_STATUS 0x04f8
  73. /* CLDMA MISC */
  74. #define REG_CLDMA_L2TISAR0 0x0810
  75. #define REG_CLDMA_L2TISAR1 0x0814
  76. #define REG_CLDMA_L2TIMR0 0x0818
  77. #define REG_CLDMA_L2TIMR1 0x081c
  78. #define REG_CLDMA_L2TIMCR0 0x0820
  79. #define REG_CLDMA_L2TIMCR1 0x0824
  80. #define REG_CLDMA_L2TIMSR0 0x0828
  81. #define REG_CLDMA_L2TIMSR1 0x082c
  82. #define REG_CLDMA_L3TISAR0 0x0830
  83. #define REG_CLDMA_L3TISAR1 0x0834
  84. #define REG_CLDMA_L2RISAR0 0x0850
  85. #define REG_CLDMA_L2RISAR1 0x0854
  86. #define REG_CLDMA_L3RISAR0 0x0870
  87. #define REG_CLDMA_L3RISAR1 0x0874
  88. #define REG_CLDMA_IP_BUSY 0x08b4
  89. #define IP_BUSY_WAKEUP BIT(0)
  90. #define CLDMA_L2TISAR0_ALL_INT_MASK GENMASK(15, 0)
  91. #define CLDMA_L2RISAR0_ALL_INT_MASK GENMASK(15, 0)
  92. /* CLDMA MISC */
  93. #define REG_CLDMA_L2RIMR0 0x0858
  94. #define REG_CLDMA_L2RIMR1 0x085c
  95. #define REG_CLDMA_L2RIMCR0 0x0860
  96. #define REG_CLDMA_L2RIMCR1 0x0864
  97. #define REG_CLDMA_L2RIMSR0 0x0868
  98. #define REG_CLDMA_L2RIMSR1 0x086c
  99. #define REG_CLDMA_BUSY_MASK 0x0954
  100. #define BUSY_MASK_PCIE BIT(0)
  101. #define BUSY_MASK_AP BIT(1)
  102. #define BUSY_MASK_MD BIT(2)
  103. #define REG_CLDMA_INT_MASK 0x0960
  104. /* CLDMA RESET */
  105. #define REG_INFRA_RST4_SET 0x0730
  106. #define RST4_CLDMA1_SW_RST_SET BIT(20)
  107. #define REG_INFRA_RST4_CLR 0x0734
  108. #define RST4_CLDMA1_SW_RST_CLR BIT(20)
  109. #define REG_INFRA_RST2_SET 0x0140
  110. #define RST2_PMIC_SW_RST_SET BIT(18)
  111. #define REG_INFRA_RST2_CLR 0x0144
  112. #define RST2_PMIC_SW_RST_CLR BIT(18)
  113. enum mtk_txrx {
  114. MTK_TX,
  115. MTK_RX,
  116. };
  117. enum t7xx_hw_mode {
  118. MODE_BIT_32,
  119. MODE_BIT_36,
  120. MODE_BIT_40,
  121. MODE_BIT_64,
  122. };
  123. struct t7xx_cldma_hw {
  124. enum t7xx_hw_mode hw_mode;
  125. void __iomem *ap_ao_base;
  126. void __iomem *ap_pdn_base;
  127. u32 phy_interrupt_id;
  128. };
  129. void t7xx_cldma_hw_irq_dis_txrx(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  130. enum mtk_txrx tx_rx);
  131. void t7xx_cldma_hw_irq_dis_eq(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  132. enum mtk_txrx tx_rx);
  133. void t7xx_cldma_hw_irq_en_txrx(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  134. enum mtk_txrx tx_rx);
  135. void t7xx_cldma_hw_irq_en_eq(struct t7xx_cldma_hw *hw_info, unsigned int qno, enum mtk_txrx tx_rx);
  136. unsigned int t7xx_cldma_hw_queue_status(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  137. enum mtk_txrx tx_rx);
  138. void t7xx_cldma_hw_init(struct t7xx_cldma_hw *hw_info);
  139. void t7xx_cldma_hw_resume_queue(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  140. enum mtk_txrx tx_rx);
  141. void t7xx_cldma_hw_start(struct t7xx_cldma_hw *hw_info);
  142. void t7xx_cldma_hw_start_queue(struct t7xx_cldma_hw *hw_info, unsigned int qno,
  143. enum mtk_txrx tx_rx);
  144. void t7xx_cldma_hw_tx_done(struct t7xx_cldma_hw *hw_info, unsigned int bitmask);
  145. void t7xx_cldma_hw_rx_done(struct t7xx_cldma_hw *hw_info, unsigned int bitmask);
  146. void t7xx_cldma_hw_stop_all_qs(struct t7xx_cldma_hw *hw_info, enum mtk_txrx tx_rx);
  147. void t7xx_cldma_hw_set_start_addr(struct t7xx_cldma_hw *hw_info,
  148. unsigned int qno, u64 address, enum mtk_txrx tx_rx);
  149. void t7xx_cldma_hw_reset(void __iomem *ao_base);
  150. void t7xx_cldma_hw_stop(struct t7xx_cldma_hw *hw_info, enum mtk_txrx tx_rx);
  151. unsigned int t7xx_cldma_hw_int_status(struct t7xx_cldma_hw *hw_info, unsigned int bitmask,
  152. enum mtk_txrx tx_rx);
  153. void t7xx_cldma_hw_restore(struct t7xx_cldma_hw *hw_info);
  154. void t7xx_cldma_clear_ip_busy(struct t7xx_cldma_hw *hw_info);
  155. bool t7xx_cldma_tx_addr_is_set(struct t7xx_cldma_hw *hw_info, unsigned int qno);
  156. #endif