blob: 87881ade475d65d373d68cf37dfb96d3e60d5cb0 [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmancceec342015-11-11 11:37:20 -08002 * Copyright (c) 2013-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/*
29 * NB: Inappropriate references to "HTC" are used in this (and other)
30 * HIF implementations. HTC is typically the calling layer, but it
31 * theoretically could be some alternative.
32 */
33
34/*
35 * This holds all state needed to process a pending send/recv interrupt.
36 * The information is saved here as soon as the interrupt occurs (thus
37 * allowing the underlying CE to re-use the ring descriptor). The
38 * information here is eventually processed by a completion processing
39 * thread.
40 */
41
42#ifndef __HIF_MAIN_H__
43#define __HIF_MAIN_H__
44
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053045#include <qdf_atomic.h> /* qdf_atomic_read */
46#include "qdf_lock.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080047#include "cepci.h"
48#include "hif.h"
Houston Hoffman32bc8eb2016-03-14 21:11:34 -070049#include "multibus.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080050
51#define HIF_MIN_SLEEP_INACTIVITY_TIME_MS 50
52#define HIF_SLEEP_INACTIVITY_TIMER_PERIOD_MS 60
53
54/*
55 * This macro implementation is exposed for efficiency only.
56 * The implementation may change and callers should
57 * consider the targid to be a completely opaque handle.
58 */
59#define TARGID_TO_PCI_ADDR(targid) (*((A_target_id_t *)(targid)))
60
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080061#ifdef QCA_WIFI_3_0
62#define DISABLE_L1SS_STATES 1
63#endif
64#ifdef CONFIG_SLUB_DEBUG_ON
65#define MAX_NUM_OF_RECEIVES 100 /* Maximum number of Rx buf to process before*
66 * break out in SLUB debug builds */
67#elif defined(FEATURE_NAPI)
68#define MAX_NUM_OF_RECEIVES HIF_NAPI_MAX_RECEIVES
69#else /* no SLUBS, no NAPI */
70/* Maximum number of Rx buf to process before break out */
71#define MAX_NUM_OF_RECEIVES 1000
72#endif /* SLUB_DEBUG_ON / FEATURE_NAPI */
73
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080074#ifdef QCA_WIFI_3_0_ADRASTEA
75#define ADRASTEA_BU 1
76#else
77#define ADRASTEA_BU 0
78#endif
79
80#ifdef QCA_WIFI_3_0
81#define HAS_FW_INDICATOR 0
82#else
83#define HAS_FW_INDICATOR 1
84#endif
85
86
87#define AR9888_DEVICE_ID (0x003c)
88#define AR6320_DEVICE_ID (0x003e)
89#define AR6320_FW_1_1 (0x11)
90#define AR6320_FW_1_3 (0x13)
91#define AR6320_FW_2_0 (0x20)
92#define AR6320_FW_3_0 (0x30)
93#define AR6320_FW_3_2 (0x32)
94#define ADRASTEA_DEVICE_ID (0xabcd)
95#define ADRASTEA_DEVICE_ID_P2_E12 (0x7021)
Houston Hoffman06bc4f52015-12-16 18:43:34 -080096#if (defined(QVIT))
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080097#define QCA6180_DEVICE_ID (0xabcd)
98#else
99#define QCA6180_DEVICE_ID (0x041)
100#endif
101
Komal Seelam02cf2f82016-02-22 20:44:25 +0530102#define HIF_GET_PCI_SOFTC(scn) ((struct hif_pci_softc *)scn)
103#define HIF_GET_CE_STATE(scn) ((struct HIF_CE_state *)scn)
Komal Seelam644263d2016-02-22 20:45:49 +0530104#define HIF_GET_SOFTC(scn) ((struct hif_softc *)scn)
Komal Seelam5584a7c2016-02-24 19:22:48 +0530105#define GET_HIF_OPAQUE_HDL(scn) ((struct hif_opaque_softc *)scn)
Komal Seelam02cf2f82016-02-22 20:44:25 +0530106
Komal Seelam644263d2016-02-22 20:45:49 +0530107struct hif_ce_stats {
108 int hif_pipe_no_resrc_count;
109 int ce_ring_delta_fail_count;
110};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800111
Komal Seelam644263d2016-02-22 20:45:49 +0530112struct hif_softc {
Komal Seelam5584a7c2016-02-24 19:22:48 +0530113 struct hif_opaque_softc osc;
Komal Seelam644263d2016-02-22 20:45:49 +0530114 struct hif_config_info hif_config;
115 struct hif_target_info target_info;
Komal Seelam644263d2016-02-22 20:45:49 +0530116 void __iomem *mem;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530117 enum qdf_bus_type bus_type;
Houston Hoffman32bc8eb2016-03-14 21:11:34 -0700118 struct hif_bus_ops bus_ops;
Komal Seelam644263d2016-02-22 20:45:49 +0530119 void *ce_id_to_state[CE_COUNT_MAX];
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530120 qdf_device_t qdf_dev;
Komal Seelam644263d2016-02-22 20:45:49 +0530121 bool hif_init_done;
122 bool request_irq_done;
123 /* Packet statistics */
124 struct hif_ce_stats pkt_stats;
125 ol_target_status target_status;
126
127 struct targetdef_s *targetdef;
128 struct ce_reg_def *target_ce_def;
129 struct hostdef_s *hostdef;
130 struct host_shadow_regs_s *host_shadow_regs;
131
132 bool recovery;
133 bool notice_send;
134 uint32_t ce_irq_summary;
135 /* No of copy engines supported */
136 unsigned int ce_count;
137 atomic_t active_tasklet_cnt;
138 atomic_t link_suspended;
139 uint32_t *vaddr_rri_on_ddr;
140 int linkstate_vote;
141 int fastpath_mode_on;
142 atomic_t tasklet_from_intr;
143 int htc_endpoint;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530144 qdf_dma_addr_t mem_pa;
Komal Seelam644263d2016-02-22 20:45:49 +0530145 bool athdiag_procfs_inited;
146#ifdef FEATURE_NAPI
147 struct qca_napi_data napi_data;
148#endif /* FEATURE_NAPI */
Komal Seelam75080122016-03-02 15:18:25 +0530149 struct hif_driver_state_callbacks callbacks;
Komal Seelambd7c51d2016-02-24 10:27:30 +0530150 uint32_t hif_con_param;
Komal Seelam644263d2016-02-22 20:45:49 +0530151};
152
153A_target_id_t hif_get_target_id(struct hif_softc *scn);
154void hif_dump_pipe_debug_count(struct hif_softc *scn);
155
Komal Seelambd7c51d2016-02-24 10:27:30 +0530156bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count);
Houston Hoffman108da402016-03-14 21:11:24 -0700157int hif_bus_configure(struct hif_softc *scn);
Komal Seelam644263d2016-02-22 20:45:49 +0530158int hif_config_ce(struct hif_softc *scn);
Houston Hoffman108da402016-03-14 21:11:24 -0700159void hif_unconfig_ce(struct hif_softc *scn);
160void hif_ce_prepare_config(struct hif_softc *scn);
Houston Hoffman108da402016-03-14 21:11:24 -0700161QDF_STATUS hif_ce_open(struct hif_softc *scn);
162void hif_ce_close(struct hif_softc *scn);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800163int athdiag_procfs_init(void *scn);
164void athdiag_procfs_remove(void);
165/* routine to modify the initial buffer count to be allocated on an os
166 * platform basis. Platform owner will need to modify this as needed
167 */
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530168qdf_size_t init_buffer_count(qdf_size_t maxSize);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800169
170irqreturn_t hif_fw_interrupt_handler(int irq, void *arg);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800171int hif_get_device_type(uint32_t device_id,
172 uint32_t revision_id,
173 uint32_t *hif_type, uint32_t *target_type);
174/*These functions are exposed to HDD*/
Komal Seelam644263d2016-02-22 20:45:49 +0530175void hif_nointrs(struct hif_softc *scn);
176void hif_bus_close(struct hif_softc *ol_sc);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530177QDF_STATUS hif_bus_open(struct hif_softc *ol_sc,
178 enum qdf_bus_type bus_type);
179QDF_STATUS hif_enable_bus(struct hif_softc *ol_sc, struct device *dev,
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800180 void *bdev, const hif_bus_id *bid, enum hif_enable_type type);
Vishwajith Upendra3f78aa62016-02-09 17:53:02 +0530181void hif_disable_bus(struct hif_softc *scn);
Komal Seelam644263d2016-02-22 20:45:49 +0530182void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag);
Houston Hoffman162164c2016-03-14 21:12:10 -0700183int hif_bus_get_context_size(enum qdf_bus_type bus_type);
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530184void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *bar_value);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530185uint32_t hif_get_conparam(struct hif_softc *scn);
Komal Seelam75080122016-03-02 15:18:25 +0530186struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn);
Komal Seelambd7c51d2016-02-24 10:27:30 +0530187bool hif_is_driver_unloading(struct hif_softc *scn);
188bool hif_is_load_or_unload_in_progress(struct hif_softc *scn);
189bool hif_is_recovery_in_progress(struct hif_softc *scn);
Houston Hoffman4ca03b62016-03-14 21:11:51 -0700190int hif_target_sleep_state_adjust(struct hif_softc *scn,
191 bool sleep_ok,
192 bool wait_for_it);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800193#endif /* __HIF_MAIN_H__ */