blob: fbc0f6c5c3e3ff156447b10baa626a80e6dfadaa [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Houston Hoffmanebc68142016-01-18 15:38:27 -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#ifndef __CE_H__
29#define __CE_H__
30
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053031#include "qdf_atomic.h"
32#include "qdf_lock.h"
Komal Seelam644263d2016-02-22 20:45:49 +053033#include "hif_main.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053034#include "qdf_util.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080035
36#define CE_HTT_T2H_MSG 1
37#define CE_HTT_H2T_MSG 4
38
Govind Singh2443fb32016-01-13 17:44:48 +053039#define CE_OFFSET 0x00000400
40#define CE_USEFUL_SIZE 0x00000058
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +053041#define CE_ALL_BITMAP 0xFFFF
Govind Singh2443fb32016-01-13 17:44:48 +053042
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080043/**
44 * enum ce_id_type
45 *
46 * @ce_id_type: Copy engine ID
47 */
48enum ce_id_type {
49 CE_ID_0,
50 CE_ID_1,
51 CE_ID_2,
52 CE_ID_3,
53 CE_ID_4,
54 CE_ID_5,
55 CE_ID_6,
56 CE_ID_7,
57 CE_ID_8,
58 CE_ID_9,
59 CE_ID_10,
60 CE_ID_11,
61 CE_ID_MAX
62};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080063
Houston Hoffmanabd00772016-05-06 17:02:48 -070064#ifdef CONFIG_WIN
Houston Hoffmanabd00772016-05-06 17:02:48 -070065#define QWLAN_VERSIONSTR "WIN"
66#endif
67
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080068enum ol_ath_hif_pkt_ecodes {
69 HIF_PIPE_NO_RESOURCE = 0
70};
71
72struct HIF_CE_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080073
74/* Per-pipe state. */
75struct HIF_CE_pipe_info {
76 /* Handle of underlying Copy Engine */
77 struct CE_handle *ce_hdl;
78
79 /* Our pipe number; facilitiates use of pipe_info ptrs. */
80 uint8_t pipe_num;
81
82 /* Convenience back pointer to HIF_CE_state. */
83 struct HIF_CE_state *HIF_CE_state;
84
85 /* Instantaneous number of receive buffers that should be posted */
86 atomic_t recv_bufs_needed;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053087 qdf_size_t buf_sz;
88 qdf_spinlock_t recv_bufs_needed_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080089
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053090 qdf_spinlock_t completion_freeq_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080091 /* Limit the number of outstanding send requests. */
92 int num_sends_allowed;
Houston Hoffman9c12f7f2015-09-28 16:52:14 -070093
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080094 /* adding three counts for debugging ring buffer errors */
95 uint32_t nbuf_alloc_err_count;
96 uint32_t nbuf_dma_err_count;
97 uint32_t nbuf_ce_enqueue_err_count;
98};
99
100/**
101 * struct ce_tasklet_entry
102 *
103 * @intr_tq: intr_tq
104 * @ce_id: ce_id
105 * @inited: inited
106 * @hif_ce_state: hif_ce_state
107 * @from_irq: from_irq
108 */
109struct ce_tasklet_entry {
110 struct tasklet_struct intr_tq;
111 enum ce_id_type ce_id;
112 bool inited;
113 void *hif_ce_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800114};
115
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530116struct hif_ext_group_entry {
117 uint32_t numirq;
118 uint32_t irq[HIF_MAX_GRP_IRQ];
119 uint32_t grp_id;
120 void *context;
121 ext_intr_handler handler;
122 struct tasklet_struct intr_tq;
123 bool configured;
124 bool inited;
125 void *hif_state;
126};
127
Nirav Shahb70bd732016-05-25 14:31:51 +0530128struct ce_intr_stats {
129 uint32_t ce_per_cpu[CE_COUNT_MAX][QDF_MAX_AVAILABLE_CPU];
130};
131
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800132struct HIF_CE_state {
Komal Seelam644263d2016-02-22 20:45:49 +0530133 struct hif_softc ol_sc;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800134 bool started;
135 struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530136 struct hif_ext_group_entry hif_ext_group[HIF_MAX_GROUP];
137 uint32_t hif_num_extgroup;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530138 qdf_spinlock_t keep_awake_lock;
Venkateswara Swamy Bandaru9fd9af02016-09-20 20:27:31 +0530139 qdf_spinlock_t irq_reg_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800140 unsigned int keep_awake_count;
141 bool verified_awake;
142 bool fake_sleep;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530143 qdf_timer_t sleep_timer;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800144 bool sleep_timer_init;
Houston Hoffman2bfb82f2016-04-29 16:09:04 -0700145 qdf_time_t sleep_ticks;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800146
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530147 struct CE_pipe_config *target_ce_config;
148 struct CE_attr *host_ce_config;
149 uint32_t target_ce_config_sz;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800150 /* Per-pipe state. */
151 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX];
152 /* to be activated after BMI_DONE */
153 struct hif_msg_callbacks msg_callbacks_pending;
154 /* current msg callbacks in use */
155 struct hif_msg_callbacks msg_callbacks_current;
156
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800157 /* Target address used to signal a pending firmware event */
158 uint32_t fw_indicator_address;
159
160 /* Copy Engine used for Diagnostic Accesses */
161 struct CE_handle *ce_diag;
Nirav Shahb70bd732016-05-25 14:31:51 +0530162 struct ce_intr_stats stats;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800163};
Govind Singh8f7a1ff2016-05-06 16:35:12 +0530164
165/*
166 * HIA Map Definition
167 */
168struct host_interest_area_t {
169 uint32_t hi_interconnect_state;
170 uint32_t hi_early_alloc;
171 uint32_t hi_option_flag2;
172 uint32_t hi_board_data;
173 uint32_t hi_board_data_initialized;
174 uint32_t hi_failure_state;
175 uint32_t hi_rddi_msi_num;
176 uint32_t hi_pcie_perst_couple_en;
177 uint32_t hi_sw_protocol_version;
178};
179
180struct shadow_reg_cfg {
181 uint16_t ce_id;
182 uint16_t reg_offset;
183};
184
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530185void hif_ce_stop(struct hif_softc *scn);
Komal Seelam644263d2016-02-22 20:45:49 +0530186int hif_dump_ce_registers(struct hif_softc *scn);
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530187void
188hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base,
189 uint32_t address, uint32_t size);
Houston Hoffman854e67f2016-03-14 21:11:39 -0700190
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530191#ifdef IPA_OFFLOAD
192void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
193 qdf_dma_addr_t *ce_sr_base_paddr,
194 uint32_t *ce_sr_ring_size,
195 qdf_dma_addr_t *ce_reg_paddr);
196#else
197static inline
198void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
199 qdf_dma_addr_t *ce_sr_base_paddr,
200 uint32_t *ce_sr_ring_size,
201 qdf_dma_addr_t *ce_reg_paddr)
202{
203 return;
204}
205
206#endif
Houston Hoffman854e67f2016-03-14 21:11:39 -0700207int hif_wlan_enable(struct hif_softc *scn);
208void hif_wlan_disable(struct hif_softc *scn);
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530209void hif_get_target_ce_config(struct hif_softc *scn,
210 struct CE_pipe_config **target_ce_config_ret,
Houston Hoffman854e67f2016-03-14 21:11:39 -0700211 int *target_ce_config_sz_ret,
212 struct service_to_pipe **target_service_to_ce_map_ret,
213 int *target_service_to_ce_map_sz_ret,
214 struct shadow_reg_cfg **target_shadow_reg_cfg_ret,
215 int *shadow_cfg_sz_ret);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800216#endif /* __CE_H__ */