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