1
2
3
4
5
6
7#ifndef _HIF_H_
8#define _HIF_H_
9
10#include <linux/kernel.h>
11#include "core.h"
12#include "bmi.h"
13#include "debug.h"
14
15
16enum ath_dbg_mode {
17 ATH10K_ENABLE_FW_LOG_DIAG,
18 ATH10K_ENABLE_FW_LOG_CE,
19};
20
21struct ath10k_hif_sg_item {
22 u16 transfer_id;
23 void *transfer_context;
24 void *vaddr;
25 dma_addr_t paddr;
26 u16 len;
27};
28
29struct ath10k_hif_ops {
30
31 int (*tx_sg)(struct ath10k *ar, u8 pipe_id,
32 struct ath10k_hif_sg_item *items, int n_items);
33
34
35 int (*diag_read)(struct ath10k *ar, u32 address, void *buf,
36 size_t buf_len);
37
38 int (*diag_write)(struct ath10k *ar, u32 address, const void *data,
39 int nbytes);
40
41
42
43
44
45 int (*exchange_bmi_msg)(struct ath10k *ar,
46 void *request, u32 request_len,
47 void *response, u32 *response_len);
48
49
50 int (*start)(struct ath10k *ar);
51
52
53
54
55 void (*stop)(struct ath10k *ar);
56
57 int (*swap_mailbox)(struct ath10k *ar);
58
59 int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id,
60 u8 *ul_pipe, u8 *dl_pipe);
61
62 void (*get_default_pipe)(struct ath10k *ar, u8 *ul_pipe, u8 *dl_pipe);
63
64
65
66
67
68
69
70
71
72 void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force);
73
74 u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id);
75
76 u32 (*read32)(struct ath10k *ar, u32 address);
77
78 void (*write32)(struct ath10k *ar, u32 address, u32 value);
79
80
81 int (*power_up)(struct ath10k *ar, enum ath10k_firmware_mode fw_mode);
82
83
84
85
86 void (*power_down)(struct ath10k *ar);
87
88 int (*suspend)(struct ath10k *ar);
89 int (*resume)(struct ath10k *ar);
90
91
92 int (*fetch_cal_eeprom)(struct ath10k *ar, void **data,
93 size_t *data_len);
94
95 int (*get_target_info)(struct ath10k *ar,
96 struct bmi_target_info *target_info);
97 int (*set_target_log_mode)(struct ath10k *ar, u8 fw_log_mode);
98};
99
100static inline int ath10k_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
101 struct ath10k_hif_sg_item *items,
102 int n_items)
103{
104 return ar->hif.ops->tx_sg(ar, pipe_id, items, n_items);
105}
106
107static inline int ath10k_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
108 size_t buf_len)
109{
110 return ar->hif.ops->diag_read(ar, address, buf, buf_len);
111}
112
113static inline int ath10k_hif_diag_write(struct ath10k *ar, u32 address,
114 const void *data, int nbytes)
115{
116 if (!ar->hif.ops->diag_write)
117 return -EOPNOTSUPP;
118
119 return ar->hif.ops->diag_write(ar, address, data, nbytes);
120}
121
122static inline int ath10k_hif_exchange_bmi_msg(struct ath10k *ar,
123 void *request, u32 request_len,
124 void *response, u32 *response_len)
125{
126 return ar->hif.ops->exchange_bmi_msg(ar, request, request_len,
127 response, response_len);
128}
129
130static inline int ath10k_hif_start(struct ath10k *ar)
131{
132 return ar->hif.ops->start(ar);
133}
134
135static inline void ath10k_hif_stop(struct ath10k *ar)
136{
137 return ar->hif.ops->stop(ar);
138}
139
140static inline int ath10k_hif_swap_mailbox(struct ath10k *ar)
141{
142 if (ar->hif.ops->swap_mailbox)
143 return ar->hif.ops->swap_mailbox(ar);
144 return 0;
145}
146
147static inline int ath10k_hif_map_service_to_pipe(struct ath10k *ar,
148 u16 service_id,
149 u8 *ul_pipe, u8 *dl_pipe)
150{
151 return ar->hif.ops->map_service_to_pipe(ar, service_id,
152 ul_pipe, dl_pipe);
153}
154
155static inline void ath10k_hif_get_default_pipe(struct ath10k *ar,
156 u8 *ul_pipe, u8 *dl_pipe)
157{
158 ar->hif.ops->get_default_pipe(ar, ul_pipe, dl_pipe);
159}
160
161static inline void ath10k_hif_send_complete_check(struct ath10k *ar,
162 u8 pipe_id, int force)
163{
164 ar->hif.ops->send_complete_check(ar, pipe_id, force);
165}
166
167static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar,
168 u8 pipe_id)
169{
170 return ar->hif.ops->get_free_queue_number(ar, pipe_id);
171}
172
173static inline int ath10k_hif_power_up(struct ath10k *ar,
174 enum ath10k_firmware_mode fw_mode)
175{
176 return ar->hif.ops->power_up(ar, fw_mode);
177}
178
179static inline void ath10k_hif_power_down(struct ath10k *ar)
180{
181 ar->hif.ops->power_down(ar);
182}
183
184static inline int ath10k_hif_suspend(struct ath10k *ar)
185{
186 if (!ar->hif.ops->suspend)
187 return -EOPNOTSUPP;
188
189 return ar->hif.ops->suspend(ar);
190}
191
192static inline int ath10k_hif_resume(struct ath10k *ar)
193{
194 if (!ar->hif.ops->resume)
195 return -EOPNOTSUPP;
196
197 return ar->hif.ops->resume(ar);
198}
199
200static inline u32 ath10k_hif_read32(struct ath10k *ar, u32 address)
201{
202 if (!ar->hif.ops->read32) {
203 ath10k_warn(ar, "hif read32 not supported\n");
204 return 0xdeaddead;
205 }
206
207 return ar->hif.ops->read32(ar, address);
208}
209
210static inline void ath10k_hif_write32(struct ath10k *ar,
211 u32 address, u32 data)
212{
213 if (!ar->hif.ops->write32) {
214 ath10k_warn(ar, "hif write32 not supported\n");
215 return;
216 }
217
218 ar->hif.ops->write32(ar, address, data);
219}
220
221static inline int ath10k_hif_fetch_cal_eeprom(struct ath10k *ar,
222 void **data,
223 size_t *data_len)
224{
225 if (!ar->hif.ops->fetch_cal_eeprom)
226 return -EOPNOTSUPP;
227
228 return ar->hif.ops->fetch_cal_eeprom(ar, data, data_len);
229}
230
231static inline int ath10k_hif_get_target_info(struct ath10k *ar,
232 struct bmi_target_info *tgt_info)
233{
234 if (!ar->hif.ops->get_target_info)
235 return -EOPNOTSUPP;
236
237 return ar->hif.ops->get_target_info(ar, tgt_info);
238}
239
240static inline int ath10k_hif_set_target_log_mode(struct ath10k *ar,
241 u8 fw_log_mode)
242{
243 if (!ar->hif.ops->set_target_log_mode)
244 return -EOPNOTSUPP;
245
246 return ar->hif.ops->set_target_log_mode(ar, fw_log_mode);
247}
248#endif
249