blob: 8806bd31367dd54db7dbc637e82ce9e162523482 [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
31#include "cdf_atomic.h"
32#include "cdf_lock.h"
33#include "hif.h"
34
35#define CE_HTT_T2H_MSG 1
36#define CE_HTT_H2T_MSG 4
37
38/**
39 * enum ce_id_type
40 *
41 * @ce_id_type: Copy engine ID
42 */
43enum ce_id_type {
44 CE_ID_0,
45 CE_ID_1,
46 CE_ID_2,
47 CE_ID_3,
48 CE_ID_4,
49 CE_ID_5,
50 CE_ID_6,
51 CE_ID_7,
52 CE_ID_8,
53 CE_ID_9,
54 CE_ID_10,
55 CE_ID_11,
56 CE_ID_MAX
57};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080058
59enum ol_ath_hif_pkt_ecodes {
60 HIF_PIPE_NO_RESOURCE = 0
61};
62
63struct HIF_CE_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080064
65/* Per-pipe state. */
66struct HIF_CE_pipe_info {
67 /* Handle of underlying Copy Engine */
68 struct CE_handle *ce_hdl;
69
70 /* Our pipe number; facilitiates use of pipe_info ptrs. */
71 uint8_t pipe_num;
72
73 /* Convenience back pointer to HIF_CE_state. */
74 struct HIF_CE_state *HIF_CE_state;
75
76 /* Instantaneous number of receive buffers that should be posted */
77 atomic_t recv_bufs_needed;
78 cdf_size_t buf_sz;
79 cdf_spinlock_t recv_bufs_needed_lock;
80
81 cdf_spinlock_t completion_freeq_lock;
82 /* Limit the number of outstanding send requests. */
83 int num_sends_allowed;
Houston Hoffman9c12f7f2015-09-28 16:52:14 -070084
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080085 /* adding three counts for debugging ring buffer errors */
86 uint32_t nbuf_alloc_err_count;
87 uint32_t nbuf_dma_err_count;
88 uint32_t nbuf_ce_enqueue_err_count;
89};
90
91/**
92 * struct ce_tasklet_entry
93 *
94 * @intr_tq: intr_tq
95 * @ce_id: ce_id
96 * @inited: inited
97 * @hif_ce_state: hif_ce_state
98 * @from_irq: from_irq
99 */
100struct ce_tasklet_entry {
101 struct tasklet_struct intr_tq;
102 enum ce_id_type ce_id;
103 bool inited;
104 void *hif_ce_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800105};
106
107struct HIF_CE_state {
108 struct ol_softc *scn;
109 bool started;
110 struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
111 cdf_spinlock_t keep_awake_lock;
112 unsigned int keep_awake_count;
113 bool verified_awake;
114 bool fake_sleep;
115 cdf_softirq_timer_t sleep_timer;
116 bool sleep_timer_init;
117 unsigned long sleep_ticks;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800118
119 /* Per-pipe state. */
120 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX];
121 /* to be activated after BMI_DONE */
122 struct hif_msg_callbacks msg_callbacks_pending;
123 /* current msg callbacks in use */
124 struct hif_msg_callbacks msg_callbacks_current;
125
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800126 /* Target address used to signal a pending firmware event */
127 uint32_t fw_indicator_address;
128
129 /* Copy Engine used for Diagnostic Accesses */
130 struct CE_handle *ce_diag;
131};
132#endif /* __CE_H__ */