1 /*******************************************************************************
2 * E X T E R N A L R E F E R E N C E S
3 ********************************************************************************
5 #if 0 //to do---- need check why need this header file
6 #include <linux/types.h>
7 #include <linux/major.h>
8 #include <linux/errno.h>
9 #include <linux/signal.h>
10 #include <linux/fcntl.h>
11 #include <linux/sched.h>
12 #include <linux/interrupt.h>
13 #include <linux/tty.h>
14 #include <linux/timer.h>
15 #include <linux/ctype.h>
17 #include <linux/string.h>
18 #include <linux/slab.h>
19 #include <linux/poll.h>
20 #include <linux/bitops.h>
21 #include <linux/audit.h>
22 #include <linux/file.h>
23 #include <linux/module.h>
25 #include <linux/spinlock.h>
26 #include <linux/delay.h> /* udelay() */
28 #include <asm/uaccess.h>
29 #include <asm/system.h>
34 /*******************************************************************************
36 ********************************************************************************
40 /*******************************************************************************
42 ********************************************************************************
46 /*******************************************************************************
48 ********************************************************************************
50 /*******************************************************************************
51 * P R I V A T E D A T A
52 ********************************************************************************
54 static MTK_WCN_STP_IF_TX stp_uart_if_tx = NULL;
55 static MTK_WCN_STP_IF_TX stp_sdio_if_tx = NULL;
56 static ENUM_STP_TX_IF_TYPE g_stp_if_type = STP_MAX_IF_TX;
57 static MTK_WCN_STP_IF_RX stp_if_rx = NULL;
58 static MTK_WCN_STP_EVENT_CB event_callback_tbl[MTKSTP_MAX_TASK_NUM] = {0x0};
59 static MTK_WCN_STP_EVENT_CB tx_event_callback_tbl[MTKSTP_MAX_TASK_NUM] = {0x0};
61 /******************************************************************************
62 * F U N C T I O N D E C L A R A T I O N S
63 *******************************************************************************
66 /*******************************************************************************
68 ********************************************************************************
71 INT32 mtk_wcn_sys_if_rx(UINT8 *data, INT32 size)
79 (*stp_if_rx)(data, size);
84 static INT32 mtk_wcn_sys_if_tx (
91 if (STP_UART_IF_TX == g_stp_if_type) {
92 return stp_uart_if_tx != NULL ? (*stp_uart_if_tx)(data, size, written_size) : -1;
94 else if (STP_SDIO_IF_TX == g_stp_if_type) {
95 return stp_sdio_if_tx != NULL ? (*stp_sdio_if_tx)(data, size, written_size) : -1;
98 /*if (g_stp_if_type >= STP_MAX_IF_TX) */ /* George: remove ALWAYS TRUE condition */
103 static INT32 mtk_wcn_sys_event_set(UINT8 function_type)
105 if((function_type < MTKSTP_MAX_TASK_NUM) && (event_callback_tbl[function_type] != 0x0))
107 (*event_callback_tbl[function_type])();
110 /* FIXME: error handling */
111 osal_dbg_print("[%s] STP set event fail. It seems the function is not active.\n", __func__);
117 static INT32 mtk_wcn_sys_event_tx_resume(UINT8 winspace)
121 for(type = 0 ; type < MTKSTP_MAX_TASK_NUM ; type ++ )
123 if(tx_event_callback_tbl[type])
125 tx_event_callback_tbl[type]();
132 static INT32 mtk_wcn_sys_check_function_status(UINT8 type, UINT8 op){
134 /*op == FUNCTION_ACTIVE, to check if funciton[type] is active ?*/
135 if(!(type >= 0 && type < MTKSTP_MAX_TASK_NUM))
137 return STATUS_FUNCTION_INVALID;
140 if(op == OP_FUNCTION_ACTIVE)
142 if(event_callback_tbl[type] != 0x0)
144 return STATUS_FUNCTION_ACTIVE;
148 return STATUS_FUNCTION_INACTIVE;
151 /*you can define more operation here ..., to queury function's status/information*/
153 return STATUS_OP_INVALID;
156 INT32 mtk_wcn_stp_register_if_rx(MTK_WCN_STP_IF_RX func)
163 VOID mtk_wcn_stp_set_if_tx_type (
164 ENUM_STP_TX_IF_TYPE stp_if_type
167 g_stp_if_type = stp_if_type;
168 osal_dbg_print("[%s] set STP_IF_TX to %s.\n",
170 (STP_UART_IF_TX == stp_if_type)? "UART" : ((STP_SDIO_IF_TX == stp_if_type) ? "SDIO" : "NULL"));
173 INT32 mtk_wcn_stp_register_if_tx (
174 ENUM_STP_TX_IF_TYPE stp_if,
175 MTK_WCN_STP_IF_TX func
178 if (STP_UART_IF_TX == stp_if)
180 stp_uart_if_tx = func;
182 else if (STP_SDIO_IF_TX == stp_if)
184 stp_sdio_if_tx = func;
188 osal_dbg_print("[%s] STP_IF_TX(%d) out of boundary.\n", __FUNCTION__, stp_if);
195 INT32 mtk_wcn_stp_register_event_cb(INT32 type, MTK_WCN_STP_EVENT_CB func)
197 if (type < MTKSTP_MAX_TASK_NUM)
199 event_callback_tbl[type] = func;
202 osal_dbg_print("Flush type = %d Rx Queue\n", type);
203 mtk_wcn_stp_flush_rx_queue(type);
209 INT32 mtk_wcn_stp_register_tx_event_cb(INT32 type, MTK_WCN_STP_EVENT_CB func)
211 if(type < MTKSTP_MAX_TASK_NUM)
213 tx_event_callback_tbl[type] = func;
223 INT32 stp_drv_init(VOID)
227 .cb_if_tx = mtk_wcn_sys_if_tx,
228 .cb_event_set = mtk_wcn_sys_event_set,
229 .cb_event_tx_resume = mtk_wcn_sys_event_tx_resume,
230 .cb_check_funciton_status = mtk_wcn_sys_check_function_status
233 return mtk_wcn_stp_init(&cb);
236 VOID stp_drv_exit(VOID)
238 mtk_wcn_stp_deinit();
243 EXPORT_SYMBOL(mtk_wcn_stp_register_if_tx);
244 EXPORT_SYMBOL(mtk_wcn_stp_register_if_rx);
245 EXPORT_SYMBOL(mtk_wcn_stp_register_event_cb);
246 EXPORT_SYMBOL(mtk_wcn_stp_register_tx_event_cb);
247 EXPORT_SYMBOL(mtk_wcn_stp_parser_data);
248 EXPORT_SYMBOL(mtk_wcn_stp_send_data);
249 EXPORT_SYMBOL(mtk_wcn_stp_send_data_raw);
250 EXPORT_SYMBOL(mtk_wcn_stp_receive_data);
251 EXPORT_SYMBOL(mtk_wcn_stp_is_rxqueue_empty);
252 EXPORT_SYMBOL(mtk_wcn_stp_set_bluez);
253 EXPORT_SYMBOL(mtk_wcn_stp_is_ready);
254 EXPORT_SYMBOL(mtk_wcn_stp_dbg_log_ctrl);