aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath10k/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/pci.h')
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.h76
1 files changed, 30 insertions, 46 deletions
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index 871bb339d56d..52fb7b973571 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -43,22 +43,23 @@ struct bmi_xfer {
43 u32 resp_len; 43 u32 resp_len;
44}; 44};
45 45
46enum ath10k_pci_compl_state {
47 ATH10K_PCI_COMPL_FREE = 0,
48 ATH10K_PCI_COMPL_SEND,
49 ATH10K_PCI_COMPL_RECV,
50};
51
46struct ath10k_pci_compl { 52struct ath10k_pci_compl {
47 struct list_head list; 53 struct list_head list;
48 int send_or_recv; 54 enum ath10k_pci_compl_state state;
49 struct ce_state *ce_state; 55 struct ath10k_ce_pipe *ce_state;
50 struct hif_ce_pipe_info *pipe_info; 56 struct ath10k_pci_pipe *pipe_info;
51 void *transfer_context; 57 struct sk_buff *skb;
52 unsigned int nbytes; 58 unsigned int nbytes;
53 unsigned int transfer_id; 59 unsigned int transfer_id;
54 unsigned int flags; 60 unsigned int flags;
55}; 61};
56 62
57/* compl_state.send_or_recv */
58#define HIF_CE_COMPLETE_FREE 0
59#define HIF_CE_COMPLETE_SEND 1
60#define HIF_CE_COMPLETE_RECV 2
61
62/* 63/*
63 * PCI-specific Target state 64 * PCI-specific Target state
64 * 65 *
@@ -152,17 +153,16 @@ struct service_to_pipe {
152 153
153enum ath10k_pci_features { 154enum ath10k_pci_features {
154 ATH10K_PCI_FEATURE_MSI_X = 0, 155 ATH10K_PCI_FEATURE_MSI_X = 0,
155 ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND = 1, 156 ATH10K_PCI_FEATURE_SOC_POWER_SAVE = 1,
156 ATH10K_PCI_FEATURE_SOC_POWER_SAVE = 2,
157 157
158 /* keep last */ 158 /* keep last */
159 ATH10K_PCI_FEATURE_COUNT 159 ATH10K_PCI_FEATURE_COUNT
160}; 160};
161 161
162/* Per-pipe state. */ 162/* Per-pipe state. */
163struct hif_ce_pipe_info { 163struct ath10k_pci_pipe {
164 /* Handle of underlying Copy Engine */ 164 /* Handle of underlying Copy Engine */
165 struct ce_state *ce_hdl; 165 struct ath10k_ce_pipe *ce_hdl;
166 166
167 /* Our pipe number; facilitiates use of pipe_info ptrs. */ 167 /* Our pipe number; facilitiates use of pipe_info ptrs. */
168 u8 pipe_num; 168 u8 pipe_num;
@@ -178,9 +178,6 @@ struct hif_ce_pipe_info {
178 /* List of free CE completion slots */ 178 /* List of free CE completion slots */
179 struct list_head compl_free; 179 struct list_head compl_free;
180 180
181 /* Limit the number of outstanding send requests. */
182 int num_sends_allowed;
183
184 struct ath10k_pci *ar_pci; 181 struct ath10k_pci *ar_pci;
185 struct tasklet_struct intr; 182 struct tasklet_struct intr;
186}; 183};
@@ -190,7 +187,6 @@ struct ath10k_pci {
190 struct device *dev; 187 struct device *dev;
191 struct ath10k *ar; 188 struct ath10k *ar;
192 void __iomem *mem; 189 void __iomem *mem;
193 int cacheline_sz;
194 190
195 DECLARE_BITMAP(features, ATH10K_PCI_FEATURE_COUNT); 191 DECLARE_BITMAP(features, ATH10K_PCI_FEATURE_COUNT);
196 192
@@ -219,7 +215,7 @@ struct ath10k_pci {
219 215
220 bool compl_processing; 216 bool compl_processing;
221 217
222 struct hif_ce_pipe_info pipe_info[CE_COUNT_MAX]; 218 struct ath10k_pci_pipe pipe_info[CE_COUNT_MAX];
223 219
224 struct ath10k_hif_cb msg_callbacks_current; 220 struct ath10k_hif_cb msg_callbacks_current;
225 221
@@ -227,16 +223,13 @@ struct ath10k_pci {
227 u32 fw_indicator_address; 223 u32 fw_indicator_address;
228 224
229 /* Copy Engine used for Diagnostic Accesses */ 225 /* Copy Engine used for Diagnostic Accesses */
230 struct ce_state *ce_diag; 226 struct ath10k_ce_pipe *ce_diag;
231 227
232 /* FIXME: document what this really protects */ 228 /* FIXME: document what this really protects */
233 spinlock_t ce_lock; 229 spinlock_t ce_lock;
234 230
235 /* Map CE id to ce_state */ 231 /* Map CE id to ce_state */
236 struct ce_state *ce_id_to_state[CE_COUNT_MAX]; 232 struct ath10k_ce_pipe ce_states[CE_COUNT_MAX];
237
238 /* makes sure that dummy reads are atomic */
239 spinlock_t hw_v1_workaround_lock;
240}; 233};
241 234
242static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar) 235static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
@@ -244,14 +237,18 @@ static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)
244 return ar->hif.priv; 237 return ar->hif.priv;
245} 238}
246 239
247static inline u32 ath10k_pci_reg_read32(void __iomem *mem, u32 addr) 240static inline u32 ath10k_pci_reg_read32(struct ath10k *ar, u32 addr)
248{ 241{
249 return ioread32(mem + PCIE_LOCAL_BASE_ADDRESS + addr); 242 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
243
244 return ioread32(ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + addr);
250} 245}
251 246
252static inline void ath10k_pci_reg_write32(void __iomem *mem, u32 addr, u32 val) 247static inline void ath10k_pci_reg_write32(struct ath10k *ar, u32 addr, u32 val)
253{ 248{
254 iowrite32(val, mem + PCIE_LOCAL_BASE_ADDRESS + addr); 249 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
250
251 iowrite32(val, ar_pci->mem + PCIE_LOCAL_BASE_ADDRESS + addr);
255} 252}
256 253
257#define ATH_PCI_RESET_WAIT_MAX 10 /* ms */ 254#define ATH_PCI_RESET_WAIT_MAX 10 /* ms */
@@ -310,23 +307,8 @@ static inline void ath10k_pci_write32(struct ath10k *ar, u32 offset,
310 u32 value) 307 u32 value)
311{ 308{
312 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 309 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
313 void __iomem *addr = ar_pci->mem;
314
315 if (test_bit(ATH10K_PCI_FEATURE_HW_1_0_WORKAROUND, ar_pci->features)) {
316 unsigned long irq_flags;
317 310
318 spin_lock_irqsave(&ar_pci->hw_v1_workaround_lock, irq_flags); 311 iowrite32(value, ar_pci->mem + offset);
319
320 ioread32(addr+offset+4); /* 3rd read prior to write */
321 ioread32(addr+offset+4); /* 2nd read prior to write */
322 ioread32(addr+offset+4); /* 1st read prior to write */
323 iowrite32(value, addr+offset);
324
325 spin_unlock_irqrestore(&ar_pci->hw_v1_workaround_lock,
326 irq_flags);
327 } else {
328 iowrite32(value, addr+offset);
329 }
330} 312}
331 313
332static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset) 314static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset)
@@ -336,15 +318,17 @@ static inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset)
336 return ioread32(ar_pci->mem + offset); 318 return ioread32(ar_pci->mem + offset);
337} 319}
338 320
339void ath10k_do_pci_wake(struct ath10k *ar); 321int ath10k_do_pci_wake(struct ath10k *ar);
340void ath10k_do_pci_sleep(struct ath10k *ar); 322void ath10k_do_pci_sleep(struct ath10k *ar);
341 323
342static inline void ath10k_pci_wake(struct ath10k *ar) 324static inline int ath10k_pci_wake(struct ath10k *ar)
343{ 325{
344 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 326 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
345 327
346 if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) 328 if (test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
347 ath10k_do_pci_wake(ar); 329 return ath10k_do_pci_wake(ar);
330
331 return 0;
348} 332}
349 333
350static inline void ath10k_pci_sleep(struct ath10k *ar) 334static inline void ath10k_pci_sleep(struct ath10k *ar)