1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 28 #ifndef _MULTIBUS_H_ 29 #define _MULTIBUS_H_ 30 31 #include "osdep.h" 32 #include "qdf_status.h" 33 #include "hif_debug.h" 34 35 struct hif_softc; 36 struct hif_exec_context; 37 38 struct hif_bus_ops { 39 QDF_STATUS (*hif_bus_open)(struct hif_softc *hif_sc, 40 enum qdf_bus_type bus_type); 41 void (*hif_bus_close)(struct hif_softc *hif_sc); 42 void (*hif_bus_prevent_linkdown)(struct hif_softc *hif_sc, bool flag); 43 void (*hif_reset_soc)(struct hif_softc *hif_sc); 44 int (*hif_bus_early_suspend)(struct hif_softc *hif_ctx); 45 int (*hif_bus_late_resume)(struct hif_softc *hif_ctx); 46 int (*hif_bus_suspend)(struct hif_softc *hif_ctx); 47 int (*hif_bus_resume)(struct hif_softc *hif_ctx); 48 int (*hif_bus_suspend_noirq)(struct hif_softc *hif_ctx); 49 int (*hif_bus_resume_noirq)(struct hif_softc *hif_ctx); 50 int (*hif_target_sleep_state_adjust)(struct hif_softc *scn, 51 bool sleep_ok, bool wait_for_it); 52 void (*hif_disable_isr)(struct hif_softc *hif_sc); 53 void (*hif_nointrs)(struct hif_softc *hif_sc); 54 QDF_STATUS (*hif_enable_bus)(struct hif_softc *hif_sc, 55 struct device *dev, 56 void *bdev, 57 const struct hif_bus_id *bid, 58 enum hif_enable_type type); 59 void (*hif_disable_bus)(struct hif_softc *hif_sc); 60 int (*hif_bus_configure)(struct hif_softc *hif_sc); 61 QDF_STATUS (*hif_get_config_item)(struct hif_softc *hif_sc, 62 int opcode, void *config, uint32_t config_len); 63 void (*hif_set_mailbox_swap)(struct hif_softc *hif_sc); 64 void (*hif_claim_device)(struct hif_softc *hif_sc); 65 void (*hif_shutdown_device)(struct hif_softc *hif_sc); 66 void (*hif_stop)(struct hif_softc *hif_sc); 67 void (*hif_cancel_deferred_target_sleep)(struct hif_softc *hif_sc); 68 void (*hif_irq_disable)(struct hif_softc *hif_sc, int ce_id); 69 void (*hif_irq_enable)(struct hif_softc *hif_sc, int ce_id); 70 int (*hif_grp_irq_configure)(struct hif_softc *hif_sc, 71 struct hif_exec_context *exec); 72 int (*hif_dump_registers)(struct hif_softc *hif_sc); 73 void (*hif_dump_target_memory)(struct hif_softc *hif_sc, 74 void *ramdump_base, 75 uint32_t address, uint32_t size); 76 void (*hif_ipa_get_ce_resource)(struct hif_softc *hif_sc, 77 qdf_shared_mem_t **ce_sr, 78 uint32_t *sr_ring_size, 79 qdf_dma_addr_t *reg_paddr); 80 void (*hif_mask_interrupt_call)(struct hif_softc *hif_sc); 81 void (*hif_enable_power_management)(struct hif_softc *hif_ctx, 82 bool is_packet_log_enabled); 83 void (*hif_disable_power_management)(struct hif_softc *hif_ctx); 84 void (*hif_display_stats)(struct hif_softc *hif_ctx); 85 void (*hif_clear_stats)(struct hif_softc *hif_ctx); 86 void (*hif_set_bundle_mode)(struct hif_softc *hif_ctx, bool enabled, 87 int rx_bundle_cnt); 88 int (*hif_bus_reset_resume)(struct hif_softc *hif_ctx); 89 int (*hif_map_ce_to_irq)(struct hif_softc *hif_sc, int ce_id); 90 int (*hif_addr_in_boundary)(struct hif_softc *scn, uint32_t offset); 91 bool (*hif_needs_bmi)(struct hif_softc *hif_sc); 92 }; 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_ERROR("%s: not supported", __func__); 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 114 #ifdef HIF_PCI 115 QDF_STATUS hif_initialize_pci_ops(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_ERROR("%s: not supported", __func__); 121 return QDF_STATUS_E_NOSUPPORT; 122 } 123 /** 124 * hif_pci_get_context_size() - dummy when pci isn't supported 125 * 126 * Return: 0 as an invalid size to indicate no support 127 */ 128 static inline int hif_pci_get_context_size(void) 129 { 130 return 0; 131 } 132 #endif /* HIF_PCI */ 133 134 #ifdef HIF_AHB 135 QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops); 136 int hif_ahb_get_context_size(void); 137 #else 138 /** 139 * hif_initialize_ahb_ops() - dummy for when ahb not supported 140 * 141 * Return: QDF_STATUS_E_NOSUPPORT 142 */ 143 static inline QDF_STATUS hif_initialize_ahb_ops(struct hif_bus_ops *bus_ops) 144 { 145 HIF_ERROR("%s: not supported", __func__); 146 return QDF_STATUS_E_NOSUPPORT; 147 } 148 149 /** 150 * hif_ahb_get_context_size() - dummy for when ahb not supported 151 * 152 * Return: 0 as an invalid size to indicate no support 153 */ 154 static inline int hif_ahb_get_context_size(void) 155 { 156 return 0; 157 } 158 #endif 159 160 #ifdef HIF_SDIO 161 QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc); 162 int hif_sdio_get_context_size(void); 163 #else 164 /** 165 * hif_initialize_sdio_ops() - dummy for when sdio not supported 166 * 167 * Return: QDF_STATUS_E_NOSUPPORT 168 */ 169 170 static inline QDF_STATUS hif_initialize_sdio_ops(struct hif_softc *hif_sc) 171 { 172 HIF_ERROR("%s: not supported", __func__); 173 return QDF_STATUS_E_NOSUPPORT; 174 } 175 176 /** 177 * hif_sdio_get_context_size() - dummy when sdio isn't supported 178 * 179 * Return: 0 as an invalid size to indicate no support 180 */ 181 static inline int hif_sdio_get_context_size(void) 182 { 183 return 0; 184 } 185 #endif /* HIF_SDIO */ 186 187 int hif_grp_irq_configure(struct hif_softc *hif_sc, 188 struct hif_exec_context *hif_exec); 189 #ifdef HIF_USB 190 QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops); 191 int hif_usb_get_context_size(void); 192 #else 193 static inline QDF_STATUS hif_initialize_usb_ops(struct hif_bus_ops *bus_ops) 194 { 195 HIF_ERROR("%s: not supported", __func__); 196 return QDF_STATUS_E_NOSUPPORT; 197 } 198 /** 199 * hif_usb_get_context_size() - dummy when usb isn't supported 200 * 201 * Return: 0 as an invalid size to indicate no support 202 */ 203 static inline int hif_usb_get_context_size(void) 204 { 205 return 0; 206 } 207 #endif /* HIF_USB */ 208 #endif /* _MULTIBUS_H_ */ 209