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