multibus.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * Copyright (c) 2016-2018, 2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _MULTIBUS_H_
  19. #define _MULTIBUS_H_
  20. #include "osdep.h"
  21. #include "qdf_status.h"
  22. #include "hif_debug.h"
  23. struct hif_softc;
  24. struct hif_exec_context;
  25. struct hif_bus_ops {
  26. QDF_STATUS (*hif_bus_open)(struct hif_softc *hif_sc,
  27. enum qdf_bus_type bus_type);
  28. void (*hif_bus_close)(struct hif_softc *hif_sc);
  29. void (*hif_bus_prevent_linkdown)(struct hif_softc *hif_sc, bool flag);
  30. void (*hif_reset_soc)(struct hif_softc *hif_sc);
  31. int (*hif_bus_early_suspend)(struct hif_softc *hif_ctx);
  32. int (*hif_bus_late_resume)(struct hif_softc *hif_ctx);
  33. int (*hif_bus_suspend)(struct hif_softc *hif_ctx);
  34. int (*hif_bus_resume)(struct hif_softc *hif_ctx);
  35. int (*hif_bus_suspend_noirq)(struct hif_softc *hif_ctx);
  36. int (*hif_bus_resume_noirq)(struct hif_softc *hif_ctx);
  37. int (*hif_target_sleep_state_adjust)(struct hif_softc *scn,
  38. bool sleep_ok, bool wait_for_it);
  39. void (*hif_disable_isr)(struct hif_softc *hif_sc);
  40. void (*hif_nointrs)(struct hif_softc *hif_sc);
  41. QDF_STATUS (*hif_enable_bus)(struct hif_softc *hif_sc,
  42. struct device *dev,
  43. void *bdev,
  44. const struct hif_bus_id *bid,
  45. enum hif_enable_type type);
  46. void (*hif_disable_bus)(struct hif_softc *hif_sc);
  47. #ifdef FEATURE_RUNTIME_PM
  48. struct hif_runtime_pm_ctx *(*hif_bus_get_rpm_ctx)(
  49. struct hif_softc *hif_sc);
  50. struct device *(*hif_bus_get_dev)(struct hif_softc *hif_sc);
  51. #endif
  52. int (*hif_bus_configure)(struct hif_softc *hif_sc);
  53. QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc,
  54. int opcode, void *config, uint32_t config_len);
  55. void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc);
  56. void (*hif_claim_device)(struct hif_softc *hif_sc);
  57. void (*hif_shutdown_device)(struct hif_softc *hif_sc);
  58. void (*hif_stop)(struct hif_softc *hif_sc);
  59. void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc);
  60. void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id);
  61. void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id);
  62. int (*hif_grp_irq_configure)(struct hif_softc *hif_sc,
  63. struct hif_exec_context *exec);
  64. int (*hif_dump_registers)(struct hif_softc *hif_sc);
  65. void (*hif_dump_target_memory)(struct hif_softc *hif_sc,
  66. void *ramdump_base,
  67. uint32_t address, uint32_t size);
  68. uint32_t (*hif_reg_read32)(struct hif_softc *hif_sc,
  69. uint32_t offset);
  70. void (*hif_reg_write32)(struct hif_softc *hif_sc,
  71. uint32_t offset,
  72. uint32_t value);
  73. void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc,
  74. qdf_shared_mem_t **ce_sr,
  75. uint32_t *sr_ring_size,
  76. qdf_dma_addr_t *reg_paddr);
  77. void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc);
  78. void (*hif_enable_power_management)(struct hif_softc *hif_ctx,
  79. bool is_packet_log_enabled);
  80. void (*hif_disable_power_management)(struct hif_softc *hif_ctx);
  81. void (*hif_display_stats)(struct hif_softc *hif_ctx);
  82. void (*hif_clear_stats)(struct hif_softc *hif_ctx);
  83. void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled,
  84. int rx_bundle_cnt);
  85. int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx);
  86. int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id);
  87. int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset);
  88. bool (*hif_needs_bmi)(struct hif_softc *hif_sc);
  89. void (*hif_config_irq_affinity)(struct hif_softc *hif_sc);
  90. int (*hif_config_irq_by_ceid)(struct hif_softc *hif_sc, int ce_id);
  91. void (*hif_log_bus_info)(struct hif_softc *scn, uint8_t *data,
  92. unsigned int *offset);
  93. };
  94. #ifdef HIF_SNOC
  95. QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc);
  96. int hif_snoc_get_context_size(void);
  97. #else
  98. static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc)
  99. {
  100. hif_warn("not supported");
  101. return QDF_STATUS_E_NOSUPPORT;
  102. }
  103. /**
  104. * hif_snoc_get_context_size() - dummy when snoc isn't supported
  105. *
  106. * Return: 0 as an invalid size to indicate no support
  107. */
  108. static inline int hif_snoc_get_context_size(void)
  109. {
  110. return 0;
  111. }
  112. #endif /* HIF_SNOC */
  113. #ifdef HIF_PCI
  114. QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc);
  115. QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc);
  116. int hif_pci_get_context_size(void);
  117. #else
  118. static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
  119. {
  120. hif_warn("not supported");
  121. return QDF_STATUS_E_NOSUPPORT;
  122. }
  123. static inline
  124. QDF_STATUS hif_update_irq_ops_with_pci(struct hif_softc *hif_sc)
  125. {
  126. hif_err("not supported");
  127. return QDF_STATUS_E_NOSUPPORT;
  128. }
  129. /**
  130. * hif_pci_get_context_size() - dummy when pci isn't supported
  131. *
  132. * Return: 0 as an invalid size to indicate no support
  133. */
  134. static inline int hif_pci_get_context_size(void)
  135. {
  136. return 0;
  137. }
  138. #endif /* HIF_PCI */
  139. #ifdef HIF_IPCI
  140. /**
  141. * hif_initialize_ipci_ops() - initialize the pci ops
  142. * @hif_sc: pointer to hif context
  143. *
  144. * Return: QDF_STATUS_SUCCESS
  145. */
  146. QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc);
  147. /**
  148. * hif_ipci_get_context_size() - return the size of the ipci context
  149. *
  150. * Return the size of the context. (0 for invalid bus)
  151. */
  152. int hif_ipci_get_context_size(void);
  153. #else
  154. static inline QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc)
  155. {
  156. hif_warn("not supported");
  157. return QDF_STATUS_E_NOSUPPORT;
  158. }
  159. /**
  160. * hif_ipci_get_context_size() - dummy when ipci isn't supported
  161. *
  162. * Return: 0 as an invalid size to indicate no support
  163. */
  164. static inline int hif_ipci_get_context_size(void)
  165. {
  166. return 0;
  167. }
  168. #endif /* HIF_IPCI */
  169. #ifdef HIF_AHB
  170. QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops);
  171. int hif_ahb_get_context_size(void);
  172. #else
  173. /**
  174. * hif_initialize_ahb_ops() - dummy for when ahb not supported
  175. *
  176. * Return: QDF_STATUS_E_NOSUPPORT
  177. */
  178. static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops)
  179. {
  180. hif_warn("not supported");
  181. return QDF_STATUS_E_NOSUPPORT;
  182. }
  183. /**
  184. * hif_ahb_get_context_size() - dummy for when ahb not supported
  185. *
  186. * Return: 0 as an invalid size to indicate no support
  187. */
  188. static inline int hif_ahb_get_context_size(void)
  189. {
  190. return 0;
  191. }
  192. #endif
  193. #ifdef HIF_SDIO
  194. QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc);
  195. int hif_sdio_get_context_size(void);
  196. #else
  197. /**
  198. * hif_initialize_sdio_ops() - dummy for when sdio not supported
  199. *
  200. * Return: QDF_STATUS_E_NOSUPPORT
  201. */
  202. static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc)
  203. {
  204. hif_warn("not supported");
  205. return QDF_STATUS_E_NOSUPPORT;
  206. }
  207. /**
  208. * hif_sdio_get_context_size() - dummy when sdio isn't supported
  209. *
  210. * Return: 0 as an invalid size to indicate no support
  211. */
  212. static inline int hif_sdio_get_context_size(void)
  213. {
  214. return 0;
  215. }
  216. #endif /* HIF_SDIO */
  217. int hif_grp_irq_configure(struct hif_softc *hif_sc,
  218. struct hif_exec_context *hif_exec);
  219. #ifdef HIF_USB
  220. QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops);
  221. int hif_usb_get_context_size(void);
  222. #else
  223. static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops)
  224. {
  225. hif_warn("not supported");
  226. return QDF_STATUS_E_NOSUPPORT;
  227. }
  228. /**
  229. * hif_usb_get_context_size() - dummy when usb isn't supported
  230. *
  231. * Return: 0 as an invalid size to indicate no support
  232. */
  233. static inline int hif_usb_get_context_size(void)
  234. {
  235. return 0;
  236. }
  237. #endif /* HIF_USB */
  238. /**
  239. * hif_config_irq_affinity() - Set IRQ affinity for WLAN IRQs
  240. * @hif_sc - hif context
  241. *
  242. * Set IRQ affinity hint for WLAN IRQs in order to affine to
  243. * gold cores.
  244. *
  245. * Return: None
  246. */
  247. void hif_config_irq_affinity(struct hif_softc *hif_sc);
  248. /**
  249. * hif_config_irq_by_ceid() - register irq by CE id
  250. * @hif_sc - hif context
  251. * @ce_id - Copy Engine id for which the irq need to be configured
  252. *
  253. * Return: 0 on success, negative value on error.
  254. */
  255. int hif_config_irq_by_ceid(struct hif_softc *hif_sc, int ce_id);
  256. #ifdef HIF_BUS_LOG_INFO
  257. /**
  258. * hif_log_bus_info() - API to log bus related info
  259. * @scn: hif handle
  260. * @data: hang event data buffer
  261. * @offset: offset at which data needs to be written
  262. *
  263. * Return: None
  264. */
  265. void hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
  266. unsigned int *offset);
  267. #else
  268. static inline
  269. void hif_log_bus_info(struct hif_softc *scn, uint8_t *data,
  270. unsigned int *offset)
  271. {
  272. }
  273. #endif
  274. #endif /* _MULTIBUS_H_ */