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