1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _PCI_H_
19#define _PCI_H_
20
21#include <linux/interrupt.h>
22
23#include "hw.h"
24#include "ce.h"
25#include "ahb.h"
26
27
28
29
30
31#define DIAG_TRANSFER_LIMIT 2048
32
33struct bmi_xfer {
34 bool tx_done;
35 bool rx_done;
36 bool wait_for_resp;
37 u32 resp_len;
38};
39
40
41
42
43
44
45
46
47
48
49
50
51struct pcie_state {
52
53
54 u32 pipe_cfg_addr;
55
56
57
58 u32 svc_to_pipe_map;
59
60
61 u32 msi_requested;
62
63
64 u32 msi_granted;
65
66
67 u32 msi_addr;
68
69
70 u32 msi_data;
71
72
73
74
75
76
77 u32 msi_fw_intr_data;
78
79
80 u32 power_mgmt_method;
81
82
83 u32 config_flags;
84};
85
86
87#define PCIE_CONFIG_FLAG_ENABLE_L1 0x0000001
88
89
90#define CE_ATTR_FLAGS 0
91
92
93
94
95
96
97
98struct ce_pipe_config {
99 __le32 pipenum;
100 __le32 pipedir;
101 __le32 nentries;
102 __le32 nbytes_max;
103 __le32 flags;
104 __le32 reserved;
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119#define PIPEDIR_NONE 0
120#define PIPEDIR_IN 1
121#define PIPEDIR_OUT 2
122#define PIPEDIR_INOUT 3
123
124
125struct service_to_pipe {
126 __le32 service_id;
127 __le32 pipedir;
128 __le32 pipenum;
129};
130
131
132struct ath10k_pci_pipe {
133
134 struct ath10k_ce_pipe *ce_hdl;
135
136
137 u8 pipe_num;
138
139
140 struct ath10k *hif_ce_state;
141
142 size_t buf_sz;
143
144
145 spinlock_t pipe_lock;
146};
147
148struct ath10k_pci_supp_chip {
149 u32 dev_id;
150 u32 rev_id;
151};
152
153enum ath10k_pci_irq_mode {
154 ATH10K_PCI_IRQ_AUTO = 0,
155 ATH10K_PCI_IRQ_LEGACY = 1,
156 ATH10K_PCI_IRQ_MSI = 2,
157};
158
159struct ath10k_pci {
160 struct pci_dev *pdev;
161 struct device *dev;
162 struct ath10k *ar;
163 void __iomem *mem;
164 size_t mem_len;
165
166
167 enum ath10k_pci_irq_mode oper_irq_mode;
168
169 struct ath10k_pci_pipe pipe_info[CE_COUNT_MAX];
170
171
172 struct ath10k_ce_pipe *ce_diag;
173
174 struct ath10k_ce ce;
175 struct timer_list rx_post_retry;
176
177
178
179
180
181 u16 link_ctl;
182
183
184 spinlock_t ps_lock;
185
186
187
188
189
190
191
192 unsigned long ps_wake_refcount;
193
194
195
196
197
198
199
200
201
202 struct timer_list ps_timer;
203
204
205
206
207
208
209
210 bool ps_awake;
211
212
213
214
215
216 bool pci_ps;
217
218
219 int (*pci_soft_reset)(struct ath10k *ar);
220
221
222 int (*pci_hard_reset)(struct ath10k *ar);
223
224
225
226
227 u32 (*targ_cpu_to_ce_addr)(struct ath10k *ar, u32 addr);
228
229
230
231
232
233 struct ath10k_ahb ahb[0];
234};
235
236static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
237{
238 return (struct ath10k_pci *)ar->drv_priv;
239}
240
241#define ATH10K_PCI_RX_POST_RETRY_MS 50
242#define ATH_PCI_RESET_WAIT_MAX 10
243#define PCIE_WAKE_TIMEOUT 30000
244#define PCIE_WAKE_LATE_US 10000
245
246#define BAR_NUM 0
247
248#define CDC_WAR_MAGIC_STR 0xceef0000
249#define CDC_WAR_DATA_CE 4
250
251
252#define DIAG_ACCESS_CE_TIMEOUT_MS 10
253
254void ath10k_pci_write32(struct ath10k *ar, u32 offset, u32 value);
255void ath10k_pci_soc_write32(struct ath10k *ar, u32 addr, u32 val);
256void ath10k_pci_reg_write32(struct ath10k *ar, u32 addr, u32 val);
257
258u32 ath10k_pci_read32(struct ath10k *ar, u32 offset);
259u32 ath10k_pci_soc_read32(struct ath10k *ar, u32 addr);
260u32 ath10k_pci_reg_read32(struct ath10k *ar, u32 addr);
261
262int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
263 struct ath10k_hif_sg_item *items, int n_items);
264int ath10k_pci_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
265 size_t buf_len);
266int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
267 const void *data, int nbytes);
268int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, void *req, u32 req_len,
269 void *resp, u32 *resp_len);
270int ath10k_pci_hif_map_service_to_pipe(struct ath10k *ar, u16 service_id,
271 u8 *ul_pipe, u8 *dl_pipe);
272void ath10k_pci_hif_get_default_pipe(struct ath10k *ar, u8 *ul_pipe,
273 u8 *dl_pipe);
274void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe,
275 int force);
276u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe);
277void ath10k_pci_hif_power_down(struct ath10k *ar);
278int ath10k_pci_alloc_pipes(struct ath10k *ar);
279void ath10k_pci_free_pipes(struct ath10k *ar);
280void ath10k_pci_free_pipes(struct ath10k *ar);
281void ath10k_pci_rx_replenish_retry(struct timer_list *t);
282void ath10k_pci_ce_deinit(struct ath10k *ar);
283void ath10k_pci_init_napi(struct ath10k *ar);
284int ath10k_pci_init_pipes(struct ath10k *ar);
285int ath10k_pci_init_config(struct ath10k *ar);
286void ath10k_pci_rx_post(struct ath10k *ar);
287void ath10k_pci_flush(struct ath10k *ar);
288void ath10k_pci_enable_legacy_irq(struct ath10k *ar);
289bool ath10k_pci_irq_pending(struct ath10k *ar);
290void ath10k_pci_disable_and_clear_legacy_irq(struct ath10k *ar);
291void ath10k_pci_irq_msi_fw_mask(struct ath10k *ar);
292int ath10k_pci_wait_for_target_init(struct ath10k *ar);
293int ath10k_pci_setup_resource(struct ath10k *ar);
294void ath10k_pci_release_resource(struct ath10k *ar);
295
296
297
298
299
300#define ATH10K_PCI_SLEEP_GRACE_PERIOD_MSEC 60
301
302#endif
303