Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | /*! \file |
2 | \brief Declaration of library functions | |
3 | ||
4 | Any definitions in this file will be shared among GLUE Layer and internal Driver Stack. | |
5 | */ | |
6 | ||
7 | ||
8 | ||
9 | #ifndef _WMT_LIB_H_ | |
10 | #define _WMT_LIB_H_ | |
11 | ||
12 | ||
13 | #include "wmt_core.h" | |
14 | #include "wmt_exp.h" | |
15 | #include <mach/mtk_wcn_cmb_stub.h> | |
16 | #include "stp_wmt.h" | |
17 | #include "wmt_plat.h" | |
18 | #include "wmt_idc.h" | |
19 | #include "osal.h" | |
20 | ||
21 | ||
22 | ||
23 | /******************************************************************************* | |
24 | * C O M P I L E R F L A G S | |
25 | ******************************************************************************** | |
26 | */ | |
27 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) | |
28 | #define USE_NEW_PROC_FS_FLAG 1 | |
29 | #else | |
30 | #define USE_NEW_PROC_FS_FLAG 0 | |
31 | #endif | |
32 | ||
33 | ||
34 | /******************************************************************************* | |
35 | * M A C R O S | |
36 | ******************************************************************************** | |
37 | */ | |
38 | ||
39 | #define WMT_OP_BUF_SIZE (16) | |
40 | #if 0 /* moved to wmt_exp.h */ | |
41 | #define WMT_LOG_LOUD 4 | |
42 | #define WMT_LOG_DBG 3 | |
43 | #define WMT_LOG_INFO 2 | |
44 | #define WMT_LOG_WARN 1 | |
45 | #define WMT_LOG_ERR 0 | |
46 | #endif | |
47 | typedef enum _ENUM_WMTRSTRET_TYPE_T { | |
48 | WMTRSTRET_SUCCESS = 0x0, | |
49 | WMTRSTRET_FAIL = 0x1, | |
50 | WMTRSTRET_ONGOING = 0x2, | |
51 | WMTRSTRET_MAX | |
52 | } ENUM_WMTRSTRET_TYPE_T, *P_ENUM_WMTRSTRET_TYPE_T; | |
53 | ||
54 | #define MAX_ANT_RAM_CODE_DOWN_TIME 3000 | |
55 | /* | |
56 | 3(retry times) * 180 (STP retry time out) | |
57 | + 10 (firmware process time) + | |
58 | 10 (transmit time) + | |
59 | 10 (uart process -> WMT response pool) + | |
60 | 230 (others) | |
61 | */ | |
62 | #define WMT_LIB_RX_TIMEOUT 2000 /*800-->cover v1.2phone BT function on time (~830ms) */ | |
63 | /* | |
64 | open wifi during wifi power on procedure | |
65 | (because wlan is insert to system after mtk_hif_sdio module, | |
66 | so wifi card is not registered to hif module | |
67 | when mtk_wcn_wmt_func_on is called by wifi through rfkill) | |
68 | */ | |
69 | #define MAX_WIFI_ON_TIME 5500 | |
70 | ||
71 | #define WMT_PWRON_RTY_DFT 2 | |
72 | #define MAX_RETRY_TIME_DUE_TO_RX_TIMEOUT WMT_PWRON_RTY_DFT * WMT_LIB_RX_TIMEOUT | |
73 | #define MAX_EACH_FUNC_ON_WHEN_CHIP_POWER_ON_ALREADY WMT_LIB_RX_TIMEOUT /*each WMT command */ | |
74 | #define MAX_FUNC_ON_TIME (MAX_WIFI_ON_TIME + MAX_RETRY_TIME_DUE_TO_RX_TIMEOUT + MAX_EACH_FUNC_ON_WHEN_CHIP_POWER_ON_ALREADY * 3 + MAX_ANT_RAM_CODE_DOWN_TIME) | |
75 | ||
76 | #define MAX_EACH_FUNC_OFF WMT_LIB_RX_TIMEOUT + 1000 /*1000->WMT_LIB_RX_TIMEOUT + 1000, logical judgement */ | |
77 | #define MAX_FUNC_OFF_TIME MAX_EACH_FUNC_OFF * 4 | |
78 | ||
79 | #define MAX_EACH_WMT_CMD WMT_LIB_RX_TIMEOUT + 1000 /*1000->WMT_LIB_RX_TIMEOUT + 1000, logical judgement */ | |
80 | ||
81 | #define MAX_GPIO_CTRL_TIME (2000) /* [FixMe][GeorgeKuo] a temp value */ | |
82 | ||
4b9e9796 S |
83 | #define MAX_PATCH_NUM 10 |
84 | ||
6fa3eb70 S |
85 | /******************************************************************************* |
86 | * E X T E R N A L R E F E R E N C E S | |
87 | ******************************************************************************** | |
88 | */ | |
89 | #if 0 /* moved to wmt_exp.h */ | |
90 | /* FIXME: apply KERN_* definition? */ | |
91 | extern UINT32 gWmtDbgLvl; | |
92 | #ifndef DFT_TAG | |
93 | #define DFT_TAG "[WMT-DFT]" | |
94 | #endif | |
95 | ||
96 | #define WMT_LOUD_FUNC(fmt, arg...) if (gWmtDbgLvl >= WMT_LOG_LOUD) { osal_dbg_print(DFT_TAG "[L]%s:" fmt, __FUNCTION__ ,##arg);} | |
97 | #define WMT_INFO_FUNC(fmt, arg...) if (gWmtDbgLvl >= WMT_LOG_INFO) { osal_info_print(DFT_TAG "[I]%s:" fmt, __FUNCTION__ ,##arg);} | |
98 | #define WMT_WARN_FUNC(fmt, arg...) if (gWmtDbgLvl >= WMT_LOG_WARN) { osal_warn_print(DFT_TAG "[W]%s:" fmt, __FUNCTION__ ,##arg);} | |
99 | #define WMT_ERR_FUNC(fmt, arg...) if (gWmtDbgLvl >= WMT_LOG_ERR) { osal_err_print(DFT_TAG "[E]%s(%d):" fmt, __FUNCTION__ , __LINE__, ##arg);} | |
100 | #define WMT_DBG_FUNC(fmt, arg...) if (gWmtDbgLvl >= WMT_LOG_DBG) { osal_dbg_print(DFT_TAG "[D]%s:" fmt, __FUNCTION__ ,##arg);} | |
101 | #define WMT_TRC_FUNC(f) if (gWmtDbgLvl >= WMT_LOG_DBG) { osal_dbg_print(DFT_TAG "<%s> <%d>\n", __FUNCTION__, __LINE__);} | |
102 | #endif | |
103 | ||
104 | /******************************************************************************* | |
105 | * C O N S T A N T S | |
106 | ******************************************************************************** | |
107 | */ | |
108 | ||
109 | /* AIF FLAG definition */ | |
110 | /* bit(0): share pin or not */ | |
111 | #define WMT_LIB_AIF_FLAG_MASK (0x1UL) | |
112 | #define WMT_LIB_AIF_FLAG_SHARE (0x1UL << 0) | |
113 | #define WMT_LIB_AIF_FLAG_SEPARATE (0x0UL << 0) | |
114 | ||
115 | /******************************************************************************* | |
116 | * D A T A T Y P E S | |
117 | ******************************************************************************** | |
118 | */ | |
119 | ||
120 | /* bit field offset definition */ | |
121 | typedef enum { | |
122 | WMT_STAT_PWR = 0, /* is powered on */ | |
123 | WMT_STAT_STP_REG = 1, /* is STP driver registered: */ | |
124 | WMT_STAT_STP_OPEN = 2, /* is STP opened: default FALSE */ | |
125 | WMT_STAT_STP_EN = 3, /* is STP enabled: default FALSE */ | |
126 | WMT_STAT_STP_RDY = 4, /* is STP ready for client: default FALSE */ | |
127 | WMT_STAT_RX = 5, /* is rx data available */ | |
128 | WMT_STAT_CMD = 6, /* is cmd string to be read */ | |
129 | WMT_STAT_SDIO1_ON = 7, /* is SDIO1 on */ | |
130 | WMT_STAT_SDIO2_ON = 8, /* is SDIO2 on */ | |
131 | WMT_STAT_SDIO_WIFI_ON = 9, /* is Wi-Fi SDIO function on */ | |
132 | WMT_STAT_SDIO_STP_ON = 10, /* is STP SDIO function on */ | |
133 | WMT_STAT_RST_ON = 11, | |
134 | WMT_STAT_MAX | |
135 | } WMT_STAT; | |
136 | ||
137 | typedef enum _ENUM_WMTRSTSRC_TYPE_T { | |
138 | WMTRSTSRC_RESET_BT = 0x0, | |
139 | WMTRSTSRC_RESET_FM = 0x1, | |
140 | WMTRSTSRC_RESET_GPS = 0x2, | |
141 | WMTRSTSRC_RESET_WIFI = 0x3, | |
142 | WMTRSTSRC_RESET_STP = 0x4, | |
143 | WMTRSTSRC_RESET_TEST = 0x5, | |
144 | WMTRSTSRC_RESET_MAX | |
145 | } ENUM_WMTRSTSRC_TYPE_T, *P_ENUM_WMTRSTSRC_TYPE_T; | |
146 | ||
147 | ||
148 | typedef struct { | |
149 | PF_WMT_CB fDrvRst[WMTDRV_TYPE_MAX]; | |
150 | } WMT_FDRV_CB, *P_WMT_FDRV_CB; | |
151 | ||
152 | ||
153 | typedef struct { | |
154 | UINT32 dowloadSeq; | |
155 | UINT8 addRess[4]; | |
156 | UINT8 patchName[256]; | |
157 | } WMT_PATCH_INFO, *P_WMT_PATCH_INFO; | |
158 | ||
159 | ||
160 | /* OS independent wrapper for WMT_OP */ | |
161 | typedef struct _DEV_WMT_ { | |
162 | ||
163 | OSAL_SLEEPABLE_LOCK psm_lock; | |
164 | /* WMTd thread information */ | |
165 | /* struct task_struct *pWmtd; */ /* main thread (wmtd) handle */ | |
166 | OSAL_THREAD thread; | |
167 | /* wait_queue_head_t rWmtdWq; */ /*WMTd command wait queue */ | |
168 | OSAL_EVENT rWmtdWq; /* rename */ | |
169 | /* ULONG state; */ /* bit field of WMT_STAT */ | |
170 | OSAL_BIT_OP_VAR state; | |
171 | ||
172 | /* STP context information */ | |
173 | /* wait_queue_head_t rWmtRxWq; */ /* STP Rx wait queue */ | |
174 | OSAL_EVENT rWmtRxWq; /* rename */ | |
175 | /* WMT_STP_FUNC rStpFunc; */ /* STP functions */ | |
176 | WMT_FDRV_CB rFdrvCb; | |
177 | ||
178 | /* WMT Configurations */ | |
179 | WMT_HIF_CONF rWmtHifConf; | |
180 | WMT_GEN_CONF rWmtGenConf; | |
181 | ||
182 | /* Patch information */ | |
183 | UINT8 cPatchName[NAME_MAX + 1]; | |
184 | UINT8 cFullPatchName[NAME_MAX + 1]; | |
185 | UINT32 patchNum; | |
186 | const osal_firmware *pPatch; | |
187 | ||
188 | UINT8 cWmtcfgName[NAME_MAX + 1]; | |
189 | const osal_firmware *pWmtCfg; | |
190 | ||
191 | const osal_firmware *pNvram; | |
192 | ||
193 | /* Current used UART port description */ | |
194 | INT8 cUartName[NAME_MAX + 1]; | |
195 | ||
196 | OSAL_OP_Q rFreeOpQ; /* free op queue */ | |
197 | OSAL_OP_Q rActiveOpQ; /* active op queue */ | |
198 | OSAL_OP arQue[WMT_OP_BUF_SIZE]; /* real op instances */ | |
199 | P_OSAL_OP pCurOP; /* current op */ | |
200 | ||
201 | /* cmd str buffer */ | |
202 | UINT8 cCmd[NAME_MAX + 1]; | |
203 | INT32 cmdResult; | |
204 | /* struct completion cmd_comp; */ | |
205 | /* wait_queue_head_t cmd_wq; */ /* read command queues */ | |
206 | OSAL_SIGNAL cmdResp; | |
207 | OSAL_EVENT cmdReq; | |
208 | ||
209 | /* WMT loopback Thread Information */ | |
210 | /* WMT_CMB_VER combo_ver; */ | |
211 | /* P_WMT_CMB_CHIP_INFO_S pChipInfo; */ | |
212 | UINT32 chip_id; | |
213 | UINT32 hw_ver; | |
214 | UINT32 fw_ver; | |
215 | /* TODO: [FixMe][GeorgeKuo] remove this translated version code in the */ | |
216 | /* future. Just return the above 3 info to querist */ | |
217 | ENUM_WMTHWVER_TYPE_T eWmtHwVer; | |
218 | ||
219 | P_WMT_PATCH_INFO pWmtPatchInfo; | |
220 | } DEV_WMT, *P_DEV_WMT; | |
221 | ||
222 | /******************************************************************************* | |
223 | * P U B L I C D A T A | |
224 | ******************************************************************************** | |
225 | */ | |
226 | ||
227 | /******************************************************************************* | |
228 | * P R I V A T E D A T A | |
229 | ******************************************************************************** | |
230 | */ | |
231 | ||
232 | /******************************************************************************* | |
233 | * F U N C T I O N D E C L A R A T I O N S | |
234 | ******************************************************************************** | |
235 | */ | |
236 | extern INT32 wmt_lib_init(VOID); | |
237 | extern INT32 wmt_lib_deinit(VOID); | |
238 | extern INT32 wmt_lib_tx(PUINT8 data, UINT32 size, PUINT32 writtenSize); | |
239 | extern INT32 wmt_lib_tx_raw(PUINT8 data, UINT32 size, PUINT32 writtenSize); | |
240 | extern INT32 wmt_lib_rx(PUINT8 buff, UINT32 buffLen, PUINT32 readSize); | |
241 | extern VOID wmt_lib_flush_rx(VOID); | |
242 | ||
243 | #if CFG_WMT_PS_SUPPORT | |
244 | extern INT32 wmt_lib_ps_set_idle_time(UINT32 psIdleTime); | |
245 | extern INT32 wmt_lib_ps_init(VOID); | |
246 | extern INT32 wmt_lib_ps_deinit(VOID); | |
247 | extern INT32 wmt_lib_ps_enable(VOID); | |
248 | extern INT32 wmt_lib_ps_ctrl(UINT32 state); | |
249 | ||
250 | extern INT32 wmt_lib_ps_disable(VOID); | |
251 | extern VOID wmt_lib_ps_irq_cb(VOID); | |
252 | #endif | |
253 | extern VOID wmt_lib_ps_set_sdio_psop(PF_WMT_SDIO_PSOP own_cb); | |
254 | ||
255 | /* LXOP functions: */ | |
256 | extern P_OSAL_OP wmt_lib_get_free_op(VOID); | |
257 | extern INT32 wmt_lib_put_op_to_free_queue(P_OSAL_OP pOp); | |
258 | extern MTK_WCN_BOOL wmt_lib_put_act_op(P_OSAL_OP pOp); | |
259 | ||
260 | /* extern ENUM_WMTHWVER_TYPE_T wmt_lib_get_hwver (VOID); */ | |
261 | extern UINT32 wmt_lib_get_icinfo(ENUM_WMT_CHIPINFO_TYPE_T type); | |
262 | ||
263 | extern MTK_WCN_BOOL wmt_lib_is_therm_ctrl_support(VOID); | |
264 | extern MTK_WCN_BOOL wmt_lib_is_dsns_ctrl_support(VOID); | |
265 | extern INT32 wmt_lib_trigger_cmd_signal(INT32 result); | |
266 | extern PUINT8 wmt_lib_get_cmd(VOID); | |
267 | extern P_OSAL_EVENT wmt_lib_get_cmd_event(VOID); | |
268 | extern INT32 wmt_lib_set_patch_name(PUINT8 cPatchName); | |
269 | extern INT32 wmt_lib_set_uart_name(PINT8 cUartName); | |
270 | extern INT32 wmt_lib_set_hif(unsigned long hifconf); | |
271 | extern P_WMT_HIF_CONF wmt_lib_get_hif(VOID); | |
272 | extern MTK_WCN_BOOL wmt_lib_get_cmd_status(VOID); | |
273 | ||
274 | /* GeorgeKuo: replace set_chip_gpio() with more specific ones */ | |
275 | #if 0 /* moved to wmt_exp.h */ | |
276 | extern INT32 wmt_lib_set_aif(CMB_STUB_AIF_X aif, MTK_WCN_BOOL share); /* set AUDIO interface options */ | |
277 | #endif | |
278 | extern INT32 wmt_lib_host_awake_get(VOID); | |
279 | extern INT32 wmt_lib_host_awake_put(VOID); | |
280 | extern UINT32 wmt_lib_dbg_level_set(UINT32 level); | |
281 | ||
282 | extern INT32 wmt_lib_msgcb_reg(ENUM_WMTDRV_TYPE_T eType, PF_WMT_CB pCb); | |
283 | ||
284 | extern INT32 wmt_lib_msgcb_unreg(ENUM_WMTDRV_TYPE_T eType); | |
285 | ENUM_WMTRSTRET_TYPE_T wmt_lib_cmb_rst(ENUM_WMTRSTSRC_TYPE_T src); | |
286 | MTK_WCN_BOOL wmt_lib_sw_rst(INT32 baudRst); | |
287 | MTK_WCN_BOOL wmt_lib_hw_rst(VOID); | |
288 | INT32 wmt_lib_reg_rw(UINT32 isWrite, UINT32 offset, PUINT32 pvalue, UINT32 mask); | |
289 | INT32 wmt_lib_efuse_rw(UINT32 isWrite, UINT32 offset, PUINT32 pvalue, UINT32 mask); | |
290 | INT32 wmt_lib_sdio_ctrl(UINT32 on); | |
291 | ||
292 | extern INT32 DISABLE_PSM_MONITOR(VOID); | |
293 | extern VOID ENABLE_PSM_MONITOR(VOID); | |
294 | extern INT32 wmt_lib_notify_stp_sleep(VOID); | |
295 | extern VOID wmt_lib_psm_lock_release(VOID); | |
296 | extern INT32 wmt_lib_psm_lock_aquire(VOID); | |
297 | extern INT32 wmt_lib_set_stp_wmt_last_close(UINT32 value); | |
298 | ||
299 | extern VOID wmt_lib_set_patch_num(unsigned long num); | |
300 | extern VOID wmt_lib_set_patch_info(P_WMT_PATCH_INFO pPatchinfo); | |
301 | ||
302 | extern INT32 wmt_lib_set_current_op(P_DEV_WMT pWmtDev, P_OSAL_OP pOp); | |
303 | extern P_OSAL_OP wmt_lib_get_current_op(P_DEV_WMT pWmtDev); | |
304 | ||
305 | extern INT32 wmt_lib_merge_if_flag_ctrl(UINT32 enable); | |
306 | extern INT32 wmt_lib_merge_if_flag_get(UINT32 enable); | |
307 | ||
308 | extern PUINT8 wmt_lib_get_cpupcr_xml_format(PUINT32 len); | |
309 | extern UINT32 wmt_lib_set_host_assert_info(UINT32 type, UINT32 reason, UINT32 en); | |
310 | #if CFG_WMT_LTE_COEX_HANDLING | |
311 | extern MTK_WCN_BOOL wmt_lib_handle_idc_msg(ipc_ilm_t *idc_infor); | |
312 | #endif | |
313 | #if WMT_FOR_SDIO_1V_AUTOK | |
314 | extern UINT32 wmt_lib_get_drv_status(UINT32 type); | |
315 | #endif | |
316 | extern INT32 wmt_lib_tm_temp_query(VOID); | |
317 | extern INT32 wmt_lib_trigger_reset(VOID); | |
318 | /******************************************************************************* | |
319 | * F U N C T I O N S | |
320 | ******************************************************************************** | |
321 | */ | |
322 | ||
323 | #endif /* _WMT_LIB_H_ */ |