1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3
4 #include "../include/odm_precomp.h"
5 /* ODM IO Relative API. */
6
ODM_Read1Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr)7 u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr)
8 {
9 struct adapter *Adapter = pDM_Odm->Adapter;
10 return rtw_read8(Adapter, RegAddr);
11 }
12
ODM_Read2Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr)13 u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr)
14 {
15 struct adapter *Adapter = pDM_Odm->Adapter;
16 return rtw_read16(Adapter, RegAddr);
17 }
18
ODM_Read4Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr)19 u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr)
20 {
21 struct adapter *Adapter = pDM_Odm->Adapter;
22 return rtw_read32(Adapter, RegAddr);
23 }
24
ODM_Write1Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u8 Data)25 void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data)
26 {
27 struct adapter *Adapter = pDM_Odm->Adapter;
28 rtw_write8(Adapter, RegAddr, Data);
29 }
30
ODM_Write2Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u16 Data)31 void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data)
32 {
33 struct adapter *Adapter = pDM_Odm->Adapter;
34 rtw_write16(Adapter, RegAddr, Data);
35 }
36
ODM_Write4Byte(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u32 Data)37 void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data)
38 {
39 struct adapter *Adapter = pDM_Odm->Adapter;
40 rtw_write32(Adapter, RegAddr, Data);
41 }
42
ODM_SetMACReg(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u32 BitMask,u32 Data)43 void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data)
44 {
45 struct adapter *Adapter = pDM_Odm->Adapter;
46 PHY_SetBBReg(Adapter, RegAddr, BitMask, Data);
47 }
48
ODM_GetMACReg(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u32 BitMask)49 u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask)
50 {
51 struct adapter *Adapter = pDM_Odm->Adapter;
52 return PHY_QueryBBReg(Adapter, RegAddr, BitMask);
53 }
54
ODM_SetBBReg(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u32 BitMask,u32 Data)55 void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data)
56 {
57 struct adapter *Adapter = pDM_Odm->Adapter;
58 PHY_SetBBReg(Adapter, RegAddr, BitMask, Data);
59 }
60
ODM_GetBBReg(struct odm_dm_struct * pDM_Odm,u32 RegAddr,u32 BitMask)61 u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask)
62 {
63 struct adapter *Adapter = pDM_Odm->Adapter;
64 return PHY_QueryBBReg(Adapter, RegAddr, BitMask);
65 }
66
ODM_SetRFReg(struct odm_dm_struct * pDM_Odm,enum rf_radio_path eRFPath,u32 RegAddr,u32 BitMask,u32 Data)67 void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
68 {
69 struct adapter *Adapter = pDM_Odm->Adapter;
70 PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask, Data);
71 }
72
ODM_GetRFReg(struct odm_dm_struct * pDM_Odm,enum rf_radio_path eRFPath,u32 RegAddr,u32 BitMask)73 u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask)
74 {
75 struct adapter *Adapter = pDM_Odm->Adapter;
76 return PHY_QueryRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask);
77 }
78
79 /* ODM Memory relative API. */
ODM_AllocateMemory(struct odm_dm_struct * pDM_Odm,void ** pPtr,u32 length)80 void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length)
81 {
82 *pPtr = vzalloc(length);
83 }
84
85 /* length could be ignored, used to detect memory leakage. */
ODM_FreeMemory(struct odm_dm_struct * pDM_Odm,void * pPtr,u32 length)86 void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length)
87 {
88 vfree(pPtr);
89 }
90
ODM_CompareMemory(struct odm_dm_struct * pDM_Odm,void * pBuf1,void * pBuf2,u32 length)91 s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length)
92 {
93 return !memcmp(pBuf1, pBuf2, length);
94 }
95
96 /* ODM MISC relative API. */
ODM_AcquireSpinLock(struct odm_dm_struct * pDM_Odm,enum RT_SPINLOCK_TYPE type)97 void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type)
98 {
99 }
100
ODM_ReleaseSpinLock(struct odm_dm_struct * pDM_Odm,enum RT_SPINLOCK_TYPE type)101 void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type)
102 {
103 }
104
105 /* Work item relative API. FOr MP driver only~! */
ODM_InitializeWorkItem(struct odm_dm_struct * pDM_Odm,void * pRtWorkItem,RT_WORKITEM_CALL_BACK RtWorkItemCallback,void * pContext,const char * szID)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 }
111
ODM_StartWorkItem(void * pRtWorkItem)112 void ODM_StartWorkItem(void *pRtWorkItem)
113 {
114 }
115
ODM_StopWorkItem(void * pRtWorkItem)116 void ODM_StopWorkItem(void *pRtWorkItem)
117 {
118 }
119
ODM_FreeWorkItem(void * pRtWorkItem)120 void ODM_FreeWorkItem(void *pRtWorkItem)
121 {
122 }
123
ODM_ScheduleWorkItem(void * pRtWorkItem)124 void ODM_ScheduleWorkItem(void *pRtWorkItem)
125 {
126 }
127
ODM_IsWorkItemScheduled(void * pRtWorkItem)128 void ODM_IsWorkItemScheduled(void *pRtWorkItem)
129 {
130 }
131
132 /* ODM Timer relative API. */
ODM_StallExecution(u32 usDelay)133 void ODM_StallExecution(u32 usDelay)
134 {
135 udelay(usDelay);
136 }
137
ODM_delay_ms(u32 ms)138 void ODM_delay_ms(u32 ms)
139 {
140 mdelay(ms);
141 }
142
ODM_delay_us(u32 us)143 void ODM_delay_us(u32 us)
144 {
145 udelay(us);
146 }
147
ODM_sleep_ms(u32 ms)148 void ODM_sleep_ms(u32 ms)
149 {
150 msleep(ms);
151 }
152
ODM_sleep_us(u32 us)153 void ODM_sleep_us(u32 us)
154 {
155 rtw_usleep_os(us);
156 }
157
ODM_SetTimer(struct odm_dm_struct * pDM_Odm,struct timer_list * pTimer,u32 msDelay)158 void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay)
159 {
160 _set_timer(pTimer, msDelay); /* ms */
161 }
162
ODM_CancelTimer(struct odm_dm_struct * pDM_Odm,struct timer_list * pTimer)163 void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer)
164 {
165 _cancel_timer_ex(pTimer);
166 }
167
ODM_ReleaseTimer(struct odm_dm_struct * pDM_Odm,struct timer_list * pTimer)168 void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer)
169 {
170 }
171
172 /* ODM FW relative API. */
ODM_FillH2CCmd(u8 * pH2CBuffer,u32 H2CBufferLen,u32 CmdNum,u32 * pElementID,u32 * pCmdLen,u8 ** pCmbBuffer,u8 * CmdStartSeq)173 u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum,
174 u32 *pElementID, u32 *pCmdLen,
175 u8 **pCmbBuffer, u8 *CmdStartSeq)
176 {
177 return true;
178 }
179