1 /* 2 * Copyright (c) 2020 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef _IPCI_API_H_ 18 #define _IPCI_API_H_ 19 struct hif_exec_context; 20 21 /** 22 * hif_ipci_open(): hif_bus_open 23 * @hif_ctx: hif context 24 * @bus_type: bus type 25 * 26 * Return: 0 for success or QDF_STATUS_E_NOMEM 27 */ 28 QDF_STATUS hif_ipci_open(struct hif_softc *hif_ctx, 29 enum qdf_bus_type bus_type); 30 31 /** 32 * hif_ipci_close(): hif_bus_close 33 * @hif_ctx: hif context 34 * 35 * Return: n/a 36 */ 37 void hif_ipci_close(struct hif_softc *hif_ctx); 38 39 /** 40 * hif_bus_prevent_linkdown(): allow or permit linkdown 41 * @scn: struct hif_softc 42 * @flag: true prevents linkdown, false allows 43 * 44 * Calls into the platform driver to vote against taking down the 45 * pcie link. 46 * 47 * Return: n/a 48 */ 49 void hif_ipci_prevent_linkdown(struct hif_softc *scn, bool flag); 50 51 /** 52 * hif_ipci_bus_suspend(): prepare hif for suspend 53 * @scn: struct hif_softc 54 * 55 * Return: Errno 56 */ 57 int hif_ipci_bus_suspend(struct hif_softc *scn); 58 59 /** 60 * hif_ipci_bus_suspend_noirq() - ensure there are no pending transactions 61 * @scn: hif context 62 * 63 * Ensure that if we received the wakeup message before the irq 64 * was disabled that the message is pocessed before suspending. 65 * 66 * Return: -EBUSY if we fail to flush the tasklets. 67 */ 68 int hif_ipci_bus_suspend_noirq(struct hif_softc *scn); 69 70 /** 71 * hif_ipci_bus_resume(): prepare hif for resume 72 * @scn: struct hif_softc 73 * 74 * Return: Errno 75 */ 76 int hif_ipci_bus_resume(struct hif_softc *scn); 77 78 /** 79 * hif_ipci_bus_resume_noirq() - ensure there are no pending transactions 80 * @scn: hif context 81 * 82 * Ensure that if we received the wakeup message before the irq 83 * was disabled that the message is pocessed before suspending. 84 * 85 * Return: -EBUSY if we fail to flush the tasklets. 86 */ 87 int hif_ipci_bus_resume_noirq(struct hif_softc *scn); 88 89 /** 90 * hif_ipci_disable_isr(): disable interrupt 91 * @scn: struct hif_softc 92 * 93 * Return: n/a 94 */ 95 void hif_ipci_disable_isr(struct hif_softc *scn); 96 97 /** 98 * hif_ipci_nointrs(): disable IRQ 99 * @scn: struct hif_softc 100 * 101 * This function stops interrupt(s) 102 * 103 * Return: none 104 */ 105 void hif_ipci_nointrs(struct hif_softc *scn); 106 107 /** 108 * hif_ipci_dump_registers(): dump bus debug registers 109 * @scn: struct hif_opaque_softc 110 * 111 * This function dumps hif bus debug registers 112 * 113 * Return: 0 for success or error code 114 */ 115 int hif_ipci_dump_registers(struct hif_softc *scn); 116 117 /** 118 * hif_ipci_enable_bus(): enable bus 119 * 120 * This function enables the bus 121 * 122 * @ol_sc: soft_sc struct 123 * @dev: device pointer 124 * @bdev: bus dev pointer 125 * bid: bus id pointer 126 * type: enum hif_enable_type such as HIF_ENABLE_TYPE_PROBE 127 * Return: QDF_STATUS 128 */ 129 QDF_STATUS hif_ipci_enable_bus( 130 struct hif_softc *scn, 131 struct device *dev, void *bdev, 132 const struct hif_bus_id *bid, 133 enum hif_enable_type type); 134 135 /** 136 * hif_ipci_disable_bus(): hif_disable_bus 137 * 138 * This function disables the bus 139 * 140 * @scn: struct hif_softc 141 * 142 * Return: none 143 */ 144 void hif_ipci_disable_bus(struct hif_softc *scn); 145 146 #ifdef FEATURE_RUNTIME_PM 147 /** 148 * hif_ipci_get_rpm_ctx() - Map corresponding hif_runtime_pm_ctx 149 * @scn: hif context 150 * 151 * This function will map and return the corresponding 152 * hif_runtime_pm_ctx based on ipcie interface. 153 * 154 * Return: struct hif_runtime_pm_ctx pointer 155 */ 156 struct hif_runtime_pm_ctx *hif_ipci_get_rpm_ctx(struct hif_softc *hif_sc); 157 158 /** 159 * hif_ipci_get_dev() - Map corresponding device structure 160 * @scn: hif context 161 * 162 * This function will map and return the corresponding 163 * device structure based on ipcie interface. 164 * 165 * Return: struct device pointer 166 */ 167 struct device *hif_ipci_get_dev(struct hif_softc *hif_sc); 168 #endif 169 170 /** 171 * hif_ipci_bus_configure() - configure the pcie bus 172 * @hif_sc: pointer to the hif context. 173 * 174 * return: 0 for success. nonzero for failure. 175 */ 176 int hif_ipci_bus_configure(struct hif_softc *scn); 177 178 /** 179 * hif_ipci_enable_power_management() - enable power management 180 * @hif_ctx: hif context 181 * @is_packet_log_enabled: pktlog enabled or disabled 182 * 183 * Return: none 184 */ 185 void hif_ipci_enable_power_management( 186 struct hif_softc *hif_ctx, 187 bool is_packet_log_enabled); 188 189 /** 190 * hif_ipci_disable_power_management() - disable power management 191 * @hif_ctx: hif context 192 * 193 * Return: none 194 */ 195 void hif_ipci_disable_power_management(struct hif_softc *hif_ctx); 196 197 /** 198 * hif_ipci_configure_grp_irq() - configure HW block irq 199 * @scn: hif context 200 * @exec: hif exec context 201 * 202 * Return:Errno 203 */ 204 int hif_ipci_configure_grp_irq( 205 struct hif_softc *scn, 206 struct hif_exec_context *exec); 207 208 /** 209 * hif_ipci_display_stats() - display stats 210 * @hif_ctx: hif context 211 * 212 * Return: none 213 */ 214 void hif_ipci_display_stats(struct hif_softc *hif_ctx); 215 216 /** 217 * hif_ipci_clear_stats() - clear stats 218 * @hif_ctx: hif context 219 * 220 * Return: none 221 */ 222 void hif_ipci_clear_stats(struct hif_softc *hif_ctx); 223 224 /** 225 * hif_ipci_needs_bmi() - return true if the soc needs bmi through the driver 226 * @scn: hif context 227 * 228 * Return: true if soc needs driver bmi otherwise false 229 */ 230 bool hif_ipci_needs_bmi(struct hif_softc *scn); 231 232 /** 233 * hif_ipci_get_irq_name() - get irqname 234 * This function gives irqnumber to irqname 235 * mapping. 236 * 237 * @irq_no: irq number 238 * 239 * Return: irq name 240 */ 241 const char *hif_ipci_get_irq_name(int irq_no); 242 243 #endif /* _IPCI_API_H_ */ 244