41 rtl_write_dword(rtlpriv,
RQPN, 0xffffffff);
42 rtl_write_dword(rtlpriv,
RQPN + 4, 0xffffffff);
43 rtl_write_byte(rtlpriv,
RQPN + 8, 0xff);
44 rtl_write_byte(rtlpriv,
RQPN + 0xB, 0x80);
52 u8 tmpu1b, cpustatus = 0;
54 _rtl92s_fw_set_rqpn(hw);
57 tmpu1b = rtl_read_byte(rtlpriv,
SYS_CLKR);
66 cpustatus = rtl_read_byte(rtlpriv,
TCR);
69 "IMEM Ready after CPU has refilled\n");
74 }
while (ichecktime--);
82 static enum fw_status _rtl92s_firmware_get_nextstatus(
87 switch (fw_currentstatus) {
104 return next_fwstatus;
107 static u8 _rtl92s_firmware_header_map_rftype(
struct ieee80211_hw *hw)
130 static void _rtl92s_firmwareheader_priveupdate(
struct ieee80211_hw *hw,
134 pfw_priv->
rf_config = _rtl92s_firmware_header_map_rftype(hw);
139 static bool _rtl92s_cmd_send_packet(
struct ieee80211_hw *hw,
154 pdesc = &ring->
desc[idx];
155 rtlpriv->
cfg->ops->fill_tx_cmddesc(hw, (
u8 *)pdesc, 1, 1, skb);
156 __skb_queue_tail(&ring->
queue, skb);
158 spin_unlock_irqrestore(&rtlpriv->
locks.irq_th_lock, flags);
163 static bool _rtl92s_firmware_downloadcode(
struct ieee80211_hw *hw,
164 u8 *code_virtual_address,
u32 buffer_len)
169 unsigned char *seg_ptr;
171 u16 frag_length, frag_offset = 0;
172 u16 extra_descoffset = 0;
175 _rtl92s_fw_set_rqpn(hw);
179 "Size over FIRMWARE_CODE_SIZE!\n");
184 extra_descoffset = 0;
187 if ((buffer_len - frag_offset) > frag_threshold) {
188 frag_length = frag_threshold + extra_descoffset;
190 frag_length = (
u16)(buffer_len - frag_offset +
197 skb = dev_alloc_skb(frag_length);
200 skb_reserve(skb, extra_descoffset);
203 memcpy(seg_ptr, code_virtual_address + frag_offset,
204 (
u32)(frag_length - extra_descoffset));
211 _rtl92s_cmd_send_packet(hw, skb, last_inipkt);
213 frag_offset += (frag_length - extra_descoffset);
215 }
while (frag_offset < buffer_len);
222 static bool _rtl92s_firmware_checkready(
struct ieee80211_hw *hw,
230 short pollingcnt = 1000;
231 bool rtstatus =
true;
234 "LoadStaus(%d)\n", loadfw_status);
238 switch (loadfw_status) {
242 cpustatus = rtl_read_byte(rtlpriv,
TCR);
246 }
while (pollingcnt--);
250 "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\n",
252 goto status_check_fail;
260 cpustatus = rtl_read_byte(rtlpriv,
TCR);
264 }
while (pollingcnt--);
268 "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\n",
270 goto status_check_fail;
274 rtstatus = _rtl92s_firmware_enable_cpu(hw);
277 "Enable CPU fail!\n");
278 goto status_check_fail;
285 cpustatus = rtl_read_byte(rtlpriv,
TCR);
289 }
while (pollingcnt--);
293 "Polling DMEM code done fail ! cpustatus(%#x)\n",
295 goto status_check_fail;
299 "DMEM code download success, cpustatus(%#x)\n",
306 cpustatus = rtl_read_byte(rtlpriv,
TCR);
307 if (cpustatus &
FWRDY)
310 }
while (pollingcnt--);
313 "Polling Load Firmware ready, cpustatus(%x)\n",
319 "Polling Load Firmware ready fail ! cpustatus(%x)\n",
321 goto status_check_fail;
326 tmpu4b = rtl_read_dword(rtlpriv,
TCR);
327 rtl_write_dword(rtlpriv,
TCR, (tmpu4b & (~
TCR_ICV)));
329 tmpu4b = rtl_read_dword(rtlpriv,
RCR);
334 "Current RCR settings(%#x)\n", tmpu4b);
342 "Unknown status check!\n");
349 "loadfw_status(%d), rtstatus(%x)\n",
350 loadfw_status, rtstatus);
361 u8 *puc_mappedfile =
NULL;
362 u32 ul_filelength = 0;
365 bool rtstatus =
true;
382 "signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n",
391 "memory for data image is less than IMEM required\n");
394 puc_mappedfile += fwhdr_size;
404 "memory for data image is less than EMEM required\n");
415 fwstatus = _rtl92s_firmware_get_nextstatus(firmware->
fwstatus);
420 puc_mappedfile = firmware->
fw_imem;
424 puc_mappedfile = firmware->
fw_emem;
430 pfw_priv = &pfwheader->
fwpriv;
431 _rtl92s_firmwareheader_priveupdate(hw, pfw_priv);
434 ul_filelength = fwhdr_size -
439 "Unexpected Download step!!\n");
445 rtstatus = _rtl92s_firmware_downloadcode(hw, puc_mappedfile,
454 rtstatus = _rtl92s_firmware_checkready(hw, fwstatus);
460 fwstatus = _rtl92s_firmware_get_nextstatus(firmware->
fwstatus);
468 static u32 _rtl92s_fill_h2c_cmd(
struct sk_buff *skb,
u32 h2cbufferlen,
469 u32 cmd_num,
u32 *pelement_id,
u32 *pcmd_len,
470 u8 **pcmb_buffer,
u8 *cmd_start_seq)
472 u32 totallen = 0,
len = 0, tx_desclen = 0;
473 u32 pre_continueoffset = 0;
482 if (h2cbufferlen < totallen + len + tx_desclen)
487 memset((ph2c_buffer + totallen + tx_desclen), 0, len);
495 16, 8, pelement_id[i]);
498 *cmd_start_seq = *cmd_start_seq % 0x80;
500 24, 7, *cmd_start_seq);
504 memcpy((ph2c_buffer + totallen + tx_desclen +
513 pre_continueoffset = totallen;
516 }
while (++i < cmd_num);
521 static u32 _rtl92s_get_h2c_cmdlen(
u32 h2cbufferlen,
u32 cmd_num,
u32 *pcmd_len)
523 u32 totallen = 0,
len = 0, tx_desclen = 0;
531 if (h2cbufferlen < totallen + len + tx_desclen)
535 }
while (++i < cmd_num);
537 return totallen + tx_desclen;
566 cmd_len =
sizeof(
unsigned long long);
570 cmd_len =
sizeof(
u8);
577 skb = dev_alloc_skb(len);
587 _rtl92s_cmd_send_packet(hw, skb,
false);
598 u16 max_wakeup_period = 0;
608 mac->
vif->bss_conf.beacon_int);
616 max_wakeup_period = mac->
vif->bss_conf.beacon_int;
618 max_wakeup_period = mac->
vif->bss_conf.beacon_int *
619 mac->
vif->bss_conf.dtim_period;
621 if (max_wakeup_period >= 500)
623 else if ((max_wakeup_period >= 300) && (max_wakeup_period < 500))
625 else if ((max_wakeup_period >= 200) && (max_wakeup_period < 300))
627 else if ((max_wakeup_period >= 20) && (max_wakeup_period < 200))
637 u8 mstatus,
u8 ps_qosinfo)
642 joinbss_rpt.
opmode = mstatus;
651 mac->
vif->bss_conf.beacon_int);