blob: d1670136fe816d4a4990fd0b7af50c930a9a1ca7 [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmancceec342015-11-11 11:37:20 -08002 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08003 *
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, Anuragfc06aa92016-03-03 19:05:05 +053033#include "qdf_lock.h"
34#include "qdf_status.h"
35#include "qdf_status.h"
36#include <qdf_atomic.h> /* qdf_atomic_read */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080037#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, Anuragfc06aa92016-03-03 19:05:05 +053049#include "qdf_trace.h"
50#include "qdf_status.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080051#ifdef CONFIG_CNSS
52#include <net/cnss.h>
53#endif
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080054#include "epping_main.h"
55#include "hif_debug.h"
56#include "mp_dev.h"
Houston Hoffmanbc693492016-03-14 21:11:41 -070057#include "platform_icnss.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080058
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080059#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 Seelam5584a7c2016-02-24 19:22:48 +053066void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080067{
Komal Seelam644263d2016-02-22 20:45:49 +053068 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080069 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 Seelam5584a7c2016-02-24 19:22:48 +0530104 * @scn: hif_opaque_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800105 *
106 * Return: void
107 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530108void hif_shut_down_device(struct hif_opaque_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800109{
Komal Seelam02cf2f82016-02-22 20:44:25 +0530110 hif_stop(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800111}
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 Seelam5584a7c2016-02-24 19:22:48 +0530120 * @scn: hif_opaque_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800121 *
122 * Return: void
123 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530124void hif_cancel_deferred_target_sleep(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800125{
Komal Seelam644263d2016-02-22 20:45:49 +0530126 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
127
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800128 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 Seelam644263d2016-02-22 20:45:49 +0530136 * @scn: hif_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800137 *
138 * Return: A_target_id_t
139 */
Komal Seelam644263d2016-02-22 20:45:49 +0530140A_target_id_t hif_get_target_id(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800141{
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 Seelam5584a7c2016-02-24 19:22:48 +0530153void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800154 bool sleep_ok, bool wait_for_it)
155{
Komal Seelam644263d2016-02-22 20:45:49 +0530156 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800157 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 Seelam644263d2016-02-22 20:45:49 +0530167bool hif_target_forced_awake(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800168{
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 Hoffman0dad5092015-09-28 16:25:51 -0700183
184static 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, Anuragfc06aa92016-03-03 19:05:05 +0530193 QDF_STATUS_E_FAILURE);
Houston Hoffman0dad5092015-09-28 16:25:51 -0700194}
195
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800196/**
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
207irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
208{
Komal Seelam644263d2016-02-22 20:45:49 +0530209 struct hif_softc *scn = arg;
Komal Seelam02cf2f82016-02-22 20:44:25 +0530210 struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800211 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 Hoffman0dad5092015-09-28 16:25:51 -0700226 hif_fw_event_handler(hif_state);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800227 } 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
243irqreturn_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 Seelam5584a7c2016-02-24 19:22:48 +0530255void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800256{
Komal Seelam644263d2016-02-22 20:45:49 +0530257 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
258
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800259 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 Seelam5584a7c2016-02-24 19:22:48 +0530276void hif_vote_link_down(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800277{
Komal Seelam644263d2016-02-22 20:45:49 +0530278 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530279 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800280
281 scn->linkstate_vote--;
282 if (scn->linkstate_vote == 0)
Houston Hoffmancceec342015-11-11 11:37:20 -0800283 hif_bus_prevent_linkdown(scn, false);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800284}
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 Seelam5584a7c2016-02-24 19:22:48 +0530297void hif_vote_link_up(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800298{
Komal Seelam644263d2016-02-22 20:45:49 +0530299 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530300 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800301
302 scn->linkstate_vote++;
303 if (scn->linkstate_vote == 1)
Houston Hoffmancceec342015-11-11 11:37:20 -0800304 hif_bus_prevent_linkdown(scn, true);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800305}
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 Seelam5584a7c2016-02-24 19:22:48 +0530319bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800320{
Komal Seelam644263d2016-02-22 20:45:49 +0530321 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530322 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800323
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 */
334uint32_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 Seelambd7c51d2016-02-24 10:27:30 +0530364 * @scn: HIF Context
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800365 * @count: unsigned int.
366 *
367 * Output check status as bool
368 *
369 * Return: bool
370 */
Komal Seelambd7c51d2016-02-24 10:27:30 +0530371bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800372{
Komal Seelambd7c51d2016-02-24 10:27:30 +0530373 if (WLAN_IS_EPPING_ENABLED(hif_get_conparam(scn)))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800374 return count > 120;
375 else
376 return count > MAX_NUM_OF_RECEIVES;
377}
378
379/**
380 * init_buffer_count() - initial buffer count
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530381 * @maxSize: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800382 *
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, Anuragfc06aa92016-03-03 19:05:05 +0530386 * Return: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800387 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530388qdf_size_t init_buffer_count(qdf_size_t maxSize)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800389{
390 return maxSize;
391}
392
393/**
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800394 * hif_save_htc_htt_config_endpoint():
395 * hif_save_htc_htt_config_endpoint
396 * @htc_endpoint: htc_endpoint
397 *
398 * Return: void
399 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530400void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
401 int htc_endpoint)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800402{
Komal Seelam644263d2016-02-22 20:45:49 +0530403 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800404
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 Seelam91553ce2016-01-27 18:57:10 +0530416 * @info: Target Info
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800417 *
Komal Seelam91553ce2016-01-27 18:57:10 +0530418 * Return: human readable name for the underlying wifi hardware.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800419 */
Komal Seelam91553ce2016-01-27 18:57:10 +0530420static const char *hif_get_hw_name(struct hif_target_info *info)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800421{
422 int i;
Komal Seelam91553ce2016-01-27 18:57:10 +0530423
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800424 for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) {
Komal Seelam91553ce2016-01-27 18:57:10 +0530425 if (info->target_version == qwlan_hw_list[i].id &&
426 info->target_revision == qwlan_hw_list[i].subid) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800427 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 Seelam5584a7c2016-02-24 19:22:48 +0530442void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800443 const char **target_name)
444{
Komal Seelam91553ce2016-01-27 18:57:10 +0530445 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 Dhavalid5c9f1c2015-11-08 19:04:44 -0800449}
450
451/**
452 * hif_open(): hif_open
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530453 * @qdf_ctx: QDF Context
Komal Seelambd7c51d2016-02-24 10:27:30 +0530454 * @mode: Driver Mode
455 * @bus_type: Bus Type
456 * @cbk: CDS Callbacks
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800457 *
Komal Seelambd7c51d2016-02-24 10:27:30 +0530458 * API to open HIF Context
459 *
460 * Return: HIF Opaque Pointer
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800461 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530462struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
463 enum qdf_bus_type bus_type,
Komal Seelambd7c51d2016-02-24 10:27:30 +0530464 struct hif_callbacks *cbk)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800465{
Komal Seelam644263d2016-02-22 20:45:49 +0530466 struct hif_softc *scn;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530467 QDF_STATUS status = QDF_STATUS_SUCCESS;
Komal Seelam43301de2016-02-02 18:20:48 +0530468 int bus_context_size = hif_bus_get_context_size();
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800469
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530470 scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530471 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 Dhavalid5c9f1c2015-11-08 19:04:44 -0800475 }
476
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530477 qdf_mem_zero(scn, bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530478
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530479 scn->qdf_dev = qdf_ctx;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530480 scn->hif_con_param = mode;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530481 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 Hoffman3cfe6862016-01-08 10:33:55 -0800485
486 status = hif_bus_open(scn, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530487 if (status != QDF_STATUS_SUCCESS) {
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800488 HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d",
489 __func__, status, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530490 qdf_mem_free(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530491 scn = NULL;
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800492 }
493
Komal Seelambd7c51d2016-02-24 10:27:30 +0530494 return GET_HIF_OPAQUE_HDL(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800495}
496
497/**
498 * hif_close(): hif_close
499 * @hif_ctx: hif_ctx
500 *
501 * Return: n/a
502 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530503void hif_close(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800504{
Komal Seelam644263d2016-02-22 20:45:49 +0530505 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800506
507 if (scn == NULL) {
Komal Seelam5584a7c2016-02-24 19:22:48 +0530508 HIF_ERROR("%s: hif_opaque_softc is NULL", __func__);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800509 return;
510 }
511
512 if (scn->athdiag_procfs_inited) {
513 athdiag_procfs_remove();
514 scn->athdiag_procfs_inited = false;
515 }
516
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800517 hif_bus_close(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530518 qdf_mem_free(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800519}
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, Anuragfc06aa92016-03-03 19:05:05 +0530530 * Return: QDF_STATUS
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800531 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530532QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800533 void *bdev, const hif_bus_id *bid,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530534 enum qdf_bus_type bus_type,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800535 enum hif_enable_type type)
536{
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530537 QDF_STATUS status;
Komal Seelam644263d2016-02-22 20:45:49 +0530538 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800539
540 if (scn == NULL) {
541 HIF_ERROR("%s: hif_ctx = NULL", __func__);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530542 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800543 }
544
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800545 status = hif_enable_bus(scn, dev, bdev, bid, type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530546 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800547 HIF_ERROR("%s: hif_enable_bus error = %d",
548 __func__, status);
549 return status;
550 }
551
552 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530553 hif_vote_link_up(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800554
Houston Hoffman108da402016-03-14 21:11:24 -0700555 if (hif_bus_configure(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800556 HIF_ERROR("%s: Target probe failed.", __func__);
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530557 hif_disable_bus(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530558 status = QDF_STATUS_E_FAILURE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800559 return status;
560 }
Houston Hoffman108da402016-03-14 21:11:24 -0700561
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800562 /*
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 Dhavalid5c9f1c2015-11-08 19:04:44 -0800570 scn->hif_init_done = true;
571
572 HIF_TRACE("%s: X OK", __func__);
573
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530574 return QDF_STATUS_SUCCESS;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800575}
576
577/**
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800578 * hif_wlan_disable(): call the platform driver to disable wlan
Komal Seelambd7c51d2016-02-24 10:27:30 +0530579 * @scn: HIF Context
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800580 *
581 * This function passes the con_mode to platform driver to disable
582 * wlan.
583 *
584 * Return: void
585 */
Komal Seelambd7c51d2016-02-24 10:27:30 +0530586void hif_wlan_disable(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800587{
588 enum icnss_driver_mode mode;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530589 uint32_t con_mode = hif_get_conparam(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800590
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530591 if (QDF_GLOBAL_FTM_MODE == con_mode)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800592 mode = ICNSS_FTM;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530593 else if (WLAN_IS_EPPING_ENABLED(con_mode))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800594 mode = ICNSS_EPPING;
Peng Xu7b962532015-10-02 17:17:03 -0700595 else
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800596 mode = ICNSS_MISSION;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800597
598 icnss_wlan_disable(mode);
599}
600
Komal Seelam5584a7c2016-02-24 19:22:48 +0530601void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800602{
Komal Seelam644263d2016-02-22 20:45:49 +0530603 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800604
605 if (!scn)
606 return;
607
608 hif_nointrs(scn);
609 if (scn->hif_init_done == false)
Komal Seelam644263d2016-02-22 20:45:49 +0530610 hif_shut_down_device(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800611 else
Komal Seelam644263d2016-02-22 20:45:49 +0530612 hif_stop(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800613
614 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530615 hif_vote_link_down(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800616
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530617 hif_disable_bus(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800618
Komal Seelambd7c51d2016-02-24 10:27:30 +0530619 hif_wlan_disable(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800620
621 scn->notice_send = false;
622
623 HIF_INFO("%s: X", __func__);
624}
625
626
627/**
Govind Singh2443fb32016-01-13 17:44:48 +0530628 * hif_crash_shutdown_dump_bus_register() - dump bus registers
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800629 * @hif_ctx: hif_ctx
630 *
631 * Return: n/a
632 */
633#if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \
Houston Hoffmanbc693492016-03-14 21:11:41 -0700634&& defined(DEBUG)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800635
Govind Singh2443fb32016-01-13 17:44:48 +0530636static void hif_crash_shutdown_dump_bus_register(void *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800637{
Komal Seelam5584a7c2016-02-24 19:22:48 +0530638 struct hif_opaque_softc *scn = hif_ctx;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800639
Govind Singh2443fb32016-01-13 17:44:48 +0530640 if (hif_check_soc_status(scn))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800641 return;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800642
Govind Singh2443fb32016-01-13 17:44:48 +0530643 if (hif_dump_registers(scn))
644 HIF_ERROR("Failed to dump bus registers!");
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800645}
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 Seelam5584a7c2016-02-24 19:22:48 +0530656void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800657{
Komal Seelam644263d2016-02-22 20:45:49 +0530658 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800659
Houston Hoffmanbc693492016-03-14 21:11:41 -0700660 if (!hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800661 return;
662
Houston Hoffmanbc693492016-03-14 21:11:41 -0700663 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 Dhavalid5c9f1c2015-11-08 19:04:44 -0800668
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 Seelambd7c51d2016-02-24 10:27:30 +0530675 if (hif_is_load_or_unload_in_progress(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800676 HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__);
677 return;
678 }
679
Govind Singh2443fb32016-01-13 17:44:48 +0530680 hif_crash_shutdown_dump_bus_register(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800681
Komal Seelam644263d2016-02-22 20:45:49 +0530682 if (ol_copy_ramdump(hif_ctx))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800683 goto out;
684
685 HIF_INFO_MED("%s: RAM dump collecting completed!", __func__);
686
687out:
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800688 return;
689}
690#else
Komal Seelam5584a7c2016-02-24 19:22:48 +0530691void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800692{
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 Seelam5584a7c2016-02-24 19:22:48 +0530707int hif_check_fw_reg(struct hif_opaque_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800708{
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, Anuragfc06aa92016-03-03 19:05:05 +0530721void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *phy_mem_base)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800722{
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 */
736int 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 }
790end:
791 return ret;
792}
Komal Seelam91553ce2016-01-27 18:57:10 +0530793
794/**
Houston Hoffman26352592016-03-14 21:11:43 -0700795 * 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 */
800bool 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 Hoffman60a1eeb2016-03-14 21:11:44 -0700807 * hif_get_bus_type() - return the bus type
808 *
809 * Return: enum qdf_bus_type
810 */
811enum 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 Seelam91553ce2016-01-27 18:57:10 +0530818 * 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 Seelam644263d2016-02-22 20:45:49 +0530827 * @hif_ctx: HIF Context
Komal Seelam91553ce2016-01-27 18:57:10 +0530828 *
829 * Return: pointer to hif_config_info
830 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530831struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530832{
Komal Seelam644263d2016-02-22 20:45:49 +0530833 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
834
835 return &sc->hif_config;
Komal Seelam91553ce2016-01-27 18:57:10 +0530836}
837
838/**
839 * hif_get_target_info_handle() - API to get hif_target_info handle
Komal Seelam644263d2016-02-22 20:45:49 +0530840 * @hif_ctx: HIF context
Komal Seelam91553ce2016-01-27 18:57:10 +0530841 *
842 * Return: Pointer to hif_target_info
843 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530844struct hif_target_info *hif_get_target_info_handle(
845 struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530846{
Komal Seelam644263d2016-02-22 20:45:49 +0530847 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
848
849 return &sc->target_info;
850
Komal Seelam91553ce2016-01-27 18:57:10 +0530851}
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530852
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 Seelam5584a7c2016-02-24 19:22:48 +0530862void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
863 void (handler)(void *), void *data)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530864{
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 Seelam5584a7c2016-02-24 19:22:48 +0530874void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530875{
876 ce_lro_flush_cb_deregister(scn);
877}
878#endif
Komal Seelam644263d2016-02-22 20:45:49 +0530879
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 Seelam5584a7c2016-02-24 19:22:48 +0530886ol_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx)
Komal Seelam644263d2016-02-22 20:45:49 +0530887{
888 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
889
890 return scn->target_status;
891}
892
893/**
Komal Seelama5911d32016-02-24 19:21:59 +0530894 * hif_set_target_status() - API to set target status
Komal Seelam644263d2016-02-22 20:45:49 +0530895 * @hif_ctx: HIF Context
896 * @status: Target Status
897 *
898 * Return: void
899 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530900void hif_set_target_status(struct hif_opaque_softc *hif_ctx,
901 ol_target_status status)
Komal Seelam644263d2016-02-22 20:45:49 +0530902{
903 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
904
905 scn->target_status = status;
906}
Komal Seelama5911d32016-02-24 19:21:59 +0530907
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 Seelam5584a7c2016-02-24 19:22:48 +0530915void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
916 struct hif_config_info *cfg)
Komal Seelama5911d32016-02-24 19:21:59 +0530917{
918 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
919
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530920 qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info));
Komal Seelama5911d32016-02-24 19:21:59 +0530921}
Komal Seelambd7c51d2016-02-24 10:27:30 +0530922
923/**
924 * hif_get_conparam() - API to get driver mode in HIF
925 * @scn: HIF Context
926 *
927 * Return: driver mode of operation
928 */
929uint32_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 */
943struct 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 */
954bool 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 */
971bool 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 */
988bool 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}