xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/core/rtw_btc.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2013 - 2017 Realtek Corporation.
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  *****************************************************************************/
15 #ifdef CONFIG_BTC
16 
17 #include <drv_types.h>
18 
19 typedef struct _btcdbginfo {
20 	void* p_msgprn_hdl;
21 	struct submit_ctx btc_dbg_info_sctx;
22 } BTCDBGINFO, *PBTCDBGINFO;
23 
24 BTCDBGINFO GLBtcDbgInfo;
25 
26 #define BTC_INFO_DUMP_TIMEOUT_MS	3000
27 
rtw_btc_info_dump_init(_adapter * padapter)28 static void rtw_btc_info_dump_init(_adapter *padapter)
29 {
30 	GLBtcDbgInfo.p_msgprn_hdl = NULL;
31 }
32 
rtw_btc_info_dump_set(_adapter * padapter,void * p_msgprn_hdl,u32 timeout_ms)33 static void rtw_btc_info_dump_set(_adapter *padapter, void* p_msgprn_hdl, u32 timeout_ms)
34 {
35 	GLBtcDbgInfo.p_msgprn_hdl = p_msgprn_hdl;
36 	rtw_sctx_init(&GLBtcDbgInfo.btc_dbg_info_sctx, timeout_ms);
37 }
38 
rtw_btc_info_dump(const char * pmsg)39 static void rtw_btc_info_dump(const char *pmsg)
40 {
41 	if (GLBtcDbgInfo.p_msgprn_hdl == NULL)
42 		return;
43 
44 	_RTW_PRINT_SEL(GLBtcDbgInfo.p_msgprn_hdl, "%s", pmsg);
45 }
46 
rtw_btc_info_dump_callback(void * priv,enum RTW_PHL_BTC_NOTIFY ntfy,struct rtw_phl_btc_ntfy * info)47 static int rtw_btc_info_dump_callback(void *priv, enum RTW_PHL_BTC_NOTIFY ntfy, struct rtw_phl_btc_ntfy *info)
48 {
49 	struct submit_ctx *sctx = &GLBtcDbgInfo.btc_dbg_info_sctx;
50 
51 	rtw_sctx_done(&sctx);
52 
53 	return 0;
54 }
55 
rtw_btc_info_dump_wait(_adapter * padapter)56 static int rtw_btc_info_dump_wait(_adapter *padapter)
57 {
58 	return rtw_sctx_wait(&GLBtcDbgInfo.btc_dbg_info_sctx, __func__);
59 }
60 
rtw_btc_disp_btc_info(_adapter * padapter,void * p_msgprn_hdl,u8 info_type)61 void rtw_btc_disp_btc_info(_adapter *padapter, void* p_msgprn_hdl, u8 info_type)
62 {
63 	struct rtw_phl_btc_ntfy ntfy = {0};
64 	struct rtw_phl_btc_coex_info_param *pcinfo = &ntfy.u.cinfo;
65 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
66 	struct rtw_phl_btc_ops phl_btc_ops = {rtw_btc_info_dump};
67 
68 	pcinfo->query_type = info_type;
69 
70 	ntfy.notify = PHL_BTC_NTFY_COEX_INFO;
71 	ntfy.ops = &phl_btc_ops;
72 	ntfy.priv = padapter;
73 	ntfy.ntfy_cb = rtw_btc_info_dump_callback;
74 
75 	rtw_btc_info_dump_set(padapter, p_msgprn_hdl, BTC_INFO_DUMP_TIMEOUT_MS);
76 
77 	rtw_phl_btc_notify(dvobj->phl, ntfy.notify, &ntfy);
78 
79 	/* wait here until info dump finishes or timeout expires */
80 	rtw_btc_info_dump_wait(padapter);
81 
82 	rtw_btc_info_dump_init(padapter);
83 }
84 
rtw_btc_set_dbg(_adapter * padapter,u32 * pDbgModule)85 void rtw_btc_set_dbg(_adapter *padapter, u32 *pDbgModule)
86 {
87 }
88 
rtw_btc_get_dbg(_adapter * padapter,u8 * pStrBuf,u32 bufSize)89 u32 rtw_btc_get_dbg(_adapter *padapter, u8 *pStrBuf, u32 bufSize)
90 {
91 	return 0;
92 }
93 
94 #if 0
95 u16 rtw_btc_btreg_read(_adapter *padapter, u8 type, u16 addr, u32 *data)
96 {
97 	return 0;
98 }
99 
100 u16 rtw_btc_btreg_write(_adapter *padapter, u8 type, u16 addr, u16 val)
101 {
102 	return _SUCCESS;
103 }
104 #endif
105 
106 #endif /* CONFIG_BTC */
107 
108