29 #define _RTL8712_CMD_C_
31 #include <linux/compiler.h>
32 #include <linux/kernel.h>
33 #include <linux/errno.h>
35 #include <linux/slab.h>
36 #include <linux/module.h>
38 #include <linux/netdevice.h>
41 #include <linux/usb/ch9.h>
44 #include <asm/byteorder.h>
47 #include <linux/rtnetlink.h>
55 static void check_hw_pbc(
struct _adapter *padapter)
69 DBG_8712(
"CheckPbcGPIO - PBC is pressed !!!!\n");
72 if (padapter->
pid == 0)
81 static void query_fw_rx_phy_status(
struct _adapter *padapter)
106 static void StatusWatchdogCallback(
struct _adapter *padapter)
108 check_hw_pbc(padapter);
109 query_fw_rx_phy_status(padapter);
112 static void r871x_internal_cmd_hdl(
struct _adapter *padapter,
u8 *pbuf)
119 switch (pdrvcmd->
i_cid) {
121 StatusWatchdogCallback(padapter);
129 static u8 read_macreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
135 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
136 if (pcmd_callback ==
NULL)
139 pcmd_callback(padapter, pcmd);
143 static u8 write_macreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
149 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
150 if (pcmd_callback ==
NULL)
153 pcmd_callback(padapter, pcmd);
157 static u8 read_bbreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
167 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
168 if (pcmd_callback ==
NULL)
171 pcmd_callback(padapter, pcmd);
175 static u8 write_bbreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
182 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
183 if (pcmd_callback ==
NULL)
186 pcmd_callback(padapter, pcmd);
190 static u8 read_rfreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
200 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
201 if (pcmd_callback ==
NULL)
204 pcmd_callback(padapter, pcmd);
208 static u8 write_rfreg_hdl(
struct _adapter *padapter,
u8 *pbuf)
215 pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
216 if (pcmd_callback ==
NULL)
219 pcmd_callback(padapter, pcmd);
223 static u8 sys_suspend_hdl(
struct _adapter *padapter,
u8 *pbuf)
244 read_macreg_hdl(padapter, (
u8 *)pcmd);
248 write_macreg_hdl(padapter, (
u8 *)pcmd);
252 read_bbreg_hdl(padapter, (
u8 *)pcmd);
255 write_bbreg_hdl(padapter, (
u8 *)pcmd);
258 read_rfreg_hdl(padapter, (
u8 *)pcmd);
261 write_rfreg_hdl(padapter, (
u8 *)pcmd);
264 sys_suspend_hdl(padapter, (
u8 *)pcmd);
281 r871x_internal_cmd_hdl(padapter, pcmd->
parmbuf);
300 int pollingcnts = 50;
309 if (pollingcnts == 0)
325 unsigned int cmdsz, wr_sz, *pcmdbuf, *prspbuf;
331 thread_enter(padapter);
346 pcmdbuf = (
unsigned int *)pcmdpriv->
cmd_buf;
347 prspbuf = (
unsigned int *)pcmdpriv->
rsp_buf;
348 pdesc = (
struct tx_desc *)pcmdbuf;
350 pcmd = cmd_hdl_filter(padapter, pcmd);
356 cmdsz = _RND8((pcmd->
cmdsz));
361 if ((wr_sz % 512) == 0)
364 if ((wr_sz % 64) == 0)
386 while (check_cmd_fifo(padapter, wr_sz) ==
_FAIL) {
400 pcmd_callback = cmd_callback[pcmd->
403 pcmd_callback(padapter, pcmd);
408 _enter_pwrlock(&(padapter->
415 if (_queue_empty(&(pcmdpriv->
cmd_queue))) {
422 flush_signals_thread();
437 u8 evt_code, evt_seq;
442 if (peventbuf ==
NULL)
448 if ((evt_seq & 0x7f) != pevt_priv->
event_seq) {
449 pevt_priv->
event_seq = ((evt_seq + 1) & 0x7f);
454 pevt_priv->
event_seq = ((evt_seq+1) & 0x7f);
458 pevt_priv->
event_seq = ((evt_seq+1)&0x7f);
462 if ((wlanevents[evt_code].parmsize) &&
463 (wlanevents[evt_code].parmsize != evt_sz)) {
464 pevt_priv->
event_seq = ((evt_seq+1)&0x7f);
466 }
else if ((evt_sz == 0) && (evt_code !=
GEN_EVT_CODE(_WPS_PBC))) {
467 pevt_priv->
event_seq = ((evt_seq+1)&0x7f);
473 peventbuf = peventbuf + 2;
475 event_callback = wlanevents[evt_code].event_callback;
477 event_callback(padapter, (
u8 *)peventbuf);