• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3 
4 #ifndef	__ODM_INTERFACE_H__
5 #define __ODM_INTERFACE_H__
6 
7 /*  */
8 /*  =========== Constant/Structure/Enum/... Define */
9 /*  */
10 
11 /*  */
12 /*  =========== Macro Define */
13 /*  */
14 
15 #define _reg_all(_name)			ODM_##_name
16 #define _reg_ic(_name, _ic)		ODM_##_name##_ic
17 #define _bit_all(_name)			BIT_##_name
18 #define _bit_ic(_name, _ic)		BIT_##_name##_ic
19 
20 /*  _cat: implemented by Token-Pasting Operator. */
21 
22 /*===================================
23 
24 #define ODM_REG_DIG_11N		0xC50
25 #define ODM_REG_DIG_11AC	0xDDD
26 
27 ODM_REG(DIG,_pDM_Odm)
28 =====================================*/
29 
30 #define _reg_11N(_name)			ODM_REG_##_name##_11N
31 #define _reg_11AC(_name)		ODM_REG_##_name##_11AC
32 #define _bit_11N(_name)			ODM_BIT_##_name##_11N
33 #define _bit_11AC(_name)		ODM_BIT_##_name##_11AC
34 
35 #define _cat(_name, _ic_type, _func)					\
36 	(								\
37 		((_ic_type) & ODM_IC_11N_SERIES) ? _func##_11N(_name) :	\
38 		_func##_11AC(_name)					\
39 	)
40 
41 /*  _name: name of register or bit. */
42 /*  Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)" */
43 /*         gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C",
44  *	   depends on SupportICType. */
45 #define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg)
46 #define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit)
47 
48 enum odm_h2c_cmd {
49 	ODM_H2C_RSSI_REPORT = 0,
50 	ODM_H2C_PSD_RESULT= 1,
51 	ODM_H2C_PathDiv = 2,
52 	ODM_MAX_H2CCMD
53 };
54 
55 /*  2012/02/17 MH For non-MP compile pass only. Linux does not support workitem. */
56 /*  Suggest HW team to use thread instead of workitem. Windows also support the feature. */
57 typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext);
58 
59 /*  =========== Extern Variable ??? It should be forbidden. */
60 
61 /*  =========== EXtern Function Prototype */
62 
63 u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr);
64 
65 u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr);
66 
67 u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr);
68 
69 void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data);
70 
71 void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data);
72 
73 void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data);
74 
75 void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr,
76 		   u32 BitMask, u32 Data);
77 
78 u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask);
79 
80 void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr,
81 		  u32 BitMask, u32 Data);
82 
83 u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask);
84 
85 void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath,
86 		  u32 RegAddr, u32 BitMask, u32 Data);
87 
88 u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath,
89 		 u32 RegAddr, u32 BitMask);
90 
91 /*  Memory Relative Function. */
92 void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length);
93 void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length);
94 
95 s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2,
96 		      u32 length);
97 
98 /*  ODM MISC-spin lock relative API. */
99 void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm,
100 			 enum RT_SPINLOCK_TYPE type);
101 
102 void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm,
103 			 enum RT_SPINLOCK_TYPE type);
104 
105 /*  ODM MISC-workitem relative API. */
106 void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem,
107 			    RT_WORKITEM_CALL_BACK RtWorkItemCallback,
108 			    void *pContext, const char *szID);
109 
110 void ODM_StartWorkItem(void *pRtWorkItem);
111 
112 void ODM_StopWorkItem(void *pRtWorkItem);
113 
114 void ODM_FreeWorkItem(void *pRtWorkItem);
115 
116 void ODM_ScheduleWorkItem(void *pRtWorkItem);
117 
118 void ODM_IsWorkItemScheduled(void *pRtWorkItem);
119 
120 /*  ODM Timer relative API. */
121 void ODM_StallExecution(u32 usDelay);
122 
123 void ODM_delay_ms(u32 ms);
124 
125 void ODM_delay_us(u32 us);
126 
127 void ODM_sleep_ms(u32 ms);
128 
129 void ODM_sleep_us(u32 us);
130 
131 void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer,
132 		  u32 msDelay);
133 
134 void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm,
135 			 struct timer_list *pTimer, void *CallBackFunc,
136 			 void *pContext, const char *szID);
137 
138 void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer);
139 
140 void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer);
141 
142 /*  ODM FW relative API. */
143 u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum,
144 		   u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer,
145 		   u8 *CmdStartSeq);
146 
147 #endif	/*  __ODM_INTERFACE_H__ */
148