Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 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 | #include <osdep.h> |
| 29 | #include "a_types.h" |
| 30 | #include "athdefs.h" |
| 31 | #include "osapi_linux.h" |
| 32 | #include "targcfg.h" |
| 33 | #include "cdf_lock.h" |
| 34 | #include "cdf_status.h" |
| 35 | #include <cdf_atomic.h> /* cdf_atomic_read */ |
| 36 | #include <targaddrs.h> |
| 37 | #include <bmi_msg.h> |
| 38 | #include "hif_io32.h" |
| 39 | #include <hif.h> |
| 40 | #include <htc_services.h> |
| 41 | #include "regtable.h" |
| 42 | #define ATH_MODULE_NAME hif |
| 43 | #include <a_debug.h> |
| 44 | #include "hif_main.h" |
| 45 | #include "hif_hw_version.h" |
| 46 | #include "ce_api.h" |
| 47 | #include "ce_tasklet.h" |
| 48 | #include "cdf_trace.h" |
| 49 | #include "cdf_status.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 50 | #ifdef CONFIG_CNSS |
| 51 | #include <net/cnss.h> |
| 52 | #endif |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 53 | #include "epping_main.h" |
| 54 | #include "hif_debug.h" |
| 55 | #include "mp_dev.h" |
| 56 | #ifdef HIF_PCI |
| 57 | #include "icnss_stub.h" |
| 58 | #else |
| 59 | #include <soc/qcom/icnss.h> |
| 60 | #endif |
| 61 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 62 | #define AGC_DUMP 1 |
| 63 | #define CHANINFO_DUMP 2 |
| 64 | #define BB_WATCHDOG_DUMP 3 |
| 65 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 66 | #define PCIE_ACCESS_DUMP 4 |
| 67 | #endif |
| 68 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 69 | void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 70 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 71 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 72 | switch (cmd_id) { |
| 73 | case AGC_DUMP: |
| 74 | if (start) |
| 75 | priv_start_agc(scn); |
| 76 | else |
| 77 | priv_dump_agc(scn); |
| 78 | break; |
| 79 | |
| 80 | case CHANINFO_DUMP: |
| 81 | if (start) |
| 82 | priv_start_cap_chaninfo(scn); |
| 83 | else |
| 84 | priv_dump_chaninfo(scn); |
| 85 | break; |
| 86 | |
| 87 | case BB_WATCHDOG_DUMP: |
| 88 | priv_dump_bbwatchdog(scn); |
| 89 | break; |
| 90 | |
| 91 | #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG |
| 92 | case PCIE_ACCESS_DUMP: |
| 93 | hif_target_dump_access_log(); |
| 94 | break; |
| 95 | #endif |
| 96 | default: |
| 97 | HIF_ERROR("%s: Invalid htc dump command", __func__); |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * hif_shut_down_device() - hif_shut_down_device |
| 104 | * |
| 105 | * SThis fucntion shuts down the device |
| 106 | * |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 107 | * @scn: hif_opaque_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 108 | * |
| 109 | * Return: void |
| 110 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 111 | void hif_shut_down_device(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 112 | { |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 113 | hif_stop(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
| 117 | |
| 118 | /** |
| 119 | * hif_cancel_deferred_target_sleep() - cancel deferred target sleep |
| 120 | * |
| 121 | * This function cancels the defered target sleep |
| 122 | * |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 123 | * @scn: hif_opaque_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 124 | * |
| 125 | * Return: void |
| 126 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 127 | void hif_cancel_deferred_target_sleep(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 128 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 129 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 130 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 131 | hif_pci_cancel_deferred_target_sleep(scn); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * hif_get_target_id(): hif_get_target_id |
| 136 | * |
| 137 | * Return the virtual memory base address to the caller |
| 138 | * |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 139 | * @scn: hif_softc |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 140 | * |
| 141 | * Return: A_target_id_t |
| 142 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 143 | A_target_id_t hif_get_target_id(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 144 | { |
| 145 | return scn->mem; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * hif_set_target_sleep(): hif_set_target_sleep |
| 150 | * @scn: scn |
| 151 | * @sleep_ok: sleep_ok |
| 152 | * @wait_for_it: wait |
| 153 | * |
| 154 | * Return: void |
| 155 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 156 | void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 157 | bool sleep_ok, bool wait_for_it) |
| 158 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 159 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 160 | hif_target_sleep_state_adjust(scn, |
| 161 | sleep_ok, wait_for_it); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * hif_target_forced_awake(): hif_target_forced_awake |
| 166 | * @scn: scn |
| 167 | * |
| 168 | * Return: bool |
| 169 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 170 | bool hif_target_forced_awake(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 171 | { |
| 172 | A_target_id_t addr = scn->mem; |
| 173 | bool awake; |
| 174 | bool forced_awake; |
| 175 | |
| 176 | awake = hif_targ_is_awake(scn, addr); |
| 177 | |
| 178 | forced_awake = |
| 179 | !!(hif_read32_mb |
| 180 | (addr + PCIE_LOCAL_BASE_ADDRESS + |
| 181 | PCIE_SOC_WAKE_ADDRESS) & PCIE_SOC_WAKE_V_MASK); |
| 182 | |
| 183 | return awake && forced_awake; |
| 184 | } |
| 185 | |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 186 | |
| 187 | static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state) |
| 188 | { |
| 189 | struct hif_msg_callbacks *msg_callbacks = |
| 190 | &hif_state->msg_callbacks_current; |
| 191 | |
| 192 | if (!msg_callbacks->fwEventHandler) |
| 193 | return; |
| 194 | |
| 195 | msg_callbacks->fwEventHandler(msg_callbacks->Context, |
| 196 | CDF_STATUS_E_FAILURE); |
| 197 | } |
| 198 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 199 | /** |
| 200 | * hif_fw_interrupt_handler(): FW interrupt handler |
| 201 | * |
| 202 | * This function is the FW interrupt handlder |
| 203 | * |
| 204 | * @irq: irq number |
| 205 | * @arg: the user pointer |
| 206 | * |
| 207 | * Return: bool |
| 208 | */ |
| 209 | #ifndef QCA_WIFI_3_0 |
| 210 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 211 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 212 | struct hif_softc *scn = arg; |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 213 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 214 | uint32_t fw_indicator_address, fw_indicator; |
| 215 | |
| 216 | A_TARGET_ACCESS_BEGIN_RET(scn); |
| 217 | |
| 218 | fw_indicator_address = hif_state->fw_indicator_address; |
| 219 | /* For sudden unplug this will return ~0 */ |
| 220 | fw_indicator = A_TARGET_READ(scn, fw_indicator_address); |
| 221 | |
| 222 | if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) { |
| 223 | /* ACK: clear Target-side pending event */ |
| 224 | A_TARGET_WRITE(scn, fw_indicator_address, |
| 225 | fw_indicator & ~FW_IND_EVENT_PENDING); |
| 226 | A_TARGET_ACCESS_END_RET(scn); |
| 227 | |
| 228 | if (hif_state->started) { |
Houston Hoffman | 0dad509 | 2015-09-28 16:25:51 -0700 | [diff] [blame] | 229 | hif_fw_event_handler(hif_state); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 230 | } else { |
| 231 | /* |
| 232 | * Probable Target failure before we're prepared |
| 233 | * to handle it. Generally unexpected. |
| 234 | */ |
| 235 | AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
| 236 | ("%s: Early firmware event indicated\n", |
| 237 | __func__)); |
| 238 | } |
| 239 | } else { |
| 240 | A_TARGET_ACCESS_END_RET(scn); |
| 241 | } |
| 242 | |
| 243 | return ATH_ISR_SCHED; |
| 244 | } |
| 245 | #else |
| 246 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) |
| 247 | { |
| 248 | return ATH_ISR_SCHED; |
| 249 | } |
| 250 | #endif /* #ifdef QCA_WIFI_3_0 */ |
| 251 | |
| 252 | /** |
| 253 | * hif_get_targetdef(): hif_get_targetdef |
| 254 | * @scn: scn |
| 255 | * |
| 256 | * Return: void * |
| 257 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 258 | void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 259 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 260 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 261 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 262 | return scn->targetdef; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * hif_vote_link_down(): unvote for link up |
| 267 | * |
| 268 | * Call hif_vote_link_down to release a previous request made using |
| 269 | * hif_vote_link_up. A hif_vote_link_down call should only be made |
| 270 | * after a corresponding hif_vote_link_up, otherwise you could be |
| 271 | * negating a vote from another source. When no votes are present |
| 272 | * hif will not guarantee the linkstate after hif_bus_suspend. |
| 273 | * |
| 274 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 275 | * and initialization deinitialization sequencences. |
| 276 | * |
| 277 | * Return: n/a |
| 278 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 279 | void hif_vote_link_down(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 280 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 281 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 282 | CDF_BUG(scn); |
| 283 | |
| 284 | scn->linkstate_vote--; |
| 285 | if (scn->linkstate_vote == 0) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 286 | hif_bus_prevent_linkdown(scn, false); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /** |
| 290 | * hif_vote_link_up(): vote to prevent bus from suspending |
| 291 | * |
| 292 | * Makes hif guarantee that fw can message the host normally |
| 293 | * durring suspend. |
| 294 | * |
| 295 | * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread |
| 296 | * and initialization deinitialization sequencences. |
| 297 | * |
| 298 | * Return: n/a |
| 299 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 300 | void hif_vote_link_up(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 301 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 302 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 303 | CDF_BUG(scn); |
| 304 | |
| 305 | scn->linkstate_vote++; |
| 306 | if (scn->linkstate_vote == 1) |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 307 | hif_bus_prevent_linkdown(scn, true); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /** |
| 311 | * hif_can_suspend_link(): query if hif is permitted to suspend the link |
| 312 | * |
| 313 | * Hif will ensure that the link won't be suspended if the upperlayers |
| 314 | * don't want it to. |
| 315 | * |
| 316 | * SYNCHRONIZATION: MC thread is stopped before bus suspend thus |
| 317 | * we don't need extra locking to ensure votes dont change while |
| 318 | * we are in the process of suspending or resuming. |
| 319 | * |
| 320 | * Return: false if hif will guarantee link up durring suspend. |
| 321 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 322 | bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 323 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 324 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 325 | CDF_BUG(scn); |
| 326 | |
| 327 | return scn->linkstate_vote == 0; |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * hif_hia_item_address(): hif_hia_item_address |
| 332 | * @target_type: target_type |
| 333 | * @item_offset: item_offset |
| 334 | * |
| 335 | * Return: n/a |
| 336 | */ |
| 337 | uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset) |
| 338 | { |
| 339 | switch (target_type) { |
| 340 | case TARGET_TYPE_AR6002: |
| 341 | return AR6002_HOST_INTEREST_ADDRESS + item_offset; |
| 342 | case TARGET_TYPE_AR6003: |
| 343 | return AR6003_HOST_INTEREST_ADDRESS + item_offset; |
| 344 | case TARGET_TYPE_AR6004: |
| 345 | return AR6004_HOST_INTEREST_ADDRESS + item_offset; |
| 346 | case TARGET_TYPE_AR6006: |
| 347 | return AR6006_HOST_INTEREST_ADDRESS + item_offset; |
| 348 | case TARGET_TYPE_AR9888: |
| 349 | return AR9888_HOST_INTEREST_ADDRESS + item_offset; |
| 350 | case TARGET_TYPE_AR6320: |
| 351 | case TARGET_TYPE_AR6320V2: |
| 352 | return AR6320_HOST_INTEREST_ADDRESS + item_offset; |
| 353 | case TARGET_TYPE_QCA6180: |
| 354 | return QCA6180_HOST_INTEREST_ADDRESS + item_offset; |
| 355 | case TARGET_TYPE_ADRASTEA: |
| 356 | /* ADRASTEA doesn't have a host interest address */ |
| 357 | ASSERT(0); |
| 358 | return 0; |
| 359 | default: |
| 360 | ASSERT(0); |
| 361 | return 0; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * hif_max_num_receives_reached() - check max receive is reached |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 367 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 368 | * @count: unsigned int. |
| 369 | * |
| 370 | * Output check status as bool |
| 371 | * |
| 372 | * Return: bool |
| 373 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 374 | bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 375 | { |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 376 | if (WLAN_IS_EPPING_ENABLED(hif_get_conparam(scn))) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 377 | return count > 120; |
| 378 | else |
| 379 | return count > MAX_NUM_OF_RECEIVES; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * init_buffer_count() - initial buffer count |
| 384 | * @maxSize: cdf_size_t |
| 385 | * |
| 386 | * routine to modify the initial buffer count to be allocated on an os |
| 387 | * platform basis. Platform owner will need to modify this as needed |
| 388 | * |
| 389 | * Return: cdf_size_t |
| 390 | */ |
| 391 | cdf_size_t init_buffer_count(cdf_size_t maxSize) |
| 392 | { |
| 393 | return maxSize; |
| 394 | } |
| 395 | |
| 396 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 397 | * hif_save_htc_htt_config_endpoint(): |
| 398 | * hif_save_htc_htt_config_endpoint |
| 399 | * @htc_endpoint: htc_endpoint |
| 400 | * |
| 401 | * Return: void |
| 402 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 403 | void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx, |
| 404 | int htc_endpoint) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 405 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 406 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 407 | |
| 408 | if (!scn) { |
| 409 | HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!", |
| 410 | __func__); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | scn->htc_endpoint = htc_endpoint; |
| 415 | } |
| 416 | |
| 417 | /** |
| 418 | * hif_get_hw_name(): get a human readable name for the hardware |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 419 | * @info: Target Info |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 420 | * |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 421 | * Return: human readable name for the underlying wifi hardware. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 422 | */ |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 423 | static const char *hif_get_hw_name(struct hif_target_info *info) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 424 | { |
| 425 | int i; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 426 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 427 | for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 428 | if (info->target_version == qwlan_hw_list[i].id && |
| 429 | info->target_revision == qwlan_hw_list[i].subid) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 430 | return qwlan_hw_list[i].name; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | return "Unknown Device"; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * hif_get_hw_info(): hif_get_hw_info |
| 439 | * @scn: scn |
| 440 | * @version: version |
| 441 | * @revision: revision |
| 442 | * |
| 443 | * Return: n/a |
| 444 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 445 | void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 446 | const char **target_name) |
| 447 | { |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 448 | struct hif_target_info *info = hif_get_target_info_handle(scn); |
| 449 | *version = info->target_version; |
| 450 | *revision = info->target_revision; |
| 451 | *target_name = hif_get_hw_name(info); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | /** |
| 455 | * hif_open(): hif_open |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 456 | * @cdf_ctx: CDF Context |
| 457 | * @mode: Driver Mode |
| 458 | * @bus_type: Bus Type |
| 459 | * @cbk: CDS Callbacks |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 460 | * |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 461 | * API to open HIF Context |
| 462 | * |
| 463 | * Return: HIF Opaque Pointer |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 464 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 465 | struct hif_opaque_softc *hif_open(cdf_device_t cdf_ctx, uint32_t mode, |
| 466 | enum ath_hal_bus_type bus_type, |
| 467 | struct hif_callbacks *cbk) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 468 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 469 | struct hif_softc *scn; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 470 | CDF_STATUS status = CDF_STATUS_SUCCESS; |
Komal Seelam | 43301de | 2016-02-02 18:20:48 +0530 | [diff] [blame] | 471 | int bus_context_size = hif_bus_get_context_size(); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 472 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 473 | scn = (struct hif_softc *)cdf_mem_malloc(bus_context_size); |
| 474 | if (!scn) { |
| 475 | HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d", |
| 476 | __func__, bus_context_size); |
| 477 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 478 | } |
| 479 | |
Komal Seelam | 43301de | 2016-02-02 18:20:48 +0530 | [diff] [blame] | 480 | cdf_mem_zero(scn, bus_context_size); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 481 | |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 482 | scn->cdf_dev = cdf_ctx; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 483 | scn->hif_con_param = mode; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 484 | cdf_atomic_init(&scn->active_tasklet_cnt); |
| 485 | cdf_atomic_init(&scn->link_suspended); |
| 486 | cdf_atomic_init(&scn->tasklet_from_intr); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 487 | cdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_callbacks)); |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 488 | |
| 489 | status = hif_bus_open(scn, bus_type); |
| 490 | if (status != CDF_STATUS_SUCCESS) { |
| 491 | HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d", |
| 492 | __func__, status, bus_type); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 493 | cdf_mem_free(scn); |
| 494 | scn = NULL; |
Houston Hoffman | 3cfe686 | 2016-01-08 10:33:55 -0800 | [diff] [blame] | 495 | } |
| 496 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 497 | return GET_HIF_OPAQUE_HDL(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | /** |
| 501 | * hif_close(): hif_close |
| 502 | * @hif_ctx: hif_ctx |
| 503 | * |
| 504 | * Return: n/a |
| 505 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 506 | void hif_close(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 507 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 508 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 509 | |
| 510 | if (scn == NULL) { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 511 | HIF_ERROR("%s: hif_opaque_softc is NULL", __func__); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 512 | return; |
| 513 | } |
| 514 | |
| 515 | if (scn->athdiag_procfs_inited) { |
| 516 | athdiag_procfs_remove(); |
| 517 | scn->athdiag_procfs_inited = false; |
| 518 | } |
| 519 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 520 | hif_bus_close(scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 521 | cdf_mem_free(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /** |
| 525 | * hif_enable(): hif_enable |
| 526 | * @hif_ctx: hif_ctx |
| 527 | * @dev: dev |
| 528 | * @bdev: bus dev |
| 529 | * @bid: bus ID |
| 530 | * @bus_type: bus type |
| 531 | * @type: enable type |
| 532 | * |
| 533 | * Return: CDF_STATUS |
| 534 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 535 | CDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 536 | void *bdev, const hif_bus_id *bid, |
| 537 | enum ath_hal_bus_type bus_type, |
| 538 | enum hif_enable_type type) |
| 539 | { |
| 540 | CDF_STATUS status; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 541 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 542 | |
| 543 | if (scn == NULL) { |
| 544 | HIF_ERROR("%s: hif_ctx = NULL", __func__); |
| 545 | return CDF_STATUS_E_NULL_VALUE; |
| 546 | } |
| 547 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 548 | status = hif_enable_bus(scn, dev, bdev, bid, type); |
| 549 | if (status != CDF_STATUS_SUCCESS) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 550 | HIF_ERROR("%s: hif_enable_bus error = %d", |
| 551 | __func__, status); |
| 552 | return status; |
| 553 | } |
| 554 | |
| 555 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 556 | hif_vote_link_up(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 557 | |
| 558 | if (hif_config_ce(scn)) { |
| 559 | HIF_ERROR("%s: Target probe failed.", __func__); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 560 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 561 | status = CDF_STATUS_E_FAILURE; |
| 562 | return status; |
| 563 | } |
| 564 | /* |
| 565 | * Flag to avoid potential unallocated memory access from MSI |
| 566 | * interrupt handler which could get scheduled as soon as MSI |
| 567 | * is enabled, i.e to take care of the race due to the order |
| 568 | * in where MSI is enabled before the memory, that will be |
| 569 | * in interrupt handlers, is allocated. |
| 570 | */ |
| 571 | |
| 572 | #ifdef HIF_PCI |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 573 | status = hif_configure_irq(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 574 | if (status < 0) { |
| 575 | HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d", |
| 576 | __func__, status); |
| 577 | return CDF_STATUS_E_FAILURE; |
| 578 | } |
| 579 | #endif |
| 580 | |
| 581 | scn->hif_init_done = true; |
| 582 | |
| 583 | HIF_TRACE("%s: X OK", __func__); |
| 584 | |
| 585 | return CDF_STATUS_SUCCESS; |
| 586 | } |
| 587 | |
| 588 | /** |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 589 | * hif_wlan_disable(): call the platform driver to disable wlan |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 590 | * @scn: HIF Context |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 591 | * |
| 592 | * This function passes the con_mode to platform driver to disable |
| 593 | * wlan. |
| 594 | * |
| 595 | * Return: void |
| 596 | */ |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 597 | void hif_wlan_disable(struct hif_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 598 | { |
| 599 | enum icnss_driver_mode mode; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 600 | uint32_t con_mode = hif_get_conparam(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 601 | |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 602 | if (CDF_GLOBAL_FTM_MODE == con_mode) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 603 | mode = ICNSS_FTM; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 604 | else if (WLAN_IS_EPPING_ENABLED(con_mode)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 605 | mode = ICNSS_EPPING; |
Peng Xu | 7b96253 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 606 | else |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 607 | mode = ICNSS_MISSION; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 608 | |
| 609 | icnss_wlan_disable(mode); |
| 610 | } |
| 611 | |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 612 | void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 613 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 614 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 615 | |
| 616 | if (!scn) |
| 617 | return; |
| 618 | |
| 619 | hif_nointrs(scn); |
| 620 | if (scn->hif_init_done == false) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 621 | hif_shut_down_device(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 622 | else |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 623 | hif_stop(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 624 | |
| 625 | if (ADRASTEA_BU) |
Komal Seelam | f860068 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 626 | hif_vote_link_down(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 627 | |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 628 | hif_disable_bus(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 629 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 630 | hif_wlan_disable(scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 631 | |
| 632 | scn->notice_send = false; |
| 633 | |
| 634 | HIF_INFO("%s: X", __func__); |
| 635 | } |
| 636 | |
| 637 | |
| 638 | /** |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 639 | * hif_crash_shutdown_dump_bus_register() - dump bus registers |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 640 | * @hif_ctx: hif_ctx |
| 641 | * |
| 642 | * Return: n/a |
| 643 | */ |
| 644 | #if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \ |
| 645 | && defined(HIF_PCI) && defined(DEBUG) |
| 646 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 647 | static void hif_crash_shutdown_dump_bus_register(void *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 648 | { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 649 | struct hif_opaque_softc *scn = hif_ctx; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 650 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 651 | if (hif_check_soc_status(scn)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 652 | return; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 653 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 654 | if (hif_dump_registers(scn)) |
| 655 | HIF_ERROR("Failed to dump bus registers!"); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | /** |
| 659 | * hif_crash_shutdown(): hif_crash_shutdown |
| 660 | * |
| 661 | * This function is called by the platform driver to dump CE registers |
| 662 | * |
| 663 | * @hif_ctx: hif_ctx |
| 664 | * |
| 665 | * Return: n/a |
| 666 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 667 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 668 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 669 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 670 | struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 671 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 672 | if (!hif_state) |
| 673 | return; |
| 674 | |
| 675 | |
| 676 | if (OL_TRGET_STATUS_RESET == scn->target_status) { |
| 677 | HIF_INFO_MED("%s: Target is already asserted, ignore!", |
| 678 | __func__); |
| 679 | return; |
| 680 | } |
| 681 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 682 | if (hif_is_load_or_unload_in_progress(scn)) { |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 683 | HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__); |
| 684 | return; |
| 685 | } |
| 686 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 687 | hif_crash_shutdown_dump_bus_register(hif_ctx); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 688 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 689 | if (ol_copy_ramdump(hif_ctx)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 690 | goto out; |
| 691 | |
| 692 | HIF_INFO_MED("%s: RAM dump collecting completed!", __func__); |
| 693 | |
| 694 | out: |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 695 | return; |
| 696 | } |
| 697 | #else |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 698 | void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 699 | { |
| 700 | HIF_INFO_MED("%s: Collecting target RAM dump disabled", |
| 701 | __func__); |
| 702 | return; |
| 703 | } |
| 704 | #endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */ |
| 705 | |
| 706 | #ifdef QCA_WIFI_3_0 |
| 707 | /** |
| 708 | * hif_check_fw_reg(): hif_check_fw_reg |
| 709 | * @scn: scn |
| 710 | * @state: |
| 711 | * |
| 712 | * Return: int |
| 713 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 714 | int hif_check_fw_reg(struct hif_opaque_softc *scn) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 715 | { |
| 716 | return 0; |
| 717 | } |
| 718 | #endif |
| 719 | |
| 720 | #ifdef IPA_OFFLOAD |
| 721 | /** |
| 722 | * hif_read_phy_mem_base(): hif_read_phy_mem_base |
| 723 | * @scn: scn |
| 724 | * @phy_mem_base: physical mem base |
| 725 | * |
| 726 | * Return: n/a |
| 727 | */ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 728 | void hif_read_phy_mem_base(struct hif_softc *scn, cdf_dma_addr_t *phy_mem_base) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 729 | { |
| 730 | *phy_mem_base = scn->mem_pa; |
| 731 | } |
| 732 | #endif /* IPA_OFFLOAD */ |
| 733 | |
| 734 | /** |
| 735 | * hif_get_device_type(): hif_get_device_type |
| 736 | * @device_id: device_id |
| 737 | * @revision_id: revision_id |
| 738 | * @hif_type: returned hif_type |
| 739 | * @target_type: returned target_type |
| 740 | * |
| 741 | * Return: int |
| 742 | */ |
| 743 | int hif_get_device_type(uint32_t device_id, |
| 744 | uint32_t revision_id, |
| 745 | uint32_t *hif_type, uint32_t *target_type) |
| 746 | { |
| 747 | int ret = 0; |
| 748 | |
| 749 | switch (device_id) { |
| 750 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 751 | case ADRASTEA_DEVICE_ID: |
| 752 | case ADRASTEA_DEVICE_ID_P2_E12: |
| 753 | |
| 754 | *hif_type = HIF_TYPE_ADRASTEA; |
| 755 | *target_type = TARGET_TYPE_ADRASTEA; |
| 756 | break; |
| 757 | #else |
| 758 | case QCA6180_DEVICE_ID: |
| 759 | *hif_type = HIF_TYPE_QCA6180; |
| 760 | *target_type = TARGET_TYPE_QCA6180; |
| 761 | break; |
| 762 | #endif |
| 763 | |
| 764 | case AR9888_DEVICE_ID: |
| 765 | *hif_type = HIF_TYPE_AR9888; |
| 766 | *target_type = TARGET_TYPE_AR9888; |
| 767 | break; |
| 768 | |
| 769 | case AR6320_DEVICE_ID: |
| 770 | switch (revision_id) { |
| 771 | case AR6320_FW_1_1: |
| 772 | case AR6320_FW_1_3: |
| 773 | *hif_type = HIF_TYPE_AR6320; |
| 774 | *target_type = TARGET_TYPE_AR6320; |
| 775 | break; |
| 776 | |
| 777 | case AR6320_FW_2_0: |
| 778 | case AR6320_FW_3_0: |
| 779 | case AR6320_FW_3_2: |
| 780 | *hif_type = HIF_TYPE_AR6320V2; |
| 781 | *target_type = TARGET_TYPE_AR6320V2; |
| 782 | break; |
| 783 | |
| 784 | default: |
| 785 | HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x", |
| 786 | __func__, device_id, revision_id); |
| 787 | ret = -ENODEV; |
| 788 | goto end; |
| 789 | } |
| 790 | break; |
| 791 | |
| 792 | default: |
| 793 | HIF_ERROR("%s: Unsupported device ID!", __func__); |
| 794 | ret = -ENODEV; |
| 795 | break; |
| 796 | } |
| 797 | end: |
| 798 | return ret; |
| 799 | } |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 800 | |
| 801 | /** |
| 802 | * Target info and ini parameters are global to the driver |
| 803 | * Hence these structures are exposed to all the modules in |
| 804 | * the driver and they don't need to maintains multiple copies |
| 805 | * of the same info, instead get the handle from hif and |
| 806 | * modify them in hif |
| 807 | */ |
| 808 | |
| 809 | /** |
| 810 | * hif_get_ini_handle() - API to get hif_config_param handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 811 | * @hif_ctx: HIF Context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 812 | * |
| 813 | * Return: pointer to hif_config_info |
| 814 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 815 | struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 816 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 817 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 818 | |
| 819 | return &sc->hif_config; |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 820 | } |
| 821 | |
| 822 | /** |
| 823 | * hif_get_target_info_handle() - API to get hif_target_info handle |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 824 | * @hif_ctx: HIF context |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 825 | * |
| 826 | * Return: Pointer to hif_target_info |
| 827 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 828 | struct hif_target_info *hif_get_target_info_handle( |
| 829 | struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 830 | { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 831 | struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx); |
| 832 | |
| 833 | return &sc->target_info; |
| 834 | |
Komal Seelam | 91553ce | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 835 | } |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 836 | |
| 837 | #if defined(FEATURE_LRO) |
| 838 | /** |
| 839 | * hif_lro_flush_cb_register - API to register for LRO Flush Callback |
| 840 | * @scn: HIF Context |
| 841 | * @handler: Function pointer to be called by HIF |
| 842 | * @data: Private data to be used by the module registering to HIF |
| 843 | * |
| 844 | * Return: void |
| 845 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 846 | void hif_lro_flush_cb_register(struct hif_opaque_softc *scn, |
| 847 | void (handler)(void *), void *data) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 848 | { |
| 849 | ce_lro_flush_cb_register(scn, handler, data); |
| 850 | } |
| 851 | |
| 852 | /** |
| 853 | * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks |
| 854 | * @scn: HIF Context |
| 855 | * |
| 856 | * Return: void |
| 857 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 858 | void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn) |
Komal Seelam | c92a0cf | 2016-02-22 20:43:52 +0530 | [diff] [blame] | 859 | { |
| 860 | ce_lro_flush_cb_deregister(scn); |
| 861 | } |
| 862 | #endif |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 863 | |
| 864 | /** |
| 865 | * hif_get_target_status - API to get target status |
| 866 | * @hif_ctx: HIF Context |
| 867 | * |
| 868 | * Return: enum ol_target_status |
| 869 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 870 | ol_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 871 | { |
| 872 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 873 | |
| 874 | return scn->target_status; |
| 875 | } |
| 876 | |
| 877 | /** |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 878 | * hif_set_target_status() - API to set target status |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 879 | * @hif_ctx: HIF Context |
| 880 | * @status: Target Status |
| 881 | * |
| 882 | * Return: void |
| 883 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 884 | void hif_set_target_status(struct hif_opaque_softc *hif_ctx, |
| 885 | ol_target_status status) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 886 | { |
| 887 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 888 | |
| 889 | scn->target_status = status; |
| 890 | } |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 891 | |
| 892 | /** |
| 893 | * hif_init_ini_config() - API to initialize HIF configuration parameters |
| 894 | * @hif_ctx: HIF Context |
| 895 | * @cfg: HIF Configuration |
| 896 | * |
| 897 | * Return: void |
| 898 | */ |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 899 | void hif_init_ini_config(struct hif_opaque_softc *hif_ctx, |
| 900 | struct hif_config_info *cfg) |
Komal Seelam | a5911d3 | 2016-02-24 19:21:59 +0530 | [diff] [blame] | 901 | { |
| 902 | struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx); |
| 903 | |
| 904 | cdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info)); |
| 905 | } |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame^] | 906 | |
| 907 | /** |
| 908 | * hif_get_conparam() - API to get driver mode in HIF |
| 909 | * @scn: HIF Context |
| 910 | * |
| 911 | * Return: driver mode of operation |
| 912 | */ |
| 913 | uint32_t hif_get_conparam(struct hif_softc *scn) |
| 914 | { |
| 915 | if (!scn) |
| 916 | return 0; |
| 917 | |
| 918 | return scn->hif_con_param; |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * hif_get_callbacks_handle() - API to get callbacks Handle |
| 923 | * @scn: HIF Context |
| 924 | * |
| 925 | * Return: pointer to HIF Callbacks |
| 926 | */ |
| 927 | struct hif_callbacks *hif_get_callbacks_handle(struct hif_softc *scn) |
| 928 | { |
| 929 | return &scn->callbacks; |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * hif_is_driver_unloading() - API to query upper layers if driver is unloading |
| 934 | * @scn: HIF Context |
| 935 | * |
| 936 | * Return: True/False |
| 937 | */ |
| 938 | bool hif_is_driver_unloading(struct hif_softc *scn) |
| 939 | { |
| 940 | struct hif_callbacks *cbk = hif_get_callbacks_handle(scn); |
| 941 | |
| 942 | if (cbk && cbk->is_driver_unloading) |
| 943 | return cbk->is_driver_unloading(cbk->context); |
| 944 | |
| 945 | return false; |
| 946 | } |
| 947 | |
| 948 | /** |
| 949 | * hif_is_load_or_unload_in_progress() - API to query upper layers if |
| 950 | * load/unload in progress |
| 951 | * @scn: HIF Context |
| 952 | * |
| 953 | * Return: True/False |
| 954 | */ |
| 955 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn) |
| 956 | { |
| 957 | struct hif_callbacks *cbk = hif_get_callbacks_handle(scn); |
| 958 | |
| 959 | if (cbk && cbk->is_load_unload_in_progress) |
| 960 | return cbk->is_load_unload_in_progress(cbk->context); |
| 961 | |
| 962 | return false; |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * hif_is_recovery_in_progress() - API to query upper layers if recovery in |
| 967 | * progress |
| 968 | * @scn: HIF Context |
| 969 | * |
| 970 | * Return: True/False |
| 971 | */ |
| 972 | bool hif_is_recovery_in_progress(struct hif_softc *scn) |
| 973 | { |
| 974 | struct hif_callbacks *cbk = hif_get_callbacks_handle(scn); |
| 975 | |
| 976 | if (cbk && cbk->is_recovery_in_progress) |
| 977 | return cbk->is_recovery_in_progress(cbk->context); |
| 978 | |
| 979 | return false; |
| 980 | } |