blob: ef1aca1939f01a29cd29b74a4e9189682bd40eda [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"
33#include "cdf_lock.h"
34#include "cdf_status.h"
35#include <cdf_atomic.h> /* cdf_atomic_read */
36#include <targaddrs.h>
37#include <bmi_msg.h>
38#include "hif_io32.h"
39#include <hif.h>
40#include <htc_services.h>
41#include "regtable.h"
42#define ATH_MODULE_NAME hif
43#include <a_debug.h>
44#include "hif_main.h"
45#include "hif_hw_version.h"
46#include "ce_api.h"
47#include "ce_tasklet.h"
48#include "cdf_trace.h"
49#include "cdf_status.h"
50#include "cds_api.h"
51#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"
57#ifdef HIF_PCI
58#include "icnss_stub.h"
59#else
60#include <soc/qcom/icnss.h>
61#endif
62
63#ifndef REMOVE_PKT_LOG
64#include "pktlog_ac.h"
65#endif
66
Chandrasekaran, Manishekar681d1372015-11-05 10:42:48 +053067#include "cds_concurrency.h"
68
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080069#define AGC_DUMP 1
70#define CHANINFO_DUMP 2
71#define BB_WATCHDOG_DUMP 3
72#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
73#define PCIE_ACCESS_DUMP 4
74#endif
75
76void hif_dump(struct ol_softc *scn, uint8_t cmd_id, bool start)
77{
78 switch (cmd_id) {
79 case AGC_DUMP:
80 if (start)
81 priv_start_agc(scn);
82 else
83 priv_dump_agc(scn);
84 break;
85
86 case CHANINFO_DUMP:
87 if (start)
88 priv_start_cap_chaninfo(scn);
89 else
90 priv_dump_chaninfo(scn);
91 break;
92
93 case BB_WATCHDOG_DUMP:
94 priv_dump_bbwatchdog(scn);
95 break;
96
97#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
98 case PCIE_ACCESS_DUMP:
99 hif_target_dump_access_log();
100 break;
101#endif
102 default:
103 HIF_ERROR("%s: Invalid htc dump command", __func__);
104 break;
105 }
106}
107
108/**
109 * hif_shut_down_device() - hif_shut_down_device
110 *
111 * SThis fucntion shuts down the device
112 *
113 * @scn: ol_softc
114 *
115 * Return: void
116 */
117void hif_shut_down_device(struct ol_softc *scn)
118{
119 if (scn && scn->hif_hdl) {
120 struct HIF_CE_state *hif_state =
121 (struct HIF_CE_state *)scn->hif_hdl;
122
123 hif_stop(scn);
124 cdf_mem_free(hif_state);
125 scn->hif_hdl = NULL;
126 }
127
128}
129
130
131
132/**
133 * hif_cancel_deferred_target_sleep() - cancel deferred target sleep
134 *
135 * This function cancels the defered target sleep
136 *
137 * @scn: ol_softc
138 *
139 * Return: void
140 */
141void hif_cancel_deferred_target_sleep(struct ol_softc *scn)
142{
143 hif_pci_cancel_deferred_target_sleep(scn);
144}
145
146/**
147 * hif_get_target_id(): hif_get_target_id
148 *
149 * Return the virtual memory base address to the caller
150 *
151 * @scn: ol_softc
152 *
153 * Return: A_target_id_t
154 */
155A_target_id_t hif_get_target_id(struct ol_softc *scn)
156{
157 return scn->mem;
158}
159
160/**
161 * hif_set_target_sleep(): hif_set_target_sleep
162 * @scn: scn
163 * @sleep_ok: sleep_ok
164 * @wait_for_it: wait
165 *
166 * Return: void
167 */
168void hif_set_target_sleep(struct ol_softc *scn,
169 bool sleep_ok, bool wait_for_it)
170{
171 hif_target_sleep_state_adjust(scn,
172 sleep_ok, wait_for_it);
173}
174
175/**
176 * hif_target_forced_awake(): hif_target_forced_awake
177 * @scn: scn
178 *
179 * Return: bool
180 */
181bool hif_target_forced_awake(struct ol_softc *scn)
182{
183 A_target_id_t addr = scn->mem;
184 bool awake;
185 bool forced_awake;
186
187 awake = hif_targ_is_awake(scn, addr);
188
189 forced_awake =
190 !!(hif_read32_mb
191 (addr + PCIE_LOCAL_BASE_ADDRESS +
192 PCIE_SOC_WAKE_ADDRESS) & PCIE_SOC_WAKE_V_MASK);
193
194 return awake && forced_awake;
195}
196
Houston Hoffman0dad5092015-09-28 16:25:51 -0700197
198static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
199{
200 struct hif_msg_callbacks *msg_callbacks =
201 &hif_state->msg_callbacks_current;
202
203 if (!msg_callbacks->fwEventHandler)
204 return;
205
206 msg_callbacks->fwEventHandler(msg_callbacks->Context,
207 CDF_STATUS_E_FAILURE);
208}
209
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800210/**
211 * hif_fw_interrupt_handler(): FW interrupt handler
212 *
213 * This function is the FW interrupt handlder
214 *
215 * @irq: irq number
216 * @arg: the user pointer
217 *
218 * Return: bool
219 */
220#ifndef QCA_WIFI_3_0
221irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
222{
223 struct ol_softc *scn = arg;
224 struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl;
225 uint32_t fw_indicator_address, fw_indicator;
226
227 A_TARGET_ACCESS_BEGIN_RET(scn);
228
229 fw_indicator_address = hif_state->fw_indicator_address;
230 /* For sudden unplug this will return ~0 */
231 fw_indicator = A_TARGET_READ(scn, fw_indicator_address);
232
233 if ((fw_indicator != ~0) && (fw_indicator & FW_IND_EVENT_PENDING)) {
234 /* ACK: clear Target-side pending event */
235 A_TARGET_WRITE(scn, fw_indicator_address,
236 fw_indicator & ~FW_IND_EVENT_PENDING);
237 A_TARGET_ACCESS_END_RET(scn);
238
239 if (hif_state->started) {
Houston Hoffman0dad5092015-09-28 16:25:51 -0700240 hif_fw_event_handler(hif_state);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800241 } else {
242 /*
243 * Probable Target failure before we're prepared
244 * to handle it. Generally unexpected.
245 */
246 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
247 ("%s: Early firmware event indicated\n",
248 __func__));
249 }
250 } else {
251 A_TARGET_ACCESS_END_RET(scn);
252 }
253
254 return ATH_ISR_SCHED;
255}
256#else
257irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
258{
259 return ATH_ISR_SCHED;
260}
261#endif /* #ifdef QCA_WIFI_3_0 */
262
263/**
264 * hif_get_targetdef(): hif_get_targetdef
265 * @scn: scn
266 *
267 * Return: void *
268 */
269void *hif_get_targetdef(struct ol_softc *scn)
270{
271 return scn->targetdef;
272}
273
274/**
275 * hif_vote_link_down(): unvote for link up
276 *
277 * Call hif_vote_link_down to release a previous request made using
278 * hif_vote_link_up. A hif_vote_link_down call should only be made
279 * after a corresponding hif_vote_link_up, otherwise you could be
280 * negating a vote from another source. When no votes are present
281 * hif will not guarantee the linkstate after hif_bus_suspend.
282 *
283 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
284 * and initialization deinitialization sequencences.
285 *
286 * Return: n/a
287 */
288void hif_vote_link_down(void)
289{
290 struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
291 CDF_BUG(scn);
292
293 scn->linkstate_vote--;
294 if (scn->linkstate_vote == 0)
Houston Hoffmancceec342015-11-11 11:37:20 -0800295 hif_bus_prevent_linkdown(scn, false);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800296}
297
298/**
299 * hif_vote_link_up(): vote to prevent bus from suspending
300 *
301 * Makes hif guarantee that fw can message the host normally
302 * durring suspend.
303 *
304 * SYNCHRONIZE WITH hif_vote_link_up by only calling in MC thread
305 * and initialization deinitialization sequencences.
306 *
307 * Return: n/a
308 */
309void hif_vote_link_up(void)
310{
311 struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
312 CDF_BUG(scn);
313
314 scn->linkstate_vote++;
315 if (scn->linkstate_vote == 1)
Houston Hoffmancceec342015-11-11 11:37:20 -0800316 hif_bus_prevent_linkdown(scn, true);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800317}
318
319/**
320 * hif_can_suspend_link(): query if hif is permitted to suspend the link
321 *
322 * Hif will ensure that the link won't be suspended if the upperlayers
323 * don't want it to.
324 *
325 * SYNCHRONIZATION: MC thread is stopped before bus suspend thus
326 * we don't need extra locking to ensure votes dont change while
327 * we are in the process of suspending or resuming.
328 *
329 * Return: false if hif will guarantee link up durring suspend.
330 */
331bool hif_can_suspend_link(void)
332{
333 struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
334 CDF_BUG(scn);
335
336 return scn->linkstate_vote == 0;
337}
338
339/**
340 * hif_hia_item_address(): hif_hia_item_address
341 * @target_type: target_type
342 * @item_offset: item_offset
343 *
344 * Return: n/a
345 */
346uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset)
347{
348 switch (target_type) {
349 case TARGET_TYPE_AR6002:
350 return AR6002_HOST_INTEREST_ADDRESS + item_offset;
351 case TARGET_TYPE_AR6003:
352 return AR6003_HOST_INTEREST_ADDRESS + item_offset;
353 case TARGET_TYPE_AR6004:
354 return AR6004_HOST_INTEREST_ADDRESS + item_offset;
355 case TARGET_TYPE_AR6006:
356 return AR6006_HOST_INTEREST_ADDRESS + item_offset;
357 case TARGET_TYPE_AR9888:
358 return AR9888_HOST_INTEREST_ADDRESS + item_offset;
359 case TARGET_TYPE_AR6320:
360 case TARGET_TYPE_AR6320V2:
361 return AR6320_HOST_INTEREST_ADDRESS + item_offset;
362 case TARGET_TYPE_QCA6180:
363 return QCA6180_HOST_INTEREST_ADDRESS + item_offset;
364 case TARGET_TYPE_ADRASTEA:
365 /* ADRASTEA doesn't have a host interest address */
366 ASSERT(0);
367 return 0;
368 default:
369 ASSERT(0);
370 return 0;
371 }
372}
373
374/**
375 * hif_max_num_receives_reached() - check max receive is reached
376 * @count: unsigned int.
377 *
378 * Output check status as bool
379 *
380 * Return: bool
381 */
382bool hif_max_num_receives_reached(unsigned int count)
383{
384 if (WLAN_IS_EPPING_ENABLED(cds_get_conparam()))
385 return count > 120;
386 else
387 return count > MAX_NUM_OF_RECEIVES;
388}
389
390/**
391 * init_buffer_count() - initial buffer count
392 * @maxSize: cdf_size_t
393 *
394 * routine to modify the initial buffer count to be allocated on an os
395 * platform basis. Platform owner will need to modify this as needed
396 *
397 * Return: cdf_size_t
398 */
399cdf_size_t init_buffer_count(cdf_size_t maxSize)
400{
401 return maxSize;
402}
403
404/**
405 * hif_init_cdf_ctx(): hif_init_cdf_ctx
406 * @hif_ctx: hif_ctx
407 *
408 * Return: int
409 */
410int hif_init_cdf_ctx(void *hif_ctx)
411{
412 cdf_device_t cdf_ctx;
413 struct ol_softc *scn = (struct ol_softc *)hif_ctx;
414
415 cdf_ctx = cds_get_context(CDF_MODULE_ID_CDF_DEVICE);
416 if (!cdf_ctx) {
417 HIF_ERROR("%s: CDF is NULL", __func__);
418 return -ENOMEM;
419 }
420
421 cdf_ctx->drv = &scn->aps_osdev;
422 cdf_ctx->drv_hdl = scn->aps_osdev.bdev;
423 cdf_ctx->dev = scn->aps_osdev.device;
424 scn->cdf_dev = cdf_ctx;
425 return 0;
426}
427
428/**
429 * hif_deinit_cdf_ctx(): hif_deinit_cdf_ctx
430 * @hif_ctx: hif_ctx
431 *
432 * Return: void
433 */
434void hif_deinit_cdf_ctx(void *hif_ctx)
435{
436 struct ol_softc *scn = (struct ol_softc *)hif_ctx;
437
438 if (scn == NULL || !scn->cdf_dev)
439 return;
440 scn->cdf_dev = NULL;
441}
442
443/**
444 * hif_save_htc_htt_config_endpoint():
445 * hif_save_htc_htt_config_endpoint
446 * @htc_endpoint: htc_endpoint
447 *
448 * Return: void
449 */
450void hif_save_htc_htt_config_endpoint(int htc_endpoint)
451{
452 struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
453
454 if (!scn) {
455 HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!",
456 __func__);
457 return;
458 }
459
460 scn->htc_endpoint = htc_endpoint;
461}
462
463/**
464 * hif_get_hw_name(): get a human readable name for the hardware
465 *
466 * Return: human readible name for the underlying wifi hardware.
467 */
468const char *hif_get_hw_name(struct ol_softc *scn)
469{
470 int i;
471 for (i = 0; i < ARRAY_SIZE(qwlan_hw_list); i++) {
472 if (scn->target_version == qwlan_hw_list[i].id &&
473 scn->target_revision == qwlan_hw_list[i].subid) {
474 return qwlan_hw_list[i].name;
475 }
476 }
477
478 return "Unknown Device";
479}
480
481/**
482 * hif_get_hw_info(): hif_get_hw_info
483 * @scn: scn
484 * @version: version
485 * @revision: revision
486 *
487 * Return: n/a
488 */
489void hif_get_hw_info(void *scn, u32 *version, u32 *revision,
490 const char **target_name)
491{
492 *version = ((struct ol_softc *)scn)->target_version;
493 *revision = ((struct ol_softc *)scn)->target_revision;
494 *target_name = hif_get_hw_name((struct ol_softc *)scn);
495}
496
497/**
498 * hif_set_fw_info(): set the target_fw_version
499 * @scn: scn
500 * @target_fw_version: target_fw_version
501 *
502 * Return: n/a
503 */
504void hif_set_fw_info(void *scn, uint32_t target_fw_version)
505{
506 ((struct ol_softc *)scn)->target_fw_version = target_fw_version;
507}
508
509/**
510 * hif_open(): hif_open
511 *
512 * Return: scn
513 */
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800514CDF_STATUS hif_open(enum ath_hal_bus_type bus_type)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800515{
516 struct ol_softc *scn;
517 v_CONTEXT_t cds_context;
518 CDF_STATUS status = CDF_STATUS_SUCCESS;
519
520 cds_context = cds_get_global_context();
521 status = cds_alloc_context(cds_context, CDF_MODULE_ID_HIF,
522 (void **)&scn, sizeof(*scn));
523 if (status != CDF_STATUS_SUCCESS) {
524 HIF_ERROR("%s: cannot alloc ol_sc", __func__);
525 return status;
526 }
527
528 cdf_mem_zero(scn, sizeof(*scn));
529 scn->enableuartprint = 0;
530 scn->enablefwlog = 0;
531 scn->max_no_of_peers = 1;
532 scn->pkt_log_init = false;
533 cdf_atomic_init(&scn->wow_done);
534 cdf_atomic_init(&scn->active_tasklet_cnt);
535 cdf_atomic_init(&scn->link_suspended);
536 cdf_atomic_init(&scn->tasklet_from_intr);
537 init_waitqueue_head(&scn->aps_osdev.event_queue);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800538 scn->linkstate_vote = 0;
Houston Hoffman3cfe6862016-01-08 10:33:55 -0800539
540 status = hif_bus_open(scn, bus_type);
541 if (status != CDF_STATUS_SUCCESS) {
542 HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d",
543 __func__, status, bus_type);
544 cds_free_context(cds_context, CDF_MODULE_ID_HIF, scn);
545 }
546
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800547 return status;
548}
549
550/**
551 * hif_close(): hif_close
552 * @hif_ctx: hif_ctx
553 *
554 * Return: n/a
555 */
556void hif_close(void *hif_ctx)
557{
558 struct ol_softc *scn = hif_ctx;
559
560 if (scn == NULL) {
561 HIF_ERROR("%s: ol_softc is NULL", __func__);
562 return;
563 }
564
565 if (scn->athdiag_procfs_inited) {
566 athdiag_procfs_remove();
567 scn->athdiag_procfs_inited = false;
568 }
569
570 if (scn->hif_hdl) {
571 cdf_mem_free(scn->hif_hdl);
572 scn->hif_hdl = NULL;
573 }
574 hif_bus_close(scn);
575 cds_free_context(cds_get_global_context(),
576 CDF_MODULE_ID_HIF, hif_ctx);
577}
578
579/**
580 * hif_enable(): hif_enable
581 * @hif_ctx: hif_ctx
582 * @dev: dev
583 * @bdev: bus dev
584 * @bid: bus ID
585 * @bus_type: bus type
586 * @type: enable type
587 *
588 * Return: CDF_STATUS
589 */
590CDF_STATUS hif_enable(void *hif_ctx, struct device *dev,
591 void *bdev, const hif_bus_id *bid,
592 enum ath_hal_bus_type bus_type,
593 enum hif_enable_type type)
594{
595 CDF_STATUS status;
596 struct ol_softc *scn = hif_ctx;
597
598 if (scn == NULL) {
599 HIF_ERROR("%s: hif_ctx = NULL", __func__);
600 return CDF_STATUS_E_NULL_VALUE;
601 }
602
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800603 status = hif_enable_bus(scn, dev, bdev, bid, type);
604 if (status != CDF_STATUS_SUCCESS) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800605 HIF_ERROR("%s: hif_enable_bus error = %d",
606 __func__, status);
607 return status;
608 }
609
610 if (ADRASTEA_BU)
611 hif_vote_link_up();
612
613 if (hif_config_ce(scn)) {
614 HIF_ERROR("%s: Target probe failed.", __func__);
615 hif_disable_bus(scn->aps_osdev.bdev);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800616 status = CDF_STATUS_E_FAILURE;
617 return status;
618 }
619 /*
620 * Flag to avoid potential unallocated memory access from MSI
621 * interrupt handler which could get scheduled as soon as MSI
622 * is enabled, i.e to take care of the race due to the order
623 * in where MSI is enabled before the memory, that will be
624 * in interrupt handlers, is allocated.
625 */
626
627#ifdef HIF_PCI
628 status = hif_configure_irq(scn->hif_sc);
629 if (status < 0) {
630 HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d",
631 __func__, status);
632 return CDF_STATUS_E_FAILURE;
633 }
634#endif
635
636 scn->hif_init_done = true;
637
638 HIF_TRACE("%s: X OK", __func__);
639
640 return CDF_STATUS_SUCCESS;
641}
642
643/**
644 * hif_pktlogmod_exit(): hif_pktlogmod_exit
645 * @scn: scn
646 *
647 * Return: n/a
648 */
649#ifndef REMOVE_PKT_LOG
650void hif_pktlogmod_exit(void *hif_ctx)
651{
652 struct ol_softc *scn = hif_ctx;
653
Peng Xu7b962532015-10-02 17:17:03 -0700654 if (scn && cds_get_conparam() != CDF_GLOBAL_FTM_MODE &&
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800655 !WLAN_IS_EPPING_ENABLED(cds_get_conparam()) && scn->pkt_log_init) {
656 pktlogmod_exit(scn);
657 scn->pkt_log_init = false;
658 }
659}
660#else
661void hif_pktlogmod_exit(void *hif_ctx)
662{
663}
664#endif
665
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800666/**
667 * hif_wlan_disable(): call the platform driver to disable wlan
668 *
669 * This function passes the con_mode to platform driver to disable
670 * wlan.
671 *
672 * Return: void
673 */
674void hif_wlan_disable(void)
675{
676 enum icnss_driver_mode mode;
677 uint32_t con_mode = cds_get_conparam();
678
Peng Xu7b962532015-10-02 17:17:03 -0700679 if (CDF_GLOBAL_FTM_MODE == con_mode)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800680 mode = ICNSS_FTM;
Peng Xu7b962532015-10-02 17:17:03 -0700681 else if (WLAN_IS_EPPING_ENABLED(cds_get_conparam()))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800682 mode = ICNSS_EPPING;
Peng Xu7b962532015-10-02 17:17:03 -0700683 else
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800684 mode = ICNSS_MISSION;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800685
686 icnss_wlan_disable(mode);
687}
688
689void hif_disable(void *hif_ctx, enum hif_disable_type type)
690{
691 struct ol_softc *scn = hif_ctx;
692
693 if (!scn)
694 return;
695
696 hif_nointrs(scn);
697 if (scn->hif_init_done == false)
698 hif_shut_down_device(scn);
699 else
700 hif_stop(scn);
701
702 if (ADRASTEA_BU)
703 hif_vote_link_down();
704
705 if (scn->aps_osdev.bdev)
706 hif_disable_bus(scn->aps_osdev.bdev);
707
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800708 hif_wlan_disable();
709
710 scn->notice_send = false;
711
712 HIF_INFO("%s: X", __func__);
713}
714
715
716/**
717 * hif_crash_shutdown_dump_ce_register():
718 * hif_crash_shutdown_dump_ce_register
719 * @hif_ctx: hif_ctx
720 *
721 * Return: n/a
722 */
723#if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \
724&& defined(HIF_PCI) && defined(DEBUG)
725
726static void hif_crash_shutdown_dump_ce_register(void *hif_ctx)
727{
728 struct ol_softc *scn = hif_ctx;
729
730 if (hif_check_soc_status(scn)
731 || dump_ce_register(scn)) {
732 return;
733 }
734
735 dump_ce_debug_register(scn);
736}
737
738/**
739 * hif_crash_shutdown(): hif_crash_shutdown
740 *
741 * This function is called by the platform driver to dump CE registers
742 *
743 * @hif_ctx: hif_ctx
744 *
745 * Return: n/a
746 */
747void hif_crash_shutdown(void *hif_ctx)
748{
749 struct ol_softc *scn = hif_ctx;
750 struct HIF_CE_state *hif_state;
751
752 if (!scn)
753 return;
754
755 hif_state = (struct HIF_CE_state *)scn->hif_hdl;
756 if (!hif_state)
757 return;
758
759
760 if (OL_TRGET_STATUS_RESET == scn->target_status) {
761 HIF_INFO_MED("%s: Target is already asserted, ignore!",
762 __func__);
763 return;
764 }
765
Rajeev Kumare3b4b4b2016-01-19 15:23:52 -0800766 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800767 HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__);
768 return;
769 }
770
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800771 hif_crash_shutdown_dump_ce_register(hif_ctx);
772
773 if (ol_copy_ramdump(scn))
774 goto out;
775
776 HIF_INFO_MED("%s: RAM dump collecting completed!", __func__);
777
778out:
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800779 return;
780}
781#else
782void hif_crash_shutdown(void *hif_ctx)
783{
784 HIF_INFO_MED("%s: Collecting target RAM dump disabled",
785 __func__);
786 return;
787}
788#endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */
789
790#ifdef QCA_WIFI_3_0
791/**
792 * hif_check_fw_reg(): hif_check_fw_reg
793 * @scn: scn
794 * @state:
795 *
796 * Return: int
797 */
798int hif_check_fw_reg(struct ol_softc *scn)
799{
800 return 0;
801}
802#endif
803
804#ifdef IPA_OFFLOAD
805/**
806 * hif_read_phy_mem_base(): hif_read_phy_mem_base
807 * @scn: scn
808 * @phy_mem_base: physical mem base
809 *
810 * Return: n/a
811 */
812void hif_read_phy_mem_base(struct ol_softc *scn, cdf_dma_addr_t *phy_mem_base)
813{
814 *phy_mem_base = scn->mem_pa;
815}
816#endif /* IPA_OFFLOAD */
817
818/**
819 * hif_get_device_type(): hif_get_device_type
820 * @device_id: device_id
821 * @revision_id: revision_id
822 * @hif_type: returned hif_type
823 * @target_type: returned target_type
824 *
825 * Return: int
826 */
827int hif_get_device_type(uint32_t device_id,
828 uint32_t revision_id,
829 uint32_t *hif_type, uint32_t *target_type)
830{
831 int ret = 0;
832
833 switch (device_id) {
834#ifdef QCA_WIFI_3_0_ADRASTEA
835 case ADRASTEA_DEVICE_ID:
836 case ADRASTEA_DEVICE_ID_P2_E12:
837
838 *hif_type = HIF_TYPE_ADRASTEA;
839 *target_type = TARGET_TYPE_ADRASTEA;
840 break;
841#else
842 case QCA6180_DEVICE_ID:
843 *hif_type = HIF_TYPE_QCA6180;
844 *target_type = TARGET_TYPE_QCA6180;
845 break;
846#endif
847
848 case AR9888_DEVICE_ID:
849 *hif_type = HIF_TYPE_AR9888;
850 *target_type = TARGET_TYPE_AR9888;
851 break;
852
853 case AR6320_DEVICE_ID:
854 switch (revision_id) {
855 case AR6320_FW_1_1:
856 case AR6320_FW_1_3:
857 *hif_type = HIF_TYPE_AR6320;
858 *target_type = TARGET_TYPE_AR6320;
859 break;
860
861 case AR6320_FW_2_0:
862 case AR6320_FW_3_0:
863 case AR6320_FW_3_2:
864 *hif_type = HIF_TYPE_AR6320V2;
865 *target_type = TARGET_TYPE_AR6320V2;
866 break;
867
868 default:
869 HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x",
870 __func__, device_id, revision_id);
871 ret = -ENODEV;
872 goto end;
873 }
874 break;
875
876 default:
877 HIF_ERROR("%s: Unsupported device ID!", __func__);
878 ret = -ENODEV;
879 break;
880 }
881end:
882 return ret;
883}