1 /* 2 * Copyright (c) 2016-2018, 2020-2021 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 19 #ifndef _MULTIBUS_H_ 20 #define _MULTIBUS_H_ 21 22 #include "osdep.h" 23 #include "qdf_status.h" 24 #include "hif_debug.h" 25 26 struct hif_softc; 27 struct hif_exec_context; 28 29 struct hif_bus_ops { 30 QDF_STATUS (*hif_bus_open)(struct hif_softc *hif_sc, 31 enum qdf_bus_type bus_type); 32 void (*hif_bus_close)(struct hif_softc *hif_sc); 33 void (*hif_bus_prevent_linkdown)(struct hif_softc *hif_sc, bool flag); 34 void (*hif_reset_soc)(struct hif_softc *hif_sc); 35 int (*hif_bus_early_suspend)(struct hif_softc *hif_ctx); 36 int (*hif_bus_late_resume)(struct hif_softc *hif_ctx); 37 int (*hif_bus_suspend)(struct hif_softc *hif_ctx); 38 int (*hif_bus_resume)(struct hif_softc *hif_ctx); 39 int (*hif_bus_suspend_noirq)(struct hif_softc *hif_ctx); 40 int (*hif_bus_resume_noirq)(struct hif_softc *hif_ctx); 41 int (*hif_target_sleep_state_adjust)(struct hif_softc *scn, 42 bool sleep_ok, bool wait_for_it); 43 void (*hif_disable_isr)(struct hif_softc *hif_sc); 44 void (*hif_nointrs)(struct hif_softc *hif_sc); 45 QDF_STATUS (*hif_enable_bus)(struct hif_softc *hif_sc, 46 struct device *dev, 47 void *bdev, 48 const struct hif_bus_id *bid, 49 enum hif_enable_type type); 50 void (*hif_disable_bus)(struct hif_softc *hif_sc); 51 #ifdef FEATURE_RUNTIME_PM 52 struct hif_runtime_pm_ctx *(*hif_bus_get_rpm_ctx)( 53 struct hif_softc *hif_sc); 54 struct device *(*hif_bus_get_dev)(struct hif_softc *hif_sc); 55 #endif 56 int (*hif_bus_configure)(struct hif_softc *hif_sc); 57 QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc, 58 int opcode, void *config, uint32_t config_len); 59 void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc); 60 void (*hif_claim_device)(struct hif_softc *hif_sc); 61 void (*hif_shutdown_device)(struct hif_softc *hif_sc); 62 void (*hif_stop)(struct hif_softc *hif_sc); 63 void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc); 64 void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id); 65 void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id); 66 int (*hif_grp_irq_configure)(struct hif_softc *hif_sc, 67 struct hif_exec_context *exec); 68 void (*hif_grp_irq_deconfigure)(struct hif_softc *hif_sc); 69 int (*hif_dump_registers)(struct hif_softc *hif_sc); 70 void (*hif_dump_target_memory)(struct hif_softc *hif_sc, 71 void *ramdump_base, 72 uint32_t address, uint32_t size); 73 uint32_t (*hif_reg_read32)(struct hif_softc *hif_sc, 74 uint32_t offset); 75 void (*hif_reg_write32)(struct hif_softc *hif_sc, 76 uint32_t offset, 77 uint32_t value); 78 void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc, 79 qdf_shared_mem_t **ce_sr, 80 uint32_t *sr_ring_size, 81 qdf_dma_addr_t *reg_paddr); 82 void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc); 83 void (*hif_enable_power_management)(struct hif_softc *hif_ctx, 84 bool is_packet_log_enabled); 85 void (*hif_disable_power_management)(struct hif_softc *hif_ctx); 86 void (*hif_display_stats)(struct hif_softc *hif_ctx); 87 void (*hif_clear_stats)(struct hif_softc *hif_ctx); 88 void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled, 89 int rx_bundle_cnt); 90 int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx); 91 int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id); 92 int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset); 93 bool (*hif_needs_bmi)(struct hif_softc *hif_sc); 94 void (*hif_config_irq_affinity)(struct hif_softc *hif_sc); 95 int (*hif_config_irq_by_ceid)(struct hif_softc *hif_sc, int ce_id); 96 void (*hif_config_irq_clear_cpu_affinity)(struct hif_softc *hif_sc, 97 int intr_ctxt_id, int cpu); 98 bool (*hif_log_bus_info)(struct hif_softc *scn, uint8_t *data, 99 unsigned int *offset); 100 int (*hif_enable_grp_irqs)(struct hif_softc *scn); 101 int (*hif_disable_grp_irqs)(struct hif_softc *scn); 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