blob: 7a799689ac5f7018c6781d5e931ec91f33f248a5 [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"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080034
35#define CE_HTT_T2H_MSG 1
36#define CE_HTT_H2T_MSG 4
37
Govind Singh2443fb32016-01-13 17:44:48 +053038#define CE_OFFSET 0x00000400
39#define CE_USEFUL_SIZE 0x00000058
40
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080041/**
42 * enum ce_id_type
43 *
44 * @ce_id_type: Copy engine ID
45 */
46enum ce_id_type {
47 CE_ID_0,
48 CE_ID_1,
49 CE_ID_2,
50 CE_ID_3,
51 CE_ID_4,
52 CE_ID_5,
53 CE_ID_6,
54 CE_ID_7,
55 CE_ID_8,
56 CE_ID_9,
57 CE_ID_10,
58 CE_ID_11,
59 CE_ID_MAX
60};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080061
Houston Hoffmanabd00772016-05-06 17:02:48 -070062#ifdef CONFIG_WIN
63struct shadow_reg_cfg {
64 uint16_t ce_id;
65 uint16_t reg_offset;
66};
67
68#define QWLAN_VERSIONSTR "WIN"
69#endif
70
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080071enum ol_ath_hif_pkt_ecodes {
72 HIF_PIPE_NO_RESOURCE = 0
73};
74
75struct HIF_CE_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080076
77/* Per-pipe state. */
78struct HIF_CE_pipe_info {
79 /* Handle of underlying Copy Engine */
80 struct CE_handle *ce_hdl;
81
82 /* Our pipe number; facilitiates use of pipe_info ptrs. */
83 uint8_t pipe_num;
84
85 /* Convenience back pointer to HIF_CE_state. */
86 struct HIF_CE_state *HIF_CE_state;
87
88 /* Instantaneous number of receive buffers that should be posted */
89 atomic_t recv_bufs_needed;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053090 qdf_size_t buf_sz;
91 qdf_spinlock_t recv_bufs_needed_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080092
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053093 qdf_spinlock_t completion_freeq_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080094 /* Limit the number of outstanding send requests. */
95 int num_sends_allowed;
Houston Hoffman9c12f7f2015-09-28 16:52:14 -070096
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080097 /* adding three counts for debugging ring buffer errors */
98 uint32_t nbuf_alloc_err_count;
99 uint32_t nbuf_dma_err_count;
100 uint32_t nbuf_ce_enqueue_err_count;
101};
102
103/**
104 * struct ce_tasklet_entry
105 *
106 * @intr_tq: intr_tq
107 * @ce_id: ce_id
108 * @inited: inited
109 * @hif_ce_state: hif_ce_state
110 * @from_irq: from_irq
111 */
112struct ce_tasklet_entry {
113 struct tasklet_struct intr_tq;
114 enum ce_id_type ce_id;
115 bool inited;
116 void *hif_ce_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800117};
118
119struct HIF_CE_state {
Komal Seelam644263d2016-02-22 20:45:49 +0530120 struct hif_softc ol_sc;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800121 bool started;
122 struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530123 qdf_spinlock_t keep_awake_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800124 unsigned int keep_awake_count;
125 bool verified_awake;
126 bool fake_sleep;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530127 qdf_timer_t sleep_timer;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800128 bool sleep_timer_init;
Houston Hoffman2bfb82f2016-04-29 16:09:04 -0700129 qdf_time_t sleep_ticks;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800130
131 /* Per-pipe state. */
132 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX];
133 /* to be activated after BMI_DONE */
134 struct hif_msg_callbacks msg_callbacks_pending;
135 /* current msg callbacks in use */
136 struct hif_msg_callbacks msg_callbacks_current;
137
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800138 /* Target address used to signal a pending firmware event */
139 uint32_t fw_indicator_address;
140
141 /* Copy Engine used for Diagnostic Accesses */
142 struct CE_handle *ce_diag;
143};
Komal Seelam644263d2016-02-22 20:45:49 +0530144int hif_dump_ce_registers(struct hif_softc *scn);
Houston Hoffman854e67f2016-03-14 21:11:39 -0700145
146int hif_wlan_enable(struct hif_softc *scn);
147void hif_wlan_disable(struct hif_softc *scn);
148void hif_get_target_ce_config(struct CE_pipe_config **target_ce_config_ret,
149 int *target_ce_config_sz_ret,
150 struct service_to_pipe **target_service_to_ce_map_ret,
151 int *target_service_to_ce_map_sz_ret,
152 struct shadow_reg_cfg **target_shadow_reg_cfg_ret,
153 int *shadow_cfg_sz_ret);
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800154#endif /* __CE_H__ */