hif.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _HIF_H_
  6. #define _HIF_H_
  7. #include "core.h"
  8. struct ath11k_hif_ops {
  9. u32 (*read32)(struct ath11k_base *sc, u32 address);
  10. void (*write32)(struct ath11k_base *sc, u32 address, u32 data);
  11. int (*read)(struct ath11k_base *ab, void *buf, u32 start, u32 end);
  12. void (*irq_enable)(struct ath11k_base *sc);
  13. void (*irq_disable)(struct ath11k_base *sc);
  14. int (*start)(struct ath11k_base *sc);
  15. void (*stop)(struct ath11k_base *sc);
  16. int (*power_up)(struct ath11k_base *sc);
  17. void (*power_down)(struct ath11k_base *sc);
  18. int (*suspend)(struct ath11k_base *ab);
  19. int (*resume)(struct ath11k_base *ab);
  20. int (*map_service_to_pipe)(struct ath11k_base *sc, u16 service_id,
  21. u8 *ul_pipe, u8 *dl_pipe);
  22. int (*get_user_msi_vector)(struct ath11k_base *ab, char *user_name,
  23. int *num_vectors, u32 *user_base_data,
  24. u32 *base_vector);
  25. void (*get_msi_address)(struct ath11k_base *ab, u32 *msi_addr_lo,
  26. u32 *msi_addr_hi);
  27. void (*ce_irq_enable)(struct ath11k_base *ab);
  28. void (*ce_irq_disable)(struct ath11k_base *ab);
  29. void (*get_ce_msi_idx)(struct ath11k_base *ab, u32 ce_id, u32 *msi_idx);
  30. };
  31. static inline void ath11k_hif_ce_irq_enable(struct ath11k_base *ab)
  32. {
  33. if (ab->hif.ops->ce_irq_enable)
  34. ab->hif.ops->ce_irq_enable(ab);
  35. }
  36. static inline void ath11k_hif_ce_irq_disable(struct ath11k_base *ab)
  37. {
  38. if (ab->hif.ops->ce_irq_disable)
  39. ab->hif.ops->ce_irq_disable(ab);
  40. }
  41. static inline int ath11k_hif_start(struct ath11k_base *sc)
  42. {
  43. return sc->hif.ops->start(sc);
  44. }
  45. static inline void ath11k_hif_stop(struct ath11k_base *sc)
  46. {
  47. sc->hif.ops->stop(sc);
  48. }
  49. static inline void ath11k_hif_irq_enable(struct ath11k_base *sc)
  50. {
  51. sc->hif.ops->irq_enable(sc);
  52. }
  53. static inline void ath11k_hif_irq_disable(struct ath11k_base *sc)
  54. {
  55. sc->hif.ops->irq_disable(sc);
  56. }
  57. static inline int ath11k_hif_power_up(struct ath11k_base *sc)
  58. {
  59. return sc->hif.ops->power_up(sc);
  60. }
  61. static inline void ath11k_hif_power_down(struct ath11k_base *sc)
  62. {
  63. sc->hif.ops->power_down(sc);
  64. }
  65. static inline int ath11k_hif_suspend(struct ath11k_base *ab)
  66. {
  67. if (ab->hif.ops->suspend)
  68. return ab->hif.ops->suspend(ab);
  69. return 0;
  70. }
  71. static inline int ath11k_hif_resume(struct ath11k_base *ab)
  72. {
  73. if (ab->hif.ops->resume)
  74. return ab->hif.ops->resume(ab);
  75. return 0;
  76. }
  77. static inline u32 ath11k_hif_read32(struct ath11k_base *sc, u32 address)
  78. {
  79. return sc->hif.ops->read32(sc, address);
  80. }
  81. static inline void ath11k_hif_write32(struct ath11k_base *sc, u32 address, u32 data)
  82. {
  83. sc->hif.ops->write32(sc, address, data);
  84. }
  85. static inline int ath11k_hif_read(struct ath11k_base *ab, void *buf,
  86. u32 start, u32 end)
  87. {
  88. if (!ab->hif.ops->read)
  89. return -EOPNOTSUPP;
  90. return ab->hif.ops->read(ab, buf, start, end);
  91. }
  92. static inline int ath11k_hif_map_service_to_pipe(struct ath11k_base *sc, u16 service_id,
  93. u8 *ul_pipe, u8 *dl_pipe)
  94. {
  95. return sc->hif.ops->map_service_to_pipe(sc, service_id, ul_pipe, dl_pipe);
  96. }
  97. static inline int ath11k_get_user_msi_vector(struct ath11k_base *ab, char *user_name,
  98. int *num_vectors, u32 *user_base_data,
  99. u32 *base_vector)
  100. {
  101. if (!ab->hif.ops->get_user_msi_vector)
  102. return -EOPNOTSUPP;
  103. return ab->hif.ops->get_user_msi_vector(ab, user_name, num_vectors,
  104. user_base_data,
  105. base_vector);
  106. }
  107. static inline void ath11k_get_msi_address(struct ath11k_base *ab, u32 *msi_addr_lo,
  108. u32 *msi_addr_hi)
  109. {
  110. if (!ab->hif.ops->get_msi_address)
  111. return;
  112. ab->hif.ops->get_msi_address(ab, msi_addr_lo, msi_addr_hi);
  113. }
  114. static inline void ath11k_get_ce_msi_idx(struct ath11k_base *ab, u32 ce_id,
  115. u32 *msi_data_idx)
  116. {
  117. if (ab->hif.ops->get_ce_msi_idx)
  118. ab->hif.ops->get_ce_msi_idx(ab, ce_id, msi_data_idx);
  119. else
  120. *msi_data_idx = ce_id;
  121. }
  122. #endif /* _HIF_H_ */