1 /* 2 * Copyright (c) 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 any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _IPCI_API_H_ 19 #define _IPCI_API_H_ 20 struct hif_exec_context; 21 22 /** 23 * hif_ipci_open(): hif_bus_open 24 * @hif_ctx: hif context 25 * @bus_type: bus type 26 * 27 * Return: 0 for success or QDF_STATUS_E_NOMEM 28 */ 29 QDF_STATUS hif_ipci_open(struct hif_softc *hif_ctx, 30 enum qdf_bus_type bus_type); 31 32 /** 33 * hif_ipci_close(): hif_bus_close 34 * @hif_ctx: hif context 35 * 36 * Return: n/a 37 */ 38 void hif_ipci_close(struct hif_softc *hif_ctx); 39 40 /** 41 * hif_bus_prevent_linkdown(): allow or permit linkdown 42 * @scn: struct hif_softc 43 * @flag: true prevents linkdown, false allows 44 * 45 * Calls into the platform driver to vote against taking down the 46 * pcie link. 47 * 48 * Return: n/a 49 */ 50 void hif_ipci_prevent_linkdown(struct hif_softc *scn, bool flag); 51 52 /** 53 * hif_ipci_bus_suspend(): prepare hif for suspend 54 * @scn: struct hif_softc 55 * 56 * Return: Errno 57 */ 58 int hif_ipci_bus_suspend(struct hif_softc *scn); 59 60 /** 61 * hif_ipci_bus_suspend_noirq() - ensure there are no pending transactions 62 * @scn: hif context 63 * 64 * Ensure that if we received the wakeup message before the irq 65 * was disabled that the message is pocessed before suspending. 66 * 67 * Return: -EBUSY if we fail to flush the tasklets. 68 */ 69 int hif_ipci_bus_suspend_noirq(struct hif_softc *scn); 70 71 /** 72 * hif_ipci_bus_resume(): prepare hif for resume 73 * @scn: struct hif_softc 74 * 75 * Return: Errno 76 */ 77 int hif_ipci_bus_resume(struct hif_softc *scn); 78 79 /** 80 * hif_ipci_bus_resume_noirq() - ensure there are no pending transactions 81 * @scn: hif context 82 * 83 * Ensure that if we received the wakeup message before the irq 84 * was disabled that the message is pocessed before suspending. 85 * 86 * Return: -EBUSY if we fail to flush the tasklets. 87 */ 88 int hif_ipci_bus_resume_noirq(struct hif_softc *scn); 89 90 /** 91 * hif_ipci_disable_isr(): disable interrupt 92 * @scn: struct hif_softc 93 * 94 * Return: n/a 95 */ 96 void hif_ipci_disable_isr(struct hif_softc *scn); 97 98 /** 99 * hif_ipci_nointrs(): disable IRQ 100 * @scn: struct hif_softc 101 * 102 * This function stops interrupt(s) 103 * 104 * Return: none 105 */ 106 void hif_ipci_nointrs(struct hif_softc *scn); 107 108 /** 109 * hif_ipci_dump_registers(): dump bus debug registers 110 * @scn: struct hif_opaque_softc 111 * 112 * This function dumps hif bus debug registers 113 * 114 * Return: 0 for success or error code 115 */ 116 int hif_ipci_dump_registers(struct hif_softc *scn); 117 118 /** 119 * hif_ipci_enable_bus(): enable bus 120 * 121 * This function enables the bus 122 * 123 * @ol_sc: soft_sc struct 124 * @dev: device pointer 125 * @bdev: bus dev pointer 126 * bid: bus id pointer 127 * type: enum hif_enable_type such as HIF_ENABLE_TYPE_PROBE 128 * Return: QDF_STATUS 129 */ 130 QDF_STATUS hif_ipci_enable_bus( 131 struct hif_softc *scn, 132 struct device *dev, void *bdev, 133 const struct hif_bus_id *bid, 134 enum hif_enable_type type); 135 136 /** 137 * hif_ipci_disable_bus(): hif_disable_bus 138 * 139 * This function disables the bus 140 * 141 * @scn: struct hif_softc 142 * 143 * Return: none 144 */ 145 void hif_ipci_disable_bus(struct hif_softc *scn); 146 147 /** 148 * hif_ipci_bus_configure() - configure the pcie bus 149 * @hif_sc: pointer to the hif context. 150 * 151 * return: 0 for success. nonzero for failure. 152 */ 153 int hif_ipci_bus_configure(struct hif_softc *scn); 154 155 /** 156 * hif_ipci_enable_power_management() - enable power management 157 * @hif_ctx: hif context 158 * @is_packet_log_enabled: pktlog enabled or disabled 159 * 160 * Return: none 161 */ 162 void hif_ipci_enable_power_management( 163 struct hif_softc *hif_ctx, 164 bool is_packet_log_enabled); 165 166 /** 167 * hif_ipci_disable_power_management() - disable power management 168 * @hif_ctx: hif context 169 * 170 * Return: none 171 */ 172 void hif_ipci_disable_power_management(struct hif_softc *hif_ctx); 173 174 /** 175 * hif_ipci_configure_grp_irq() - configure HW block irq 176 * @scn: hif context 177 * @exec: hif exec context 178 * 179 * Return:Errno 180 */ 181 int hif_ipci_configure_grp_irq( 182 struct hif_softc *scn, 183 struct hif_exec_context *exec); 184 185 /** 186 * hif_ipci_deconfigure_grp_irq() - deconfigure HW block irq 187 * @scn: hif context 188 * 189 * Return: None 190 */ 191 void hif_ipci_deconfigure_grp_irq(struct hif_softc *scn); 192 193 /** 194 * hif_ipci_display_stats() - display stats 195 * @hif_ctx: hif context 196 * 197 * Return: none 198 */ 199 void hif_ipci_display_stats(struct hif_softc *hif_ctx); 200 201 /** 202 * hif_ipci_clear_stats() - clear stats 203 * @hif_ctx: hif context 204 * 205 * Return: none 206 */ 207 void hif_ipci_clear_stats(struct hif_softc *hif_ctx); 208 209 /** 210 * hif_ipci_needs_bmi() - return true if the soc needs bmi through the driver 211 * @scn: hif context 212 * 213 * Return: true if soc needs driver bmi otherwise false 214 */ 215 bool hif_ipci_needs_bmi(struct hif_softc *scn); 216 217 /** 218 * hif_ipci_get_irq_name() - get irqname 219 * This function gives irqnumber to irqname 220 * mapping. 221 * 222 * @irq_no: irq number 223 * 224 * Return: irq name 225 */ 226 const char *hif_ipci_get_irq_name(int irq_no); 227 228 /** 229 * hif_ipci_enable_grp_irqs(): enable grp IRQs 230 * @scn: struct hif_softc 231 * 232 * This function enables grp irqs 233 * 234 * Return: 0 if success, error code if failure 235 */ 236 int hif_ipci_enable_grp_irqs(struct hif_softc *scn); 237 238 #ifdef HIF_CPU_PERF_AFFINE_MASK 239 /** hif_ipci_config_irq_affinity() - set the irq affinity 240 * @scn: hif context 241 * 242 * set irq affinity hint for wlan irqs to gold cores only for 243 * defconfig builds. 244 * 245 * return: none 246 */ 247 void hif_ipci_config_irq_affinity(struct hif_softc *scn); 248 #endif 249 250 #ifdef HIF_CPU_CLEAR_AFFINITY 251 /** 252 * hif_ipci_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ 253 * @scn: HIF handle 254 * @intr_ctxt_id: interrupt group index 255 * @cpu: CPU core to clear 256 * 257 * Return: None 258 */ 259 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn, 260 int intr_ctxt_id, int cpu); 261 #else 262 static inline 263 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn, 264 int intr_ctxt_id, int cpu) 265 { 266 } 267 #endif 268 269 /** 270 * hif_ipci_disable_grp_irqs(): disable grp IRQs 271 * @scn: struct hif_softc 272 * 273 * This function disables grp irqs 274 * 275 * Return: 0 if success, error code if failure 276 */ 277 int hif_ipci_disable_grp_irqs(struct hif_softc *scn); 278 279 #ifdef FEATURE_IRQ_AFFINITY 280 /* 281 * hif_ipci_set_grp_intr_affinity() - Set irq affinity hint for grp 282 * intrs based on bitmask 283 * @scn: hif context 284 * @grp_intr_bitmask: group intr bitmask 285 * @perf: affine to perf or non-perf cluster 286 * 287 * Return: None 288 */ 289 void hif_ipci_set_grp_intr_affinity(struct hif_softc *scn, 290 uint32_t grp_intr_bitmask, bool perf); 291 #endif 292 #endif /* _IPCI_API_H_ */ 293