net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / hal / phydm / phydm_interface.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20
21
22 #ifndef __ODM_INTERFACE_H__
23 #define __ODM_INTERFACE_H__
24
25 #define INTERFACE_VERSION       "1.1"           /*2015.07.29  YuChen*/
26
27 /*
28  * =========== Constant/Structure/Enum/... Define
29  *   */
30
31
32
33 /*
34  * =========== Macro Define
35  *   */
36
37 #define _reg_all(_name)                 ODM_##_name
38 #define _reg_ic(_name, _ic)             ODM_##_name##_ic
39 #define _bit_all(_name)                 BIT_##_name
40 #define _bit_ic(_name, _ic)             BIT_##_name##_ic
41
42 /* _cat: implemented by Token-Pasting Operator. */
43 #if 0
44 #define _cat(_name, _ic_type, _func)                                                            \
45         (\
46          _func##_all(_name)                                                                             \
47         )
48 #endif
49
50 /*===================================
51
52 #define ODM_REG_DIG_11N         0xC50
53 #define ODM_REG_DIG_11AC        0xDDD
54
55 ODM_REG(DIG,_pdm_odm)
56 =====================================*/
57
58 #define _reg_11N(_name)                 ODM_REG_##_name##_11N
59 #define _reg_11AC(_name)                ODM_REG_##_name##_11AC
60 #define _bit_11N(_name)                 ODM_BIT_##_name##_11N
61 #define _bit_11AC(_name)                ODM_BIT_##_name##_11AC
62
63 #ifdef __ECOS
64 #define _rtk_cat(_name, _ic_type, _func)                \
65         (\
66          ((_ic_type) & ODM_IC_11N_SERIES) ? _func##_11N(_name) :                \
67          _func##_11AC(_name)    \
68         )
69 #else
70
71 #define _cat(_name, _ic_type, _func)                                                                    \
72         (\
73          ((_ic_type) & ODM_IC_11N_SERIES) ? _func##_11N(_name) :                \
74          _func##_11AC(_name)                                                                    \
75         )
76 #endif
77 /*
78  * only sample code
79  *#define _cat(_name, _ic_type, _func)                                                                  \
80  *      (                                                                                                                       \
81  *              ((_ic_type) & ODM_RTL8188E) ? _func##_ic(_name, _8188E) :               \
82  *              _func##_ic(_name, _8195)                                                                        \
83  *      )
84  */
85
86 /* _name: name of register or bit.
87  * Example: "ODM_REG(R_A_AGC_CORE1, p_dm_odm)"
88  * gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", depends on support_ic_type. */
89 #ifdef __ECOS
90         #define ODM_REG(_name, _pdm_odm)        _rtk_cat(_name, _pdm_odm->support_ic_type, _reg)
91         #define ODM_BIT(_name, _pdm_odm)        _rtk_cat(_name, _pdm_odm->support_ic_type, _bit)
92 #else
93         #define ODM_REG(_name, _pdm_odm)        _cat(_name, _pdm_odm->support_ic_type, _reg)
94         #define ODM_BIT(_name, _pdm_odm)        _cat(_name, _pdm_odm->support_ic_type, _bit)
95 #endif
96 enum phydm_h2c_cmd {
97         PHYDM_H2C_TXBF                  = 0x41,
98         ODM_H2C_RSSI_REPORT             = 0x42,
99         ODM_H2C_IQ_CALIBRATION  = 0x45,
100         ODM_H2C_RA_PARA_ADJUST  = 0x47,
101         PHYDM_H2C_DYNAMIC_TX_PATH = 0x48,
102         PHYDM_H2C_FW_TRACE_EN   = 0x49,
103         ODM_H2C_WIFI_CALIBRATION        = 0x6d,
104         PHYDM_H2C_MU                            = 0x4a,
105         ODM_MAX_H2CCMD
106 };
107
108 enum phydm_c2h_evt {
109         PHYDM_C2H_DBG = 0,
110         PHYDM_C2H_LB = 1,
111         PHYDM_C2H_XBF = 2,
112         PHYDM_C2H_TX_REPORT = 3,
113         PHYDM_C2H_INFO = 9,
114         PHYDM_C2H_BT_MP = 11,
115         PHYDM_C2H_RA_RPT = 12,
116         PHYDM_C2H_RA_PARA_RPT = 14,
117         PHYDM_C2H_DYNAMIC_TX_PATH_RPT = 15,
118         PHYDM_C2H_IQK_FINISH = 17, /*0x11*/
119         PHYDM_C2H_DBG_CODE = 0xFE,
120         PHYDM_C2H_EXTEND = 0xFF,
121 };
122
123 enum phydm_extend_c2h_evt {
124         PHYDM_EXTEND_C2H_DBG_PRINT = 0
125
126 };
127
128
129 /*
130  * =========== Extern Variable ??? It should be forbidden.
131  *   */
132
133
134 /*
135  * =========== EXtern Function Prototype
136  *   */
137
138
139 u8
140 odm_read_1byte(
141         struct PHY_DM_STRUCT            *p_dm_odm,
142         u32                     reg_addr
143 );
144
145 u16
146 odm_read_2byte(
147         struct PHY_DM_STRUCT            *p_dm_odm,
148         u32                     reg_addr
149 );
150
151 u32
152 odm_read_4byte(
153         struct PHY_DM_STRUCT            *p_dm_odm,
154         u32                     reg_addr
155 );
156
157 void
158 odm_write_1byte(
159         struct PHY_DM_STRUCT            *p_dm_odm,
160         u32                     reg_addr,
161         u8                      data
162 );
163
164 void
165 odm_write_2byte(
166         struct PHY_DM_STRUCT            *p_dm_odm,
167         u32                     reg_addr,
168         u16                     data
169 );
170
171 void
172 odm_write_4byte(
173         struct PHY_DM_STRUCT            *p_dm_odm,
174         u32                     reg_addr,
175         u32                     data
176 );
177
178 void
179 odm_set_mac_reg(
180         struct PHY_DM_STRUCT    *p_dm_odm,
181         u32             reg_addr,
182         u32             bit_mask,
183         u32             data
184 );
185
186 u32
187 odm_get_mac_reg(
188         struct PHY_DM_STRUCT    *p_dm_odm,
189         u32             reg_addr,
190         u32             bit_mask
191 );
192
193 void
194 odm_set_bb_reg(
195         struct PHY_DM_STRUCT    *p_dm_odm,
196         u32             reg_addr,
197         u32             bit_mask,
198         u32             data
199 );
200
201 u32
202 odm_get_bb_reg(
203         struct PHY_DM_STRUCT    *p_dm_odm,
204         u32             reg_addr,
205         u32             bit_mask
206 );
207
208 void
209 odm_set_rf_reg(
210         struct PHY_DM_STRUCT                    *p_dm_odm,
211         enum odm_rf_radio_path_e        e_rf_path,
212         u32                             reg_addr,
213         u32                             bit_mask,
214         u32                             data
215 );
216
217 u32
218 odm_get_rf_reg(
219         struct PHY_DM_STRUCT                    *p_dm_odm,
220         enum odm_rf_radio_path_e        e_rf_path,
221         u32                             reg_addr,
222         u32                             bit_mask
223 );
224
225
226 /*
227  * Memory Relative Function.
228  *   */
229 void
230 odm_allocate_memory(
231         struct PHY_DM_STRUCT    *p_dm_odm,
232         void **p_ptr,
233         u32             length
234 );
235 void
236 odm_free_memory(
237         struct PHY_DM_STRUCT    *p_dm_odm,
238         void            *p_ptr,
239         u32             length
240 );
241
242 void
243 odm_move_memory(
244         struct PHY_DM_STRUCT    *p_dm_odm,
245         void            *p_dest,
246         void            *p_src,
247         u32             length
248 );
249
250 s32 odm_compare_memory(
251         struct PHY_DM_STRUCT    *p_dm_odm,
252         void           *p_buf1,
253         void           *p_buf2,
254         u32          length
255 );
256
257 void odm_memory_set
258 (struct PHY_DM_STRUCT   *p_dm_odm,
259  void   *pbuf,
260  s8     value,
261  u32    length);
262
263 /*
264  * ODM MISC-spin lock relative API.
265  *   */
266 void
267 odm_acquire_spin_lock(
268         struct PHY_DM_STRUCT                    *p_dm_odm,
269         enum rt_spinlock_type   type
270 );
271
272 void
273 odm_release_spin_lock(
274         struct PHY_DM_STRUCT                    *p_dm_odm,
275         enum rt_spinlock_type   type
276 );
277
278 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
279 /*
280  * ODM MISC-workitem relative API.
281  *   */
282 void
283 odm_initialize_work_item(
284         struct PHY_DM_STRUCT                                    *p_dm_odm,
285         PRT_WORK_ITEM                           p_rt_work_item,
286         RT_WORKITEM_CALL_BACK           rt_work_item_callback,
287         void                                            *p_context,
288         const char                                      *sz_id
289 );
290
291 void
292 odm_start_work_item(
293         PRT_WORK_ITEM   p_rt_work_item
294 );
295
296 void
297 odm_stop_work_item(
298         PRT_WORK_ITEM   p_rt_work_item
299 );
300
301 void
302 odm_free_work_item(
303         PRT_WORK_ITEM   p_rt_work_item
304 );
305
306 void
307 odm_schedule_work_item(
308         PRT_WORK_ITEM   p_rt_work_item
309 );
310
311 boolean
312 odm_is_work_item_scheduled(
313         PRT_WORK_ITEM   p_rt_work_item
314 );
315 #endif
316
317 /*
318  * ODM Timer relative API.
319  *   */
320 void
321 odm_stall_execution(
322         u32     us_delay
323 );
324
325 void
326 ODM_delay_ms(u32        ms);
327
328
329
330 void
331 ODM_delay_us(u32        us);
332
333 void
334 ODM_sleep_ms(u32        ms);
335
336 void
337 ODM_sleep_us(u32        us);
338
339 void
340 odm_set_timer(
341         struct PHY_DM_STRUCT            *p_dm_odm,
342         struct timer_list               *p_timer,
343         u32                     ms_delay
344 );
345
346 void
347 odm_initialize_timer(
348         struct PHY_DM_STRUCT                    *p_dm_odm,
349         struct timer_list                       *p_timer,
350         void    *call_back_func,
351         void                            *p_context,
352         const char                      *sz_id
353 );
354
355 void
356 odm_cancel_timer(
357         struct PHY_DM_STRUCT            *p_dm_odm,
358         struct timer_list               *p_timer
359 );
360
361 void
362 odm_release_timer(
363         struct PHY_DM_STRUCT            *p_dm_odm,
364         struct timer_list               *p_timer
365 );
366
367 /*
368  * ODM FW relative API.
369  *   */
370 void
371 odm_fill_h2c_cmd(
372         struct PHY_DM_STRUCT            *p_dm_odm,
373         u8                      element_id,
374         u32                     cmd_len,
375         u8                      *p_cmd_buffer
376 );
377
378 u8
379 phydm_c2H_content_parsing(
380         void                    *p_dm_void,
381         u8                      c2h_cmd_id,
382         u8                      c2h_cmd_len,
383         u8                      *tmp_buf
384 );
385
386 u64
387 odm_get_current_time(
388         struct PHY_DM_STRUCT            *p_dm_odm
389 );
390 u64
391 odm_get_progressing_time(
392         struct PHY_DM_STRUCT            *p_dm_odm,
393         u64                     start_time
394 );
395
396 #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
397
398 void
399 phydm_set_hw_reg_handler_interface (
400         struct PHY_DM_STRUCT            *p_dm_odm,
401         u8                              reg_Name,
402         u8                              *val
403         );
404
405 void
406 phydm_get_hal_def_var_handler_interface (
407         struct PHY_DM_STRUCT            *p_dm_odm,
408         enum _HAL_DEF_VARIABLE          e_variable,
409         void                                            *p_value
410         );
411
412 #endif
413
414 void
415 odm_set_tx_power_index_by_rate_section (
416         struct PHY_DM_STRUCT    *p_dm_odm,
417         u8                              RFPath,
418         u8                              Channel,
419         u8                              RateSection
420 );
421
422 u8
423 odm_get_tx_power_index (
424         struct PHY_DM_STRUCT    *p_dm_odm,
425         u8                              RFPath,
426         u8                              tx_rate,
427         u8                              band_width,
428         u8                              Channel
429 );
430
431
432
433 #endif /* __ODM_INTERFACE_H__ */
434