blob: e76c64c9a59090ba42634f0b350741cfdfaf6b7c [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 */
514CDF_STATUS hif_open(void)
515{
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;
539 return status;
540}
541
542/**
543 * hif_close(): hif_close
544 * @hif_ctx: hif_ctx
545 *
546 * Return: n/a
547 */
548void hif_close(void *hif_ctx)
549{
550 struct ol_softc *scn = hif_ctx;
551
552 if (scn == NULL) {
553 HIF_ERROR("%s: ol_softc is NULL", __func__);
554 return;
555 }
556
557 if (scn->athdiag_procfs_inited) {
558 athdiag_procfs_remove();
559 scn->athdiag_procfs_inited = false;
560 }
561
562 if (scn->hif_hdl) {
563 cdf_mem_free(scn->hif_hdl);
564 scn->hif_hdl = NULL;
565 }
566 hif_bus_close(scn);
567 cds_free_context(cds_get_global_context(),
568 CDF_MODULE_ID_HIF, hif_ctx);
569}
570
571/**
572 * hif_enable(): hif_enable
573 * @hif_ctx: hif_ctx
574 * @dev: dev
575 * @bdev: bus dev
576 * @bid: bus ID
577 * @bus_type: bus type
578 * @type: enable type
579 *
580 * Return: CDF_STATUS
581 */
582CDF_STATUS hif_enable(void *hif_ctx, struct device *dev,
583 void *bdev, const hif_bus_id *bid,
584 enum ath_hal_bus_type bus_type,
585 enum hif_enable_type type)
586{
587 CDF_STATUS status;
588 struct ol_softc *scn = hif_ctx;
589
590 if (scn == NULL) {
591 HIF_ERROR("%s: hif_ctx = NULL", __func__);
592 return CDF_STATUS_E_NULL_VALUE;
593 }
594
595 status = hif_bus_open(scn, bus_type);
596 if (status != CDF_STATUS_SUCCESS) {
597 HIF_ERROR("%s: hif_bus_open error = %d, bus_type = %d",
598 __func__, status, bus_type);
599 return status;
600 }
601
602 status = hif_enable_bus(scn, dev, bdev, bid, type);
603 if (status != CDF_STATUS_SUCCESS) {
604 hif_bus_close(scn);
605 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);
616 hif_bus_close(scn);
617 status = CDF_STATUS_E_FAILURE;
618 return status;
619 }
620 /*
621 * Flag to avoid potential unallocated memory access from MSI
622 * interrupt handler which could get scheduled as soon as MSI
623 * is enabled, i.e to take care of the race due to the order
624 * in where MSI is enabled before the memory, that will be
625 * in interrupt handlers, is allocated.
626 */
627
628#ifdef HIF_PCI
629 status = hif_configure_irq(scn->hif_sc);
630 if (status < 0) {
631 HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d",
632 __func__, status);
633 return CDF_STATUS_E_FAILURE;
634 }
635#endif
636
637 scn->hif_init_done = true;
638
639 HIF_TRACE("%s: X OK", __func__);
640
641 return CDF_STATUS_SUCCESS;
642}
643
644/**
645 * hif_pktlogmod_exit(): hif_pktlogmod_exit
646 * @scn: scn
647 *
648 * Return: n/a
649 */
650#ifndef REMOVE_PKT_LOG
651void hif_pktlogmod_exit(void *hif_ctx)
652{
653 struct ol_softc *scn = hif_ctx;
654
Peng Xu7b962532015-10-02 17:17:03 -0700655 if (scn && cds_get_conparam() != CDF_GLOBAL_FTM_MODE &&
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800656 !WLAN_IS_EPPING_ENABLED(cds_get_conparam()) && scn->pkt_log_init) {
657 pktlogmod_exit(scn);
658 scn->pkt_log_init = false;
659 }
660}
661#else
662void hif_pktlogmod_exit(void *hif_ctx)
663{
664}
665#endif
666
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800667/**
668 * hif_wlan_disable(): call the platform driver to disable wlan
669 *
670 * This function passes the con_mode to platform driver to disable
671 * wlan.
672 *
673 * Return: void
674 */
675void hif_wlan_disable(void)
676{
677 enum icnss_driver_mode mode;
678 uint32_t con_mode = cds_get_conparam();
679
Peng Xu7b962532015-10-02 17:17:03 -0700680 if (CDF_GLOBAL_FTM_MODE == con_mode)
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800681 mode = ICNSS_FTM;
Peng Xu7b962532015-10-02 17:17:03 -0700682 else if (WLAN_IS_EPPING_ENABLED(cds_get_conparam()))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800683 mode = ICNSS_EPPING;
Peng Xu7b962532015-10-02 17:17:03 -0700684 else
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800685 mode = ICNSS_MISSION;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800686
687 icnss_wlan_disable(mode);
688}
689
690void hif_disable(void *hif_ctx, enum hif_disable_type type)
691{
692 struct ol_softc *scn = hif_ctx;
693
694 if (!scn)
695 return;
696
697 hif_nointrs(scn);
698 if (scn->hif_init_done == false)
699 hif_shut_down_device(scn);
700 else
701 hif_stop(scn);
702
703 if (ADRASTEA_BU)
704 hif_vote_link_down();
705
706 if (scn->aps_osdev.bdev)
707 hif_disable_bus(scn->aps_osdev.bdev);
708
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800709 hif_wlan_disable();
710
711 scn->notice_send = false;
712
713 HIF_INFO("%s: X", __func__);
714}
715
716
717/**
718 * hif_crash_shutdown_dump_ce_register():
719 * hif_crash_shutdown_dump_ce_register
720 * @hif_ctx: hif_ctx
721 *
722 * Return: n/a
723 */
724#if defined(TARGET_RAMDUMP_AFTER_KERNEL_PANIC) \
725&& defined(HIF_PCI) && defined(DEBUG)
726
727static void hif_crash_shutdown_dump_ce_register(void *hif_ctx)
728{
729 struct ol_softc *scn = hif_ctx;
730
731 if (hif_check_soc_status(scn)
732 || dump_ce_register(scn)) {
733 return;
734 }
735
736 dump_ce_debug_register(scn);
737}
738
739/**
740 * hif_crash_shutdown(): hif_crash_shutdown
741 *
742 * This function is called by the platform driver to dump CE registers
743 *
744 * @hif_ctx: hif_ctx
745 *
746 * Return: n/a
747 */
748void hif_crash_shutdown(void *hif_ctx)
749{
750 struct ol_softc *scn = hif_ctx;
751 struct HIF_CE_state *hif_state;
752
753 if (!scn)
754 return;
755
756 hif_state = (struct HIF_CE_state *)scn->hif_hdl;
757 if (!hif_state)
758 return;
759
760
761 if (OL_TRGET_STATUS_RESET == scn->target_status) {
762 HIF_INFO_MED("%s: Target is already asserted, ignore!",
763 __func__);
764 return;
765 }
766
767 if (cds_is_load_unload_in_progress()) {
768 HIF_ERROR("%s: Load/unload is in progress, ignore!", __func__);
769 return;
770 }
771
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800772 hif_crash_shutdown_dump_ce_register(hif_ctx);
773
774 if (ol_copy_ramdump(scn))
775 goto out;
776
777 HIF_INFO_MED("%s: RAM dump collecting completed!", __func__);
778
779out:
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800780 return;
781}
782#else
783void hif_crash_shutdown(void *hif_ctx)
784{
785 HIF_INFO_MED("%s: Collecting target RAM dump disabled",
786 __func__);
787 return;
788}
789#endif /* TARGET_RAMDUMP_AFTER_KERNEL_PANIC */
790
791#ifdef QCA_WIFI_3_0
792/**
793 * hif_check_fw_reg(): hif_check_fw_reg
794 * @scn: scn
795 * @state:
796 *
797 * Return: int
798 */
799int hif_check_fw_reg(struct ol_softc *scn)
800{
801 return 0;
802}
803#endif
804
805#ifdef IPA_OFFLOAD
806/**
807 * hif_read_phy_mem_base(): hif_read_phy_mem_base
808 * @scn: scn
809 * @phy_mem_base: physical mem base
810 *
811 * Return: n/a
812 */
813void hif_read_phy_mem_base(struct ol_softc *scn, cdf_dma_addr_t *phy_mem_base)
814{
815 *phy_mem_base = scn->mem_pa;
816}
817#endif /* IPA_OFFLOAD */
818
819/**
820 * hif_get_device_type(): hif_get_device_type
821 * @device_id: device_id
822 * @revision_id: revision_id
823 * @hif_type: returned hif_type
824 * @target_type: returned target_type
825 *
826 * Return: int
827 */
828int hif_get_device_type(uint32_t device_id,
829 uint32_t revision_id,
830 uint32_t *hif_type, uint32_t *target_type)
831{
832 int ret = 0;
833
834 switch (device_id) {
835#ifdef QCA_WIFI_3_0_ADRASTEA
836 case ADRASTEA_DEVICE_ID:
837 case ADRASTEA_DEVICE_ID_P2_E12:
838
839 *hif_type = HIF_TYPE_ADRASTEA;
840 *target_type = TARGET_TYPE_ADRASTEA;
841 break;
842#else
843 case QCA6180_DEVICE_ID:
844 *hif_type = HIF_TYPE_QCA6180;
845 *target_type = TARGET_TYPE_QCA6180;
846 break;
847#endif
848
849 case AR9888_DEVICE_ID:
850 *hif_type = HIF_TYPE_AR9888;
851 *target_type = TARGET_TYPE_AR9888;
852 break;
853
854 case AR6320_DEVICE_ID:
855 switch (revision_id) {
856 case AR6320_FW_1_1:
857 case AR6320_FW_1_3:
858 *hif_type = HIF_TYPE_AR6320;
859 *target_type = TARGET_TYPE_AR6320;
860 break;
861
862 case AR6320_FW_2_0:
863 case AR6320_FW_3_0:
864 case AR6320_FW_3_2:
865 *hif_type = HIF_TYPE_AR6320V2;
866 *target_type = TARGET_TYPE_AR6320V2;
867 break;
868
869 default:
870 HIF_ERROR("%s: error - dev_id = 0x%x, rev_id = 0x%x",
871 __func__, device_id, revision_id);
872 ret = -ENODEV;
873 goto end;
874 }
875 break;
876
877 default:
878 HIF_ERROR("%s: Unsupported device ID!", __func__);
879 ret = -ENODEV;
880 break;
881 }
882end:
883 return ret;
884}