blob: a8f3d695951661c95777ea6c8d13e9e6d0d0f53b [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
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080028#include "targcfg.h"
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053029#include "qdf_lock.h"
30#include "qdf_status.h"
31#include "qdf_status.h"
32#include <qdf_atomic.h> /* qdf_atomic_read */
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080033#include <targaddrs.h>
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080034#include "hif_io32.h"
35#include <hif.h>
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080036#include "regtable.h"
37#define ATH_MODULE_NAME hif
38#include <a_debug.h>
39#include "hif_main.h"
40#include "hif_hw_version.h"
41#include "ce_api.h"
42#include "ce_tasklet.h"
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053043#include "qdf_trace.h"
44#include "qdf_status.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080045#ifdef CONFIG_CNSS
46#include <net/cnss.h>
47#endif
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080048#include "hif_debug.h"
49#include "mp_dev.h"
Houston Hoffmanbc693492016-03-14 21:11:41 -070050#include "platform_icnss.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080051
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080052#define AGC_DUMP 1
53#define CHANINFO_DUMP 2
54#define BB_WATCHDOG_DUMP 3
55#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
56#define PCIE_ACCESS_DUMP 4
57#endif
58
Komal Seelam5584a7c2016-02-24 19:22:48 +053059void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t cmd_id, bool start)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080060{
Komal Seelam644263d2016-02-22 20:45:49 +053061 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080062 switch (cmd_id) {
63 case AGC_DUMP:
64 if (start)
65 priv_start_agc(scn);
66 else
67 priv_dump_agc(scn);
68 break;
69
70 case CHANINFO_DUMP:
71 if (start)
72 priv_start_cap_chaninfo(scn);
73 else
74 priv_dump_chaninfo(scn);
75 break;
76
77 case BB_WATCHDOG_DUMP:
78 priv_dump_bbwatchdog(scn);
79 break;
80
81#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
82 case PCIE_ACCESS_DUMP:
83 hif_target_dump_access_log();
84 break;
85#endif
86 default:
87 HIF_ERROR("%s: Invalid htc dump command", __func__);
88 break;
89 }
90}
91
92/**
93 * hif_shut_down_device() - hif_shut_down_device
94 *
95 * SThis fucntion shuts down the device
96 *
Komal Seelam5584a7c2016-02-24 19:22:48 +053097 * @scn: hif_opaque_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080098 *
99 * Return: void
100 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530101void hif_shut_down_device(struct hif_opaque_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800102{
Komal Seelam02cf2f82016-02-22 20:44:25 +0530103 hif_stop(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800104}
105
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800106/**
107 * hif_get_target_id(): hif_get_target_id
108 *
109 * Return the virtual memory base address to the caller
110 *
Komal Seelam644263d2016-02-22 20:45:49 +0530111 * @scn: hif_softc
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800112 *
113 * Return: A_target_id_t
114 */
Komal Seelam644263d2016-02-22 20:45:49 +0530115A_target_id_t hif_get_target_id(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800116{
117 return scn->mem;
118}
119
Houston Hoffman0dad5092015-09-28 16:25:51 -0700120static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
121{
122 struct hif_msg_callbacks *msg_callbacks =
123 &hif_state->msg_callbacks_current;
124
125 if (!msg_callbacks->fwEventHandler)
126 return;
127
128 msg_callbacks->fwEventHandler(msg_callbacks->Context,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530129 QDF_STATUS_E_FAILURE);
Houston Hoffman0dad5092015-09-28 16:25:51 -0700130}
131
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800132/**
133 * hif_fw_interrupt_handler(): FW interrupt handler
134 *
135 * This function is the FW interrupt handlder
136 *
137 * @irq: irq number
138 * @arg: the user pointer
139 *
140 * Return: bool
141 */
142#ifndef QCA_WIFI_3_0
143irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
144{
Komal Seelam644263d2016-02-22 20:45:49 +0530145 struct hif_softc *scn = arg;
Komal Seelam02cf2f82016-02-22 20:44:25 +0530146 struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800147 uint32_t fw_indicator_address, fw_indicator;
148
Houston Hoffman2c32cf62016-03-14 21:12:00 -0700149 if (Q_TARGET_ACCESS_BEGIN(scn) < 0)
150 return ATH_ISR_NOSCHED;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800151
152 fw_indicator_address = hif_state->fw_indicator_address;
153 /* For sudden unplug this will return ~0 */
154 fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
155
156 if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
157 /* ACK: clear Target-side pending event */
158 A_TARGET_WRITE(scn, fw_indicator_address,
159 fw_indicator & ~FW_IND_EVENT_PENDING);
Houston Hoffman2c32cf62016-03-14 21:12:00 -0700160 if (Q_TARGET_ACCESS_END(scn) < 0)
161 return ATH_ISR_SCHED;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800162
163 if (hif_state->started) {
Houston Hoffman0dad5092015-09-28 16:25:51 -0700164 hif_fw_event_handler(hif_state);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800165 } else {
166 /*
167 * Probable Target failure before we're prepared
168 * to handle it. Generally unexpected.
169 */
170 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
171 ("%s: Early firmware event indicated\n",
172 __func__));
173 }
174 } else {
Houston Hoffman2c32cf62016-03-14 21:12:00 -0700175 if (Q_TARGET_ACCESS_END(scn) < 0)
176 return ATH_ISR_SCHED;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800177 }
178
179 return ATH_ISR_SCHED;
180}
181#else
182irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
183{
184 return ATH_ISR_SCHED;
185}
186#endif /* #ifdef QCA_WIFI_3_0 */
187
188/**
189 * hif_get_targetdef(): hif_get_targetdef
190 * @scn: scn
191 *
192 * Return: void *
193 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530194void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800195{
Komal Seelam644263d2016-02-22 20:45:49 +0530196 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
197
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800198 return scn->targetdef;
199}
200
201/**
202 * hif_vote_link_down(): unvote for link up
203 *
204 * Call hif_vote_link_down to release a previous request made using
205 * hif_vote_link_up. A hif_vote_link_down call should only be made
206 * after a corresponding hif_vote_link_up, otherwise you could be
207 * negating a vote from another source. When no votes are present
208 * hif will not guarantee the linkstate after hif_bus_suspend.
209 *
210 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
211 * and initialization deinitialization sequencences.
212 *
213 * Return: n/a
214 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530215void hif_vote_link_down(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800216{
Komal Seelam644263d2016-02-22 20:45:49 +0530217 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530218 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800219
220 scn->linkstate_vote--;
221 if (scn->linkstate_vote == 0)
Houston Hoffmancceec342015-11-11 11:37:20 -0800222 hif_bus_prevent_linkdown(scn, false);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800223}
224
225/**
226 * hif_vote_link_up(): vote to prevent bus from suspending
227 *
228 * Makes hif guarantee that fw can message the host normally
229 * durring suspend.
230 *
231 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
232 * and initialization deinitialization sequencences.
233 *
234 * Return: n/a
235 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530236void hif_vote_link_up(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800237{
Komal Seelam644263d2016-02-22 20:45:49 +0530238 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530239 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800240
241 scn->linkstate_vote++;
242 if (scn->linkstate_vote == 1)
Houston Hoffmancceec342015-11-11 11:37:20 -0800243 hif_bus_prevent_linkdown(scn, true);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800244}
245
246/**
247 * hif_can_suspend_link(): query if hif is permitted to suspend the link
248 *
249 * Hif will ensure that the link won't be suspended if the upperlayers
250 * don't want it to.
251 *
252 * SYNCHRONIZATION: MC thread is stopped before bus suspend thus
253 * we don't need extra locking to ensure votes dont change while
254 * we are in the process of suspending or resuming.
255 *
256 * Return: false if hif will guarantee link up durring suspend.
257 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530258bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800259{
Komal Seelam644263d2016-02-22 20:45:49 +0530260 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530261 QDF_BUG(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800262
263 return scn->linkstate_vote == 0;
264}
265
266/**
267 * hif_hia_item_address(): hif_hia_item_address
268 * @target_type: target_type
269 * @item_offset: item_offset
270 *
271 * Return: n/a
272 */
273uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset)
274{
275 switch (target_type) {
276 case TARGET_TYPE_AR6002:
277 return AR6002_HOST_INTEREST_ADDRESS + item_offset;
278 case TARGET_TYPE_AR6003:
279 return AR6003_HOST_INTEREST_ADDRESS + item_offset;
280 case TARGET_TYPE_AR6004:
281 return AR6004_HOST_INTEREST_ADDRESS + item_offset;
282 case TARGET_TYPE_AR6006:
283 return AR6006_HOST_INTEREST_ADDRESS + item_offset;
284 case TARGET_TYPE_AR9888:
285 return AR9888_HOST_INTEREST_ADDRESS + item_offset;
286 case TARGET_TYPE_AR6320:
287 case TARGET_TYPE_AR6320V2:
288 return AR6320_HOST_INTEREST_ADDRESS + item_offset;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800289 case TARGET_TYPE_ADRASTEA:
290 /* ADRASTEA doesn't have a host interest address */
291 ASSERT(0);
292 return 0;
293 default:
294 ASSERT(0);
295 return 0;
296 }
297}
298
299/**
300 * hif_max_num_receives_reached() - check max receive is reached
Komal Seelambd7c51d2016-02-24 10:27:30 +0530301 * @scn: HIF Context
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800302 * @count: unsigned int.
303 *
304 * Output check status as bool
305 *
306 * Return: bool
307 */
Komal Seelambd7c51d2016-02-24 10:27:30 +0530308bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800309{
Houston Hoffman75ef5a52016-04-14 17:15:49 -0700310 if (QDF_IS_EPPING_ENABLED(hif_get_conparam(scn)))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800311 return count > 120;
312 else
313 return count > MAX_NUM_OF_RECEIVES;
314}
315
316/**
317 * init_buffer_count() - initial buffer count
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530318 * @maxSize: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800319 *
320 * routine to modify the initial buffer count to be allocated on an os
321 * platform basis. Platform owner will need to modify this as needed
322 *
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530323 * Return: qdf_size_t
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800324 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530325qdf_size_t init_buffer_count(qdf_size_t maxSize)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800326{
327 return maxSize;
328}
329
330/**
Nirav Shahd7f91592016-04-21 14:18:43 +0530331 * hif_save_htc_htt_config_endpoint() - save htt_tx_endpoint
332 * @hif_ctx: hif context
333 * @htc_htt_tx_endpoint: htt_tx_endpoint
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800334 *
335 * Return: void
336 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530337void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
Nirav Shahd7f91592016-04-21 14:18:43 +0530338 int htc_htt_tx_endpoint)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800339{
Komal Seelam644263d2016-02-22 20:45:49 +0530340 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800341
342 if (!scn) {
343 HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!",
344 __func__);
345 return;
346 }
347
Nirav Shahd7f91592016-04-21 14:18:43 +0530348 scn->htc_htt_tx_endpoint = htc_htt_tx_endpoint;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800349}
350
Houston Hoffmanec93ab02016-05-03 20:09:55 -0700351static const struct qwlan_hw qwlan_hw_list[] = {
352 {
353 .id = AR6320_REV1_VERSION,
354 .subid = 0,
355 .name = "QCA6174_REV1",
356 },
357 {
358 .id = AR6320_REV1_1_VERSION,
359 .subid = 0x1,
360 .name = "QCA6174_REV1_1",
361 },
362 {
363 .id = AR6320_REV1_3_VERSION,
364 .subid = 0x2,
365 .name = "QCA6174_REV1_3",
366 },
367 {
368 .id = AR6320_REV2_1_VERSION,
369 .subid = 0x4,
370 .name = "QCA6174_REV2_1",
371 },
372 {
373 .id = AR6320_REV2_1_VERSION,
374 .subid = 0x5,
375 .name = "QCA6174_REV2_2",
376 },
377 {
378 .id = AR6320_REV3_VERSION,
379 .subid = 0x6,
380 .name = "QCA6174_REV2.3",
381 },
382 {
383 .id = AR6320_REV3_VERSION,
384 .subid = 0x8,
385 .name = "QCA6174_REV3",
386 },
387 {
388 .id = AR6320_REV3_VERSION,
389 .subid = 0x9,
390 .name = "QCA6174_REV3_1",
391 },
392 {
393 .id = AR6320_REV3_2_VERSION,
394 .subid = 0xA,
395 .name = "AR6320_REV3_2_VERSION",
396 }
397};
398
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800399/**
400 * hif_get_hw_name(): get a human readable name for the hardware
Komal Seelam91553ce2016-01-27 18:57:10 +0530401 * @info: Target Info
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800402 *
Komal Seelam91553ce2016-01-27 18:57:10 +0530403 * Return: human readable name for the underlying wifi hardware.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800404 */
Komal Seelam91553ce2016-01-27 18:57:10 +0530405static const char *hif_get_hw_name(struct hif_target_info *info)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800406{
407 int i;
Komal Seelam91553ce2016-01-27 18:57:10 +0530408
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800409 for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) {
Komal Seelam91553ce2016-01-27 18:57:10 +0530410 if (info->target_version == qwlan_hw_list[i].id &&
411 info->target_revision == qwlan_hw_list[i].subid) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800412 return qwlan_hw_list[i].name;
413 }
414 }
415
416 return "Unknown Device";
417}
418
419/**
420 * hif_get_hw_info(): hif_get_hw_info
421 * @scn: scn
422 * @version: version
423 * @revision: revision
424 *
425 * Return: n/a
426 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530427void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800428 const char **target_name)
429{
Komal Seelam91553ce2016-01-27 18:57:10 +0530430 struct hif_target_info *info = hif_get_target_info_handle(scn);
431 *version = info->target_version;
432 *revision = info->target_revision;
433 *target_name = hif_get_hw_name(info);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800434}
435
436/**
437 * hif_open(): hif_open
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530438 * @qdf_ctx: QDF Context
Komal Seelambd7c51d2016-02-24 10:27:30 +0530439 * @mode: Driver Mode
440 * @bus_type: Bus Type
441 * @cbk: CDS Callbacks
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800442 *
Komal Seelambd7c51d2016-02-24 10:27:30 +0530443 * API to open HIF Context
444 *
445 * Return: HIF Opaque Pointer
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800446 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530447struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
448 enum qdf_bus_type bus_type,
Komal Seelam75080122016-03-02 15:18:25 +0530449 struct hif_driver_state_callbacks *cbk)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800450{
Komal Seelam644263d2016-02-22 20:45:49 +0530451 struct hif_softc *scn;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530452 QDF_STATUS status = QDF_STATUS_SUCCESS;
Houston Hoffman162164c2016-03-14 21:12:10 -0700453 int bus_context_size = hif_bus_get_context_size(bus_type);
454
455 if (bus_context_size == 0) {
456 HIF_ERROR("%s: context size 0 not allowed", __func__);
457 return NULL;
458 }
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800459
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530460 scn = (struct hif_softc *)qdf_mem_malloc(bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530461 if (!scn) {
462 HIF_ERROR("%s: cannot alloc memory for HIF context of size:%d",
463 __func__, bus_context_size);
464 return GET_HIF_OPAQUE_HDL(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800465 }
466
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530467 qdf_mem_zero(scn, bus_context_size);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530468
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530469 scn->qdf_dev = qdf_ctx;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530470 scn->hif_con_param = mode;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530471 qdf_atomic_init(&scn->active_tasklet_cnt);
472 qdf_atomic_init(&scn->link_suspended);
473 qdf_atomic_init(&scn->tasklet_from_intr);
Komal Seelam75080122016-03-02 15:18:25 +0530474 qdf_mem_copy(&scn->callbacks, cbk, sizeof(struct hif_driver_state_callbacks));
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800475
476 status = hif_bus_open(scn, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530477 if (status != QDF_STATUS_SUCCESS) {
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800478 HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d",
479 __func__, status, bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530480 qdf_mem_free(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530481 scn = NULL;
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800482 }
483
Komal Seelambd7c51d2016-02-24 10:27:30 +0530484 return GET_HIF_OPAQUE_HDL(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800485}
486
487/**
488 * hif_close(): hif_close
489 * @hif_ctx: hif_ctx
490 *
491 * Return: n/a
492 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530493void hif_close(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800494{
Komal Seelam644263d2016-02-22 20:45:49 +0530495 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800496
497 if (scn == NULL) {
Komal Seelam5584a7c2016-02-24 19:22:48 +0530498 HIF_ERROR("%s: hif_opaque_softc is NULL", __func__);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800499 return;
500 }
501
502 if (scn->athdiag_procfs_inited) {
503 athdiag_procfs_remove();
504 scn->athdiag_procfs_inited = false;
505 }
506
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800507 hif_bus_close(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530508 qdf_mem_free(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800509}
510
511/**
512 * hif_enable(): hif_enable
513 * @hif_ctx: hif_ctx
514 * @dev: dev
515 * @bdev: bus dev
516 * @bid: bus ID
517 * @bus_type: bus type
518 * @type: enable type
519 *
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530520 * Return: QDF_STATUS
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800521 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530522QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800523 void *bdev, const hif_bus_id *bid,
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530524 enum qdf_bus_type bus_type,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800525 enum hif_enable_type type)
526{
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530527 QDF_STATUS status;
Komal Seelam644263d2016-02-22 20:45:49 +0530528 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800529
530 if (scn == NULL) {
531 HIF_ERROR("%s: hif_ctx = NULL", __func__);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530532 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800533 }
534
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800535 status = hif_enable_bus(scn, dev, bdev, bid, type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530536 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800537 HIF_ERROR("%s: hif_enable_bus error = %d",
538 __func__, status);
539 return status;
540 }
541
542 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530543 hif_vote_link_up(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800544
Houston Hoffman108da402016-03-14 21:11:24 -0700545 if (hif_bus_configure(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800546 HIF_ERROR("%s: Target probe failed.", __func__);
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530547 hif_disable_bus(scn);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530548 status = QDF_STATUS_E_FAILURE;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800549 return status;
550 }
Houston Hoffman108da402016-03-14 21:11:24 -0700551
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800552 /*
553 * Flag to avoid potential unallocated memory access from MSI
554 * interrupt handler which could get scheduled as soon as MSI
555 * is enabled, i.e to take care of the race due to the order
556 * in where MSI is enabled before the memory, that will be
557 * in interrupt handlers, is allocated.
558 */
559
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800560 scn->hif_init_done = true;
561
562 HIF_TRACE("%s: X OK", __func__);
563
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530564 return QDF_STATUS_SUCCESS;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800565}
566
567/**
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800568 * hif_wlan_disable(): call the platform driver to disable wlan
Komal Seelambd7c51d2016-02-24 10:27:30 +0530569 * @scn: HIF Context
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800570 *
571 * This function passes the con_mode to platform driver to disable
572 * wlan.
573 *
574 * Return: void
575 */
Komal Seelambd7c51d2016-02-24 10:27:30 +0530576void hif_wlan_disable(struct hif_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800577{
578 enum icnss_driver_mode mode;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530579 uint32_t con_mode = hif_get_conparam(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800580
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530581 if (QDF_GLOBAL_FTM_MODE == con_mode)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800582 mode = ICNSS_FTM;
Houston Hoffman75ef5a52016-04-14 17:15:49 -0700583 else if (QDF_IS_EPPING_ENABLED(con_mode))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800584 mode = ICNSS_EPPING;
Peng Xu7b962532015-10-02 17:17:03 -0700585 else
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800586 mode = ICNSS_MISSION;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800587
588 icnss_wlan_disable(mode);
589}
590
Komal Seelam5584a7c2016-02-24 19:22:48 +0530591void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800592{
Komal Seelam644263d2016-02-22 20:45:49 +0530593 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800594
595 if (!scn)
596 return;
597
598 hif_nointrs(scn);
599 if (scn->hif_init_done == false)
Komal Seelam644263d2016-02-22 20:45:49 +0530600 hif_shut_down_device(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800601 else
Komal Seelam644263d2016-02-22 20:45:49 +0530602 hif_stop(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800603
604 if (ADRASTEA_BU)
Komal Seelamf8600682016-02-02 18:17:13 +0530605 hif_vote_link_down(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800606
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530607 hif_disable_bus(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800608
Komal Seelambd7c51d2016-02-24 10:27:30 +0530609 hif_wlan_disable(scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800610
611 scn->notice_send = false;
612
613 HIF_INFO("%s: X", __func__);
614}
615
616
617/**
Govind Singh2443fb32016-01-13 17:44:48 +0530618 * hif_crash_shutdown_dump_bus_register() - dump bus registers
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800619 * @hif_ctx: hif_ctx
620 *
621 * Return: n/a
622 */
623#if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \
Houston Hoffmanbc693492016-03-14 21:11:41 -0700624&& defined(DEBUG)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800625
Govind Singh2443fb32016-01-13 17:44:48 +0530626static void hif_crash_shutdown_dump_bus_register(void *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800627{
Komal Seelam5584a7c2016-02-24 19:22:48 +0530628 struct hif_opaque_softc *scn = hif_ctx;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800629
Govind Singh2443fb32016-01-13 17:44:48 +0530630 if (hif_check_soc_status(scn))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800631 return;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800632
Govind Singh2443fb32016-01-13 17:44:48 +0530633 if (hif_dump_registers(scn))
634 HIF_ERROR("Failed to dump bus registers!");
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800635}
636
637/**
638 * hif_crash_shutdown(): hif_crash_shutdown
639 *
640 * This function is called by the platform driver to dump CE registers
641 *
642 * @hif_ctx: hif_ctx
643 *
644 * Return: n/a
645 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530646void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800647{
Komal Seelam644263d2016-02-22 20:45:49 +0530648 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800649
Houston Hoffmanbc693492016-03-14 21:11:41 -0700650 if (!hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800651 return;
652
Houston Hoffmanbc693492016-03-14 21:11:41 -0700653 if (scn->bus_type == QDF_BUS_TYPE_SNOC) {
654 HIF_INFO_MED("%s: RAM dump disabled for bustype %d",
655 __func__, scn->bus_type);
656 return;
657 }
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800658
Komal Seelam6ee55902016-04-11 17:11:07 +0530659 if (TARGET_STATUS_RESET == scn->target_status) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800660 HIF_INFO_MED("%s: Target is already asserted, ignore!",
661 __func__);
662 return;
663 }
664
Komal Seelambd7c51d2016-02-24 10:27:30 +0530665 if (hif_is_load_or_unload_in_progress(scn)) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800666 HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__);
667 return;
668 }
669
Govind Singh2443fb32016-01-13 17:44:48 +0530670 hif_crash_shutdown_dump_bus_register(hif_ctx);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800671
Komal Seelam644263d2016-02-22 20:45:49 +0530672 if (ol_copy_ramdump(hif_ctx))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800673 goto out;
674
675 HIF_INFO_MED("%s: RAM dump collecting completed!", __func__);
676
677out:
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800678 return;
679}
680#else
Komal Seelam5584a7c2016-02-24 19:22:48 +0530681void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800682{
683 HIF_INFO_MED("%s: Collecting target RAM dump disabled",
684 __func__);
685 return;
686}
687#endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */
688
689#ifdef QCA_WIFI_3_0
690/**
691 * hif_check_fw_reg(): hif_check_fw_reg
692 * @scn: scn
693 * @state:
694 *
695 * Return: int
696 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530697int hif_check_fw_reg(struct hif_opaque_softc *scn)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800698{
699 return 0;
700}
701#endif
702
703#ifdef IPA_OFFLOAD
704/**
705 * hif_read_phy_mem_base(): hif_read_phy_mem_base
706 * @scn: scn
707 * @phy_mem_base: physical mem base
708 *
709 * Return: n/a
710 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530711void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *phy_mem_base)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800712{
713 *phy_mem_base = scn->mem_pa;
714}
715#endif /* IPA_OFFLOAD */
716
717/**
718 * hif_get_device_type(): hif_get_device_type
719 * @device_id: device_id
720 * @revision_id: revision_id
721 * @hif_type: returned hif_type
722 * @target_type: returned target_type
723 *
724 * Return: int
725 */
726int hif_get_device_type(uint32_t device_id,
727 uint32_t revision_id,
728 uint32_t *hif_type, uint32_t *target_type)
729{
730 int ret = 0;
731
732 switch (device_id) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800733 case ADRASTEA_DEVICE_ID:
734 case ADRASTEA_DEVICE_ID_P2_E12:
735
736 *hif_type = HIF_TYPE_ADRASTEA;
737 *target_type = TARGET_TYPE_ADRASTEA;
738 break;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800739
740 case AR9888_DEVICE_ID:
741 *hif_type = HIF_TYPE_AR9888;
742 *target_type = TARGET_TYPE_AR9888;
743 break;
744
745 case AR6320_DEVICE_ID:
746 switch (revision_id) {
747 case AR6320_FW_1_1:
748 case AR6320_FW_1_3:
749 *hif_type = HIF_TYPE_AR6320;
750 *target_type = TARGET_TYPE_AR6320;
751 break;
752
753 case AR6320_FW_2_0:
754 case AR6320_FW_3_0:
755 case AR6320_FW_3_2:
756 *hif_type = HIF_TYPE_AR6320V2;
757 *target_type = TARGET_TYPE_AR6320V2;
758 break;
759
760 default:
761 HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x",
762 __func__, device_id, revision_id);
763 ret = -ENODEV;
764 goto end;
765 }
766 break;
767
768 default:
769 HIF_ERROR("%s: Unsupported device ID!", __func__);
770 ret = -ENODEV;
771 break;
772 }
773end:
774 return ret;
775}
Komal Seelam91553ce2016-01-27 18:57:10 +0530776
777/**
Houston Hoffman26352592016-03-14 21:11:43 -0700778 * hif_needs_bmi() - return true if the soc needs bmi through the driver
779 * @hif_ctx: hif context
780 *
781 * Return: true if the soc needs driver bmi otherwise false
782 */
783bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
784{
785 struct hif_softc *hif_sc = HIF_GET_SOFTC(hif_ctx);
786 return hif_sc->bus_type != QDF_BUS_TYPE_SNOC;
787}
788
789/**
Houston Hoffman60a1eeb2016-03-14 21:11:44 -0700790 * hif_get_bus_type() - return the bus type
791 *
792 * Return: enum qdf_bus_type
793 */
794enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl)
795{
796 struct hif_softc *scn = HIF_GET_SOFTC(hif_hdl);
797 return scn->bus_type;
798}
799
800/**
Komal Seelam91553ce2016-01-27 18:57:10 +0530801 * Target info and ini parameters are global to the driver
802 * Hence these structures are exposed to all the modules in
803 * the driver and they don't need to maintains multiple copies
804 * of the same info, instead get the handle from hif and
805 * modify them in hif
806 */
807
808/**
809 * hif_get_ini_handle() - API to get hif_config_param handle
Komal Seelam644263d2016-02-22 20:45:49 +0530810 * @hif_ctx: HIF Context
Komal Seelam91553ce2016-01-27 18:57:10 +0530811 *
812 * Return: pointer to hif_config_info
813 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530814struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530815{
Komal Seelam644263d2016-02-22 20:45:49 +0530816 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
817
818 return &sc->hif_config;
Komal Seelam91553ce2016-01-27 18:57:10 +0530819}
820
821/**
822 * hif_get_target_info_handle() - API to get hif_target_info handle
Komal Seelam644263d2016-02-22 20:45:49 +0530823 * @hif_ctx: HIF context
Komal Seelam91553ce2016-01-27 18:57:10 +0530824 *
825 * Return: Pointer to hif_target_info
826 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530827struct hif_target_info *hif_get_target_info_handle(
828 struct hif_opaque_softc *hif_ctx)
Komal Seelam91553ce2016-01-27 18:57:10 +0530829{
Komal Seelam644263d2016-02-22 20:45:49 +0530830 struct hif_softc *sc = HIF_GET_SOFTC(hif_ctx);
831
832 return &sc->target_info;
833
Komal Seelam91553ce2016-01-27 18:57:10 +0530834}
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530835
836#if defined(FEATURE_LRO)
837/**
838 * hif_lro_flush_cb_register - API to register for LRO Flush Callback
839 * @scn: HIF Context
840 * @handler: Function pointer to be called by HIF
841 * @data: Private data to be used by the module registering to HIF
842 *
843 * Return: void
844 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530845void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
846 void (handler)(void *), void *data)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530847{
848 ce_lro_flush_cb_register(scn, handler, data);
849}
850
851/**
852 * hif_lro_flush_cb_deregister - API to deregister for LRO Flush Callbacks
853 * @scn: HIF Context
854 *
855 * Return: void
856 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530857void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn)
Komal Seelamc92a0cf2016-02-22 20:43:52 +0530858{
859 ce_lro_flush_cb_deregister(scn);
860}
861#endif
Komal Seelam644263d2016-02-22 20:45:49 +0530862
863/**
864 * hif_get_target_status - API to get target status
865 * @hif_ctx: HIF Context
866 *
Komal Seelam6ee55902016-04-11 17:11:07 +0530867 * Return: enum hif_target_status
Komal Seelam644263d2016-02-22 20:45:49 +0530868 */
Komal Seelam6ee55902016-04-11 17:11:07 +0530869enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx)
Komal Seelam644263d2016-02-22 20:45:49 +0530870{
871 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
872
873 return scn->target_status;
874}
875
876/**
Komal Seelama5911d32016-02-24 19:21:59 +0530877 * hif_set_target_status() - API to set target status
Komal Seelam644263d2016-02-22 20:45:49 +0530878 * @hif_ctx: HIF Context
879 * @status: Target Status
880 *
881 * Return: void
882 */
Komal Seelam6ee55902016-04-11 17:11:07 +0530883void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
884 hif_target_status status)
Komal Seelam644263d2016-02-22 20:45:49 +0530885{
886 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
887
888 scn->target_status = status;
889}
Komal Seelama5911d32016-02-24 19:21:59 +0530890
891/**
892 * hif_init_ini_config() - API to initialize HIF configuration parameters
893 * @hif_ctx: HIF Context
894 * @cfg: HIF Configuration
895 *
896 * Return: void
897 */
Komal Seelam5584a7c2016-02-24 19:22:48 +0530898void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
899 struct hif_config_info *cfg)
Komal Seelama5911d32016-02-24 19:21:59 +0530900{
901 struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
902
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530903 qdf_mem_copy(&scn->hif_config, cfg, sizeof(struct hif_config_info));
Komal Seelama5911d32016-02-24 19:21:59 +0530904}
Komal Seelambd7c51d2016-02-24 10:27:30 +0530905
906/**
907 * hif_get_conparam() - API to get driver mode in HIF
908 * @scn: HIF Context
909 *
910 * Return: driver mode of operation
911 */
912uint32_t hif_get_conparam(struct hif_softc *scn)
913{
914 if (!scn)
915 return 0;
916
917 return scn->hif_con_param;
918}
919
920/**
921 * hif_get_callbacks_handle() - API to get callbacks Handle
922 * @scn: HIF Context
923 *
924 * Return: pointer to HIF Callbacks
925 */
Komal Seelam75080122016-03-02 15:18:25 +0530926struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn)
Komal Seelambd7c51d2016-02-24 10:27:30 +0530927{
928 return &scn->callbacks;
929}
930
931/**
932 * hif_is_driver_unloading() - API to query upper layers if driver is unloading
933 * @scn: HIF Context
934 *
935 * Return: True/False
936 */
937bool hif_is_driver_unloading(struct hif_softc *scn)
938{
Komal Seelam75080122016-03-02 15:18:25 +0530939 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530940
941 if (cbk && cbk->is_driver_unloading)
942 return cbk->is_driver_unloading(cbk->context);
943
944 return false;
945}
946
947/**
948 * hif_is_load_or_unload_in_progress() - API to query upper layers if
949 * load/unload in progress
950 * @scn: HIF Context
951 *
952 * Return: True/False
953 */
954bool hif_is_load_or_unload_in_progress(struct hif_softc *scn)
955{
Komal Seelam75080122016-03-02 15:18:25 +0530956 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530957
958 if (cbk && cbk->is_load_unload_in_progress)
959 return cbk->is_load_unload_in_progress(cbk->context);
960
961 return false;
962}
963
964/**
965 * hif_is_recovery_in_progress() - API to query upper layers if recovery in
966 * progress
967 * @scn: HIF Context
968 *
969 * Return: True/False
970 */
971bool hif_is_recovery_in_progress(struct hif_softc *scn)
972{
Komal Seelam75080122016-03-02 15:18:25 +0530973 struct hif_driver_state_callbacks *cbk = hif_get_callbacks_handle(scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530974
975 if (cbk && cbk->is_recovery_in_progress)
976 return cbk->is_recovery_in_progress(cbk->context);
977
978 return false;
979}