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 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 int (*hif_bus_configure)(struct hif_softc *hif_sc); 52 QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc, 53 int opcode, void *config, uint32_t config_len); 54 void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc); 55 void (*hif_claim_device)(struct hif_softc *hif_sc); 56 void (*hif_shutdown_device)(struct hif_softc *hif_sc); 57 void (*hif_stop)(struct hif_softc *hif_sc); 58 void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc); 59 void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id); 60 void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id); 61 int (*hif_grp_irq_configure)(struct hif_softc *hif_sc, 62 struct hif_exec_context *exec); 63 int (*hif_dump_registers)(struct hif_softc *hif_sc); 64 void (*hif_dump_target_memory)(struct hif_softc *hif_sc, 65 void *ramdump_base, 66 uint32_t address, uint32_t size); 67 void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc, 68 qdf_shared_mem_t **ce_sr, 69 uint32_t *sr_ring_size, 70 qdf_dma_addr_t *reg_paddr); 71 void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc); 72 void (*hif_enable_power_management)(struct hif_softc *hif_ctx, 73 bool is_packet_log_enabled); 74 void (*hif_disable_power_management)(struct hif_softc *hif_ctx); 75 void (*hif_display_stats)(struct hif_softc *hif_ctx); 76 void (*hif_clear_stats)(struct hif_softc *hif_ctx); 77 void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled, 78 int rx_bundle_cnt); 79 int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx); 80 int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id); 81 int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset); 82 bool (*hif_needs_bmi)(struct hif_softc *hif_sc); 83 }; 84 85 #ifdef HIF_SNOC 86 QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc); 87 int hif_snoc_get_context_size(void); 88 #else 89 static inline QDF_STATUS hif_initialize_snoc_ops(struct hif_bus_ops *hif_sc) 90 { 91 HIF_ERROR("%s: not supported", __func__); 92 return QDF_STATUS_E_NOSUPPORT; 93 } 94 /** 95 * hif_snoc_get_context_size() - dummy when snoc isn't supported 96 * 97 * Return: 0 as an invalid size to indicate no support 98 */ 99 static inline int hif_snoc_get_context_size(void) 100 { 101 return 0; 102 } 103 #endif /* HIF_SNOC */ 104 105 #ifdef HIF_PCI 106 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc); 107 int hif_pci_get_context_size(void); 108 #else 109 static inline QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc) 110 { 111 HIF_ERROR("%s: not supported", __func__); 112 return QDF_STATUS_E_NOSUPPORT; 113 } 114 /** 115 * hif_pci_get_context_size() - dummy when pci isn't supported 116 * 117 * Return: 0 as an invalid size to indicate no support 118 */ 119 static inline int hif_pci_get_context_size(void) 120 { 121 return 0; 122 } 123 #endif /* HIF_PCI */ 124 125 #ifdef HIF_IPCI 126 /** 127 * hif_initialize_ipci_ops() - initialize the pci ops 128 * @hif_sc: pointer to hif context 129 * 130 * Return: QDF_STATUS_SUCCESS 131 */ 132 QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc); 133 134 /** 135 * hif_ipci_get_context_size() - return the size of the ipci context 136 * 137 * Return the size of the context. (0 for invalid bus) 138 */ 139 int hif_ipci_get_context_size(void); 140 #else 141 static inline QDF_STATUS hif_initialize_ipci_ops(struct hif_softc *hif_sc) 142 { 143 HIF_ERROR("%s: not supported", __func__); 144 return QDF_STATUS_E_NOSUPPORT; 145 } 146 147 /** 148 * hif_ipci_get_context_size() - dummy when ipci isn't supported 149 * 150 * Return: 0 as an invalid size to indicate no support 151 */ 152 static inline int hif_ipci_get_context_size(void) 153 { 154 return 0; 155 } 156 #endif /* HIF_IPCI */ 157 158 #ifdef HIF_AHB 159 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops); 160 int hif_ahb_get_context_size(void); 161 #else 162 /** 163 * hif_initialize_ahb_ops() - dummy for when ahb not supported 164 * 165 * Return: QDF_STATUS_E_NOSUPPORT 166 */ 167 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops) 168 { 169 HIF_ERROR("%s: not supported", __func__); 170 return QDF_STATUS_E_NOSUPPORT; 171 } 172 173 /** 174 * hif_ahb_get_context_size() - dummy for when ahb not supported 175 * 176 * Return: 0 as an invalid size to indicate no support 177 */ 178 static inline int hif_ahb_get_context_size(void) 179 { 180 return 0; 181 } 182 #endif 183 184 #ifdef HIF_SDIO 185 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc); 186 int hif_sdio_get_context_size(void); 187 #else 188 /** 189 * hif_initialize_sdio_ops() - dummy for when sdio not supported 190 * 191 * Return: QDF_STATUS_E_NOSUPPORT 192 */ 193 194 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc) 195 { 196 HIF_ERROR("%s: not supported", __func__); 197 return QDF_STATUS_E_NOSUPPORT; 198 } 199 200 /** 201 * hif_sdio_get_context_size() - dummy when sdio isn't supported 202 * 203 * Return: 0 as an invalid size to indicate no support 204 */ 205 static inline int hif_sdio_get_context_size(void) 206 { 207 return 0; 208 } 209 #endif /* HIF_SDIO */ 210 211 int hif_grp_irq_configure(struct hif_softc *hif_sc, 212 struct hif_exec_context *hif_exec); 213 #ifdef HIF_USB 214 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops); 215 int hif_usb_get_context_size(void); 216 #else 217 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops) 218 { 219 HIF_ERROR("%s: not supported", __func__); 220 return QDF_STATUS_E_NOSUPPORT; 221 } 222 /** 223 * hif_usb_get_context_size() - dummy when usb isn't supported 224 * 225 * Return: 0 as an invalid size to indicate no support 226 */ 227 static inline int hif_usb_get_context_size(void) 228 { 229 return 0; 230 } 231 #endif /* HIF_USB */ 232 #endif /* _MULTIBUS_H_ */ 233